Commit 079b768e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed the ColorDisplayNode struct entirely. GimpDisplayShell->filters is

2002-10-20  Michael Natterer  <mitch@gimp.org>

	* app/display/gimpdisplayshell-filter.[ch]: removed the
	ColorDisplayNode struct entirely. GimpDisplayShell->filters is now
	just a GList of GimpColorDisplay objects.

	* app/display/gimpdisplayshell-filter-dialog.c
	* app/display/gimpdisplayshell-render.c: changed accordingly.
parent d7055a33
2002-10-20 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-filter.[ch]: removed the
ColorDisplayNode struct entirely. GimpDisplayShell->filters is now
just a GList of GimpColorDisplay objects.
* app/display/gimpdisplayshell-filter-dialog.c
* app/display/gimpdisplayshell-render.c: changed accordingly.
2002-10-20 Michael Natterer <mitch@gimp.org>
 
Ported module loading to GTypeModule, getting rid of all own
......
......@@ -352,21 +352,21 @@ color_display_add_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->src_sel, &model, &iter))
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, 1, &val);
node = gimp_display_shell_filter_attach (cdd->shell,
(GType) g_value_get_pointer (&val));
filter = gimp_display_shell_filter_attach (cdd->shell,
(GType) g_value_get_pointer (&val));
g_value_unset (&val);
gtk_tree_store_append (cdd->dest, &iter, NULL);
gtk_tree_store_set (cdd->dest, &iter,
0, node->cd_name,
1, node,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name,
1, filter,
-1);
cdd->modified = TRUE;
......@@ -386,12 +386,12 @@ color_display_remove_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter))
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, 1, &val);
node = g_value_get_pointer (&val);
filter = g_value_get_pointer (&val);
g_value_unset (&val);
......@@ -399,10 +399,10 @@ color_display_remove_callback (GtkWidget *widget,
cdd->modified = TRUE;
if (g_list_find (cdd->old_nodes, node))
gimp_display_shell_filter_detach (cdd->shell, node);
if (g_list_find (cdd->old_nodes, filter))
gimp_display_shell_filter_detach (cdd->shell, filter);
else
gimp_display_shell_filter_detach_destroy (cdd->shell, node);
gimp_display_shell_filter_detach_destroy (cdd->shell, filter);
color_display_update_up_and_down (cdd);
......@@ -421,27 +421,27 @@ color_display_up_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter1))
{
GtkTreePath *path;
ColorDisplayNode *node1;
ColorDisplayNode *node2;
GimpColorDisplay *filter1;
GimpColorDisplay *filter2;
path = gtk_tree_model_get_path (model, &iter1);
gtk_tree_path_prev (path);
gtk_tree_model_get_iter (model, &iter2, path);
gtk_tree_path_free (path);
gtk_tree_model_get (model, &iter1, 1, &node1, -1);
gtk_tree_model_get (model, &iter2, 1, &node2, -1);
gtk_tree_model_get (model, &iter1, 1, &filter1, -1);
gtk_tree_model_get (model, &iter2, 1, &filter2, -1);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter1,
0, node2->cd_name,
1, node2,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter2)->name,
1, filter2,
-1);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter2,
0, node1->cd_name,
1, node1,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter1)->name,
1, filter1,
-1);
gimp_display_shell_filter_reorder_up (cdd->shell, node1);
gimp_display_shell_filter_reorder_up (cdd->shell, filter1);
cdd->modified = TRUE;
......@@ -462,27 +462,27 @@ color_display_down_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter1))
{
GtkTreePath *path;
ColorDisplayNode *node1;
ColorDisplayNode *node2;
GimpColorDisplay *filter1;
GimpColorDisplay *filter2;
path = gtk_tree_model_get_path (model, &iter1);
gtk_tree_path_next (path);
gtk_tree_model_get_iter (model, &iter2, path);
gtk_tree_path_free (path);
gtk_tree_model_get (model, &iter1, 1, &node1, -1);
gtk_tree_model_get (model, &iter2, 1, &node2, -1);
gtk_tree_model_get (model, &iter1, 1, &filter1, -1);
gtk_tree_model_get (model, &iter2, 1, &filter2, -1);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter1,
0, node2->cd_name,
1, node2,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter2)->name,
1, filter2,
-1);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter2,
0, node1->cd_name,
1, node1,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter1)->name,
1, filter1,
-1);
gimp_display_shell_filter_reorder_down (cdd->shell, node1);
gimp_display_shell_filter_reorder_down (cdd->shell, filter1);
cdd->modified = TRUE;
......@@ -501,19 +501,19 @@ color_display_configure_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter))
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, 1, &val);
node = g_value_get_pointer (&val);
filter = g_value_get_pointer (&val);
g_value_unset (&val);
if (! g_list_find (cdd->conf_nodes, node))
cdd->conf_nodes = g_list_append (cdd->conf_nodes, node);
if (! g_list_find (cdd->conf_nodes, filter))
cdd->conf_nodes = g_list_append (cdd->conf_nodes, filter);
gimp_display_shell_filter_configure (node, NULL, NULL, NULL, NULL);
gimp_color_display_configure (filter, NULL, NULL, NULL, NULL);
cdd->modified = TRUE;
......@@ -567,19 +567,19 @@ static void
dest_list_populate (GList *node_list,
GtkTreeStore *dest)
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
GList *list;
GtkTreeIter iter;
for (list = node_list; list; list = g_list_next (list))
{
node = (ColorDisplayNode *) list->data;
filter = (GimpColorDisplay *) list->data;
gtk_tree_store_append (dest, &iter, NULL);
gtk_tree_store_set (dest, &iter,
0, node->cd_name,
1, node,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name,
1, filter,
-1);
}
}
......@@ -612,7 +612,7 @@ dest_selection_changed (GtkTreeSelection *sel,
{
GtkTreeModel *model;
GtkTreeIter iter;
ColorDisplayNode *node = NULL;
GimpColorDisplay *filter = NULL;
if (gtk_tree_selection_get_selected (sel, &model, &iter))
{
......@@ -620,13 +620,13 @@ dest_selection_changed (GtkTreeSelection *sel,
gtk_tree_model_get_value (model, &iter, 1, &val);
node = g_value_get_pointer (&val);
filter = g_value_get_pointer (&val);
g_value_unset (&val);
}
gtk_widget_set_sensitive (cdd->remove_button, (node != NULL));
gtk_widget_set_sensitive (cdd->configure_button, (node != NULL));
gtk_widget_set_sensitive (cdd->remove_button, (filter != NULL));
gtk_widget_set_sensitive (cdd->configure_button, (filter != NULL));
color_display_update_up_and_down (cdd);
}
......@@ -35,32 +35,22 @@
#include "gimpdisplayshell-filter.h"
static void gimp_display_shell_filter_detach_real (GimpDisplayShell *shell,
ColorDisplayNode *node);
ColorDisplayNode *
GimpColorDisplay *
gimp_display_shell_filter_attach (GimpDisplayShell *shell,
GType type)
{
GimpColorDisplay *color_display;
ColorDisplayNode *node;
GimpColorDisplay *filter;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (g_type_is_a (type, GIMP_TYPE_COLOR_DISPLAY), NULL);
color_display = gimp_color_display_new (type);
filter = gimp_color_display_new (type);
if (color_display)
if (filter)
{
node = g_new (ColorDisplayNode, 1);
node->cd_name = g_strdup (GIMP_COLOR_DISPLAY_GET_CLASS (color_display)->name);
node->color_display = color_display;
shell->filters = g_list_append (shell->filters, node);
shell->filters = g_list_append (shell->filters, filter);
return node;
return filter;
}
else
g_warning ("Tried to attach a nonexistant color display");
......@@ -68,28 +58,22 @@ gimp_display_shell_filter_attach (GimpDisplayShell *shell,
return NULL;
}
ColorDisplayNode *
GimpColorDisplay *
gimp_display_shell_filter_attach_clone (GimpDisplayShell *shell,
ColorDisplayNode *node)
GimpColorDisplay *filter)
{
GimpColorDisplay *color_display;
ColorDisplayNode *clone;
GimpColorDisplay *clone;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (node != NULL, NULL);
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (filter), NULL);
color_display = gimp_color_display_clone (node->color_display);
clone = gimp_color_display_clone (filter);
if (color_display)
if (clone)
{
clone = g_new (ColorDisplayNode, 1);
shell->filters = g_list_append (shell->filters, clone);
clone->cd_name = g_strdup (node->cd_name);
clone->color_display = color_display;
shell->filters = g_list_append (shell->filters, node);
return node;
return clone;
}
else
g_warning ("Tried to clone a nonexistant color display");
......@@ -99,106 +83,68 @@ gimp_display_shell_filter_attach_clone (GimpDisplayShell *shell,
void
gimp_display_shell_filter_detach (GimpDisplayShell *shell,
ColorDisplayNode *node)
GimpColorDisplay *filter)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
shell->filters = g_list_remove (shell->filters, node);
shell->filters = g_list_remove (shell->filters, filter);
}
void
gimp_display_shell_filter_detach_destroy (GimpDisplayShell *shell,
ColorDisplayNode *node)
GimpColorDisplay *filter)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
gimp_display_shell_filter_detach_real (shell, node);
g_object_unref (filter);
shell->filters = g_list_remove (shell->filters, node);
shell->filters = g_list_remove (shell->filters, filter);
}
void
gimp_display_shell_filter_detach_all (GimpDisplayShell *shell)
{
GList *list;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
for (list = shell->filters; list; list = g_list_next (list))
{
gimp_display_shell_filter_detach_real (shell, list->data);
}
g_list_foreach (shell->filters, (GFunc) g_object_unref, NULL);
g_list_free (shell->filters);
shell->filters = NULL;
}
static void
gimp_display_shell_filter_detach_real (GimpDisplayShell *shell,
ColorDisplayNode *node)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (node != NULL);
g_object_unref (node->color_display);
g_free (node->cd_name);
g_free (node);
}
void
gimp_display_shell_filter_reorder_up (GimpDisplayShell *shell,
ColorDisplayNode *node)
GimpColorDisplay *filter)
{
GList *node_list;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (node != NULL);
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
node_list = g_list_find (shell->filters, node);
node_list = g_list_find (shell->filters, filter);
if (node_list->prev)
{
node_list->data = node_list->prev->data;
node_list->prev->data = node;
node_list->data = node_list->prev->data;
node_list->prev->data = filter;
}
}
void
gimp_display_shell_filter_reorder_down (GimpDisplayShell *shell,
ColorDisplayNode *node)
GimpColorDisplay *filter)
{
GList *node_list;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (node != NULL);
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (filter));
node_list = g_list_find (shell->filters, node);
node_list = g_list_find (shell->filters, filter);
if (node_list->next)
{
node_list->data = node_list->next->data;
node_list->next->data = node;
node_list->data = node_list->next->data;
node_list->next->data = filter;
}
}
void
gimp_display_shell_filter_configure (ColorDisplayNode *node,
GFunc ok_func,
gpointer ok_data,
GFunc cancel_func,
gpointer cancel_data)
{
g_return_if_fail (node != NULL);
gimp_color_display_configure (node->color_display,
ok_func, ok_data,
cancel_func, cancel_data);
}
void
gimp_display_shell_filter_configure_cancel (ColorDisplayNode *node)
{
g_return_if_fail (node != NULL);
gimp_color_display_configure_cancel (node->color_display);
}
......@@ -20,37 +20,21 @@
#define __GIMP_DISPLAY_SHELL_FILTER_H__
typedef struct _ColorDisplayNode ColorDisplayNode;
struct _ColorDisplayNode
{
GimpColorDisplay *color_display;
gchar *cd_name;
};
ColorDisplayNode *
GimpColorDisplay *
gimp_display_shell_filter_attach (GimpDisplayShell *shell,
GType type);
ColorDisplayNode *
GimpColorDisplay *
gimp_display_shell_filter_attach_clone (GimpDisplayShell *shell,
ColorDisplayNode *node);
GimpColorDisplay *filter);
void gimp_display_shell_filter_detach (GimpDisplayShell *shell,
ColorDisplayNode *node);
GimpColorDisplay *filter);
void gimp_display_shell_filter_detach_destroy (GimpDisplayShell *shell,
ColorDisplayNode *node);
GimpColorDisplay *filter);
void gimp_display_shell_filter_detach_all (GimpDisplayShell *shell);
void gimp_display_shell_filter_reorder_up (GimpDisplayShell *shell,
ColorDisplayNode *node);
GimpColorDisplay *filter);
void gimp_display_shell_filter_reorder_down (GimpDisplayShell *shell,
ColorDisplayNode *node);
void gimp_display_shell_filter_configure (ColorDisplayNode *node,
GFunc ok_func,
gpointer ok_data,
GFunc cancel_func,
gpointer cancel_data);
void gimp_display_shell_filter_configure_cancel (ColorDisplayNode *node);
GimpColorDisplay *filter);
#endif /* __GIMP_DISPLAY_SHELL_FILTER_H__ */
......@@ -237,15 +237,15 @@ gimp_display_shell_render (GimpDisplayShell *shell,
gint w,
gint h)
{
RenderInfo info;
gint image_type;
GList *list;
RenderInfo info;
GimpImageType image_type;
GList *list;
render_image_init_info (&info, shell, x, y, w, h);
image_type = gimp_image_projection_type (shell->gdisp->gimage);
if ((image_type < 0) || (image_type > 5))
if ((image_type < GIMP_RGB_IMAGE) || (image_type > GIMP_INDEXEDA_IMAGE))
{
g_message ("unknown gimage projection type: %d",
gimp_image_projection_type (shell->gdisp->gimage));
......@@ -269,11 +269,11 @@ gimp_display_shell_render (GimpDisplayShell *shell,
/* apply filters to the rendered projection */
for (list = shell->filters; list; list = g_list_next (list))
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
node = (ColorDisplayNode *) list->data;
filter = (GimpColorDisplay *) list->data;
gimp_color_display_convert (node->color_display,
gimp_color_display_convert (filter,
shell->render_buf,
w, h,
3,
......
......@@ -352,21 +352,21 @@ color_display_add_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->src_sel, &model, &iter))
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, 1, &val);
node = gimp_display_shell_filter_attach (cdd->shell,
(GType) g_value_get_pointer (&val));
filter = gimp_display_shell_filter_attach (cdd->shell,
(GType) g_value_get_pointer (&val));
g_value_unset (&val);
gtk_tree_store_append (cdd->dest, &iter, NULL);
gtk_tree_store_set (cdd->dest, &iter,
0, node->cd_name,
1, node,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter)->name,
1, filter,
-1);
cdd->modified = TRUE;
......@@ -386,12 +386,12 @@ color_display_remove_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter))
{
ColorDisplayNode *node;
GimpColorDisplay *filter;
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, 1, &val);
node = g_value_get_pointer (&val);
filter = g_value_get_pointer (&val);
g_value_unset (&val);
......@@ -399,10 +399,10 @@ color_display_remove_callback (GtkWidget *widget,
cdd->modified = TRUE;
if (g_list_find (cdd->old_nodes, node))
gimp_display_shell_filter_detach (cdd->shell, node);
if (g_list_find (cdd->old_nodes, filter))
gimp_display_shell_filter_detach (cdd->shell, filter);
else
gimp_display_shell_filter_detach_destroy (cdd->shell, node);
gimp_display_shell_filter_detach_destroy (cdd->shell, filter);
color_display_update_up_and_down (cdd);
......@@ -421,27 +421,27 @@ color_display_up_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter1))
{
GtkTreePath *path;
ColorDisplayNode *node1;
ColorDisplayNode *node2;
GimpColorDisplay *filter1;
GimpColorDisplay *filter2;
path = gtk_tree_model_get_path (model, &iter1);
gtk_tree_path_prev (path);
gtk_tree_model_get_iter (model, &iter2, path);
gtk_tree_path_free (path);
gtk_tree_model_get (model, &iter1, 1, &node1, -1);
gtk_tree_model_get (model, &iter2, 1, &node2, -1);
gtk_tree_model_get (model, &iter1, 1, &filter1, -1);
gtk_tree_model_get (model, &iter2, 1, &filter2, -1);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter1,
0, node2->cd_name,
1, node2,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter2)->name,
1, filter2,
-1);
gtk_tree_store_set (GTK_TREE_STORE (model), &iter2,
0, node1->cd_name,
1, node1,
0, GIMP_COLOR_DISPLAY_GET_CLASS (filter1)->name,
1, filter1,
-1);
gimp_display_shell_filter_reorder_up (cdd->shell, node1);
gimp_display_shell_filter_reorder_up (cdd->shell, filter1);
cdd->modified = TRUE;
......@@ -462,27 +462,27 @@ color_display_down_callback (GtkWidget *widget,
if (gtk_tree_selection_get_selected (cdd->dest_sel, &model, &iter1))
{