From eb6e907b36e47dd0294f0a48e83b368d569f5345 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 9 Feb 2003 17:32:52 +0000 Subject: [PATCH] simplified everything a lot by merging the public GimpContextPropType enum 2003-02-09 Michael Natterer * app/core/gimpcontext.[ch]: simplified everything a lot by merging the public GimpContextPropType enum with the internal anonymous object property id enum. Removed the internal copy_prop functions and handle property copying in a big switch() in gimp_context_copy_property(). Removed the separate signal connections for each property of the parent context and do the same using a single "notify" handler. Emit "notify" signals all over the place. Removed internal arrays which are no longer needed due to enum merge and copy_property simplification. Removed the array of signal names and use g_signal_name(). Removed gimp_context_unset_parent() and allow "parent" being NULL in gimp_context_set_parent(). * app/tools/tool_manager.c * app/widgets/gimpdevices.c: changed accordingly. * libgimptool/gimptooltypes.h: changed GimpToolOptionsGUIFunc to return a GtkWidget (the created tool options widget). * libgimptool/gimptoolmodule.c: #include * app/tools/tool_options.[ch]: removed the "main_vbox" from the GimpToolOptions struct. Changed gimp_tool_options_gui() to create and return the main_vbox. * app/tools/tool_manager.c: create the "This Tool has no Options" label here if NULL was passed as "options_gui_func". Attach the options widget to the tool_options object using g_object_set_data(). * app/gui/tool-options-dialog.c: changed accordingly. * app/tools/gimpairbrushtool.c * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpclonetool.c * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimpcropoptions.[ch] * app/tools/gimpdodgeburntool.c * app/tools/gimperasertool.c * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimpselectionoptions.[ch] * app/tools/gimpsmudgetool.c * app/tools/gimptextoptions.[ch] * app/tools/gimptransformoptions.[ch] * app/tools/gimpvectoroptions.[ch] * app/tools/paint_options.[ch]: return the options vbox from all tool_options_gui functions. --- ChangeLog | 56 +++ app/core/gimpcontext.c | 723 ++++++++++++---------------- app/core/gimpcontext.h | 58 +-- app/core/gimptooloptions.c | 12 +- app/core/gimptooloptions.h | 4 +- app/gui/tool-options-dialog.c | 18 +- app/paint/gimpinkoptions.c | 8 +- app/paint/gimpinkoptions.h | 4 +- app/tools/gimpairbrushtool.c | 14 +- app/tools/gimpblendoptions.c | 8 +- app/tools/gimpblendoptions.h | 4 +- app/tools/gimpbucketfilloptions.c | 8 +- app/tools/gimpbucketfilloptions.h | 4 +- app/tools/gimpclonetool.c | 10 +- app/tools/gimpcolorpickeroptions.c | 6 +- app/tools/gimpcolorpickeroptions.h | 4 +- app/tools/gimpconvolvetool.c | 10 +- app/tools/gimpcropoptions.c | 6 +- app/tools/gimpcropoptions.h | 4 +- app/tools/gimpdodgeburntool.c | 10 +- app/tools/gimperasertool.c | 10 +- app/tools/gimpflipoptions.c | 6 +- app/tools/gimpflipoptions.h | 4 +- app/tools/gimpinkoptions-gui.c | 8 +- app/tools/gimpinkoptions-gui.h | 4 +- app/tools/gimpinkoptions.c | 8 +- app/tools/gimpinkoptions.h | 4 +- app/tools/gimpmagnifyoptions.c | 6 +- app/tools/gimpmagnifyoptions.h | 4 +- app/tools/gimpmeasureoptions.c | 6 +- app/tools/gimpmeasureoptions.h | 4 +- app/tools/gimpmoveoptions.c | 6 +- app/tools/gimpmoveoptions.h | 4 +- app/tools/gimppaintoptions-gui.c | 6 +- app/tools/gimppaintoptions-gui.h | 2 +- app/tools/gimpselectionoptions.c | 6 +- app/tools/gimpselectionoptions.h | 4 +- app/tools/gimpsmudgetool.c | 14 +- app/tools/gimpsourcetool.c | 10 +- app/tools/gimptextoptions.c | 6 +- app/tools/gimptextoptions.h | 4 +- app/tools/gimptransformoptions.c | 6 +- app/tools/gimptransformoptions.h | 4 +- app/tools/gimpvectoroptions.c | 6 +- app/tools/gimpvectoroptions.h | 4 +- app/tools/paint_options.c | 6 +- app/tools/paint_options.h | 2 +- app/tools/tool_manager.c | 29 +- app/tools/tool_options.c | 12 +- app/tools/tool_options.h | 4 +- app/widgets/gimpdevices.c | 2 +- app/widgets/gimptooloptionseditor.c | 18 +- libgimptool/gimptoolmodule.c | 2 +- libgimptool/gimptooltypes.h | 2 +- 54 files changed, 597 insertions(+), 597 deletions(-) diff --git a/ChangeLog b/ChangeLog index da4615c158..9ce3367d06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,59 @@ +2003-02-09 Michael Natterer + + * app/core/gimpcontext.[ch]: simplified everything a lot by + merging the public GimpContextPropType enum with the internal + anonymous object property id enum. Removed the internal copy_prop + functions and handle property copying in a big switch() in + gimp_context_copy_property(). Removed the separate signal + connections for each property of the parent context and do the + same using a single "notify" handler. Emit "notify" signals all + over the place. Removed internal arrays which are no longer + needed due to enum merge and copy_property simplification. + Removed the array of signal names and use g_signal_name(). + Removed gimp_context_unset_parent() and allow "parent" being NULL + in gimp_context_set_parent(). + + * app/tools/tool_manager.c + * app/widgets/gimpdevices.c: changed accordingly. + + * libgimptool/gimptooltypes.h: changed GimpToolOptionsGUIFunc to + return a GtkWidget (the created tool options widget). + + * libgimptool/gimptoolmodule.c: #include + + * app/tools/tool_options.[ch]: removed the "main_vbox" from the + GimpToolOptions struct. Changed gimp_tool_options_gui() to create + and return the main_vbox. + + * app/tools/tool_manager.c: create the "This Tool has no Options" + label here if NULL was passed as "options_gui_func". Attach the + options widget to the tool_options object using + g_object_set_data(). + + * app/gui/tool-options-dialog.c: changed accordingly. + + * app/tools/gimpairbrushtool.c + * app/tools/gimpblendoptions.[ch] + * app/tools/gimpbucketfilloptions.[ch] + * app/tools/gimpclonetool.c + * app/tools/gimpcolorpickeroptions.[ch] + * app/tools/gimpconvolvetool.c + * app/tools/gimpcropoptions.[ch] + * app/tools/gimpdodgeburntool.c + * app/tools/gimperasertool.c + * app/tools/gimpflipoptions.[ch] + * app/tools/gimpinkoptions.[ch] + * app/tools/gimpmagnifyoptions.[ch] + * app/tools/gimpmeasureoptions.[ch] + * app/tools/gimpmoveoptions.[ch] + * app/tools/gimpselectionoptions.[ch] + * app/tools/gimpsmudgetool.c + * app/tools/gimptextoptions.[ch] + * app/tools/gimptransformoptions.[ch] + * app/tools/gimpvectoroptions.[ch] + * app/tools/paint_options.[ch]: return the options vbox from + all tool_options_gui functions. + 2003-02-08 Sven Neumann * app/text/gimptext.c diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index c87efa64d2..e7bf476751 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -59,9 +59,9 @@ typedef void (* GimpContextCopyPropFunc) (GimpContext *src, GimpContext *dest); -#define context_find_defined(context,prop_mask) \ - while (!(((context)->defined_props) & prop_mask) && (context)->parent) \ - (context) = (context)->parent +#define context_find_defined(context,prop) \ + while (!(((context)->defined_props) & (1 << (prop))) && (context)->parent) \ + (context) = (context)->parent /* local function prototypes */ @@ -103,8 +103,6 @@ static void gimp_context_image_removed (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_image (GimpContext *context, GimpImage *image); -static void gimp_context_copy_image (GimpContext *src, - GimpContext *dest); /* display */ static void gimp_context_display_removed (GimpContainer *container, @@ -112,8 +110,6 @@ static void gimp_context_display_removed (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_display (GimpContext *context, gpointer display); -static void gimp_context_copy_display (GimpContext *src, - GimpContext *dest); /* tool */ static void gimp_context_tool_dirty (GimpToolInfo *tool_info, @@ -125,33 +121,22 @@ static void gimp_context_tool_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_tool (GimpContext *context, GimpToolInfo *tool_info); -static void gimp_context_copy_tool (GimpContext *src, - GimpContext *dest); /* foreground */ static void gimp_context_real_set_foreground (GimpContext *context, const GimpRGB *color); -static void gimp_context_copy_foreground (GimpContext *src, - GimpContext *dest); /* background */ static void gimp_context_real_set_background (GimpContext *context, const GimpRGB *color); -static void gimp_context_copy_background (GimpContext *src, - GimpContext *dest); /* opacity */ static void gimp_context_real_set_opacity (GimpContext *context, gdouble opacity); -static void gimp_context_copy_opacity (GimpContext *src, - GimpContext *dest); /* paint mode */ static void gimp_context_real_set_paint_mode (GimpContext *context, - GimpLayerModeEffects - paint_mode); -static void gimp_context_copy_paint_mode (GimpContext *src, - GimpContext *dest); + GimpLayerModeEffects paint_mode); /* brush */ static void gimp_context_brush_dirty (GimpBrush *brush, @@ -163,8 +148,6 @@ static void gimp_context_brush_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_brush (GimpContext *context, GimpBrush *brush); -static void gimp_context_copy_brush (GimpContext *src, - GimpContext *dest); /* pattern */ static void gimp_context_pattern_dirty (GimpPattern *pattern, @@ -176,8 +159,6 @@ static void gimp_context_pattern_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_pattern (GimpContext *context, GimpPattern *pattern); -static void gimp_context_copy_pattern (GimpContext *src, - GimpContext *dest); /* gradient */ static void gimp_context_gradient_dirty (GimpGradient *gradient, @@ -189,8 +170,6 @@ static void gimp_context_gradient_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_gradient (GimpContext *context, GimpGradient *gradient); -static void gimp_context_copy_gradient (GimpContext *src, - GimpContext *dest); /* palette */ static void gimp_context_palette_dirty (GimpPalette *palette, @@ -202,8 +181,6 @@ static void gimp_context_palette_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_palette (GimpContext *context, GimpPalette *palatte); -static void gimp_context_copy_palette (GimpContext *src, - GimpContext *dest); /* buffer */ static void gimp_context_buffer_dirty (GimpBuffer *buffer, @@ -215,8 +192,6 @@ static void gimp_context_buffer_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_buffer (GimpContext *context, GimpBuffer *buffer); -static void gimp_context_copy_buffer (GimpContext *src, - GimpContext *dest); /* imagefile */ static void gimp_context_imagefile_dirty (GimpImagefile *imagefile, @@ -228,33 +203,22 @@ static void gimp_context_imagefile_list_thaw (GimpContainer *container, GimpContext *context); static void gimp_context_real_set_imagefile (GimpContext *context, GimpImagefile *imagefile); -static void gimp_context_copy_imagefile (GimpContext *src, - GimpContext *dest); /* properties & signals */ enum { - PROP_0, - PROP_GIMP, - PROP_IMAGE, - PROP_DISPLAY, - PROP_TOOL, - PROP_FOREGROUND, - PROP_BACKGROUND, - PROP_OPACITY, - PROP_PAINT_MODE, - PROP_BRUSH, - PROP_PATTERN, - PROP_GRADIENT, - PROP_PALETTE, - PROP_BUFFER, - PROP_IMAGEFILE + GIMP_CONTEXT_PROP_0, + GIMP_CONTEXT_PROP_GIMP + + /* remaining values are in gimpcontext.h */ }; enum { + DUMMY_0, + DUMMY_1, IMAGE_CHANGED, DISPLAY_CHANGED, TOOL_CHANGED, @@ -273,13 +237,15 @@ enum static gchar *gimp_context_prop_names[] = { + NULL, /* PROP_0 */ + "gimp", "image", "display", "tool", "foreground", "background", "opacity", - "paint_mode", + "paint-mode", "brush", "pattern", "gradient", @@ -288,25 +254,10 @@ static gchar *gimp_context_prop_names[] = "imagefile" }; -static GimpContextCopyPropFunc gimp_context_copy_prop_funcs[] = -{ - gimp_context_copy_image, - gimp_context_copy_display, - gimp_context_copy_tool, - gimp_context_copy_foreground, - gimp_context_copy_background, - gimp_context_copy_opacity, - gimp_context_copy_paint_mode, - gimp_context_copy_brush, - gimp_context_copy_pattern, - gimp_context_copy_gradient, - gimp_context_copy_palette, - gimp_context_copy_buffer, - gimp_context_copy_imagefile -}; - static GType gimp_context_prop_types[] = { + G_TYPE_NONE, /* PROP_0 */ + G_TYPE_NONE, /* PROP_GIMP */ 0, G_TYPE_NONE, 0, @@ -322,45 +273,17 @@ static GType gimp_context_prop_types[] = 0 }; -static gchar *gimp_context_signal_names[] = -{ - "image_changed", - "display_changed", - "tool_changed", - "foreground_changed", - "background_changed", - "opacity_changed", - "paint_mode_changed", - "brush_changed", - "pattern_changed", - "gradient_changed", - "palette_changed", - "buffer_changed", - "imagefile_changed" -}; - -static GCallback gimp_context_signal_handlers[] = -{ - G_CALLBACK (gimp_context_real_set_image), - G_CALLBACK (gimp_context_real_set_display), - G_CALLBACK (gimp_context_real_set_tool), - G_CALLBACK (gimp_context_real_set_foreground), - G_CALLBACK (gimp_context_real_set_background), - G_CALLBACK (gimp_context_real_set_opacity), - G_CALLBACK (gimp_context_real_set_paint_mode), - G_CALLBACK (gimp_context_real_set_brush), - G_CALLBACK (gimp_context_real_set_pattern), - G_CALLBACK (gimp_context_real_set_gradient), - G_CALLBACK (gimp_context_real_set_palette), - G_CALLBACK (gimp_context_real_set_buffer), - G_CALLBACK (gimp_context_real_set_imagefile) -}; - static guint gimp_context_signals[LAST_SIGNAL] = { 0 }; static GimpObjectClass * parent_class = NULL; +static GimpToolInfo *standard_tool_info = NULL; +static GimpBrush *standard_brush = NULL; +static GimpPattern *standard_pattern = NULL; +static GimpGradient *standard_gradient = NULL; +static GimpPalette *standard_palette = NULL; + GType gimp_context_get_type (void) @@ -417,7 +340,7 @@ gimp_context_class_init (GimpContextClass *klass) parent_class = g_type_class_peek_parent (klass); gimp_context_signals[IMAGE_CHANGED] = - g_signal_new (gimp_context_signal_names[IMAGE_CHANGED], + g_signal_new ("image_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, image_changed), @@ -427,7 +350,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_IMAGE); gimp_context_signals[DISPLAY_CHANGED] = - g_signal_new (gimp_context_signal_names[DISPLAY_CHANGED], + g_signal_new ("display_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, display_changed), @@ -437,7 +360,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_OBJECT); gimp_context_signals[TOOL_CHANGED] = - g_signal_new (gimp_context_signal_names[TOOL_CHANGED], + g_signal_new ("tool_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, tool_changed), @@ -447,7 +370,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_TOOL_INFO); gimp_context_signals[FOREGROUND_CHANGED] = - g_signal_new (gimp_context_signal_names[FOREGROUND_CHANGED], + g_signal_new ("foreground_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, foreground_changed), @@ -457,7 +380,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_COLOR); gimp_context_signals[BACKGROUND_CHANGED] = - g_signal_new (gimp_context_signal_names[BACKGROUND_CHANGED], + g_signal_new ("background_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, background_changed), @@ -467,7 +390,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_COLOR); gimp_context_signals[OPACITY_CHANGED] = - g_signal_new (gimp_context_signal_names[OPACITY_CHANGED], + g_signal_new ("opacity_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, opacity_changed), @@ -477,7 +400,7 @@ gimp_context_class_init (GimpContextClass *klass) G_TYPE_DOUBLE); gimp_context_signals[PAINT_MODE_CHANGED] = - g_signal_new (gimp_context_signal_names[PAINT_MODE_CHANGED], + g_signal_new ("paint_mode_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, paint_mode_changed), @@ -487,7 +410,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_LAYER_MODE_EFFECTS); gimp_context_signals[BRUSH_CHANGED] = - g_signal_new (gimp_context_signal_names[BRUSH_CHANGED], + g_signal_new ("brush_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, brush_changed), @@ -497,7 +420,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_BRUSH); gimp_context_signals[PATTERN_CHANGED] = - g_signal_new (gimp_context_signal_names[PATTERN_CHANGED], + g_signal_new ("pattern_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, pattern_changed), @@ -507,7 +430,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_PATTERN); gimp_context_signals[GRADIENT_CHANGED] = - g_signal_new (gimp_context_signal_names[GRADIENT_CHANGED], + g_signal_new ("gradient_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, gradient_changed), @@ -517,7 +440,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_GRADIENT); gimp_context_signals[PALETTE_CHANGED] = - g_signal_new (gimp_context_signal_names[PALETTE_CHANGED], + g_signal_new ("palette_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, palette_changed), @@ -527,7 +450,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_PALETTE); gimp_context_signals[BUFFER_CHANGED] = - g_signal_new (gimp_context_signal_names[BUFFER_CHANGED], + g_signal_new ("buffer_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, buffer_changed), @@ -537,7 +460,7 @@ gimp_context_class_init (GimpContextClass *klass) GIMP_TYPE_BUFFER); gimp_context_signals[IMAGEFILE_CHANGED] = - g_signal_new (gimp_context_signal_names[IMAGEFILE_CHANGED], + g_signal_new ("imagefile_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GimpContextClass, imagefile_changed), @@ -577,89 +500,89 @@ gimp_context_class_init (GimpContextClass *klass) gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER] = GIMP_TYPE_BUFFER; gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE] = GIMP_TYPE_IMAGEFILE; - g_object_class_install_property (object_class, PROP_GIMP, + g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_GIMP, g_param_spec_object ("gimp", NULL, NULL, GIMP_TYPE_GIMP, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, PROP_IMAGE, - g_param_spec_object (gimp_context_prop_names[IMAGE_CHANGED], - NULL, NULL, - GIMP_TYPE_IMAGE, - G_PARAM_READWRITE)); + g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_IMAGE, + g_param_spec_object (gimp_context_prop_names[GIMP_CONTEXT_PROP_IMAGE], + NULL, NULL, + GIMP_TYPE_IMAGE, + G_PARAM_READWRITE)); - g_object_class_install_property (object_class, PROP_DISPLAY, - g_param_spec_object (gimp_context_prop_names[DISPLAY_CHANGED], + g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_DISPLAY, + g_param_spec_object (gimp_context_prop_names[GIMP_CONTEXT_PROP_DISPLAY], NULL, NULL, GIMP_TYPE_OBJECT, G_PARAM_READWRITE)); - GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_TOOL, - gimp_context_prop_names[TOOL_CHANGED], NULL, + GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_TOOL, + gimp_context_prop_names[GIMP_CONTEXT_PROP_TOOL], NULL, GIMP_TYPE_TOOL_INFO, 0); - GIMP_CONFIG_INSTALL_PROP_COLOR (object_class, PROP_FOREGROUND, - gimp_context_prop_names[FOREGROUND_CHANGED], + GIMP_CONFIG_INSTALL_PROP_COLOR (object_class, GIMP_CONTEXT_PROP_FOREGROUND, + gimp_context_prop_names[GIMP_CONTEXT_PROP_FOREGROUND], NULL, &black, 0); - GIMP_CONFIG_INSTALL_PROP_COLOR (object_class, PROP_BACKGROUND, - gimp_context_prop_names[BACKGROUND_CHANGED], + GIMP_CONFIG_INSTALL_PROP_COLOR (object_class, GIMP_CONTEXT_PROP_BACKGROUND, + gimp_context_prop_names[GIMP_CONTEXT_PROP_BACKGROUND], NULL, &white, 0); - GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_OPACITY, - gimp_context_prop_names[OPACITY_CHANGED], + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, GIMP_CONTEXT_PROP_OPACITY, + gimp_context_prop_names[GIMP_CONTEXT_PROP_OPACITY], NULL, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE, GIMP_OPACITY_OPAQUE, 0); - GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PAINT_MODE, - gimp_context_prop_names[PAINT_MODE_CHANGED], + GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, GIMP_CONTEXT_PROP_PAINT_MODE, + gimp_context_prop_names[GIMP_CONTEXT_PROP_PAINT_MODE], NULL, GIMP_TYPE_LAYER_MODE_EFFECTS, GIMP_NORMAL_MODE, 0); - GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_BRUSH, - gimp_context_prop_names[BRUSH_CHANGED], + GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_BRUSH, + gimp_context_prop_names[GIMP_CONTEXT_PROP_BRUSH], NULL, GIMP_TYPE_BRUSH, 0); - GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_PATTERN, - gimp_context_prop_names[PATTERN_CHANGED], + GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_PATTERN, + gimp_context_prop_names[GIMP_CONTEXT_PROP_PATTERN], NULL, GIMP_TYPE_PATTERN, 0); - GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_GRADIENT, - gimp_context_prop_names[GRADIENT_CHANGED], + GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_GRADIENT, + gimp_context_prop_names[GIMP_CONTEXT_PROP_GRADIENT], NULL, GIMP_TYPE_GRADIENT, 0); - GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_PALETTE, - gimp_context_prop_names[PALETTE_CHANGED], + GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_PALETTE, + gimp_context_prop_names[GIMP_CONTEXT_PROP_PALETTE], NULL, GIMP_TYPE_PALETTE, 0); - g_object_class_install_property (object_class, PROP_BUFFER, - g_param_spec_object (gimp_context_prop_names[BUFFER_CHANGED], + g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_BUFFER, + g_param_spec_object (gimp_context_prop_names[GIMP_CONTEXT_PROP_BUFFER], NULL, NULL, GIMP_TYPE_BUFFER, G_PARAM_READWRITE)); - g_object_class_install_property (object_class, PROP_IMAGEFILE, - g_param_spec_object (gimp_context_prop_names[IMAGEFILE_CHANGED], + g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_IMAGEFILE, + g_param_spec_object (gimp_context_prop_names[GIMP_CONTEXT_PROP_IMAGEFILE], NULL, NULL, GIMP_TYPE_IMAGEFILE, G_PARAM_READWRITE)); @@ -817,7 +740,7 @@ gimp_context_finalize (GObject *object) context = GIMP_CONTEXT (object); if (context->parent) - gimp_context_unset_parent (context); + gimp_context_set_parent (context, NULL); context->image = NULL; context->display = NULL; @@ -904,48 +827,48 @@ gimp_context_set_property (GObject *object, switch (property_id) { - case PROP_GIMP: + case GIMP_CONTEXT_PROP_GIMP: context->gimp = g_value_get_object (value); context->gimp->context_list = g_list_prepend (context->gimp->context_list, context); break; - case PROP_IMAGE: + case GIMP_CONTEXT_PROP_IMAGE: gimp_context_set_image (context, g_value_get_object (value)); break; - case PROP_DISPLAY: + case GIMP_CONTEXT_PROP_DISPLAY: gimp_context_set_display (context, g_value_get_object (value)); break; - case PROP_TOOL: + case GIMP_CONTEXT_PROP_TOOL: gimp_context_set_tool (context, g_value_get_object (value)); break; - case PROP_FOREGROUND: + case GIMP_CONTEXT_PROP_FOREGROUND: gimp_context_set_foreground (context, g_value_get_boxed (value)); break; - case PROP_BACKGROUND: + case GIMP_CONTEXT_PROP_BACKGROUND: gimp_context_set_background (context, g_value_get_boxed (value)); break; - case PROP_OPACITY: + case GIMP_CONTEXT_PROP_OPACITY: gimp_context_set_opacity (context, g_value_get_double (value)); break; - case PROP_PAINT_MODE: + case GIMP_CONTEXT_PROP_PAINT_MODE: gimp_context_set_paint_mode (context, g_value_get_enum (value)); break; - case PROP_BRUSH: + case GIMP_CONTEXT_PROP_BRUSH: gimp_context_set_brush (context, g_value_get_object (value)); break; - case PROP_PATTERN: + case GIMP_CONTEXT_PROP_PATTERN: gimp_context_set_pattern (context, g_value_get_object (value)); break; - case PROP_GRADIENT: + case GIMP_CONTEXT_PROP_GRADIENT: gimp_context_set_gradient (context, g_value_get_object (value)); break; - case PROP_PALETTE: + case GIMP_CONTEXT_PROP_PALETTE: gimp_context_set_palette (context, g_value_get_object (value)); break; - case PROP_BUFFER: + case GIMP_CONTEXT_PROP_BUFFER: gimp_context_set_buffer (context, g_value_get_object (value)); break; - case PROP_IMAGEFILE: + case GIMP_CONTEXT_PROP_IMAGEFILE: gimp_context_set_imagefile (context, g_value_get_object (value)); break; default: @@ -966,19 +889,19 @@ gimp_context_get_property (GObject *object, switch (property_id) { - case PROP_GIMP: + case GIMP_CONTEXT_PROP_GIMP: g_value_set_object (value, context->gimp); break; - case PROP_IMAGE: + case GIMP_CONTEXT_PROP_IMAGE: g_value_set_object (value, gimp_context_get_image (context)); break; - case PROP_DISPLAY: + case GIMP_CONTEXT_PROP_DISPLAY: g_value_set_object (value, gimp_context_get_display (context)); break; - case PROP_TOOL: + case GIMP_CONTEXT_PROP_TOOL: g_value_set_object (value, gimp_context_get_tool (context)); break; - case PROP_FOREGROUND: + case GIMP_CONTEXT_PROP_FOREGROUND: { GimpRGB color; @@ -986,7 +909,7 @@ gimp_context_get_property (GObject *object, g_value_set_boxed (value, &color); } break; - case PROP_BACKGROUND: + case GIMP_CONTEXT_PROP_BACKGROUND: { GimpRGB color; @@ -994,28 +917,28 @@ gimp_context_get_property (GObject *object, g_value_set_boxed (value, &color); } break; - case PROP_OPACITY: + case GIMP_CONTEXT_PROP_OPACITY: g_value_set_double (value, gimp_context_get_opacity (context)); break; - case PROP_PAINT_MODE: + case GIMP_CONTEXT_PROP_PAINT_MODE: g_value_set_enum (value, gimp_context_get_paint_mode (context)); break; - case PROP_BRUSH: + case GIMP_CONTEXT_PROP_BRUSH: g_value_set_object (value, gimp_context_get_brush (context)); break; - case PROP_PATTERN: + case GIMP_CONTEXT_PROP_PATTERN: g_value_set_object (value, gimp_context_get_pattern (context)); break; - case PROP_GRADIENT: + case GIMP_CONTEXT_PROP_GRADIENT: g_value_set_object (value, gimp_context_get_gradient (context)); break; - case PROP_PALETTE: + case GIMP_CONTEXT_PROP_PALETTE: g_value_set_object (value, gimp_context_get_palette (context)); break; - case PROP_BUFFER: + case GIMP_CONTEXT_PROP_BUFFER: g_value_set_object (value, gimp_context_get_buffer (context)); break; - case PROP_IMAGEFILE: + case GIMP_CONTEXT_PROP_IMAGEFILE: g_value_set_object (value, gimp_context_get_imagefile (context)); break; default: @@ -1059,13 +982,19 @@ gimp_context_serialize_property (GObject *object, context = GIMP_CONTEXT (object); +#if 0 + /* serialize nothing if the property is not defined */ + if (! ((1 << property_id) & context->defined_props)) + return TRUE; +#endif + switch (property_id) { - case PROP_TOOL: - case PROP_BRUSH: - case PROP_PATTERN: - case PROP_GRADIENT: - case PROP_PALETTE: + case GIMP_CONTEXT_PROP_TOOL: + case GIMP_CONTEXT_PROP_BRUSH: + case GIMP_CONTEXT_PROP_PATTERN: + case GIMP_CONTEXT_PROP_GRADIENT: + case GIMP_CONTEXT_PROP_PALETTE: serialize_obj = g_value_get_object (value); break; @@ -1108,32 +1037,32 @@ gimp_context_deserialize_property (GObject *object, switch (property_id) { - case PROP_TOOL: + case GIMP_CONTEXT_PROP_TOOL: container = context->gimp->tool_info_list; current = (GimpObject *) context->tool_info; name_loc = &context->tool_name; no_data = TRUE; break; - case PROP_BRUSH: + case GIMP_CONTEXT_PROP_BRUSH: container = context->gimp->brush_factory->container; current = (GimpObject *) context->brush; name_loc = &context->brush_name; break; - case PROP_PATTERN: + case GIMP_CONTEXT_PROP_PATTERN: container = context->gimp->pattern_factory->container; current = (GimpObject *) context->pattern; name_loc = &context->pattern_name; break; - case PROP_GRADIENT: + case GIMP_CONTEXT_PROP_GRADIENT: container = context->gimp->gradient_factory->container; current = (GimpObject *) context->gradient; name_loc = &context->gradient_name; break; - case PROP_PALETTE: + case GIMP_CONTEXT_PROP_PALETTE: container = context->gimp->palette_factory->container; current = (GimpObject *) context->palette; name_loc = &context->palette_name; @@ -1239,51 +1168,51 @@ gimp_context_get_parent (const GimpContext *context) return context->parent; } +static void +gimp_context_parent_notify (GimpContext *parent, + GParamSpec *pspec, + GimpContext *context) +{ + /* copy from parent if the changed property is undefined */ + if (! ((1 << pspec->param_id) & context->defined_props)) + gimp_context_copy_property (parent, context, pspec->param_id); +} + void gimp_context_set_parent (GimpContext *context, GimpContext *parent) { - GimpContextPropType prop; - g_return_if_fail (GIMP_IS_CONTEXT (context)); - g_return_if_fail (! parent || GIMP_IS_CONTEXT (parent)); + g_return_if_fail (parent == NULL || GIMP_IS_CONTEXT (parent)); + g_return_if_fail (parent == NULL || parent->parent != context); g_return_if_fail (context != parent); - if (context == parent || context->parent == parent) + if (context->parent == parent) return; - for (prop = 0; prop < GIMP_CONTEXT_NUM_PROPS; prop++) - if (! ((1 << prop) & context->defined_props)) - { - gimp_context_copy_property (parent, context, prop); - g_signal_connect_object (parent, - gimp_context_signal_names[prop], - gimp_context_signal_handlers[prop], - context, - G_CONNECT_SWAPPED); - } + if (context->parent) + { + g_signal_handlers_disconnect_by_func (context->parent, + gimp_context_parent_notify, + context); + } context->parent = parent; + + if (parent) + { + /* copy all undefined properties from the new parent */ + gimp_context_copy_properties (parent, context, + ~context->defined_props & + GIMP_CONTEXT_ALL_PROPS_MASK); + + g_signal_connect_object (parent, "notify", + G_CALLBACK (gimp_context_parent_notify), + context, + 0); + } } -void -gimp_context_unset_parent (GimpContext *context) -{ - GimpContextPropType prop; - - g_return_if_fail (GIMP_IS_CONTEXT (context)); - g_return_if_fail (GIMP_IS_CONTEXT (context->parent)); - - for (prop = 0; prop < GIMP_CONTEXT_NUM_PROPS; prop++) - if (! ((1 << prop) & context->defined_props)) - { - g_signal_handlers_disconnect_by_func (context->parent, - gimp_context_signal_handlers[prop], - context); - } - - context->parent = NULL; -} /* define / undefinine context properties */ @@ -1295,7 +1224,8 @@ gimp_context_define_property (GimpContext *context, GimpContextPropMask mask; g_return_if_fail (GIMP_IS_CONTEXT (context)); - g_return_if_fail ((prop >= 0) && (prop < GIMP_CONTEXT_NUM_PROPS)); + g_return_if_fail ((prop >= GIMP_CONTEXT_FIRST_PROP) && + (prop <= GIMP_CONTEXT_LAST_PROP)); mask = (1 << prop); @@ -1304,10 +1234,6 @@ gimp_context_define_property (GimpContext *context, if (! (context->defined_props & mask)) { context->defined_props |= mask; - if (context->parent) - g_signal_handlers_disconnect_by_func (context->parent, - gimp_context_signal_handlers[prop], - context); } } else @@ -1315,15 +1241,9 @@ gimp_context_define_property (GimpContext *context, if (context->defined_props & mask) { context->defined_props &= ~mask; + if (context->parent) - { - gimp_context_copy_property (context->parent, context, prop); - g_signal_connect_object (context->parent, - gimp_context_signal_names[prop], - gimp_context_signal_handlers[prop], - context, - G_CONNECT_SWAPPED); - } + gimp_context_copy_property (context->parent, context, prop); } } } @@ -1339,18 +1259,19 @@ gimp_context_property_defined (GimpContext *context, void gimp_context_define_properties (GimpContext *context, - GimpContextPropMask props_mask, + GimpContextPropMask prop_mask, gboolean defined) { GimpContextPropType prop; g_return_if_fail (GIMP_IS_CONTEXT (context)); - for (prop = 0; prop < GIMP_CONTEXT_NUM_PROPS; prop++) - if ((1 << prop) & props_mask) + for (prop = GIMP_CONTEXT_FIRST_PROP; prop <= GIMP_CONTEXT_LAST_PROP; prop++) + if ((1 << prop) & prop_mask) gimp_context_define_property (context, prop, defined); } + /* copying context properties */ void @@ -1358,28 +1279,117 @@ gimp_context_copy_property (GimpContext *src, GimpContext *dest, GimpContextPropType prop) { + gpointer object = NULL; + gpointer standard_object = NULL; + gchar *src_name = NULL; + gchar **dest_name_loc = NULL; + g_return_if_fail (GIMP_IS_CONTEXT (src)); g_return_if_fail (GIMP_IS_CONTEXT (dest)); - g_return_if_fail ((prop >= 0) && (prop < GIMP_CONTEXT_NUM_PROPS)); + g_return_if_fail ((prop >= GIMP_CONTEXT_FIRST_PROP) && + (prop <= GIMP_CONTEXT_LAST_PROP)); - gimp_context_copy_prop_funcs[prop] (src, dest); + switch (prop) + { + case GIMP_CONTEXT_PROP_IMAGE: + gimp_context_real_set_image (dest, src->image); + break; + + case GIMP_CONTEXT_PROP_DISPLAY: + gimp_context_real_set_display (dest, src->display); + break; + + case GIMP_CONTEXT_PROP_TOOL: + gimp_context_real_set_tool (dest, src->tool_info); + object = src->tool_info; + standard_object = standard_tool_info; + src_name = src->tool_name; + dest_name_loc = &dest->tool_name; + break; + + case GIMP_CONTEXT_PROP_FOREGROUND: + gimp_context_real_set_foreground (dest, &src->foreground); + break; + + case GIMP_CONTEXT_PROP_BACKGROUND: + gimp_context_real_set_background (dest, &src->background); + break; + + case GIMP_CONTEXT_PROP_OPACITY: + gimp_context_real_set_opacity (dest, src->opacity); + break; + + case GIMP_CONTEXT_PROP_PAINT_MODE: + gimp_context_real_set_paint_mode (dest, src->paint_mode); + break; + + case GIMP_CONTEXT_PROP_BRUSH: + gimp_context_real_set_brush (dest, src->brush); + object = src->brush; + standard_object = standard_brush; + src_name = src->brush_name; + dest_name_loc = &dest->brush_name; + break; + + case GIMP_CONTEXT_PROP_PATTERN: + gimp_context_real_set_pattern (dest, src->pattern); + object = src->pattern; + standard_object = standard_pattern; + src_name = src->pattern_name; + dest_name_loc = &dest->pattern_name; + break; + + case GIMP_CONTEXT_PROP_GRADIENT: + gimp_context_real_set_gradient (dest, src->gradient); + object = src->gradient; + standard_object = standard_gradient; + src_name = src->gradient_name; + dest_name_loc = &dest->gradient_name; + break; + + case GIMP_CONTEXT_PROP_PALETTE: + gimp_context_real_set_palette (dest, src->palette); + object = src->palette; + standard_object = standard_palette; + src_name = src->palette_name; + dest_name_loc = &dest->palette_name; + break; + + case GIMP_CONTEXT_PROP_BUFFER: + gimp_context_real_set_buffer (dest, src->buffer); + break; + + case GIMP_CONTEXT_PROP_IMAGEFILE: + gimp_context_real_set_imagefile (dest, src->imagefile); + break; + + default: + break; + } + + if (src_name && dest_name_loc) + { + if (! object || object == standard_object) + { + g_free (*dest_name_loc); + *dest_name_loc = g_strdup (src_name); + } + } } void gimp_context_copy_properties (GimpContext *src, GimpContext *dest, - GimpContextPropMask props_mask) + GimpContextPropMask prop_mask) { GimpContextPropType prop; g_return_if_fail (GIMP_IS_CONTEXT (src)); g_return_if_fail (GIMP_IS_CONTEXT (dest)); - for (prop = 0; prop < GIMP_CONTEXT_NUM_PROPS; prop++) - if ((1 << prop) & props_mask) - { - gimp_context_copy_property (src, dest, prop); - } + for (prop = GIMP_CONTEXT_FIRST_PROP; prop <= GIMP_CONTEXT_LAST_PROP; prop++) + if ((1 << prop) & prop_mask) + gimp_context_copy_property (src, dest, prop); } /* attribute access functions */ @@ -1390,12 +1400,12 @@ gimp_context_copy_properties (GimpContext *src, GimpContextPropType gimp_context_type_to_property (GType type) { - gint i; + GimpContextPropType prop; - for (i = 0; i < GIMP_CONTEXT_NUM_PROPS; i++) + for (prop = GIMP_CONTEXT_FIRST_PROP; prop <= GIMP_CONTEXT_LAST_PROP; prop++) { - if (g_type_is_a (type, gimp_context_prop_types[i])) - return i; + if (g_type_is_a (type, gimp_context_prop_types[prop])) + return prop; } return -1; @@ -1404,12 +1414,12 @@ gimp_context_type_to_property (GType type) const gchar * gimp_context_type_to_signal_name (GType type) { - gint i; + GimpContextPropType prop; - for (i = 0; i < GIMP_CONTEXT_NUM_PROPS; i++) + for (prop = GIMP_CONTEXT_FIRST_PROP; prop <= GIMP_CONTEXT_LAST_PROP; prop++) { - if (g_type_is_a (type, gimp_context_prop_types[i])) - return gimp_context_signal_names[i]; + if (g_type_is_a (type, gimp_context_prop_types[prop])) + return g_signal_name (gimp_context_signals[prop]); } return NULL; @@ -1487,7 +1497,7 @@ gimp_context_set_image (GimpContext *context, GimpImage *image) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_IMAGE_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_IMAGE); gimp_context_real_set_image (context, image); } @@ -1521,15 +1531,10 @@ gimp_context_real_set_image (GimpContext *context, context->image = image; + g_object_notify (G_OBJECT (context), "image"); gimp_context_image_changed (context); } -static void -gimp_context_copy_image (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_image (dest, src->image); -} /*****************************************************************************/ /* display *****************************************************************/ @@ -1547,7 +1552,7 @@ gimp_context_set_display (GimpContext *context, gpointer display) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_DISPLAY_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_DISPLAY); gimp_context_real_set_display (context, display); } @@ -1592,21 +1597,14 @@ gimp_context_real_set_display (GimpContext *context, g_object_unref (gimage); } + g_object_notify (G_OBJECT (context), "display"); gimp_context_display_changed (context); } -static void -gimp_context_copy_display (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_display (dest, src->display); -} /*****************************************************************************/ /* tool ********************************************************************/ -static GimpToolInfo *standard_tool_info = NULL; - GimpToolInfo * gimp_context_get_tool (GimpContext *context) { @@ -1621,7 +1619,7 @@ gimp_context_set_tool (GimpContext *context, { g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (! tool_info || GIMP_IS_TOOL_INFO (tool_info)); - context_find_defined (context, GIMP_CONTEXT_TOOL_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_TOOL); gimp_context_real_set_tool (context, tool_info); } @@ -1644,6 +1642,7 @@ gimp_context_tool_dirty (GimpToolInfo *tool_info, g_free (context->tool_name); context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name); + g_object_notify (G_OBJECT (context), "tool"); gimp_context_tool_changed (context); } @@ -1738,23 +1737,10 @@ gimp_context_real_set_tool (GimpContext *context, context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name); } + g_object_notify (G_OBJECT (context), "tool"); gimp_context_tool_changed (context); } -static void -gimp_context_copy_tool (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_tool (dest, src->tool_info); - - if ((! src->tool_info || src->tool_info == standard_tool_info) && - src->tool_name) - { - g_free (dest->tool_name); - dest->tool_name = g_strdup (src->tool_name); - } -} - /*****************************************************************************/ /* foreground color ********************************************************/ @@ -1775,7 +1761,7 @@ gimp_context_set_foreground (GimpContext *context, { g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (color != NULL); - context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND); gimp_context_real_set_foreground (context, color); } @@ -1799,15 +1785,10 @@ gimp_context_real_set_foreground (GimpContext *context, context->foreground = *color; + g_object_notify (G_OBJECT (context), "foreground"); gimp_context_foreground_changed (context); } -static void -gimp_context_copy_foreground (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_foreground (dest, &src->foreground); -} /*****************************************************************************/ /* background color ********************************************************/ @@ -1829,7 +1810,7 @@ gimp_context_set_background (GimpContext *context, { g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (color != NULL); - context_find_defined (context, GIMP_CONTEXT_BACKGROUND_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_BACKGROUND); gimp_context_real_set_background (context, color); } @@ -1853,15 +1834,10 @@ gimp_context_real_set_background (GimpContext *context, context->background = *color; + g_object_notify (G_OBJECT (context), "background"); gimp_context_background_changed (context); } -static void -gimp_context_copy_background (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_background (dest, &src->background); -} /*****************************************************************************/ /* color utility functions *************************************************/ @@ -1877,8 +1853,8 @@ gimp_context_set_default_colors (GimpContext *context) bg_context = context; - context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK); - context_find_defined (bg_context, GIMP_CONTEXT_BACKGROUND_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND); + context_find_defined (bg_context, GIMP_CONTEXT_PROP_BACKGROUND); gimp_rgba_set (&fg, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE); gimp_rgba_set (&bg, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE); @@ -1898,8 +1874,8 @@ gimp_context_swap_colors (GimpContext *context) bg_context = context; - context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK); - context_find_defined (bg_context, GIMP_CONTEXT_BACKGROUND_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND); + context_find_defined (bg_context, GIMP_CONTEXT_PROP_BACKGROUND); gimp_context_get_foreground (context, &fg); gimp_context_get_background (bg_context, &bg); @@ -1924,7 +1900,7 @@ gimp_context_set_opacity (GimpContext *context, gdouble opacity) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_OPACITY_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_OPACITY); gimp_context_real_set_opacity (context, opacity); } @@ -1947,15 +1923,11 @@ gimp_context_real_set_opacity (GimpContext *context, return; context->opacity = opacity; + + g_object_notify (G_OBJECT (context), "opacity"); gimp_context_opacity_changed (context); } -static void -gimp_context_copy_opacity (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_opacity (dest, src->opacity); -} /*****************************************************************************/ /* paint mode **************************************************************/ @@ -1973,7 +1945,7 @@ gimp_context_set_paint_mode (GimpContext *context, GimpLayerModeEffects paint_mode) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_PAINT_MODE_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_PAINT_MODE); gimp_context_real_set_paint_mode (context, paint_mode); } @@ -1996,21 +1968,15 @@ gimp_context_real_set_paint_mode (GimpContext *context, return; context->paint_mode = paint_mode; + + g_object_notify (G_OBJECT (context), "paint-mode"); gimp_context_paint_mode_changed (context); } -static void -gimp_context_copy_paint_mode (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_paint_mode (dest, src->paint_mode); -} /*****************************************************************************/ /* brush *******************************************************************/ -static GimpBrush *standard_brush = NULL; - GimpBrush * gimp_context_get_brush (GimpContext *context) { @@ -2025,7 +1991,7 @@ gimp_context_set_brush (GimpContext *context, { g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (! brush || GIMP_IS_BRUSH (brush)); - context_find_defined (context, GIMP_CONTEXT_BRUSH_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_BRUSH); gimp_context_real_set_brush (context, brush); } @@ -2048,6 +2014,7 @@ gimp_context_brush_dirty (GimpBrush *brush, g_free (context->brush_name); context->brush_name = g_strdup (GIMP_OBJECT (brush)->name); + g_object_notify (G_OBJECT (context), "brush"); gimp_context_brush_changed (context); } @@ -2166,28 +2133,14 @@ gimp_context_real_set_brush (GimpContext *context, context->brush_name = g_strdup (GIMP_OBJECT (brush)->name); } + g_object_notify (G_OBJECT (context), "brush"); gimp_context_brush_changed (context); } -static void -gimp_context_copy_brush (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_brush (dest, src->brush); - - if ((! src->brush || src->brush == standard_brush) && src->brush_name) - { - g_free (dest->brush_name); - dest->brush_name = g_strdup (src->brush_name); - } -} - /*****************************************************************************/ /* pattern *****************************************************************/ -static GimpPattern *standard_pattern = NULL; - GimpPattern * gimp_context_get_pattern (GimpContext *context) { @@ -2201,7 +2154,7 @@ gimp_context_set_pattern (GimpContext *context, GimpPattern *pattern) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_PATTERN_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_PATTERN); gimp_context_real_set_pattern (context, pattern); } @@ -2224,6 +2177,7 @@ gimp_context_pattern_dirty (GimpPattern *pattern, g_free (context->pattern_name); context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name); + g_object_notify (G_OBJECT (context), "pattern"); gimp_context_pattern_changed (context); } @@ -2338,28 +2292,14 @@ gimp_context_real_set_pattern (GimpContext *context, context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name); } + g_object_notify (G_OBJECT (context), "pattern"); gimp_context_pattern_changed (context); } -static void -gimp_context_copy_pattern (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_pattern (dest, src->pattern); - - if ((!src->pattern || src->pattern == standard_pattern) && src->pattern_name) - { - g_free (dest->pattern_name); - dest->pattern_name = g_strdup (src->pattern_name); - } -} - /*****************************************************************************/ /* gradient ****************************************************************/ -static GimpGradient *standard_gradient = NULL; - GimpGradient * gimp_context_get_gradient (GimpContext *context) { @@ -2373,7 +2313,7 @@ gimp_context_set_gradient (GimpContext *context, GimpGradient *gradient) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_GRADIENT_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_GRADIENT); gimp_context_real_set_gradient (context, gradient); } @@ -2396,6 +2336,7 @@ gimp_context_gradient_dirty (GimpGradient *gradient, g_free (context->gradient_name); context->gradient_name = g_strdup (GIMP_OBJECT (gradient)->name); + g_object_notify (G_OBJECT (context), "gradient"); gimp_context_gradient_changed (context); } @@ -2486,29 +2427,14 @@ gimp_context_real_set_gradient (GimpContext *context, context->gradient_name = g_strdup (GIMP_OBJECT (gradient)->name); } + g_object_notify (G_OBJECT (context), "gradient"); gimp_context_gradient_changed (context); } -static void -gimp_context_copy_gradient (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_gradient (dest, src->gradient); - - if ((!src->gradient || src->gradient == standard_gradient) && - src->gradient_name) - { - g_free (dest->gradient_name); - dest->gradient_name = g_strdup (src->gradient_name); - } -} - /*****************************************************************************/ /* palette *****************************************************************/ -static GimpPalette *standard_palette = NULL; - GimpPalette * gimp_context_get_palette (GimpContext *context) { @@ -2522,7 +2448,7 @@ gimp_context_set_palette (GimpContext *context, GimpPalette *palette) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_PALETTE_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_PALETTE); gimp_context_real_set_palette (context, palette); } @@ -2545,6 +2471,7 @@ gimp_context_palette_dirty (GimpPalette *palette, g_free (context->palette_name); context->palette_name = g_strdup (GIMP_OBJECT (palette)->name); + g_object_notify (G_OBJECT (context), "palette"); gimp_context_palette_changed (context); } @@ -2635,22 +2562,10 @@ gimp_context_real_set_palette (GimpContext *context, context->palette_name = g_strdup (GIMP_OBJECT (palette)->name); } + g_object_notify (G_OBJECT (context), "palette"); gimp_context_palette_changed (context); } -static void -gimp_context_copy_palette (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_palette (dest, src->palette); - - if ((!src->palette || src->palette == standard_palette) && src->palette_name) - { - g_free (dest->palette_name); - dest->palette_name = g_strdup (src->palette_name); - } -} - /*****************************************************************************/ /* buffer ******************************************************************/ @@ -2672,7 +2587,7 @@ gimp_context_set_buffer (GimpContext *context, GimpBuffer *buffer) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_BUFFER_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_BUFFER); gimp_context_real_set_buffer (context, buffer); } @@ -2697,6 +2612,7 @@ gimp_context_buffer_dirty (GimpBuffer *buffer, context->buffer_name = g_strdup (GIMP_OBJECT (buffer)->name); */ + g_object_notify (G_OBJECT (context), "buffer"); gimp_context_buffer_changed (context); } @@ -2721,11 +2637,16 @@ gimp_context_buffer_list_thaw (GimpContainer *container, */ if (gimp_container_num_children (container)) - gimp_context_real_set_buffer - (context, - GIMP_BUFFER (gimp_container_get_child_by_index (container, 0))); + { + gimp_context_real_set_buffer + (context, + GIMP_BUFFER (gimp_container_get_child_by_index (container, 0))); + } else - gimp_context_buffer_changed (context); + { + g_object_notify (G_OBJECT (context), "buffer"); + gimp_context_buffer_changed (context); + } /* else @@ -2800,24 +2721,10 @@ gimp_context_real_set_buffer (GimpContext *context, */ } + g_object_notify (G_OBJECT (context), "buffer"); gimp_context_buffer_changed (context); } -static void -gimp_context_copy_buffer (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_buffer (dest, src->buffer); - - /* - if ((!src->buffer || src->buffer == standard_buffer) && src->buffer_name) - { - g_free (dest->buffer_name); - dest->buffer_name = g_strdup (src->buffer_name); - } - */ -} - /*****************************************************************************/ /* imagefile ***************************************************************/ @@ -2839,7 +2746,7 @@ gimp_context_set_imagefile (GimpContext *context, GimpImagefile *imagefile) { g_return_if_fail (GIMP_IS_CONTEXT (context)); - context_find_defined (context, GIMP_CONTEXT_IMAGEFILE_MASK); + context_find_defined (context, GIMP_CONTEXT_PROP_IMAGEFILE); gimp_context_real_set_imagefile (context, imagefile); } @@ -2864,6 +2771,7 @@ gimp_context_imagefile_dirty (GimpImagefile *imagefile, context->imagefile_name = g_strdup (GIMP_OBJECT (imagefile)->name); */ + g_object_notify (G_OBJECT (context), "imagefile"); gimp_context_imagefile_changed (context); } @@ -2888,11 +2796,16 @@ gimp_context_imagefile_list_thaw (GimpContainer *container, */ if (gimp_container_num_children (container)) - gimp_context_real_set_imagefile - (context, - GIMP_IMAGEFILE (gimp_container_get_child_by_index (container, 0))); + { + gimp_context_real_set_imagefile + (context, + GIMP_IMAGEFILE (gimp_container_get_child_by_index (container, 0))); + } else - gimp_context_imagefile_changed (context); + { + g_object_notify (G_OBJECT (context), "imagefile"); + gimp_context_imagefile_changed (context); + } /* else @@ -2967,20 +2880,6 @@ gimp_context_real_set_imagefile (GimpContext *context, */ } + g_object_notify (G_OBJECT (context), "imagefile"); gimp_context_imagefile_changed (context); } - -static void -gimp_context_copy_imagefile (GimpContext *src, - GimpContext *dest) -{ - gimp_context_real_set_imagefile (dest, src->imagefile); - - /* - if ((!src->imagefile || src->imagefile == standard_imagefile) && src->imagefile_name) - { - g_free (dest->imagefile_name); - dest->imagefile_name = g_strdup (src->imagefile_name); - } - */ -} diff --git a/app/core/gimpcontext.h b/app/core/gimpcontext.h index c1afb3414c..92a82af255 100644 --- a/app/core/gimpcontext.h +++ b/app/core/gimpcontext.h @@ -28,37 +28,40 @@ typedef enum { - GIMP_CONTEXT_PROP_IMAGE, - GIMP_CONTEXT_PROP_DISPLAY, - GIMP_CONTEXT_PROP_TOOL, - GIMP_CONTEXT_PROP_FOREGROUND, - GIMP_CONTEXT_PROP_BACKGROUND, - GIMP_CONTEXT_PROP_OPACITY, - GIMP_CONTEXT_PROP_PAINT_MODE, - GIMP_CONTEXT_PROP_BRUSH, - GIMP_CONTEXT_PROP_PATTERN, - GIMP_CONTEXT_PROP_GRADIENT, - GIMP_CONTEXT_PROP_PALETTE, - GIMP_CONTEXT_PROP_BUFFER, - GIMP_CONTEXT_PROP_IMAGEFILE, - GIMP_CONTEXT_NUM_PROPS + GIMP_CONTEXT_FIRST_PROP = 2, + + GIMP_CONTEXT_PROP_IMAGE = GIMP_CONTEXT_FIRST_PROP, + GIMP_CONTEXT_PROP_DISPLAY = 3, + GIMP_CONTEXT_PROP_TOOL = 4, + GIMP_CONTEXT_PROP_FOREGROUND = 5, + GIMP_CONTEXT_PROP_BACKGROUND = 6, + GIMP_CONTEXT_PROP_OPACITY = 7, + GIMP_CONTEXT_PROP_PAINT_MODE = 8, + GIMP_CONTEXT_PROP_BRUSH = 9, + GIMP_CONTEXT_PROP_PATTERN = 10, + GIMP_CONTEXT_PROP_GRADIENT = 11, + GIMP_CONTEXT_PROP_PALETTE = 12, + GIMP_CONTEXT_PROP_BUFFER = 13, + GIMP_CONTEXT_PROP_IMAGEFILE = 14, + + GIMP_CONTEXT_LAST_PROP = GIMP_CONTEXT_PROP_IMAGEFILE } GimpContextPropType; typedef enum { - GIMP_CONTEXT_IMAGE_MASK = 1 << 0, - GIMP_CONTEXT_DISPLAY_MASK = 1 << 1, - GIMP_CONTEXT_TOOL_MASK = 1 << 2, - GIMP_CONTEXT_FOREGROUND_MASK = 1 << 3, - GIMP_CONTEXT_BACKGROUND_MASK = 1 << 4, - GIMP_CONTEXT_OPACITY_MASK = 1 << 5, - GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 6, - GIMP_CONTEXT_BRUSH_MASK = 1 << 7, - GIMP_CONTEXT_PATTERN_MASK = 1 << 8, - GIMP_CONTEXT_GRADIENT_MASK = 1 << 9, - GIMP_CONTEXT_PALETTE_MASK = 1 << 10, - GIMP_CONTEXT_BUFFER_MASK = 1 << 11, - GIMP_CONTEXT_IMAGEFILE_MASK = 1 << 12, + GIMP_CONTEXT_IMAGE_MASK = 1 << 2, + GIMP_CONTEXT_DISPLAY_MASK = 1 << 3, + GIMP_CONTEXT_TOOL_MASK = 1 << 4, + GIMP_CONTEXT_FOREGROUND_MASK = 1 << 5, + GIMP_CONTEXT_BACKGROUND_MASK = 1 << 6, + GIMP_CONTEXT_OPACITY_MASK = 1 << 7, + GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 8, + GIMP_CONTEXT_BRUSH_MASK = 1 << 9, + GIMP_CONTEXT_PATTERN_MASK = 1 << 10, + GIMP_CONTEXT_GRADIENT_MASK = 1 << 11, + GIMP_CONTEXT_PALETTE_MASK = 1 << 12, + GIMP_CONTEXT_BUFFER_MASK = 1 << 13, + GIMP_CONTEXT_IMAGEFILE_MASK = 1 << 14, /* aliases */ GIMP_CONTEXT_PAINT_PROPS_MASK = (GIMP_CONTEXT_FOREGROUND_MASK | @@ -174,7 +177,6 @@ void gimp_context_set_name (GimpContext *context, GimpContext * gimp_context_get_parent (const GimpContext *context); void gimp_context_set_parent (GimpContext *context, GimpContext *parent); -void gimp_context_unset_parent (GimpContext *context); /* define / undefinine context properties * diff --git a/app/core/gimptooloptions.c b/app/core/gimptooloptions.c index ac3e19ad60..aaf23d83ae 100644 --- a/app/core/gimptooloptions.c +++ b/app/core/gimptooloptions.c @@ -113,7 +113,6 @@ static void gimp_tool_options_init (GimpToolOptions *options) { options->tool_info = NULL; - options->main_vbox = gtk_vbox_new (FALSE, 2); } static void @@ -226,13 +225,12 @@ gimp_tool_options_deserialize (GimpToolOptions *tool_options, return retval; } -void +gpointer gimp_tool_options_gui (GimpToolOptions *tool_options) { - GtkWidget *label; + GtkWidget *vbox; - label = gtk_label_new (_("This tool has no options.")); - gtk_box_pack_start (GTK_BOX (tool_options->main_vbox), label, - FALSE, FALSE, 6); - gtk_widget_show (label); + vbox = gtk_vbox_new (FALSE, 2); + + return vbox; } diff --git a/app/core/gimptooloptions.h b/app/core/gimptooloptions.h index abe9889da9..b78729726d 100644 --- a/app/core/gimptooloptions.h +++ b/app/core/gimptooloptions.h @@ -38,8 +38,6 @@ struct _GimpToolOptions GimpContext parent_instance; GimpToolInfo *tool_info; - - gpointer main_vbox; }; struct _GimpToolOptionsClass @@ -59,7 +57,7 @@ gboolean gimp_tool_options_serialize (GimpToolOptions *tool_options, gboolean gimp_tool_options_deserialize (GimpToolOptions *tool_options, GError **error); -void gimp_tool_options_gui (GimpToolOptions *tool_options); +gpointer gimp_tool_options_gui (GimpToolOptions *tool_options); #endif /* __TOOL_OPTIONS_H__ */ diff --git a/app/gui/tool-options-dialog.c b/app/gui/tool-options-dialog.c index 660b327fa4..aa18e71bdb 100644 --- a/app/gui/tool-options-dialog.c +++ b/app/gui/tool-options-dialog.c @@ -186,22 +186,30 @@ tool_options_dialog_tool_changed (GimpContext *context, GimpToolInfo *tool_info, gpointer data) { + GtkWidget *options_gui; + if (visible_tool_options && (! tool_info || tool_info->tool_options != visible_tool_options)) { - gtk_widget_hide (visible_tool_options->main_vbox); + options_gui = g_object_get_data (G_OBJECT (visible_tool_options), + "gimp-tool-options-gui"); + + if (options_gui) + gtk_widget_hide (options_gui); visible_tool_options = NULL; } if (tool_info && tool_info->tool_options) { - if (! GTK_WIDGET (tool_info->tool_options->main_vbox)->parent) - gtk_box_pack_start (GTK_BOX (options_vbox), - tool_info->tool_options->main_vbox, + options_gui = g_object_get_data (G_OBJECT (tool_info->tool_options), + "gimp-tool-options-gui"); + + if (! options_gui->parent) + gtk_box_pack_start (GTK_BOX (options_vbox), options_gui, FALSE, FALSE, 0); - gtk_widget_show (tool_info->tool_options->main_vbox); + gtk_widget_show (options_gui); visible_tool_options = tool_info->tool_options; diff --git a/app/paint/gimpinkoptions.c b/app/paint/gimpinkoptions.c index 45106c71dc..9a59012dd2 100644 --- a/app/paint/gimpinkoptions.c +++ b/app/paint/gimpinkoptions.c @@ -240,7 +240,7 @@ gimp_ink_options_get_property (GObject *object, } } -void +GtkWidget * gimp_ink_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -252,9 +252,7 @@ gimp_ink_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* adjust sliders */ frame = gtk_frame_new (_("Adjustment")); @@ -371,6 +369,8 @@ gimp_ink_options_gui (GimpToolOptions *tool_options) brush = brush_widget_new (GIMP_INK_OPTIONS (tool_options)); gtk_container_add (GTK_CONTAINER (frame), brush); gtk_widget_show (brush); + + return vbox; } diff --git a/app/paint/gimpinkoptions.h b/app/paint/gimpinkoptions.h index 58990645c0..44354b63a5 100644 --- a/app/paint/gimpinkoptions.h +++ b/app/paint/gimpinkoptions.h @@ -51,9 +51,9 @@ struct _GimpInkOptions }; -GType gimp_ink_options_get_type (void) G_GNUC_CONST; +GType gimp_ink_options_get_type (void) G_GNUC_CONST; -void gimp_ink_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_ink_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_INK_OPTIONS_H__ */ diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c index 80da17c200..680127585a 100644 --- a/app/tools/gimpairbrushtool.c +++ b/app/tools/gimpairbrushtool.c @@ -39,10 +39,10 @@ #include "libgimp/gimpintl.h" -static void gimp_airbrush_tool_class_init (GimpAirbrushToolClass *klass); -static void gimp_airbrush_tool_init (GimpAirbrushTool *airbrush); +static void gimp_airbrush_tool_class_init (GimpAirbrushToolClass *klass); +static void gimp_airbrush_tool_init (GimpAirbrushTool *airbrush); -static void gimp_airbrush_options_gui (GimpToolOptions *tool_options); +static GtkWidget * gimp_airbrush_options_gui (GimpToolOptions *tool_options); static GimpPaintToolClass *parent_class = NULL; @@ -123,7 +123,7 @@ gimp_airbrush_tool_init (GimpAirbrushTool *airbrush) /* tool options stuff */ -static void +static GtkWidget * gimp_airbrush_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -132,9 +132,7 @@ gimp_airbrush_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); table = gtk_table_new (2, 3, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2); @@ -152,4 +150,6 @@ gimp_airbrush_options_gui (GimpToolOptions *tool_options) _("Pressure:"), 1.0, 1.0, 1, FALSE, 0.0, 0.0); + + return vbox; } diff --git a/app/tools/gimpblendoptions.c b/app/tools/gimpblendoptions.c index 1f10908142..5e64666e37 100644 --- a/app/tools/gimpblendoptions.c +++ b/app/tools/gimpblendoptions.c @@ -232,7 +232,7 @@ gimp_blend_options_get_property (GObject *object, } } -void +GtkWidget * gimp_blend_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -244,9 +244,7 @@ gimp_blend_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); gimp_dnd_viewable_dest_add (vbox, GIMP_TYPE_GRADIENT, @@ -350,6 +348,8 @@ gimp_blend_options_gui (GimpToolOptions *tool_options) _("Threshold:"), 0.01, 0.1, 2, FALSE, 0.0, 0.0); + + return vbox; } static void diff --git a/app/tools/gimpblendoptions.h b/app/tools/gimpblendoptions.h index f6de54dee5..05b6b45249 100644 --- a/app/tools/gimpblendoptions.h +++ b/app/tools/gimpblendoptions.h @@ -48,9 +48,9 @@ struct _GimpBlendOptions }; -GType gimp_blend_options_get_type (void) G_GNUC_CONST; +GType gimp_blend_options_get_type (void) G_GNUC_CONST; -void gimp_blend_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_blend_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_BLEND_OPTIONS_H__ */ diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c index 4c186f973c..ce29a6f528 100644 --- a/app/tools/gimpbucketfilloptions.c +++ b/app/tools/gimpbucketfilloptions.c @@ -217,7 +217,7 @@ gimp_bucket_fill_options_reset (GimpToolOptions *tool_options) GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); } -void +GtkWidget * gimp_bucket_fill_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -230,9 +230,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* fill type */ str = g_strdup_printf (_("Fill Type %s"), gimp_get_mod_name_control ()); @@ -278,4 +276,6 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options) FALSE, 0.0, 0.0); gimp_bucket_fill_options_reset (tool_options); + + return vbox; } diff --git a/app/tools/gimpbucketfilloptions.h b/app/tools/gimpbucketfilloptions.h index be00757eef..1befbe56cc 100644 --- a/app/tools/gimpbucketfilloptions.h +++ b/app/tools/gimpbucketfilloptions.h @@ -45,9 +45,9 @@ struct _GimpBucketFillOptions }; -GType gimp_bucket_fill_options_get_type (void) G_GNUC_CONST; +GType gimp_bucket_fill_options_get_type (void) G_GNUC_CONST; -void gimp_bucket_fill_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_bucket_fill_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_BUCKET_FILL_OPTIONS_H__ */ diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index 08f64f570d..2a313475d3 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -76,7 +76,7 @@ static void gimp_clone_pretrace_callback (GimpClone *clone, static void gimp_clone_posttrace_callback (GimpClone *clone, gpointer data); -static void gimp_clone_options_gui (GimpToolOptions *tool_options); +static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options); static GimpPaintToolClass *parent_class; @@ -362,7 +362,7 @@ gimp_clone_posttrace_callback (GimpClone *clone, /* tool options stuff */ -static void +static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -371,9 +371,7 @@ gimp_clone_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); frame = gimp_prop_enum_radio_frame_new (config, "clone-type", _("Source"), @@ -386,4 +384,6 @@ gimp_clone_options_gui (GimpToolOptions *tool_options) 0, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); + + return vbox; } diff --git a/app/tools/gimpcolorpickeroptions.c b/app/tools/gimpcolorpickeroptions.c index 6547aa4f56..a0f6c8f893 100644 --- a/app/tools/gimpcolorpickeroptions.c +++ b/app/tools/gimpcolorpickeroptions.c @@ -182,7 +182,7 @@ gimp_color_picker_options_get_property (GObject *object, } } -void +GtkWidget * gimp_color_picker_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -193,7 +193,7 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* the sample merged toggle button */ button = gimp_prop_check_button_new (config, "sample-merged", @@ -233,4 +233,6 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options) _("Update Active Color")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); + + return vbox; } diff --git a/app/tools/gimpcolorpickeroptions.h b/app/tools/gimpcolorpickeroptions.h index 10dc35e8f7..9780df7306 100644 --- a/app/tools/gimpcolorpickeroptions.h +++ b/app/tools/gimpcolorpickeroptions.h @@ -45,9 +45,9 @@ struct _GimpColorPickerOptions }; -GType gimp_color_picker_options_get_type (void) G_GNUC_CONST; +GType gimp_color_picker_options_get_type (void) G_GNUC_CONST; -void gimp_color_picker_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_color_picker_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_COLOR_PICKER_OPTIONS_H__ */ diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c index 3954036a89..aa293ec785 100644 --- a/app/tools/gimpconvolvetool.c +++ b/app/tools/gimpconvolvetool.c @@ -69,7 +69,7 @@ static void gimp_convolve_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp); -static void gimp_convolve_options_gui (GimpToolOptions *options); +static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options); static GimpPaintToolClass *parent_class; @@ -210,7 +210,7 @@ gimp_convolve_tool_cursor_update (GimpTool *tool, /* tool options stuff */ -static void +static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -221,9 +221,7 @@ gimp_convolve_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* the type radio box */ str = g_strdup_printf (_("Convolve Type %s"), @@ -247,4 +245,6 @@ gimp_convolve_options_gui (GimpToolOptions *tool_options) _("Rate:"), 1.0, 10.0, 1, FALSE, 0.0, 0.0); + + return vbox; } diff --git a/app/tools/gimpcropoptions.c b/app/tools/gimpcropoptions.c index e548d41f07..f973dc48b1 100644 --- a/app/tools/gimpcropoptions.c +++ b/app/tools/gimpcropoptions.c @@ -173,7 +173,7 @@ gimp_crop_options_get_property (GObject *object, } } -void +GtkWidget * gimp_crop_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -184,7 +184,7 @@ gimp_crop_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* tool toggle */ str = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_control ()); @@ -210,4 +210,6 @@ gimp_crop_options_gui (GimpToolOptions *tool_options) gtk_widget_show (button); g_free (str); + + return vbox; } diff --git a/app/tools/gimpcropoptions.h b/app/tools/gimpcropoptions.h index daf78effa4..223c90eeeb 100644 --- a/app/tools/gimpcropoptions.h +++ b/app/tools/gimpcropoptions.h @@ -44,9 +44,9 @@ struct _GimpCropOptions }; -GType gimp_crop_options_get_type (void) G_GNUC_CONST; +GType gimp_crop_options_get_type (void) G_GNUC_CONST; -void gimp_crop_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_crop_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_CROP_OPTIONS_H__ */ diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c index 4d4c267d1d..5945e4814e 100644 --- a/app/tools/gimpdodgeburntool.c +++ b/app/tools/gimpdodgeburntool.c @@ -51,7 +51,7 @@ static void gimp_dodgeburn_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp); -static void gimp_dodge_burn_options_gui (GimpToolOptions *tool_options); +static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options); static GimpPaintToolClass *parent_class = NULL; @@ -183,7 +183,7 @@ gimp_dodgeburn_tool_cursor_update (GimpTool *tool, /* tool options stuff */ -static void +static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -194,9 +194,7 @@ gimp_dodge_burn_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* the type (dodge or burn) */ str = g_strdup_printf (_("Type %s"), gimp_get_mod_name_control ()); @@ -225,4 +223,6 @@ gimp_dodge_burn_options_gui (GimpToolOptions *tool_options) _("Exposure:"), 1.0, 10.0, 1, FALSE, 0.0, 0.0); + + return vbox; } diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c index b54b06fe9c..f904fc8e22 100644 --- a/app/tools/gimperasertool.c +++ b/app/tools/gimperasertool.c @@ -51,7 +51,7 @@ static void gimp_eraser_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp); -static void gimp_eraser_options_gui (GimpToolOptions *tool_options); +static GtkWidget * gimp_eraser_options_gui (GimpToolOptions *tool_options); static GimpPaintToolClass *parent_class = NULL; @@ -172,7 +172,7 @@ gimp_eraser_tool_cursor_update (GimpTool *tool, /* tool options stuff */ -static void +static GtkWidget * gimp_eraser_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -182,9 +182,7 @@ gimp_eraser_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* the anti_erase toggle */ str = g_strdup_printf (_("Anti Erase %s"), gimp_get_mod_name_control ()); @@ -199,4 +197,6 @@ gimp_eraser_options_gui (GimpToolOptions *tool_options) button = gimp_prop_check_button_new (config, "hard", _("Hard Edge")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); + + return vbox; } diff --git a/app/tools/gimpflipoptions.c b/app/tools/gimpflipoptions.c index 075814f3dd..97842a6c35 100644 --- a/app/tools/gimpflipoptions.c +++ b/app/tools/gimpflipoptions.c @@ -153,7 +153,7 @@ gimp_flip_options_get_property (GObject *object, } } -void +GtkWidget * gimp_flip_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -163,7 +163,7 @@ gimp_flip_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* tool toggle */ str = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_control ()); @@ -176,4 +176,6 @@ gimp_flip_options_gui (GimpToolOptions *tool_options) gtk_widget_show (frame); g_free (str); + + return vbox; } diff --git a/app/tools/gimpflipoptions.h b/app/tools/gimpflipoptions.h index ee5bf9462e..acc803a6ba 100644 --- a/app/tools/gimpflipoptions.h +++ b/app/tools/gimpflipoptions.h @@ -42,9 +42,9 @@ struct _GimpFlipOptions }; -GType gimp_flip_options_get_type (void) G_GNUC_CONST; +GType gimp_flip_options_get_type (void) G_GNUC_CONST; -void gimp_flip_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_flip_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_FLIP_OPTIONS_H__ */ diff --git a/app/tools/gimpinkoptions-gui.c b/app/tools/gimpinkoptions-gui.c index 45106c71dc..9a59012dd2 100644 --- a/app/tools/gimpinkoptions-gui.c +++ b/app/tools/gimpinkoptions-gui.c @@ -240,7 +240,7 @@ gimp_ink_options_get_property (GObject *object, } } -void +GtkWidget * gimp_ink_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -252,9 +252,7 @@ gimp_ink_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* adjust sliders */ frame = gtk_frame_new (_("Adjustment")); @@ -371,6 +369,8 @@ gimp_ink_options_gui (GimpToolOptions *tool_options) brush = brush_widget_new (GIMP_INK_OPTIONS (tool_options)); gtk_container_add (GTK_CONTAINER (frame), brush); gtk_widget_show (brush); + + return vbox; } diff --git a/app/tools/gimpinkoptions-gui.h b/app/tools/gimpinkoptions-gui.h index 58990645c0..44354b63a5 100644 --- a/app/tools/gimpinkoptions-gui.h +++ b/app/tools/gimpinkoptions-gui.h @@ -51,9 +51,9 @@ struct _GimpInkOptions }; -GType gimp_ink_options_get_type (void) G_GNUC_CONST; +GType gimp_ink_options_get_type (void) G_GNUC_CONST; -void gimp_ink_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_ink_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_INK_OPTIONS_H__ */ diff --git a/app/tools/gimpinkoptions.c b/app/tools/gimpinkoptions.c index 45106c71dc..9a59012dd2 100644 --- a/app/tools/gimpinkoptions.c +++ b/app/tools/gimpinkoptions.c @@ -240,7 +240,7 @@ gimp_ink_options_get_property (GObject *object, } } -void +GtkWidget * gimp_ink_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -252,9 +252,7 @@ gimp_ink_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* adjust sliders */ frame = gtk_frame_new (_("Adjustment")); @@ -371,6 +369,8 @@ gimp_ink_options_gui (GimpToolOptions *tool_options) brush = brush_widget_new (GIMP_INK_OPTIONS (tool_options)); gtk_container_add (GTK_CONTAINER (frame), brush); gtk_widget_show (brush); + + return vbox; } diff --git a/app/tools/gimpinkoptions.h b/app/tools/gimpinkoptions.h index 58990645c0..44354b63a5 100644 --- a/app/tools/gimpinkoptions.h +++ b/app/tools/gimpinkoptions.h @@ -51,9 +51,9 @@ struct _GimpInkOptions }; -GType gimp_ink_options_get_type (void) G_GNUC_CONST; +GType gimp_ink_options_get_type (void) G_GNUC_CONST; -void gimp_ink_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_ink_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_INK_OPTIONS_H__ */ diff --git a/app/tools/gimpmagnifyoptions.c b/app/tools/gimpmagnifyoptions.c index c4ef79fb58..6bdd15a57b 100644 --- a/app/tools/gimpmagnifyoptions.c +++ b/app/tools/gimpmagnifyoptions.c @@ -200,7 +200,7 @@ gimp_magnify_options_reset (GimpToolOptions *tool_options) GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); } -void +GtkWidget * gimp_magnify_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -212,7 +212,7 @@ gimp_magnify_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* the allow_resize toggle button */ button = gimp_prop_check_button_new (config, "allow-resize", @@ -243,4 +243,6 @@ gimp_magnify_options_gui (GimpToolOptions *tool_options) FALSE, 0.0, 0.0); gimp_magnify_options_reset (tool_options); + + return vbox; } diff --git a/app/tools/gimpmagnifyoptions.h b/app/tools/gimpmagnifyoptions.h index 3ca8b216c9..fc469e2246 100644 --- a/app/tools/gimpmagnifyoptions.h +++ b/app/tools/gimpmagnifyoptions.h @@ -44,9 +44,9 @@ struct _GimpMagnifyOptions }; -GType gimp_magnify_options_get_type (void) G_GNUC_CONST; +GType gimp_magnify_options_get_type (void) G_GNUC_CONST; -void gimp_magnify_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_magnify_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_MAGNIFY_OPTIONS_H__ */ diff --git a/app/tools/gimpmeasureoptions.c b/app/tools/gimpmeasureoptions.c index 8d85329806..53c96ce222 100644 --- a/app/tools/gimpmeasureoptions.c +++ b/app/tools/gimpmeasureoptions.c @@ -154,7 +154,7 @@ gimp_measure_options_get_property (GObject *object, } } -void +GtkWidget * gimp_measure_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -163,11 +163,13 @@ gimp_measure_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* the use_info_window toggle button */ button = gimp_prop_check_button_new (config, "use-info-window", _("Use Info Window")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); + + return vbox; } diff --git a/app/tools/gimpmeasureoptions.h b/app/tools/gimpmeasureoptions.h index 0078f7bbdb..d9d6b7124e 100644 --- a/app/tools/gimpmeasureoptions.h +++ b/app/tools/gimpmeasureoptions.h @@ -42,9 +42,9 @@ struct _GimpMeasureOptions }; -GType gimp_measure_options_get_type (void) G_GNUC_CONST; +GType gimp_measure_options_get_type (void) G_GNUC_CONST; -void gimp_measure_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_measure_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_MEASURE_OPTIONS_H__ */ diff --git a/app/tools/gimpmoveoptions.c b/app/tools/gimpmoveoptions.c index ee7c4499f7..c6ee2ccb9c 100644 --- a/app/tools/gimpmoveoptions.c +++ b/app/tools/gimpmoveoptions.c @@ -163,7 +163,7 @@ gimp_move_options_get_property (GObject *object, } } -void +GtkWidget * gimp_move_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -173,7 +173,7 @@ gimp_move_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* tool toggle */ str = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_control ()); @@ -198,4 +198,6 @@ gimp_move_options_gui (GimpToolOptions *tool_options) gtk_widget_show (frame); g_free (str); + + return vbox; } diff --git a/app/tools/gimpmoveoptions.h b/app/tools/gimpmoveoptions.h index 0c1cb11388..feaa6c5143 100644 --- a/app/tools/gimpmoveoptions.h +++ b/app/tools/gimpmoveoptions.h @@ -43,9 +43,9 @@ struct _GimpMoveOptions }; -GType gimp_move_options_get_type (void) G_GNUC_CONST; +GType gimp_move_options_get_type (void) G_GNUC_CONST; -void gimp_move_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_move_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_MOVE_OPTIONS_H__ */ diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c index 96f327c301..6b119705c9 100644 --- a/app/tools/gimppaintoptions-gui.c +++ b/app/tools/gimppaintoptions-gui.c @@ -74,7 +74,7 @@ static void paint_options_brush_clicked (GtkWidget *widget, gpointer data); -void +GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options) { GimpPaintOptions *options; @@ -91,7 +91,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) context = GIMP_CONTEXT (tool_options); config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* the main table */ table = gtk_table_new (3, 3, FALSE); @@ -203,6 +203,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } + + return vbox; } diff --git a/app/tools/gimppaintoptions-gui.h b/app/tools/gimppaintoptions-gui.h index fd4ebc238d..9937df0150 100644 --- a/app/tools/gimppaintoptions-gui.h +++ b/app/tools/gimppaintoptions-gui.h @@ -20,7 +20,7 @@ #define __PAINT_OPTIONS_H__ -void gimp_paint_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options); #endif /* __PAINT_OPTIONS_H__ */ diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c index 3c6d3e6aa2..de0bb4545d 100644 --- a/app/tools/gimpselectionoptions.c +++ b/app/tools/gimpselectionoptions.c @@ -366,7 +366,7 @@ gimp_selection_options_reset (GimpToolOptions *tool_options) GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); } -void +GtkWidget * gimp_selection_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -377,7 +377,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); options = GIMP_SELECTION_OPTIONS (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* the selection operation radio buttons */ { @@ -593,6 +593,8 @@ gimp_selection_options_gui (GimpToolOptions *tool_options) } gimp_selection_options_reset (tool_options); + + return vbox; } diff --git a/app/tools/gimpselectionoptions.h b/app/tools/gimpselectionoptions.h index 901bd4c911..5eaeb56e63 100644 --- a/app/tools/gimpselectionoptions.h +++ b/app/tools/gimpselectionoptions.h @@ -63,9 +63,9 @@ struct _GimpSelectionOptions }; -GType gimp_selection_options_get_type (void) G_GNUC_CONST; +GType gimp_selection_options_get_type (void) G_GNUC_CONST; -void gimp_selection_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_selection_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_SELCTION_OPTIONS_H__ */ diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c index 771b3fa382..e9289c8228 100644 --- a/app/tools/gimpsmudgetool.c +++ b/app/tools/gimpsmudgetool.c @@ -37,10 +37,10 @@ #include "libgimp/gimpintl.h" -static void gimp_smudge_tool_class_init (GimpSmudgeToolClass *klass); -static void gimp_smudge_tool_init (GimpSmudgeTool *tool); +static void gimp_smudge_tool_class_init (GimpSmudgeToolClass *klass); +static void gimp_smudge_tool_init (GimpSmudgeTool *tool); -static void gimp_smudge_options_gui (GimpToolOptions *tool_options); +static GtkWidget * gimp_smudge_options_gui (GimpToolOptions *tool_options); static GimpPaintToolClass *parent_class = NULL; @@ -121,7 +121,7 @@ gimp_smudge_tool_init (GimpSmudgeTool *smudge) /* tool options stuff */ -static void +static GtkWidget * gimp_smudge_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -130,9 +130,7 @@ gimp_smudge_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); /* the rate scale */ table = gtk_table_new (1, 3, FALSE); @@ -145,4 +143,6 @@ gimp_smudge_options_gui (GimpToolOptions *tool_options) _("Rate:"), 1.0, 10.0, 1, FALSE, 0.0, 0.0); + + return vbox; } diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index 08f64f570d..2a313475d3 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -76,7 +76,7 @@ static void gimp_clone_pretrace_callback (GimpClone *clone, static void gimp_clone_posttrace_callback (GimpClone *clone, gpointer data); -static void gimp_clone_options_gui (GimpToolOptions *tool_options); +static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options); static GimpPaintToolClass *parent_class; @@ -362,7 +362,7 @@ gimp_clone_posttrace_callback (GimpClone *clone, /* tool options stuff */ -static void +static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -371,9 +371,7 @@ gimp_clone_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); - gimp_paint_options_gui (tool_options); - - vbox = tool_options->main_vbox; + vbox = gimp_paint_options_gui (tool_options); frame = gimp_prop_enum_radio_frame_new (config, "clone-type", _("Source"), @@ -386,4 +384,6 @@ gimp_clone_options_gui (GimpToolOptions *tool_options) 0, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); + + return vbox; } diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index bb2f6f5ad0..d6c35986a4 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -115,7 +115,7 @@ gimp_text_options_reset (GimpToolOptions *tool_options) GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); } -void +GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options) { GimpTextOptions *options; @@ -130,7 +130,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options) options = GIMP_TEXT_OPTIONS (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); table = gtk_table_new (4, 6, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); @@ -184,4 +184,6 @@ gimp_text_options_gui (GimpToolOptions *tool_options) gimp_table_attach_stock (GTK_TABLE (table), 5, _("Line\nSpacing:"), 0.0, spinbutton, GIMP_STOCK_LINE_SPACING); + + return vbox; } diff --git a/app/tools/gimptextoptions.h b/app/tools/gimptextoptions.h index caab21d3f2..99e707f436 100644 --- a/app/tools/gimptextoptions.h +++ b/app/tools/gimptextoptions.h @@ -43,9 +43,9 @@ struct _GimpTextOptions }; -GType gimp_text_options_get_type (void) G_GNUC_CONST; +GType gimp_text_options_get_type (void) G_GNUC_CONST; -void gimp_text_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_TEXT_OPTIONS_H__ */ diff --git a/app/tools/gimptransformoptions.c b/app/tools/gimptransformoptions.c index 4d8f78dc0e..685d8895d2 100644 --- a/app/tools/gimptransformoptions.c +++ b/app/tools/gimptransformoptions.c @@ -269,7 +269,7 @@ gimp_transform_options_reset (GimpToolOptions *tool_options) GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); } -void +GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options) { GObject *config; @@ -285,7 +285,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) config = G_OBJECT (tool_options); options = GIMP_TRANSFORM_OPTIONS (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); frame = gimp_prop_enum_radio_frame_new (config, "direction", _("Transform Direction"), 0, 0); @@ -402,6 +402,8 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) } gimp_transform_options_reset (tool_options); + + return vbox; } diff --git a/app/tools/gimptransformoptions.h b/app/tools/gimptransformoptions.h index 25b633317d..c666ffe24b 100644 --- a/app/tools/gimptransformoptions.h +++ b/app/tools/gimptransformoptions.h @@ -49,9 +49,9 @@ struct _GimpTransformOptions }; -GType gimp_transform_options_get_type (void) G_GNUC_CONST; +GType gimp_transform_options_get_type (void) G_GNUC_CONST; -void gimp_transform_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_TRANSFORM_OPTIONS_H__ */ diff --git a/app/tools/gimpvectoroptions.c b/app/tools/gimpvectoroptions.c index 500aeaf86f..1dc9e17b7f 100644 --- a/app/tools/gimpvectoroptions.c +++ b/app/tools/gimpvectoroptions.c @@ -76,7 +76,7 @@ gimp_vector_options_init (GimpVectorOptions *options) { } -void +GtkWidget * gimp_vector_options_gui (GimpToolOptions *tool_options) { GimpVectorOptions *options; @@ -84,7 +84,7 @@ gimp_vector_options_gui (GimpToolOptions *tool_options) options = GIMP_VECTOR_OPTIONS (tool_options); - gimp_selection_options_gui (tool_options); + vbox = gimp_selection_options_gui (tool_options); - vbox = tool_options->main_vbox; + return vbox; } diff --git a/app/tools/gimpvectoroptions.h b/app/tools/gimpvectoroptions.h index cfe0f0da12..52c3a71113 100644 --- a/app/tools/gimpvectoroptions.h +++ b/app/tools/gimpvectoroptions.h @@ -40,9 +40,9 @@ struct _GimpVectorOptions }; -GType gimp_vector_options_get_type (void) G_GNUC_CONST; +GType gimp_vector_options_get_type (void) G_GNUC_CONST; -void gimp_vector_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_vector_options_gui (GimpToolOptions *tool_options); #endif /* __GIMP_VECTOR_OPTIONS_H__ */ diff --git a/app/tools/paint_options.c b/app/tools/paint_options.c index 96f327c301..6b119705c9 100644 --- a/app/tools/paint_options.c +++ b/app/tools/paint_options.c @@ -74,7 +74,7 @@ static void paint_options_brush_clicked (GtkWidget *widget, gpointer data); -void +GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options) { GimpPaintOptions *options; @@ -91,7 +91,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) context = GIMP_CONTEXT (tool_options); config = G_OBJECT (tool_options); - vbox = tool_options->main_vbox; + vbox = gimp_tool_options_gui (tool_options); /* the main table */ table = gtk_table_new (3, 3, FALSE); @@ -203,6 +203,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } + + return vbox; } diff --git a/app/tools/paint_options.h b/app/tools/paint_options.h index fd4ebc238d..9937df0150 100644 --- a/app/tools/paint_options.h +++ b/app/tools/paint_options.h @@ -20,7 +20,7 @@ #define __PAINT_OPTIONS_H__ -void gimp_paint_options_gui (GimpToolOptions *tool_options); +GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options); #endif /* __PAINT_OPTIONS_H__ */ diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c index 2bb81e05e1..aca37d4617 100644 --- a/app/tools/tool_manager.c +++ b/app/tools/tool_manager.c @@ -169,7 +169,8 @@ tool_manager_restore (Gimp *gimp) list; list = g_list_next (list)) { - GimpToolOptionsGUIFunc options_gui_func; + GimpToolOptionsGUIFunc options_gui_func; + GtkWidget *options_gui; tool_info = GIMP_TOOL_INFO (list->data); @@ -177,7 +178,22 @@ tool_manager_restore (Gimp *gimp) "gimp-tool-options-gui-func"); if (options_gui_func) - options_gui_func (tool_info->tool_options); + { + options_gui = options_gui_func (tool_info->tool_options); + } + else + { + GtkWidget *label; + + options_gui = gimp_tool_options_gui (tool_info->tool_options); + + label = gtk_label_new (_("This tool has no options.")); + gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6); + gtk_widget_show (label); + } + + g_object_set_data (G_OBJECT (tool_info->tool_options), + "gimp-tool-options-gui", options_gui); } } @@ -506,11 +522,8 @@ tool_manager_register_tool (GType tool_type, g_return_if_fail (tool_options_type == G_TYPE_NONE || g_type_is_a (tool_options_type, GIMP_TYPE_TOOL_OPTIONS)); - if (tool_options_type == G_TYPE_NONE && options_gui_func == NULL) - { - tool_options_type = GIMP_TYPE_TOOL_OPTIONS; - options_gui_func = gimp_tool_options_gui; - } + if (tool_options_type == G_TYPE_NONE) + tool_options_type = GIMP_TYPE_TOOL_OPTIONS; if (tool_type == GIMP_TYPE_PENCIL_TOOL) { @@ -731,7 +744,7 @@ tool_manager_tool_changed (GimpContext *user_context, old_tool_info = tool_manager->active_tool->tool_info; - gimp_context_unset_parent (GIMP_CONTEXT (old_tool_info->tool_options)); + gimp_context_set_parent (GIMP_CONTEXT (old_tool_info->tool_options), NULL); } /* connect the new tool's context */ diff --git a/app/tools/tool_options.c b/app/tools/tool_options.c index ac3e19ad60..aaf23d83ae 100644 --- a/app/tools/tool_options.c +++ b/app/tools/tool_options.c @@ -113,7 +113,6 @@ static void gimp_tool_options_init (GimpToolOptions *options) { options->tool_info = NULL; - options->main_vbox = gtk_vbox_new (FALSE, 2); } static void @@ -226,13 +225,12 @@ gimp_tool_options_deserialize (GimpToolOptions *tool_options, return retval; } -void +gpointer gimp_tool_options_gui (GimpToolOptions *tool_options) { - GtkWidget *label; + GtkWidget *vbox; - label = gtk_label_new (_("This tool has no options.")); - gtk_box_pack_start (GTK_BOX (tool_options->main_vbox), label, - FALSE, FALSE, 6); - gtk_widget_show (label); + vbox = gtk_vbox_new (FALSE, 2); + + return vbox; } diff --git a/app/tools/tool_options.h b/app/tools/tool_options.h index abe9889da9..b78729726d 100644 --- a/app/tools/tool_options.h +++ b/app/tools/tool_options.h @@ -38,8 +38,6 @@ struct _GimpToolOptions GimpContext parent_instance; GimpToolInfo *tool_info; - - gpointer main_vbox; }; struct _GimpToolOptionsClass @@ -59,7 +57,7 @@ gboolean gimp_tool_options_serialize (GimpToolOptions *tool_options, gboolean gimp_tool_options_deserialize (GimpToolOptions *tool_options, GError **error); -void gimp_tool_options_gui (GimpToolOptions *tool_options); +gpointer gimp_tool_options_gui (GimpToolOptions *tool_options); #endif /* __TOOL_OPTIONS_H__ */ diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c index 0927472a6a..350b783e91 100644 --- a/app/widgets/gimpdevices.c +++ b/app/widgets/gimpdevices.c @@ -220,7 +220,7 @@ gimp_devices_select_device (Gimp *gimp, g_return_if_fail (GIMP_IS_DEVICE_INFO (current_device_info)); g_return_if_fail (GIMP_IS_DEVICE_INFO (new_device_info)); - gimp_context_unset_parent (GIMP_CONTEXT (current_device_info)); + gimp_context_set_parent (GIMP_CONTEXT (current_device_info), NULL); manager->current_device = new_device; diff --git a/app/widgets/gimptooloptionseditor.c b/app/widgets/gimptooloptionseditor.c index 660b327fa4..aa18e71bdb 100644 --- a/app/widgets/gimptooloptionseditor.c +++ b/app/widgets/gimptooloptionseditor.c @@ -186,22 +186,30 @@ tool_options_dialog_tool_changed (GimpContext *context, GimpToolInfo *tool_info, gpointer data) { + GtkWidget *options_gui; + if (visible_tool_options && (! tool_info || tool_info->tool_options != visible_tool_options)) { - gtk_widget_hide (visible_tool_options->main_vbox); + options_gui = g_object_get_data (G_OBJECT (visible_tool_options), + "gimp-tool-options-gui"); + + if (options_gui) + gtk_widget_hide (options_gui); visible_tool_options = NULL; } if (tool_info && tool_info->tool_options) { - if (! GTK_WIDGET (tool_info->tool_options->main_vbox)->parent) - gtk_box_pack_start (GTK_BOX (options_vbox), - tool_info->tool_options->main_vbox, + options_gui = g_object_get_data (G_OBJECT (tool_info->tool_options), + "gimp-tool-options-gui"); + + if (! options_gui->parent) + gtk_box_pack_start (GTK_BOX (options_vbox), options_gui, FALSE, FALSE, 0); - gtk_widget_show (tool_info->tool_options->main_vbox); + gtk_widget_show (options_gui); visible_tool_options = tool_info->tool_options; diff --git a/libgimptool/gimptoolmodule.c b/libgimptool/gimptoolmodule.c index 98091b047e..b5989c6e67 100644 --- a/libgimptool/gimptoolmodule.c +++ b/libgimptool/gimptoolmodule.c @@ -18,7 +18,7 @@ #include "config.h" -#include +#include #include "libgimpproxy/gimpproxytypes.h" #include "gimptooltypes.h" diff --git a/libgimptool/gimptooltypes.h b/libgimptool/gimptooltypes.h index 81931384eb..242a30481f 100644 --- a/libgimptool/gimptooltypes.h +++ b/libgimptool/gimptooltypes.h @@ -39,7 +39,7 @@ typedef struct _GimpTransformTool GimpTransformTool; /* functions */ -typedef void (* GimpToolOptionsGUIFunc) (GimpToolOptions *tool_options); +typedef GtkWidget * (* GimpToolOptionsGUIFunc) (GimpToolOptions *tool_options); typedef void (* GimpToolRegisterCallback) (GType tool_type, GType tool_option_type,