From 2e464cf5e6360726ad7160de503e7508755c3376 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 5 Feb 2001 17:48:50 +0000 Subject: [PATCH] app/gimpcontainer.[ch] made the "get_by_name" and the "by_index" access 2001-02-05 Michael Natterer * app/gimpcontainer.[ch] * app/gimplist.[ch]: made the "get_by_name" and the "by_index" access functions methods of the GimpContainerClass. The semantic of this index is somewhat unclear if we have e.g. a hash table implementation but the container needs to have an order for the ContainerView. Finally, the ordering will be a feature of the ContainerView. * app/gimpmarshal.[ch]: marshallers needed for the new methods. * app/brushes.[ch] * app/patterns.[ch]: the public global brush and pattern lists are GimpContainers now (they are really GimpLists of course). * app/brush_select.c * app/devices.c * app/gimpcontainerlistview.c * app/gimpcontext.c * app/gimpdnd.c * app/pattern_select.c * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly. --- ChangeLog | 31 ++++++++++ app/brush_select.c | 28 ++++++--- app/brushes.c | 10 ++- app/brushes.h | 2 +- app/core/gimpcontainer.c | 94 +++++++++++++++++++++++++++-- app/core/gimpcontainer.h | 69 ++++++++++++--------- app/core/gimpcontext.c | 22 ++++--- app/core/gimplist.c | 77 ++++++++++++----------- app/core/gimplist.h | 7 --- app/core/gimpmarshal.c | 51 ++++++++++++++++ app/core/gimpmarshal.h | 15 +++++ app/devices.c | 10 +-- app/gimpcontainer.c | 94 +++++++++++++++++++++++++++-- app/gimpcontainer.h | 69 ++++++++++++--------- app/gimpcontainerlistview.c | 4 +- app/gimpcontext.c | 22 ++++--- app/gimpdnd.c | 9 +-- app/gimplist.c | 77 ++++++++++++----------- app/gimplist.h | 7 --- app/gimpmarshal.c | 51 ++++++++++++++++ app/gimpmarshal.h | 15 +++++ app/gui/brush-select.c | 28 ++++++--- app/gui/device-status-dialog.c | 10 +-- app/gui/input-dialog.c | 10 +-- app/gui/pattern-select.c | 23 ++++--- app/pattern_select.c | 23 ++++--- app/patterns.c | 14 ++--- app/patterns.h | 2 +- app/pdb/brush_select_cmds.c | 4 +- app/pdb/brushes_cmds.c | 6 +- app/pdb/pattern_select_cmds.c | 4 +- app/pdb/patterns_cmds.c | 14 +++-- app/widgets/gimpcontainerlistview.c | 4 +- app/widgets/gimpdeviceinfo.c | 10 +-- app/widgets/gimpdevices.c | 10 +-- app/widgets/gimpdnd.c | 9 +-- tools/pdbgen/pdb/brush_select.pdb | 4 +- tools/pdbgen/pdb/brushes.pdb | 6 +- tools/pdbgen/pdb/pattern_select.pdb | 4 +- tools/pdbgen/pdb/patterns.pdb | 14 +++-- 40 files changed, 684 insertions(+), 279 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce0a00182b..c905caf1f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2001-02-05 Michael Natterer + + * app/gimpcontainer.[ch] + * app/gimplist.[ch]: made the "get_by_name" and the "by_index" + access functions methods of the GimpContainerClass. The semantic + of this index is somewhat unclear if we have e.g. a hash table + implementation but the container needs to have an order for the + ContainerView. Finally, the ordering will be a feature of the + ContainerView. + + * app/gimpmarshal.[ch]: marshallers needed for the new methods. + + * app/brushes.[ch] + * app/patterns.[ch]: the public global brush and pattern lists + are GimpContainers now (they are really GimpLists of course). + + * app/brush_select.c + * app/devices.c + * app/gimpcontainerlistview.c + * app/gimpcontext.c + * app/gimpdnd.c + * app/pattern_select.c + * app/pdb/brush_select_cmds.c + * app/pdb/brushes_cmds.c + * app/pdb/pattern_select_cmds.c + * app/pdb/patterns_cmds.c + * tools/pdbgen/pdb/brush_select.pdb + * tools/pdbgen/pdb/brushes.pdb + * tools/pdbgen/pdb/pattern_select.pdb + * tools/pdbgen/pdb/patterns.pdb: changed accordingly. + 2001-02-05 Michael Natterer * app/Makefile.am diff --git a/app/brush_select.c b/app/brush_select.c index 62ad43c878..8ee4b86ba2 100644 --- a/app/brush_select.c +++ b/app/brush_select.c @@ -310,8 +310,9 @@ brush_select_new (gchar *title, if (title && init_name && strlen (init_name)) { - active = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - init_name); + active = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + init_name); } else { @@ -836,7 +837,8 @@ brush_select_select (BrushSelect *bsp, gint row, col; gint scroll_offset = 0; - index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush)); + index = gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list), + GIMP_OBJECT (brush)); if (index < 0) return; @@ -886,7 +888,8 @@ brush_select_brush_dirty_callback (GimpBrush *brush, if (!bsp || bsp->freeze) return; - index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush)); + index = gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list), + GIMP_OBJECT (brush)); redraw = (brush != gimp_context_get_brush (bsp->context)); clear_brush (bsp, brush, @@ -1568,8 +1571,9 @@ brush_select_events (GtkWidget *widget, index = row * bsp->NUM_BRUSH_COLUMNS + col; /* Get the brush and check if it is editable */ - brush = GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list, - index)); + brush = (GimpBrush *) + gimp_container_get_child_by_index (GIMP_CONTAINER (global_brush_list), + index); if (GIMP_IS_BRUSH_GENERATED (brush)) brush_select_edit_brush_callback (NULL, bsp); break; @@ -1581,8 +1585,9 @@ brush_select_events (GtkWidget *widget, row = (bevent->y + bsp->scroll_offset) / bsp->cell_height; index = row * bsp->NUM_BRUSH_COLUMNS + col; - brush = (GimpBrush *) gimp_list_get_child_by_index (global_brush_list, - index); + brush = (GimpBrush *) + gimp_container_get_child_by_index (GIMP_CONTAINER (global_brush_list), + index); if (brush) bsp->dnd_brush = brush; @@ -1709,10 +1714,13 @@ brush_select_scroll_update (GtkAdjustment *adjustment, if (active) { - index = gimp_list_get_child_index (global_brush_list, - GIMP_OBJECT (active)); + index = + gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list), + GIMP_OBJECT (active)); + if (index < 0) return; + row = index / bsp->NUM_BRUSH_COLUMNS; col = index - row * bsp->NUM_BRUSH_COLUMNS; diff --git a/app/brushes.c b/app/brushes.c index c0940dcaef..f84afe1136 100644 --- a/app/brushes.c +++ b/app/brushes.c @@ -43,7 +43,7 @@ /* global variables */ -GimpList *global_brush_list = NULL; +GimpContainer *global_brush_list = NULL; /* local function prototypes */ @@ -57,7 +57,7 @@ brushes_init (gboolean no_data) if (global_brush_list) brushes_free (); else - global_brush_list = GIMP_LIST (gimp_data_list_new (GIMP_TYPE_BRUSH)); + global_brush_list = GIMP_CONTAINER (gimp_data_list_new (GIMP_TYPE_BRUSH)); if (brush_path != NULL && !no_data) { @@ -122,8 +122,7 @@ brushes_brush_load (const gchar *filename) } if (brush != NULL) - gimp_container_add (GIMP_CONTAINER (global_brush_list), - GIMP_OBJECT (brush)); + gimp_container_add (global_brush_list, GIMP_OBJECT (brush)); } void @@ -148,8 +147,7 @@ brushes_free (void) if (GIMP_IS_BRUSH_GENERATED (brush) && vbr_dir) gimp_brush_generated_save (GIMP_BRUSH_GENERATED (brush), vbr_dir); - gimp_container_remove (GIMP_CONTAINER (global_brush_list), - GIMP_OBJECT (brush)); + gimp_container_remove (global_brush_list, GIMP_OBJECT (brush)); } brush_select_thaw_all (); diff --git a/app/brushes.h b/app/brushes.h index 817195933f..a573075cb6 100644 --- a/app/brushes.h +++ b/app/brushes.h @@ -20,7 +20,7 @@ #define __BRUSHES_H__ -extern GimpList *global_brush_list; +extern GimpContainer *global_brush_list; void brushes_init (gboolean no_data); diff --git a/app/core/gimpcontainer.c b/app/core/gimpcontainer.c index 2085328692..26aa063762 100644 --- a/app/core/gimpcontainer.c +++ b/app/core/gimpcontainer.c @@ -23,6 +23,7 @@ #include "apptypes.h" #include "gimpcontainer.h" +#include "gimpmarshal.h" typedef struct _GimpContainerHandler @@ -41,6 +42,9 @@ enum REMOVE, HAVE, FOREACH, + GET_CHILD_BY_NAME, + GET_CHILD_BY_INDEX, + GET_CHILD_INDEX, LAST_SIGNAL }; @@ -143,14 +147,47 @@ gimp_container_class_init (GimpContainerClass* klass) GTK_TYPE_POINTER, GTK_TYPE_POINTER); + container_signals[GET_CHILD_BY_NAME] = + gtk_signal_new ("get_child_by_name", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContainerClass, + get_child_by_name), + gimp_marshal_POINTER__POINTER, + GIMP_TYPE_OBJECT, 1, + GTK_TYPE_POINTER); + + container_signals[GET_CHILD_BY_INDEX] = + gtk_signal_new ("get_child_by_index", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContainerClass, + get_child_by_index), + gimp_marshal_POINTER__INT, + GIMP_TYPE_OBJECT, 1, + GTK_TYPE_INT); + + container_signals[GET_CHILD_INDEX] = + gtk_signal_new ("get_child_index", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContainerClass, + get_child_index), + gtk_marshal_INT__POINTER, + GTK_TYPE_INT, 1, + GIMP_TYPE_OBJECT); + gtk_object_class_add_signals (object_class, container_signals, LAST_SIGNAL); object_class->destroy = gimp_container_destroy; - klass->add = NULL; - klass->remove = NULL; - klass->have = NULL; - klass->foreach = NULL; + klass->add = NULL; + klass->remove = NULL; + klass->have = NULL; + klass->foreach = NULL; + klass->get_child_by_name = NULL; + klass->get_child_by_index = NULL; + klass->get_child_index = NULL; } static void @@ -351,6 +388,55 @@ gimp_container_foreach (GimpContainer *container, func, user_data); } +GimpObject * +gimp_container_get_child_by_name (const GimpContainer *container, + const gchar *name) +{ + GimpObject *object = NULL; + + g_return_val_if_fail (container != NULL, NULL); + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (name != NULL, NULL); + + gtk_signal_emit (GTK_OBJECT (container), container_signals[GET_CHILD_BY_NAME], + name, &object); + + return object; +} + +GimpObject * +gimp_container_get_child_by_index (const GimpContainer *container, + gint index) +{ + GimpObject *object = NULL; + + g_return_val_if_fail (container != NULL, NULL); + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (index >= 0 && index < container->num_children, NULL); + + gtk_signal_emit (GTK_OBJECT (container), container_signals[GET_CHILD_BY_INDEX], + index, &object); + + return object; +} + +gint +gimp_container_get_child_index (const GimpContainer *container, + const GimpObject *object) +{ + gint index = -1; + + g_return_val_if_fail (container != NULL, -1); + g_return_val_if_fail (GIMP_IS_CONTAINER (container), -1); + g_return_val_if_fail (object != NULL, -1); + g_return_val_if_fail (GTK_CHECK_TYPE (object, container->children_type), -1); + + gtk_signal_emit (GTK_OBJECT (container), container_signals[GET_CHILD_INDEX], + object, &index); + + return index; +} + static void gimp_container_add_handler_foreach_func (GimpObject *object, GimpContainerHandler *handler) diff --git a/app/core/gimpcontainer.h b/app/core/gimpcontainer.h index 660bac9971..b77d4eb629 100644 --- a/app/core/gimpcontainer.h +++ b/app/core/gimpcontainer.h @@ -56,41 +56,54 @@ struct _GimpContainerClass { GimpObjectClass parent_class; - void (* add) (GimpContainer *container, - GimpObject *object); - void (* remove) (GimpContainer *container, - GimpObject *object); - gboolean (* have) (GimpContainer *container, - GimpObject *object); - void (* foreach) (GimpContainer *container, - GFunc func, - gpointer user_data); + void (* add) (GimpContainer *container, + GimpObject *object); + void (* remove) (GimpContainer *container, + GimpObject *object); + gboolean (* have) (GimpContainer *container, + GimpObject *object); + void (* foreach) (GimpContainer *container, + GFunc func, + gpointer user_data); + GimpObject * (* get_child_by_name) (GimpContainer *container, + gchar *name); + GimpObject * (* get_child_by_index) (GimpContainer *container, + gint index); + gint (* get_child_index) (GimpContainer *container, + GimpObject *object); }; -GtkType gimp_container_get_type (void); +GtkType gimp_container_get_type (void); -GtkType gimp_container_children_type (const GimpContainer *container); -GimpContainerPolicy gimp_container_policy (const GimpContainer *container); -gint gimp_container_num_children (const GimpContainer *container); +GtkType gimp_container_children_type (const GimpContainer *container); +GimpContainerPolicy gimp_container_policy (const GimpContainer *container); +gint gimp_container_num_children (const GimpContainer *container); -gboolean gimp_container_add (GimpContainer *container, - GimpObject *object); -gboolean gimp_container_remove (GimpContainer *container, - GimpObject *object); +gboolean gimp_container_add (GimpContainer *container, + GimpObject *object); +gboolean gimp_container_remove (GimpContainer *container, + GimpObject *object); -gboolean gimp_container_have (GimpContainer *container, - GimpObject *object); -void gimp_container_foreach (GimpContainer *container, - GFunc func, - gpointer user_data); +gboolean gimp_container_have (GimpContainer *container, + GimpObject *object); +void gimp_container_foreach (GimpContainer *container, + GFunc func, + gpointer user_data); -GQuark gimp_container_add_handler (GimpContainer *container, - const gchar *signame, - GtkSignalFunc handler, - gpointer user_data); -void gimp_container_remove_handler (GimpContainer *container, - GQuark id); +GimpObject * gimp_container_get_child_by_name (const GimpContainer *container, + const gchar *name); +GimpObject * gimp_container_get_child_by_index (const GimpContainer *container, + gint index); +gint gimp_container_get_child_index (const GimpContainer *container, + const GimpObject *object); + +GQuark gimp_container_add_handler (GimpContainer *container, + const gchar *signame, + GtkSignalFunc handler, + gpointer user_data); +void gimp_container_remove_handler (GimpContainer *container, + GQuark id); #endif /* __GIMP_CONTAINER_H__ */ diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index 08d0de0f51..03ebf99331 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -30,8 +30,8 @@ #include "context_manager.h" #include "gdisplay.h" #include "gimpbrush.h" +#include "gimpcontainer.h" #include "gimpcontext.h" -#include "gimplist.h" #include "gimpmarshal.h" #include "gimppattern.h" #include "gimprc.h" @@ -1490,8 +1490,9 @@ gimp_context_refresh_brush (GimpContext *context, if (! context->brush_name) context->brush_name = g_strdup (default_brush); - if ((brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - context->brush_name))) + if ((brush = (GimpBrush *) + gimp_container_get_child_by_name (global_brush_list, + context->brush_name))) { gimp_context_real_set_brush (context, brush); return; @@ -1499,8 +1500,8 @@ gimp_context_refresh_brush (GimpContext *context, if (gimp_container_num_children (GIMP_CONTAINER (global_brush_list))) gimp_context_real_set_brush - (context, GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list, - 0))); + (context, GIMP_BRUSH (gimp_container_get_child_by_index (global_brush_list, + 0))); else gimp_context_real_set_brush (context, brushes_get_standard_brush ()); } @@ -1675,9 +1676,9 @@ gimp_context_refresh_pattern (GimpContext *context, if (! context->pattern_name) context->pattern_name = g_strdup (default_pattern); - if ((pattern = - (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - context->pattern_name))) + if ((pattern = (GimpPattern *) + gimp_container_get_child_by_name (global_pattern_list, + context->pattern_name))) { gimp_context_real_set_pattern (context, pattern); return; @@ -1685,8 +1686,9 @@ gimp_context_refresh_pattern (GimpContext *context, if (gimp_container_num_children (GIMP_CONTAINER (global_pattern_list))) gimp_context_real_set_pattern - (context, GIMP_PATTERN (gimp_list_get_child_by_index (global_pattern_list, - 0))); + (context, + GIMP_PATTERN (gimp_container_get_child_by_index (global_pattern_list, + 0))); else gimp_context_real_set_pattern (context, patterns_get_standard_pattern ()); } diff --git a/app/core/gimplist.c b/app/core/gimplist.c index f31966d6e6..39972da07f 100644 --- a/app/core/gimplist.c +++ b/app/core/gimplist.c @@ -26,18 +26,24 @@ #include "gimplist.h" -static void gimp_list_class_init (GimpListClass *klass); -static void gimp_list_init (GimpList *list); -static void gimp_list_destroy (GtkObject *object); -static void gimp_list_add (GimpContainer *container, - GimpObject *object); -static void gimp_list_remove (GimpContainer *container, - GimpObject *object); -static gboolean gimp_list_have (GimpContainer *container, - GimpObject *object); -static void gimp_list_foreach (GimpContainer *container, - GFunc func, - gpointer user_data); +static void gimp_list_class_init (GimpListClass *klass); +static void gimp_list_init (GimpList *list); +static void gimp_list_destroy (GtkObject *object); +static void gimp_list_add (GimpContainer *container, + GimpObject *object); +static void gimp_list_remove (GimpContainer *container, + GimpObject *object); +static gboolean gimp_list_have (GimpContainer *container, + GimpObject *object); +static void gimp_list_foreach (GimpContainer *container, + GFunc func, + gpointer user_data); +static GimpObject * gimp_list_get_child_by_name (GimpContainer *container, + gchar *name); +static GimpObject * gimp_list_get_child_by_index (GimpContainer *container, + gint index); +static gint gimp_list_get_child_index (GimpContainer *container, + GimpObject *object); static GimpContainerClass *parent_class = NULL; @@ -81,10 +87,13 @@ gimp_list_class_init (GimpListClass *klass) object_class->destroy = gimp_list_destroy; - container_class->add = gimp_list_add; - container_class->remove = gimp_list_remove; - container_class->have = gimp_list_have; - container_class->foreach = gimp_list_foreach; + container_class->add = gimp_list_add; + container_class->remove = gimp_list_remove; + container_class->have = gimp_list_have; + container_class->foreach = gimp_list_foreach; + container_class->get_child_by_name = gimp_list_get_child_by_name; + container_class->get_child_by_index = gimp_list_get_child_by_index; + container_class->get_child_index = gimp_list_get_child_index; } static void @@ -173,16 +182,15 @@ gimp_list_new (GtkType children_type, return list; } -GimpObject * -gimp_list_get_child_by_name (const GimpList *list, - const gchar *name) +static GimpObject * +gimp_list_get_child_by_name (GimpContainer *container, + gchar *name) { + GimpList *list; GimpObject *object; GList *glist; - g_return_val_if_fail (list != NULL, NULL); - g_return_val_if_fail (GIMP_IS_LIST (list), NULL); - g_return_val_if_fail (name != NULL, NULL); + list = GIMP_LIST (container); for (glist = list->list; glist; glist = g_list_next (glist)) { @@ -195,14 +203,14 @@ gimp_list_get_child_by_name (const GimpList *list, return NULL; } -GimpObject * -gimp_list_get_child_by_index (const GimpList *list, - gint index) +static GimpObject * +gimp_list_get_child_by_index (GimpContainer *container, + gint index) { - GList *glist; + GimpList *list; + GList *glist; - g_return_val_if_fail (list != NULL, NULL); - g_return_val_if_fail (GIMP_IS_LIST (list), NULL); + list = GIMP_LIST (container); glist = g_list_nth (list->list, index); @@ -212,14 +220,13 @@ gimp_list_get_child_by_index (const GimpList *list, return NULL; } -gint -gimp_list_get_child_index (const GimpList *list, - const GimpObject *object) +static gint +gimp_list_get_child_index (GimpContainer *container, + GimpObject *object) { - g_return_val_if_fail (list != NULL, 0); - g_return_val_if_fail (GIMP_IS_LIST (list), 0); - g_return_val_if_fail (object != NULL, 0); - g_return_val_if_fail (GIMP_IS_OBJECT (list), 0); + GimpList *list; + + list = GIMP_LIST (container); return g_list_index (list->list, (gpointer) object); } diff --git a/app/core/gimplist.h b/app/core/gimplist.h index 90c9d07400..3d51d043a9 100644 --- a/app/core/gimplist.h +++ b/app/core/gimplist.h @@ -49,12 +49,5 @@ GtkType gimp_list_get_type (void); GimpList * gimp_list_new (GtkType children_type, GimpContainerPolicy policy); -GimpObject * gimp_list_get_child_by_name (const GimpList *list, - const gchar *name); -GimpObject * gimp_list_get_child_by_index (const GimpList *list, - gint index); -gint gimp_list_get_child_index (const GimpList *list, - const GimpObject *object); - #endif /* __GIMP_LIST_H__ */ diff --git a/app/core/gimpmarshal.c b/app/core/gimpmarshal.c index c154b268bd..9d5f0cdcd5 100644 --- a/app/core/gimpmarshal.c +++ b/app/core/gimpmarshal.c @@ -81,6 +81,57 @@ gimp_marshal_NONE__DOUBLE (GtkObject *object, } +typedef gint (* GimpSignal_INT__POINTER) (GtkObject *object, + gpointer arg1, + gpointer user_data); + +void +gimp_marshal_INT__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + *GTK_RETLOC_INT (args[1]) = + (* (GimpSignal_INT__POINTER) func) (object, + GTK_VALUE_POINTER (args[0]), + func_data); +} + + +typedef gpointer (* GimpSignal_POINTER__INT) (GtkObject *object, + gint arg1, + gpointer user_data); + +void +gimp_marshal_POINTER__INT (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + *GTK_RETLOC_POINTER (args[1]) = + (* (GimpSignal_POINTER__INT) func) (object, + GTK_VALUE_INT (args[0]), + func_data); +} + + +typedef gpointer (* GimpSignal_POINTER__POINTER) (GtkObject *object, + gpointer arg1, + gpointer user_data); + +void +gimp_marshal_POINTER__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + *GTK_RETLOC_POINTER (args[1]) = + (* (GimpSignal_POINTER__POINTER) func) (object, + GTK_VALUE_POINTER (args[0]), + func_data); +} + + typedef gpointer (* GimpSignal_POINTER__INT_INT) (GtkObject *object, gint arg1, gint arg2, diff --git a/app/core/gimpmarshal.h b/app/core/gimpmarshal.h index 953a337e75..adcf216338 100644 --- a/app/core/gimpmarshal.h +++ b/app/core/gimpmarshal.h @@ -35,6 +35,21 @@ void gimp_marshal_NONE__DOUBLE (GtkObject *object, gpointer func_data, GtkArg *args); +void gimp_marshal_INT__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + +void gimp_marshal_POINTER__INT (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + +void gimp_marshal_POINTER__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + void gimp_marshal_POINTER__INT_INT (GtkObject *object, GtkSignalFunc func, gpointer func_data, diff --git a/app/devices.c b/app/devices.c index 7fc9b781d1..96e1690d58 100644 --- a/app/devices.c +++ b/app/devices.c @@ -468,8 +468,9 @@ devices_rc_update (gchar *name, { GimpBrush *brush; - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - brush_name); + brush = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + brush_name); if (brush) { @@ -486,8 +487,9 @@ devices_rc_update (gchar *name, { GimpPattern *pattern; - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + pattern = (GimpPattern *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_pattern_list), + pattern_name); if (pattern) { diff --git a/app/gimpcontainer.c b/app/gimpcontainer.c index 2085328692..26aa063762 100644 --- a/app/gimpcontainer.c +++ b/app/gimpcontainer.c @@ -23,6 +23,7 @@ #include "apptypes.h" #include "gimpcontainer.h" +#include "gimpmarshal.h" typedef struct _GimpContainerHandler @@ -41,6 +42,9 @@ enum REMOVE, HAVE, FOREACH, + GET_CHILD_BY_NAME, + GET_CHILD_BY_INDEX, + GET_CHILD_INDEX, LAST_SIGNAL }; @@ -143,14 +147,47 @@ gimp_container_class_init (GimpContainerClass* klass) GTK_TYPE_POINTER, GTK_TYPE_POINTER); + container_signals[GET_CHILD_BY_NAME] = + gtk_signal_new ("get_child_by_name", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContainerClass, + get_child_by_name), + gimp_marshal_POINTER__POINTER, + GIMP_TYPE_OBJECT, 1, + GTK_TYPE_POINTER); + + container_signals[GET_CHILD_BY_INDEX] = + gtk_signal_new ("get_child_by_index", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContainerClass, + get_child_by_index), + gimp_marshal_POINTER__INT, + GIMP_TYPE_OBJECT, 1, + GTK_TYPE_INT); + + container_signals[GET_CHILD_INDEX] = + gtk_signal_new ("get_child_index", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContainerClass, + get_child_index), + gtk_marshal_INT__POINTER, + GTK_TYPE_INT, 1, + GIMP_TYPE_OBJECT); + gtk_object_class_add_signals (object_class, container_signals, LAST_SIGNAL); object_class->destroy = gimp_container_destroy; - klass->add = NULL; - klass->remove = NULL; - klass->have = NULL; - klass->foreach = NULL; + klass->add = NULL; + klass->remove = NULL; + klass->have = NULL; + klass->foreach = NULL; + klass->get_child_by_name = NULL; + klass->get_child_by_index = NULL; + klass->get_child_index = NULL; } static void @@ -351,6 +388,55 @@ gimp_container_foreach (GimpContainer *container, func, user_data); } +GimpObject * +gimp_container_get_child_by_name (const GimpContainer *container, + const gchar *name) +{ + GimpObject *object = NULL; + + g_return_val_if_fail (container != NULL, NULL); + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (name != NULL, NULL); + + gtk_signal_emit (GTK_OBJECT (container), container_signals[GET_CHILD_BY_NAME], + name, &object); + + return object; +} + +GimpObject * +gimp_container_get_child_by_index (const GimpContainer *container, + gint index) +{ + GimpObject *object = NULL; + + g_return_val_if_fail (container != NULL, NULL); + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (index >= 0 && index < container->num_children, NULL); + + gtk_signal_emit (GTK_OBJECT (container), container_signals[GET_CHILD_BY_INDEX], + index, &object); + + return object; +} + +gint +gimp_container_get_child_index (const GimpContainer *container, + const GimpObject *object) +{ + gint index = -1; + + g_return_val_if_fail (container != NULL, -1); + g_return_val_if_fail (GIMP_IS_CONTAINER (container), -1); + g_return_val_if_fail (object != NULL, -1); + g_return_val_if_fail (GTK_CHECK_TYPE (object, container->children_type), -1); + + gtk_signal_emit (GTK_OBJECT (container), container_signals[GET_CHILD_INDEX], + object, &index); + + return index; +} + static void gimp_container_add_handler_foreach_func (GimpObject *object, GimpContainerHandler *handler) diff --git a/app/gimpcontainer.h b/app/gimpcontainer.h index 660bac9971..b77d4eb629 100644 --- a/app/gimpcontainer.h +++ b/app/gimpcontainer.h @@ -56,41 +56,54 @@ struct _GimpContainerClass { GimpObjectClass parent_class; - void (* add) (GimpContainer *container, - GimpObject *object); - void (* remove) (GimpContainer *container, - GimpObject *object); - gboolean (* have) (GimpContainer *container, - GimpObject *object); - void (* foreach) (GimpContainer *container, - GFunc func, - gpointer user_data); + void (* add) (GimpContainer *container, + GimpObject *object); + void (* remove) (GimpContainer *container, + GimpObject *object); + gboolean (* have) (GimpContainer *container, + GimpObject *object); + void (* foreach) (GimpContainer *container, + GFunc func, + gpointer user_data); + GimpObject * (* get_child_by_name) (GimpContainer *container, + gchar *name); + GimpObject * (* get_child_by_index) (GimpContainer *container, + gint index); + gint (* get_child_index) (GimpContainer *container, + GimpObject *object); }; -GtkType gimp_container_get_type (void); +GtkType gimp_container_get_type (void); -GtkType gimp_container_children_type (const GimpContainer *container); -GimpContainerPolicy gimp_container_policy (const GimpContainer *container); -gint gimp_container_num_children (const GimpContainer *container); +GtkType gimp_container_children_type (const GimpContainer *container); +GimpContainerPolicy gimp_container_policy (const GimpContainer *container); +gint gimp_container_num_children (const GimpContainer *container); -gboolean gimp_container_add (GimpContainer *container, - GimpObject *object); -gboolean gimp_container_remove (GimpContainer *container, - GimpObject *object); +gboolean gimp_container_add (GimpContainer *container, + GimpObject *object); +gboolean gimp_container_remove (GimpContainer *container, + GimpObject *object); -gboolean gimp_container_have (GimpContainer *container, - GimpObject *object); -void gimp_container_foreach (GimpContainer *container, - GFunc func, - gpointer user_data); +gboolean gimp_container_have (GimpContainer *container, + GimpObject *object); +void gimp_container_foreach (GimpContainer *container, + GFunc func, + gpointer user_data); -GQuark gimp_container_add_handler (GimpContainer *container, - const gchar *signame, - GtkSignalFunc handler, - gpointer user_data); -void gimp_container_remove_handler (GimpContainer *container, - GQuark id); +GimpObject * gimp_container_get_child_by_name (const GimpContainer *container, + const gchar *name); +GimpObject * gimp_container_get_child_by_index (const GimpContainer *container, + gint index); +gint gimp_container_get_child_index (const GimpContainer *container, + const GimpObject *object); + +GQuark gimp_container_add_handler (GimpContainer *container, + const gchar *signame, + GtkSignalFunc handler, + gpointer user_data); +void gimp_container_remove_handler (GimpContainer *container, + GQuark id); #endif /* __GIMP_CONTAINER_H__ */ diff --git a/app/gimpcontainerlistview.c b/app/gimpcontainerlistview.c index bc68b1737d..916c8f13bd 100644 --- a/app/gimpcontainerlistview.c +++ b/app/gimpcontainerlistview.c @@ -222,8 +222,8 @@ gimp_container_list_view_add (GimpContainerListView *list_view, { gint index; - index = gimp_list_get_child_index (GIMP_LIST (container), - GIMP_OBJECT (viewable)); + index = gimp_container_get_child_index (container, + GIMP_OBJECT (viewable)); gimp_container_list_view_insert (list_view, viewable, index); } diff --git a/app/gimpcontext.c b/app/gimpcontext.c index 08d0de0f51..03ebf99331 100644 --- a/app/gimpcontext.c +++ b/app/gimpcontext.c @@ -30,8 +30,8 @@ #include "context_manager.h" #include "gdisplay.h" #include "gimpbrush.h" +#include "gimpcontainer.h" #include "gimpcontext.h" -#include "gimplist.h" #include "gimpmarshal.h" #include "gimppattern.h" #include "gimprc.h" @@ -1490,8 +1490,9 @@ gimp_context_refresh_brush (GimpContext *context, if (! context->brush_name) context->brush_name = g_strdup (default_brush); - if ((brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - context->brush_name))) + if ((brush = (GimpBrush *) + gimp_container_get_child_by_name (global_brush_list, + context->brush_name))) { gimp_context_real_set_brush (context, brush); return; @@ -1499,8 +1500,8 @@ gimp_context_refresh_brush (GimpContext *context, if (gimp_container_num_children (GIMP_CONTAINER (global_brush_list))) gimp_context_real_set_brush - (context, GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list, - 0))); + (context, GIMP_BRUSH (gimp_container_get_child_by_index (global_brush_list, + 0))); else gimp_context_real_set_brush (context, brushes_get_standard_brush ()); } @@ -1675,9 +1676,9 @@ gimp_context_refresh_pattern (GimpContext *context, if (! context->pattern_name) context->pattern_name = g_strdup (default_pattern); - if ((pattern = - (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - context->pattern_name))) + if ((pattern = (GimpPattern *) + gimp_container_get_child_by_name (global_pattern_list, + context->pattern_name))) { gimp_context_real_set_pattern (context, pattern); return; @@ -1685,8 +1686,9 @@ gimp_context_refresh_pattern (GimpContext *context, if (gimp_container_num_children (GIMP_CONTAINER (global_pattern_list))) gimp_context_real_set_pattern - (context, GIMP_PATTERN (gimp_list_get_child_by_index (global_pattern_list, - 0))); + (context, + GIMP_PATTERN (gimp_container_get_child_by_index (global_pattern_list, + 0))); else gimp_context_real_set_pattern (context, patterns_get_standard_pattern ()); } diff --git a/app/gimpdnd.c b/app/gimpdnd.c index 68dac23bd9..c07ddefea4 100644 --- a/app/gimpdnd.c +++ b/app/gimpdnd.c @@ -31,10 +31,10 @@ #include "fileops.h" #include "gimpimage.h" #include "gimpbrush.h" +#include "gimpcontainer.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "gimpdrawable.h" -#include "gimplist.h" #include "gimppattern.h" #include "gimprc.h" #include "gradient.h" @@ -661,7 +661,8 @@ gimp_dnd_set_brush_data (GtkWidget *widget, if (strcmp (name, "Standard") == 0) brush = brushes_get_standard_brush (); else - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, name); + brush = (GimpBrush *) gimp_container_get_child_by_name (global_brush_list, + name); if (brush) (* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data); @@ -761,8 +762,8 @@ gimp_dnd_set_pattern_data (GtkWidget *widget, if (strcmp (name, "Standard") == 0) pattern = patterns_get_standard_pattern (); else - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - name); + pattern = (GimpPattern *) gimp_container_get_child_by_name (global_pattern_list, + name); if (pattern) (* (GimpDndDropPatternFunc) set_pattern_func) (widget, pattern, diff --git a/app/gimplist.c b/app/gimplist.c index f31966d6e6..39972da07f 100644 --- a/app/gimplist.c +++ b/app/gimplist.c @@ -26,18 +26,24 @@ #include "gimplist.h" -static void gimp_list_class_init (GimpListClass *klass); -static void gimp_list_init (GimpList *list); -static void gimp_list_destroy (GtkObject *object); -static void gimp_list_add (GimpContainer *container, - GimpObject *object); -static void gimp_list_remove (GimpContainer *container, - GimpObject *object); -static gboolean gimp_list_have (GimpContainer *container, - GimpObject *object); -static void gimp_list_foreach (GimpContainer *container, - GFunc func, - gpointer user_data); +static void gimp_list_class_init (GimpListClass *klass); +static void gimp_list_init (GimpList *list); +static void gimp_list_destroy (GtkObject *object); +static void gimp_list_add (GimpContainer *container, + GimpObject *object); +static void gimp_list_remove (GimpContainer *container, + GimpObject *object); +static gboolean gimp_list_have (GimpContainer *container, + GimpObject *object); +static void gimp_list_foreach (GimpContainer *container, + GFunc func, + gpointer user_data); +static GimpObject * gimp_list_get_child_by_name (GimpContainer *container, + gchar *name); +static GimpObject * gimp_list_get_child_by_index (GimpContainer *container, + gint index); +static gint gimp_list_get_child_index (GimpContainer *container, + GimpObject *object); static GimpContainerClass *parent_class = NULL; @@ -81,10 +87,13 @@ gimp_list_class_init (GimpListClass *klass) object_class->destroy = gimp_list_destroy; - container_class->add = gimp_list_add; - container_class->remove = gimp_list_remove; - container_class->have = gimp_list_have; - container_class->foreach = gimp_list_foreach; + container_class->add = gimp_list_add; + container_class->remove = gimp_list_remove; + container_class->have = gimp_list_have; + container_class->foreach = gimp_list_foreach; + container_class->get_child_by_name = gimp_list_get_child_by_name; + container_class->get_child_by_index = gimp_list_get_child_by_index; + container_class->get_child_index = gimp_list_get_child_index; } static void @@ -173,16 +182,15 @@ gimp_list_new (GtkType children_type, return list; } -GimpObject * -gimp_list_get_child_by_name (const GimpList *list, - const gchar *name) +static GimpObject * +gimp_list_get_child_by_name (GimpContainer *container, + gchar *name) { + GimpList *list; GimpObject *object; GList *glist; - g_return_val_if_fail (list != NULL, NULL); - g_return_val_if_fail (GIMP_IS_LIST (list), NULL); - g_return_val_if_fail (name != NULL, NULL); + list = GIMP_LIST (container); for (glist = list->list; glist; glist = g_list_next (glist)) { @@ -195,14 +203,14 @@ gimp_list_get_child_by_name (const GimpList *list, return NULL; } -GimpObject * -gimp_list_get_child_by_index (const GimpList *list, - gint index) +static GimpObject * +gimp_list_get_child_by_index (GimpContainer *container, + gint index) { - GList *glist; + GimpList *list; + GList *glist; - g_return_val_if_fail (list != NULL, NULL); - g_return_val_if_fail (GIMP_IS_LIST (list), NULL); + list = GIMP_LIST (container); glist = g_list_nth (list->list, index); @@ -212,14 +220,13 @@ gimp_list_get_child_by_index (const GimpList *list, return NULL; } -gint -gimp_list_get_child_index (const GimpList *list, - const GimpObject *object) +static gint +gimp_list_get_child_index (GimpContainer *container, + GimpObject *object) { - g_return_val_if_fail (list != NULL, 0); - g_return_val_if_fail (GIMP_IS_LIST (list), 0); - g_return_val_if_fail (object != NULL, 0); - g_return_val_if_fail (GIMP_IS_OBJECT (list), 0); + GimpList *list; + + list = GIMP_LIST (container); return g_list_index (list->list, (gpointer) object); } diff --git a/app/gimplist.h b/app/gimplist.h index 90c9d07400..3d51d043a9 100644 --- a/app/gimplist.h +++ b/app/gimplist.h @@ -49,12 +49,5 @@ GtkType gimp_list_get_type (void); GimpList * gimp_list_new (GtkType children_type, GimpContainerPolicy policy); -GimpObject * gimp_list_get_child_by_name (const GimpList *list, - const gchar *name); -GimpObject * gimp_list_get_child_by_index (const GimpList *list, - gint index); -gint gimp_list_get_child_index (const GimpList *list, - const GimpObject *object); - #endif /* __GIMP_LIST_H__ */ diff --git a/app/gimpmarshal.c b/app/gimpmarshal.c index c154b268bd..9d5f0cdcd5 100644 --- a/app/gimpmarshal.c +++ b/app/gimpmarshal.c @@ -81,6 +81,57 @@ gimp_marshal_NONE__DOUBLE (GtkObject *object, } +typedef gint (* GimpSignal_INT__POINTER) (GtkObject *object, + gpointer arg1, + gpointer user_data); + +void +gimp_marshal_INT__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + *GTK_RETLOC_INT (args[1]) = + (* (GimpSignal_INT__POINTER) func) (object, + GTK_VALUE_POINTER (args[0]), + func_data); +} + + +typedef gpointer (* GimpSignal_POINTER__INT) (GtkObject *object, + gint arg1, + gpointer user_data); + +void +gimp_marshal_POINTER__INT (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + *GTK_RETLOC_POINTER (args[1]) = + (* (GimpSignal_POINTER__INT) func) (object, + GTK_VALUE_INT (args[0]), + func_data); +} + + +typedef gpointer (* GimpSignal_POINTER__POINTER) (GtkObject *object, + gpointer arg1, + gpointer user_data); + +void +gimp_marshal_POINTER__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + *GTK_RETLOC_POINTER (args[1]) = + (* (GimpSignal_POINTER__POINTER) func) (object, + GTK_VALUE_POINTER (args[0]), + func_data); +} + + typedef gpointer (* GimpSignal_POINTER__INT_INT) (GtkObject *object, gint arg1, gint arg2, diff --git a/app/gimpmarshal.h b/app/gimpmarshal.h index 953a337e75..adcf216338 100644 --- a/app/gimpmarshal.h +++ b/app/gimpmarshal.h @@ -35,6 +35,21 @@ void gimp_marshal_NONE__DOUBLE (GtkObject *object, gpointer func_data, GtkArg *args); +void gimp_marshal_INT__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + +void gimp_marshal_POINTER__INT (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + +void gimp_marshal_POINTER__POINTER (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); + void gimp_marshal_POINTER__INT_INT (GtkObject *object, GtkSignalFunc func, gpointer func_data, diff --git a/app/gui/brush-select.c b/app/gui/brush-select.c index 62ad43c878..8ee4b86ba2 100644 --- a/app/gui/brush-select.c +++ b/app/gui/brush-select.c @@ -310,8 +310,9 @@ brush_select_new (gchar *title, if (title && init_name && strlen (init_name)) { - active = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - init_name); + active = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + init_name); } else { @@ -836,7 +837,8 @@ brush_select_select (BrushSelect *bsp, gint row, col; gint scroll_offset = 0; - index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush)); + index = gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list), + GIMP_OBJECT (brush)); if (index < 0) return; @@ -886,7 +888,8 @@ brush_select_brush_dirty_callback (GimpBrush *brush, if (!bsp || bsp->freeze) return; - index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush)); + index = gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list), + GIMP_OBJECT (brush)); redraw = (brush != gimp_context_get_brush (bsp->context)); clear_brush (bsp, brush, @@ -1568,8 +1571,9 @@ brush_select_events (GtkWidget *widget, index = row * bsp->NUM_BRUSH_COLUMNS + col; /* Get the brush and check if it is editable */ - brush = GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list, - index)); + brush = (GimpBrush *) + gimp_container_get_child_by_index (GIMP_CONTAINER (global_brush_list), + index); if (GIMP_IS_BRUSH_GENERATED (brush)) brush_select_edit_brush_callback (NULL, bsp); break; @@ -1581,8 +1585,9 @@ brush_select_events (GtkWidget *widget, row = (bevent->y + bsp->scroll_offset) / bsp->cell_height; index = row * bsp->NUM_BRUSH_COLUMNS + col; - brush = (GimpBrush *) gimp_list_get_child_by_index (global_brush_list, - index); + brush = (GimpBrush *) + gimp_container_get_child_by_index (GIMP_CONTAINER (global_brush_list), + index); if (brush) bsp->dnd_brush = brush; @@ -1709,10 +1714,13 @@ brush_select_scroll_update (GtkAdjustment *adjustment, if (active) { - index = gimp_list_get_child_index (global_brush_list, - GIMP_OBJECT (active)); + index = + gimp_container_get_child_index (GIMP_CONTAINER (global_brush_list), + GIMP_OBJECT (active)); + if (index < 0) return; + row = index / bsp->NUM_BRUSH_COLUMNS; col = index - row * bsp->NUM_BRUSH_COLUMNS; diff --git a/app/gui/device-status-dialog.c b/app/gui/device-status-dialog.c index 7fc9b781d1..96e1690d58 100644 --- a/app/gui/device-status-dialog.c +++ b/app/gui/device-status-dialog.c @@ -468,8 +468,9 @@ devices_rc_update (gchar *name, { GimpBrush *brush; - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - brush_name); + brush = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + brush_name); if (brush) { @@ -486,8 +487,9 @@ devices_rc_update (gchar *name, { GimpPattern *pattern; - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + pattern = (GimpPattern *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_pattern_list), + pattern_name); if (pattern) { diff --git a/app/gui/input-dialog.c b/app/gui/input-dialog.c index 7fc9b781d1..96e1690d58 100644 --- a/app/gui/input-dialog.c +++ b/app/gui/input-dialog.c @@ -468,8 +468,9 @@ devices_rc_update (gchar *name, { GimpBrush *brush; - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - brush_name); + brush = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + brush_name); if (brush) { @@ -486,8 +487,9 @@ devices_rc_update (gchar *name, { GimpPattern *pattern; - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + pattern = (GimpPattern *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_pattern_list), + pattern_name); if (pattern) { diff --git a/app/gui/pattern-select.c b/app/gui/pattern-select.c index 730bab217b..d2e0bbfa69 100644 --- a/app/gui/pattern-select.c +++ b/app/gui/pattern-select.c @@ -28,6 +28,7 @@ #include "appenv.h" #include "dialog_handler.h" +#include "gimpcontainer.h" #include "gimpcontext.h" #include "gimpdnd.h" #include "gimplist.h" @@ -230,8 +231,9 @@ pattern_select_new (gchar *title, if (title && initial_pattern && strlen (initial_pattern)) { - active = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - initial_pattern); + active = (GimpPattern *) + gimp_container_get_child_by_name (global_pattern_list, + initial_pattern); } else { @@ -550,7 +552,8 @@ pattern_select_select (PatternSelect *psp, gint row, col; gint scroll_offset = 0; - index = gimp_list_get_child_index (global_pattern_list, GIMP_OBJECT (pattern)); + index = gimp_container_get_child_index (global_pattern_list, + GIMP_OBJECT (pattern)); if (index < 0) return; @@ -589,8 +592,8 @@ pattern_select_pattern_dirty_callback (GimpPattern *pattern, if (!psp || psp->freeze) return; - index = gimp_list_get_child_index (global_pattern_list, - GIMP_OBJECT (pattern)); + index = gimp_container_get_child_index (global_pattern_list, + GIMP_OBJECT (pattern)); redraw = (pattern != gimp_context_get_pattern (psp->context)); display_pattern (psp, pattern, @@ -829,7 +832,7 @@ display_pattern (PatternSelect *psp, static void display_patterns (PatternSelect *psp) { - GList *list = global_pattern_list->list; + GList *list = GIMP_LIST (global_pattern_list)->list; gint row, col; GimpPattern *pattern; @@ -1048,8 +1051,8 @@ pattern_select_events (GtkWidget *widget, index = row * psp->NUM_PATTERN_COLUMNS + col; pattern = - (GimpPattern *) gimp_list_get_child_by_index (global_pattern_list, - index); + (GimpPattern *) gimp_container_get_child_by_index (global_pattern_list, + index); if (pattern) psp->dnd_pattern = pattern; @@ -1139,8 +1142,8 @@ pattern_select_scroll_update (GtkAdjustment *adjustment, if (active) { - index = gimp_list_get_child_index (global_pattern_list, - GIMP_OBJECT (active)); + index = gimp_container_get_child_index (global_pattern_list, + GIMP_OBJECT (active)); if (index < 0) return; diff --git a/app/pattern_select.c b/app/pattern_select.c index 730bab217b..d2e0bbfa69 100644 --- a/app/pattern_select.c +++ b/app/pattern_select.c @@ -28,6 +28,7 @@ #include "appenv.h" #include "dialog_handler.h" +#include "gimpcontainer.h" #include "gimpcontext.h" #include "gimpdnd.h" #include "gimplist.h" @@ -230,8 +231,9 @@ pattern_select_new (gchar *title, if (title && initial_pattern && strlen (initial_pattern)) { - active = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - initial_pattern); + active = (GimpPattern *) + gimp_container_get_child_by_name (global_pattern_list, + initial_pattern); } else { @@ -550,7 +552,8 @@ pattern_select_select (PatternSelect *psp, gint row, col; gint scroll_offset = 0; - index = gimp_list_get_child_index (global_pattern_list, GIMP_OBJECT (pattern)); + index = gimp_container_get_child_index (global_pattern_list, + GIMP_OBJECT (pattern)); if (index < 0) return; @@ -589,8 +592,8 @@ pattern_select_pattern_dirty_callback (GimpPattern *pattern, if (!psp || psp->freeze) return; - index = gimp_list_get_child_index (global_pattern_list, - GIMP_OBJECT (pattern)); + index = gimp_container_get_child_index (global_pattern_list, + GIMP_OBJECT (pattern)); redraw = (pattern != gimp_context_get_pattern (psp->context)); display_pattern (psp, pattern, @@ -829,7 +832,7 @@ display_pattern (PatternSelect *psp, static void display_patterns (PatternSelect *psp) { - GList *list = global_pattern_list->list; + GList *list = GIMP_LIST (global_pattern_list)->list; gint row, col; GimpPattern *pattern; @@ -1048,8 +1051,8 @@ pattern_select_events (GtkWidget *widget, index = row * psp->NUM_PATTERN_COLUMNS + col; pattern = - (GimpPattern *) gimp_list_get_child_by_index (global_pattern_list, - index); + (GimpPattern *) gimp_container_get_child_by_index (global_pattern_list, + index); if (pattern) psp->dnd_pattern = pattern; @@ -1139,8 +1142,8 @@ pattern_select_scroll_update (GtkAdjustment *adjustment, if (active) { - index = gimp_list_get_child_index (global_pattern_list, - GIMP_OBJECT (active)); + index = gimp_container_get_child_index (global_pattern_list, + GIMP_OBJECT (active)); if (index < 0) return; diff --git a/app/patterns.c b/app/patterns.c index 8d7c10f56c..839174e1d0 100644 --- a/app/patterns.c +++ b/app/patterns.c @@ -42,7 +42,7 @@ static void patterns_load_pattern (const gchar *filename); /* global variables */ -GimpList *global_pattern_list = NULL; +GimpContainer *global_pattern_list = NULL; /* static variables */ @@ -57,7 +57,7 @@ patterns_init (gboolean no_data) if (global_pattern_list) patterns_free (); else - global_pattern_list = GIMP_LIST (gimp_data_list_new (GIMP_TYPE_PATTERN)); + global_pattern_list = GIMP_CONTAINER (gimp_data_list_new (GIMP_TYPE_PATTERN)); if (pattern_path != NULL && !no_data) { @@ -79,10 +79,11 @@ patterns_free (void) pattern_select_freeze_all (); - while (global_pattern_list->list) + while (GIMP_LIST (global_pattern_list)->list) { - gimp_container_remove (GIMP_CONTAINER (global_pattern_list), - GIMP_OBJECT (global_pattern_list->list->data)); + gimp_container_remove + (global_pattern_list, + GIMP_OBJECT (GIMP_LIST (global_pattern_list)->list->data)); } pattern_select_thaw_all (); @@ -134,6 +135,5 @@ patterns_load_pattern (const gchar *filename) g_message (_("Warning: Failed to load pattern\n\"%s\""), filename); if (pattern != NULL) - gimp_container_add (GIMP_CONTAINER (global_pattern_list), - GIMP_OBJECT (pattern)); + gimp_container_add (global_pattern_list, GIMP_OBJECT (pattern)); } diff --git a/app/patterns.h b/app/patterns.h index d18adf3ceb..1a5769acff 100644 --- a/app/patterns.h +++ b/app/patterns.h @@ -20,7 +20,7 @@ #define __PATTERNS_H__ -extern GimpList *global_pattern_list; +extern GimpContainer *global_pattern_list; void patterns_init (gboolean no_data); diff --git a/app/pdb/brush_select_cmds.c b/app/pdb/brush_select_cmds.c index 33deb3b91b..fc0dc5f86b 100644 --- a/app/pdb/brush_select_cmds.c +++ b/app/pdb/brush_select_cmds.c @@ -255,8 +255,8 @@ brushes_set_popup_invoker (Argument *args) if ((prec = procedural_db_lookup (name)) && (bsp = brush_get_brushselect (name))) { - GimpObject *object = gimp_list_get_child_by_name (global_brush_list, - brush_name); + GimpObject *object = + gimp_container_get_child_by_name (global_brush_list, brush_name); if (object) { diff --git a/app/pdb/brushes_cmds.c b/app/pdb/brushes_cmds.c index 27b089db3d..f672a6029e 100644 --- a/app/pdb/brushes_cmds.c +++ b/app/pdb/brushes_cmds.c @@ -168,7 +168,7 @@ brushes_set_brush_invoker (Argument *args) if (success) { - object = gimp_list_get_child_by_name (global_brush_list, name); + object = gimp_container_get_child_by_name (global_brush_list, name); if (object) gimp_context_set_brush (NULL, GIMP_BRUSH (object)); @@ -444,7 +444,7 @@ brushes_list_invoker (Argument *args) GList *list = NULL; int i = 0; - brushes = g_new (char *, GIMP_CONTAINER (global_brush_list)->num_children); + brushes = g_new (char *, global_brush_list->num_children); success = (list = GIMP_LIST (global_brush_list)->list) != NULL; @@ -458,7 +458,7 @@ brushes_list_invoker (Argument *args) if (success) { - return_args[1].value.pdb_int = GIMP_CONTAINER (global_brush_list)->num_children; + return_args[1].value.pdb_int = global_brush_list->num_children; return_args[2].value.pdb_pointer = brushes; } diff --git a/app/pdb/pattern_select_cmds.c b/app/pdb/pattern_select_cmds.c index 64e68390f1..e19ef5f791 100644 --- a/app/pdb/pattern_select_cmds.c +++ b/app/pdb/pattern_select_cmds.c @@ -218,8 +218,8 @@ patterns_set_popup_invoker (Argument *args) (psp = pattern_get_patternselect (name))) { GimpPattern *active = - (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + (GimpPattern *) gimp_container_get_child_by_name (global_pattern_list, + pattern_name); if (active) { diff --git a/app/pdb/patterns_cmds.c b/app/pdb/patterns_cmds.c index 11992bb9c5..60c340fe91 100644 --- a/app/pdb/patterns_cmds.c +++ b/app/pdb/patterns_cmds.c @@ -119,7 +119,9 @@ patterns_set_pattern_invoker (Argument *args) { success = FALSE; - for (list = global_pattern_list->list; list; list = g_list_next (list)) + for (list = GIMP_LIST (global_pattern_list)->list; + list; + list = g_list_next (list)) { pattern = (GimpPattern *) list->data; @@ -169,9 +171,9 @@ patterns_list_invoker (Argument *args) GList *list = NULL; gint i = 0; - patterns = g_new (gchar *, GIMP_CONTAINER (global_pattern_list)->num_children); + patterns = g_new (gchar *, global_pattern_list->num_children); - success = ((list = global_pattern_list->list) != NULL); + success = ((list = GIMP_LIST (global_pattern_list)->list) != NULL); while (list) { @@ -183,7 +185,7 @@ patterns_list_invoker (Argument *args) if (success) { - return_args[1].value.pdb_int = GIMP_CONTAINER (global_pattern_list)->num_children; + return_args[1].value.pdb_int = global_pattern_list->num_children; return_args[2].value.pdb_pointer = patterns; } @@ -242,7 +244,9 @@ patterns_get_pattern_data_invoker (Argument *args) success = FALSE; - for (list = global_pattern_list->list; list; list = g_list_next (list)) + for (list = GIMP_LIST (global_pattern_list)->list; + list; + list = g_list_next (list)) { pattern = (GimpPattern *) list->data; diff --git a/app/widgets/gimpcontainerlistview.c b/app/widgets/gimpcontainerlistview.c index bc68b1737d..916c8f13bd 100644 --- a/app/widgets/gimpcontainerlistview.c +++ b/app/widgets/gimpcontainerlistview.c @@ -222,8 +222,8 @@ gimp_container_list_view_add (GimpContainerListView *list_view, { gint index; - index = gimp_list_get_child_index (GIMP_LIST (container), - GIMP_OBJECT (viewable)); + index = gimp_container_get_child_index (container, + GIMP_OBJECT (viewable)); gimp_container_list_view_insert (list_view, viewable, index); } diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c index 7fc9b781d1..96e1690d58 100644 --- a/app/widgets/gimpdeviceinfo.c +++ b/app/widgets/gimpdeviceinfo.c @@ -468,8 +468,9 @@ devices_rc_update (gchar *name, { GimpBrush *brush; - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - brush_name); + brush = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + brush_name); if (brush) { @@ -486,8 +487,9 @@ devices_rc_update (gchar *name, { GimpPattern *pattern; - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + pattern = (GimpPattern *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_pattern_list), + pattern_name); if (pattern) { diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c index 7fc9b781d1..96e1690d58 100644 --- a/app/widgets/gimpdevices.c +++ b/app/widgets/gimpdevices.c @@ -468,8 +468,9 @@ devices_rc_update (gchar *name, { GimpBrush *brush; - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, - brush_name); + brush = (GimpBrush *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_brush_list), + brush_name); if (brush) { @@ -486,8 +487,9 @@ devices_rc_update (gchar *name, { GimpPattern *pattern; - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + pattern = (GimpPattern *) + gimp_container_get_child_by_name (GIMP_CONTAINER (global_pattern_list), + pattern_name); if (pattern) { diff --git a/app/widgets/gimpdnd.c b/app/widgets/gimpdnd.c index 68dac23bd9..c07ddefea4 100644 --- a/app/widgets/gimpdnd.c +++ b/app/widgets/gimpdnd.c @@ -31,10 +31,10 @@ #include "fileops.h" #include "gimpimage.h" #include "gimpbrush.h" +#include "gimpcontainer.h" #include "gimpcontextpreview.h" #include "gimpdnd.h" #include "gimpdrawable.h" -#include "gimplist.h" #include "gimppattern.h" #include "gimprc.h" #include "gradient.h" @@ -661,7 +661,8 @@ gimp_dnd_set_brush_data (GtkWidget *widget, if (strcmp (name, "Standard") == 0) brush = brushes_get_standard_brush (); else - brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, name); + brush = (GimpBrush *) gimp_container_get_child_by_name (global_brush_list, + name); if (brush) (* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data); @@ -761,8 +762,8 @@ gimp_dnd_set_pattern_data (GtkWidget *widget, if (strcmp (name, "Standard") == 0) pattern = patterns_get_standard_pattern (); else - pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - name); + pattern = (GimpPattern *) gimp_container_get_child_by_name (global_pattern_list, + name); if (pattern) (* (GimpDndDropPatternFunc) set_pattern_func) (widget, pattern, diff --git a/tools/pdbgen/pdb/brush_select.pdb b/tools/pdbgen/pdb/brush_select.pdb index 0b1f21ba0e..2037d124b9 100644 --- a/tools/pdbgen/pdb/brush_select.pdb +++ b/tools/pdbgen/pdb/brush_select.pdb @@ -132,8 +132,8 @@ sub brushes_set_popup { if ((prec = procedural_db_lookup (name)) && (bsp = brush_get_brushselect (name))) { - GimpObject *object = gimp_list_get_child_by_name (global_brush_list, - brush_name); + GimpObject *object = + gimp_container_get_child_by_name (global_brush_list, brush_name); if (object) { diff --git a/tools/pdbgen/pdb/brushes.pdb b/tools/pdbgen/pdb/brushes.pdb index e8637ce3e6..3419761b21 100644 --- a/tools/pdbgen/pdb/brushes.pdb +++ b/tools/pdbgen/pdb/brushes.pdb @@ -135,7 +135,7 @@ HELP vars => [ 'GimpObject *object' ], code => <<'CODE' { - object = gimp_list_get_child_by_name (global_brush_list, name); + object = gimp_container_get_child_by_name (global_brush_list, name); if (object) gimp_context_set_brush (NULL, GIMP_BRUSH (object)); @@ -262,14 +262,14 @@ HELP alias => 'brushes', array => { name => 'num_brushes', desc => 'The number of brushes in the brush list', - alias => 'GIMP_CONTAINER (global_brush_list)->num_children', no_declare => 1 } } + alias => 'global_brush_list->num_children', no_declare => 1 } } ); %invoke = ( vars => [ 'GList *list = NULL', 'int i = 0' ], code => <<'CODE' { - brushes = g_new (char *, GIMP_CONTAINER (global_brush_list)->num_children); + brushes = g_new (char *, global_brush_list->num_children); success = (list = GIMP_LIST (global_brush_list)->list) != NULL; diff --git a/tools/pdbgen/pdb/pattern_select.pdb b/tools/pdbgen/pdb/pattern_select.pdb index ca807d14f6..2a2e8e672c 100644 --- a/tools/pdbgen/pdb/pattern_select.pdb +++ b/tools/pdbgen/pdb/pattern_select.pdb @@ -119,8 +119,8 @@ sub patterns_set_popup { (psp = pattern_get_patternselect (name))) { GimpPattern *active = - (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list, - pattern_name); + (GimpPattern *) gimp_container_get_child_by_name (global_pattern_list, + pattern_name); if (active) { diff --git a/tools/pdbgen/pdb/patterns.pdb b/tools/pdbgen/pdb/patterns.pdb index 67689f058e..c3beef483c 100644 --- a/tools/pdbgen/pdb/patterns.pdb +++ b/tools/pdbgen/pdb/patterns.pdb @@ -94,7 +94,9 @@ HELP { success = FALSE; - for (list = global_pattern_list->list; list; list = g_list_next (list)) + for (list = GIMP_LIST (global_pattern_list)->list; + list; + list = g_list_next (list)) { pattern = (GimpPattern *) list->data; @@ -126,16 +128,16 @@ HELP alias => 'patterns', array => { name => 'num_patterns', desc => 'The number of patterns in the pattern list', - alias => 'GIMP_CONTAINER (global_pattern_list)->num_children', no_declare => 1 } } + alias => 'global_pattern_list->num_children', no_declare => 1 } } ); %invoke = ( vars => [ 'GList *list = NULL', 'gint i = 0' ], code => <<'CODE' { - patterns = g_new (gchar *, GIMP_CONTAINER (global_pattern_list)->num_children); + patterns = g_new (gchar *, global_pattern_list->num_children); - success = ((list = global_pattern_list->list) != NULL); + success = ((list = GIMP_LIST (global_pattern_list)->list) != NULL); while (list) { @@ -190,7 +192,9 @@ HELP success = FALSE; - for (list = global_pattern_list->list; list; list = g_list_next (list)) + for (list = GIMP_LIST (global_pattern_list)->list; + list; + list = g_list_next (list)) { pattern = (GimpPattern *) list->data;