diff --git a/ChangeLog b/ChangeLog index cc6ad0a57a..0dff8d6ec3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2001-11-20 Michael Natterer + + * app/tools/tools-types.h: added GimpToolRegisterFunc, + GimpToolRegisterCallback and GimpToolOptionsNewFunc typedefs + which are used to register tools. + + * app/tools/tools.c: put the register funcs in an array of + GimpToolRegisterFuncs. Pass a Gimp pointer *plus* a + GimpToolRegisterCallback (which is tool_manager_register_tool()) + to the tools' register functions. + + * app/tools/tool_manager.[ch]: added a GimpToolOptionsNewFunc to + the parameters of tool_manager_register_tool(). Create the tool + options here, not in each tool. + + * app/tools/paint_options.[ch] + * app/tools/selection_options.[ch] + * app/tools/tool_options.[ch] + * app/tools/transform_options.[ch]: all _init() and _new() + functions take a GimpToolInfo pointer now. The _reset() func needs + to be set manually now. + + * app/tools/[all_tools].[ch]: changed accordingly: + + - pass GimpToolOptionsNewFuncs to the register callback. + - don't create the tool options in the tools' _init() function. + - removed all static tool options variables. + - get the options from the tool system in the cases i missed + in my last commit. + - added minor hacks to get rid of the static options pointer + in some pathological cases :) (i.e. the ink tool). + 2001-11-20 David Neary * app/core/gimppalette.c: Included errno,h @@ -11,8 +43,6 @@ * app/core/gimppalette.c * app/core/gimppattern.c: More of the extensive proofing. Fun fun fun! - - 2001-11-20 Sven Neumann * app/gui/preferences-dialog.c diff --git a/app/base/color-balance.c b/app/base/color-balance.c index c8ee54d54a..1c44bf34e6 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -37,7 +37,6 @@ #include "gimpcolorbalancetool.h" #include "gimpcolorbalancetool-transfer.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -88,10 +87,6 @@ static void color_balance_yb_adjustment_update (GtkAdjustment *adj, gpointer data); -/* the color balance tool options */ -static GimpToolOptions *color_balance_options = NULL; - -/* the color balance dialog */ static ColorBalanceDialog *color_balance_dialog = NULL; static GimpImageMapToolClass *parent_class = NULL; @@ -100,17 +95,19 @@ static GimpImageMapToolClass *parent_class = NULL; /* functions */ void -gimp_color_balance_tool_register (Gimp *gimp) +gimp_color_balance_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_COLOR_BALANCE_TOOL, - FALSE, - "gimp:color_balance_tool", - _("Color Balance"), - _("Adjust color balance"), - N_("/Image/Colors/Color Balance..."), NULL, - NULL, "tools/color_balance.html", - GIMP_STOCK_TOOL_COLOR_BALANCE); + (* callback) (gimp, + GIMP_TYPE_COLOR_BALANCE_TOOL, + NULL, + FALSE, + "gimp:color_balance_tool", + _("Color Balance"), + _("Adjust color balance"), + N_("/Image/Colors/Color Balance..."), NULL, + NULL, "tools/color_balance.html", + GIMP_STOCK_TOOL_COLOR_BALANCE); } GType @@ -159,17 +156,6 @@ gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass) static void gimp_color_balance_tool_init (GimpColorBalanceTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! color_balance_options) - { - color_balance_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_COLOR_BALANCE_TOOL, - (GimpToolOptions *) color_balance_options); - } } static void diff --git a/app/base/color-balance.h b/app/base/color-balance.h index 0b67c9d852..746f416102 100644 --- a/app/base/color-balance.h +++ b/app/base/color-balance.h @@ -73,9 +73,10 @@ struct _ColorBalanceDialog }; -void gimp_color_balance_tool_register (Gimp *gimp); +void gimp_color_balance_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); -GType gimp_color_balance_tool_get_type (void); +GType gimp_color_balance_tool_get_type (void); void color_balance (PixelRegion *srcPR, diff --git a/app/base/curves.c b/app/base/curves.c index 0c682adb60..290f553a6f 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -43,7 +43,6 @@ #include "gimpcurvestool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -177,14 +176,8 @@ static gboolean curves_read_from_file (FILE *f); static void curves_write_to_file (FILE *f); -/* the curves tool options */ -static GimpToolOptions * curves_options = NULL; - -/* the curves dialog */ static CurvesDialog * curves_dialog = NULL; -static GimpImageMapToolClass *parent_class = NULL; - /* the curves file dialog */ static GtkWidget *file_dlg = NULL; static gboolean load_save; @@ -199,21 +192,25 @@ static CRMatrix CR_basis = { 0.0, 1.0, 0.0, 0.0 }, }; +static GimpImageMapToolClass *parent_class = NULL; -/* functions */ + +/* public functions */ void -gimp_curves_tool_register (Gimp *gimp) +gimp_curves_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CURVES_TOOL, - FALSE, - "gimp:curves_tool", - _("Curves"), - _("Adjust color curves"), - N_("/Image/Colors/Curves..."), NULL, - NULL, "tools/curves.html", - GIMP_STOCK_TOOL_CURVES); + (* callback) (gimp, + GIMP_TYPE_CURVES_TOOL, + NULL, + FALSE, + "gimp:curves_tool", + _("Curves"), + _("Adjust color curves"), + N_("/Image/Colors/Curves..."), NULL, + NULL, "tools/curves.html", + GIMP_STOCK_TOOL_CURVES); } GType @@ -263,17 +260,6 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass) static void gimp_curves_tool_init (GimpCurvesTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! curves_options) - { - curves_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CURVES_TOOL, - (GimpToolOptions *) curves_options); - } } static void diff --git a/app/base/curves.h b/app/base/curves.h index 3dd5bc098a..4a9e96ec9c 100644 --- a/app/base/curves.h +++ b/app/base/curves.h @@ -85,7 +85,8 @@ struct _CurvesDialog }; -void gimp_curves_tool_register (Gimp *gimp); +void gimp_curves_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_curves_tool_get_type (void); diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c index f7364e9904..a87deda1c2 100644 --- a/app/base/hue-saturation.c +++ b/app/base/hue-saturation.c @@ -37,7 +37,6 @@ #include "gimphuesaturationtool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -97,15 +96,6 @@ static gint hue_saturation_hue_partition_events (GtkWidget *, HueSaturationDialog *hsd); -/* the hue-saturation tool options */ -static GimpToolOptions *hue_saturation_options = NULL; - -/* the hue-saturation tool dialog */ -static HueSaturationDialog *hue_saturation_dialog = NULL; - -static GimpImageMapToolClass *parent_class = NULL; - - /* Local variables */ static gint hue_transfer[6][256]; static gint lightness_transfer[6][256]; @@ -120,21 +110,27 @@ static gint default_colors[6][3] = { 255, 0, 255 } }; +static HueSaturationDialog *hue_saturation_dialog = NULL; -/* functions */ +static GimpImageMapToolClass *parent_class = NULL; + + +/* public functions */ void -gimp_hue_saturation_tool_register (Gimp *gimp) +gimp_hue_saturation_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_HUE_SATURATION_TOOL, - FALSE, - "gimp:hue_saturation_tool", - _("Hue-Saturation"), - _("Adjust hue and saturation"), - N_("/Image/Colors/Hue-Saturation..."), NULL, - NULL, "tools/hue_saturation.html", - GIMP_STOCK_TOOL_HUE_SATURATION); + (* callback) (gimp, + GIMP_TYPE_HUE_SATURATION_TOOL, + NULL, + FALSE, + "gimp:hue_saturation_tool", + _("Hue-Saturation"), + _("Adjust hue and saturation"), + N_("/Image/Colors/Hue-Saturation..."), NULL, + NULL, "tools/hue_saturation.html", + GIMP_STOCK_TOOL_HUE_SATURATION); } GType @@ -181,17 +177,6 @@ gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass) static void gimp_hue_saturation_tool_init (GimpHueSaturationTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! hue_saturation_options) - { - hue_saturation_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_HUE_SATURATION_TOOL, - (GimpToolOptions *) hue_saturation_options); - } } static void diff --git a/app/base/hue-saturation.h b/app/base/hue-saturation.h index 20c0cfb5b9..c5765fd478 100644 --- a/app/base/hue-saturation.h +++ b/app/base/hue-saturation.h @@ -81,7 +81,8 @@ struct _HueSaturationDialog }; -void gimp_hue_saturation_tool_register (Gimp *gimp); +void gimp_hue_saturation_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_hue_saturation_tool_get_type (void); diff --git a/app/base/threshold.c b/app/base/threshold.c index 8e1a0ba43c..ee1862e71f 100644 --- a/app/base/threshold.c +++ b/app/base/threshold.c @@ -40,7 +40,6 @@ #include "gimpthresholdtool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -96,10 +95,6 @@ static void threshold_histogram_range (GimpHistogramView *, gpointer ); -/* the threshold tool options */ -static GimpToolOptions *threshold_options = NULL; - -/* the threshold tool dialog */ static ThresholdDialog *threshold_dialog = NULL; static GimpImageMapToolClass *parent_class = NULL; @@ -108,17 +103,19 @@ static GimpImageMapToolClass *parent_class = NULL; /* functions */ void -gimp_threshold_tool_register (Gimp *gimp) +gimp_threshold_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_THRESHOLD_TOOL, - FALSE, - "gimp:threshold_tool", - _("Threshold"), - _("Reduce image to two colors using a threshold"), - N_("/Image/Colors/Threshold..."), NULL, - NULL, "tools/threshold.html", - GIMP_STOCK_TOOL_THRESHOLD); + (* callback) (gimp, + GIMP_TYPE_THRESHOLD_TOOL, + NULL, + FALSE, + "gimp:threshold_tool", + _("Threshold"), + _("Reduce image to two colors using a threshold"), + N_("/Image/Colors/Threshold..."), NULL, + NULL, "tools/threshold.html", + GIMP_STOCK_TOOL_THRESHOLD); } GType @@ -165,17 +162,6 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass) static void gimp_threshold_tool_init (GimpThresholdTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! threshold_options) - { - threshold_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_THRESHOLD_TOOL, - (GimpToolOptions *) threshold_options); - } } static void diff --git a/app/base/threshold.h b/app/base/threshold.h index dedb174759..767dc43983 100644 --- a/app/base/threshold.h +++ b/app/base/threshold.h @@ -68,7 +68,8 @@ struct _ThresholdDialog }; -void gimp_threshold_tool_register (Gimp *gimp); +void gimp_threshold_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_threshold_tool_get_type (void); diff --git a/app/core/gimpimage-pick-color.c b/app/core/gimpimage-pick-color.c index 9d46adfe77..240d00c3ee 100644 --- a/app/core/gimpimage-pick-color.c +++ b/app/core/gimpimage-pick-color.c @@ -108,11 +108,9 @@ static void gimp_color_picker_tool_cursor_update (GimpTool *tool, static void gimp_color_picker_tool_draw (GimpDrawTool *draw_tool); +static GimpToolOptions * gimp_color_picker_tool_options_new (GimpToolInfo *tool_info); +static void gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options); - -static GimpColorPickerToolOptions * gimp_color_picker_tool_options_new (void); - -static void gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options); static void gimp_color_picker_tool_info_window_close_callback (GtkWidget *widget, gpointer data); static void gimp_color_picker_tool_info_update (GimpTool *tool, @@ -131,9 +129,6 @@ static gboolean pick_color_do (GimpImage *gimage, gint final); -/* the color picker tool options */ -static GimpColorPickerToolOptions * gimp_color_picker_tool_options = NULL; - /* the color value */ gint col_value[5] = { 0, 0, 0, 0, 0 }; @@ -154,17 +149,19 @@ static GimpDrawToolClass *parent_class = NULL; void -gimp_color_picker_tool_register (Gimp *gimp) +gimp_color_picker_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_COLOR_PICKER_TOOL, - FALSE, - "gimp:color_picker_tool", - _("Color Picker"), - _("Pick colors from the image"), - N_("/Tools/Color Picker"), "O", - NULL, "tools/color_picker.html", - GIMP_STOCK_TOOL_COLOR_PICKER); + (* callback) (gimp, + GIMP_TYPE_COLOR_PICKER_TOOL, + gimp_color_picker_tool_options_new, + FALSE, + "gimp:color_picker_tool", + _("Color Picker"), + _("Pick colors from the image"), + N_("/Tools/Color Picker"), "O", + NULL, "tools/color_picker.html", + GIMP_STOCK_TOOL_COLOR_PICKER); } GtkType @@ -226,14 +223,6 @@ gimp_color_picker_tool_init (GimpColorPickerTool *color_picker_tool) tool = GIMP_TOOL (color_picker_tool); - if (! gimp_color_picker_tool_options) - { - gimp_color_picker_tool_options = gimp_color_picker_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_COLOR_PICKER_TOOL, - (GimpToolOptions *) gimp_color_picker_tool_options); - } - tool->tool_cursor = GIMP_COLOR_PICKER_TOOL_CURSOR; tool->preserve = FALSE; /* Don't preserve on drawable change */ @@ -788,8 +777,8 @@ gimp_color_picker_tool_info_window_close_callback (GtkWidget *widget, /* tool options stuff */ -static GimpColorPickerToolOptions * -gimp_color_picker_tool_options_new (void) +static GimpToolOptions * +gimp_color_picker_tool_options_new (GimpToolInfo *tool_info) { GimpColorPickerToolOptions *options; @@ -800,8 +789,10 @@ gimp_color_picker_tool_options_new (void) GtkWidget *scale; options = g_new0 (GimpColorPickerToolOptions, 1); - tool_options_init ((GimpToolOptions *) options, - gimp_color_picker_tool_options_reset); + + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = gimp_color_picker_tool_options_reset; options->sample_merged = options->sample_merged_d = FALSE; options->sample_average = options->sample_average_d = FALSE; @@ -880,7 +871,7 @@ gimp_color_picker_tool_options_new (void) &options->update_active); gtk_widget_show (options->update_active_w); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/core/gimptooloptions.c b/app/core/gimptooloptions.c index 1494cf7e1f..3bd4b8ced1 100644 --- a/app/core/gimptooloptions.c +++ b/app/core/gimptooloptions.c @@ -28,21 +28,21 @@ void -tool_options_init (GimpToolOptions *options, - ToolOptionsResetFunc reset_func) +tool_options_init (GimpToolOptions *options, + GimpToolInfo *tool_info) { - options->main_vbox = gtk_vbox_new (FALSE, 2); - options->reset_func = reset_func; + options->main_vbox = gtk_vbox_new (FALSE, 2); + options->tool_info = tool_info; } GimpToolOptions * -tool_options_new (void) +tool_options_new (GimpToolInfo *tool_info) { GimpToolOptions *options; GtkWidget *label; options = g_new0 (GimpToolOptions, 1); - tool_options_init (options, NULL); + tool_options_init (options, tool_info); label = gtk_label_new (_("This tool has no options.")); gtk_box_pack_start (GTK_BOX (options->main_vbox), label, FALSE, FALSE, 6); diff --git a/app/core/gimptooloptions.h b/app/core/gimptooloptions.h index 30a022a6e8..9b23729fe9 100644 --- a/app/core/gimptooloptions.h +++ b/app/core/gimptooloptions.h @@ -24,21 +24,22 @@ struct _GimpToolOptions { - GtkWidget *main_vbox; + GtkWidget *main_vbox; - ToolOptionsResetFunc reset_func; + GimpToolInfo *tool_info; + GimpToolOptionsResetFunc reset_func; }; /* create a dummy tool options structure * (to be used by tools without options) */ -GimpToolOptions * tool_options_new (void); +GimpToolOptions * tool_options_new (GimpToolInfo *tool_info); /* initialize an already allocated ToolOptions structure * (to be used by derived tool options only) */ -void tool_options_init (GimpToolOptions *options, - ToolOptionsResetFunc reset_func); +void tool_options_init (GimpToolOptions *options, + GimpToolInfo *tool_info); #endif /* __TOOL_OPTIONS_H__ */ diff --git a/app/paint/gimpairbrush.c b/app/paint/gimpairbrush.c index dd7f497a47..e942923fca 100644 --- a/app/paint/gimpairbrush.c +++ b/app/paint/gimpairbrush.c @@ -35,6 +35,7 @@ #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -101,7 +102,7 @@ static void gimp_airbrush_tool_motion (GimpPaintTool *paint_tool, gboolean incremental); static gint airbrush_time_out (gpointer data); -static AirbrushOptions * airbrush_options_new (void); +static GimpToolOptions * airbrush_options_new (GimpToolInfo *tool_info); static void airbrush_options_reset (GimpToolOptions *tool_options); @@ -114,25 +115,25 @@ static gdouble non_gui_rate; static gdouble non_gui_pressure; static gboolean non_gui_incremental; -static AirbrushOptions *airbrush_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_airbrush_tool_register (Gimp *gimp) +gimp_airbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_AIRBRUSH_TOOL, - TRUE, - "gimp:airbrush_tool", - _("Airbrush"), - _("Airbrush with variable pressure"), - N_("/Tools/Paint Tools/Airbrush"), "A", - NULL, "tools/airbrush.html", - GIMP_STOCK_TOOL_AIRBRUSH); + (* callback) (gimp, + GIMP_TYPE_AIRBRUSH_TOOL, + airbrush_options_new, + TRUE, + "gimp:airbrush_tool", + _("Airbrush"), + _("Airbrush with variable pressure"), + N_("/Tools/Paint Tools/Airbrush"), "A", + NULL, "tools/airbrush.html", + GIMP_STOCK_TOOL_AIRBRUSH); } GType @@ -188,18 +189,10 @@ gimp_airbrush_tool_init (GimpAirbrushTool *airbrush) tool = GIMP_TOOL (airbrush); paint_tool = GIMP_PAINT_TOOL (airbrush); - if (! airbrush_options) - { - airbrush_options = airbrush_options_new (); + tool->tool_cursor = GIMP_AIRBRUSH_TOOL_CURSOR; - tool_manager_register_tool_options (GIMP_TYPE_AIRBRUSH_TOOL, - (GimpToolOptions *) airbrush_options); - } - - tool->tool_cursor = GIMP_AIRBRUSH_TOOL_CURSOR; - - paint_tool->pick_colors = TRUE; - paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; + paint_tool->pick_colors = TRUE; + paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; } static void @@ -219,21 +212,24 @@ gimp_airbrush_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + AirbrushOptions *options; PaintPressureOptions *pressure_options; gdouble pressure; gdouble rate; gboolean incremental; GimpBrush *brush; - if (!drawable) + if (! drawable) return; - if (airbrush_options) + options = (AirbrushOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (options) { - pressure_options = airbrush_options->paint_options.pressure_options; - pressure = airbrush_options->pressure; - rate = airbrush_options->rate; - incremental = airbrush_options->paint_options.incremental; + pressure_options = options->paint_options.pressure_options; + pressure = options->pressure; + rate = options->rate; + incremental = options->paint_options.incremental; } else { @@ -281,7 +277,7 @@ gimp_airbrush_tool_paint (GimpPaintTool *paint_tool, (10000 / (rate * 2.0 * paint_tool->cur_coords.pressure)) : (10000 / rate)); - timer = gtk_timeout_add (timeout, airbrush_time_out, NULL); + timer = gtk_timeout_add (timeout, airbrush_time_out, paint_tool); timer_state = ON; } break; @@ -302,17 +298,23 @@ gimp_airbrush_tool_paint (GimpPaintTool *paint_tool, static gint airbrush_time_out (gpointer client_data) { + GimpTool *tool; + AirbrushOptions *options; PaintPressureOptions *pressure_options; gdouble pressure; gdouble rate; gboolean incremental; - if (airbrush_options) + tool = GIMP_TOOL (client_data); + + options = (AirbrushOptions *) tool->tool_info->tool_options; + + if (options) { - pressure_options = airbrush_options->paint_options.pressure_options; - pressure = airbrush_options->pressure; - rate = airbrush_options->rate; - incremental = airbrush_options->paint_options.incremental; + pressure_options = options->paint_options.pressure_options; + pressure = options->pressure; + rate = options->rate; + incremental = options->paint_options.incremental; } else { @@ -427,10 +429,16 @@ airbrush_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { - AirbrushOptions *options = airbrush_options; + GimpToolInfo *tool_info; + AirbrushOptions *options; gdouble pressure = AIRBRUSH_DEFAULT_PRESSURE; + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_AIRBRUSH_TOOL); + + options = (AirbrushOptions *) tool_info->tool_options; + if (options) pressure = options->pressure; @@ -487,8 +495,8 @@ airbrush_non_gui (GimpDrawable *drawable, return FALSE; } -static AirbrushOptions * -airbrush_options_new (void) +static GimpToolOptions * +airbrush_options_new (GimpToolInfo *tool_info) { AirbrushOptions *options; GtkWidget *vbox; @@ -496,9 +504,10 @@ airbrush_options_new (void) GtkWidget *scale; options = g_new0 (AirbrushOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_AIRBRUSH_TOOL, - airbrush_options_reset); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = airbrush_options_reset; options->rate = options->rate_d = 80.0; options->pressure = options->pressure_d = AIRBRUSH_DEFAULT_PRESSURE; @@ -539,7 +548,7 @@ airbrush_options_new (void) gtk_widget_show (table); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimpairbrush.h b/app/paint/gimpairbrush.h index a41f65bc20..6ab8c93f65 100644 --- a/app/paint/gimpairbrush.h +++ b/app/paint/gimpairbrush.h @@ -45,7 +45,8 @@ struct _GimpAirbrushToolClass }; -void gimp_airbrush_tool_register (Gimp *gimp); +void gimp_airbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_airbrush_tool_get_type (void); diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index 1d77cb2e1c..23867f75a2 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -46,8 +46,6 @@ #include "gimpclonetool.h" #include "paint_options.h" -#include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -125,16 +123,10 @@ static void gimp_clone_tool_line_pattern (GimpImage *dest, gint bytes, gint width); -static CloneOptions * clone_options_new (void); -static void clone_options_reset (GimpToolOptions *options); +static GimpToolOptions * clone_options_new (GimpToolInfo *tool_info); +static void clone_options_reset (GimpToolOptions *options); -/* The parent class */ -static GimpPaintToolClass *parent_class; - -/* the clone tool options */ -static CloneOptions *clone_options = NULL; - /* local variables */ static gint src_x = 0; /* */ static gint src_y = 0; /* position of clone src */ @@ -153,21 +145,25 @@ static gint non_gui_offset_x; static gint non_gui_offset_y; static CloneType non_gui_type; +static GimpPaintToolClass *parent_class; -/* global functions */ + +/* public functions */ void -gimp_clone_tool_register (Gimp *gimp) +gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CLONE_TOOL, - TRUE, - "gimp:clone_tool", - _("Clone"), - _("Paint using Patterns or Image Regions"), - N_("/Tools/Paint Tools/Clone"), "C", - NULL, "tools/clone.html", - GIMP_STOCK_TOOL_CLONE); + (* callback) (gimp, + GIMP_TYPE_CLONE_TOOL, + clone_options_new, + TRUE, + "gimp:clone_tool", + _("Clone"), + _("Paint using Patterns or Image Regions"), + N_("/Tools/Paint Tools/Clone"), "C", + NULL, "tools/clone.html", + GIMP_STOCK_TOOL_CLONE); } GType @@ -229,14 +225,6 @@ gimp_clone_tool_init (GimpCloneTool *clone) tool = GIMP_TOOL (clone); paint_tool = GIMP_PAINT_TOOL (clone); - if (! clone_options) - { - clone_options = clone_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CLONE_TOOL, - (GimpToolOptions *) clone_options); - } - tool->tool_cursor = GIMP_CLONE_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -818,18 +806,19 @@ gimp_clone_tool_non_gui (GimpDrawable *drawable, #endif /* 0 - non-gui functions */ -static CloneOptions * -clone_options_new (void) +static GimpToolOptions * +clone_options_new (GimpToolInfo *tool_info) { CloneOptions *options; GtkWidget *vbox; GtkWidget *frame; - /* the new clone tool options structure */ - options = g_new (CloneOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_CLONE_TOOL, - clone_options_reset); + options = g_new0 (CloneOptions, 1); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = clone_options_reset; + options->type = options->type_d = CLONE_DEFAULT_TYPE; options->aligned = options->aligned_d = CLONE_DEFAULT_ALIGNED; @@ -866,7 +855,7 @@ clone_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimpclone.h b/app/paint/gimpclone.h index 8916580e25..016415557c 100644 --- a/app/paint/gimpclone.h +++ b/app/paint/gimpclone.h @@ -52,7 +52,8 @@ struct _GimpCloneToolClass }; -void gimp_clone_tool_register (Gimp *gimp); +void gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_clone_tool_get_type (void); diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c index 324808c16c..174ef93a70 100644 --- a/app/paint/gimpconvolve.c +++ b/app/paint/gimpconvolve.c @@ -28,18 +28,17 @@ #include "base/pixel-region.h" #include "base/temp-buf.h" +#include "paint-funcs/paint-funcs.h" + #include "core/gimp.h" #include "core/gimpbrush.h" #include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" - -#include "paint-funcs/paint-funcs.h" +#include "core/gimptoolinfo.h" #include "gimpconvolvetool.h" #include "paint_options.h" -#include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -120,16 +119,10 @@ static void copy_matrix (gfloat *src, static gint sum_matrix (gint *matrix, gint size); -static ConvolveOptions * convolve_options_new (void); +static GimpToolOptions * convolve_options_new (GimpToolInfo *tool_info); static void convolve_options_reset (GimpToolOptions *options); -/* The parent class */ -static GimpPaintToolClass *parent_class; - -/* the convolve tool options */ -static ConvolveOptions * convolve_options = NULL; - /* local variables */ static gint matrix [25]; static gint matrix_size; @@ -165,21 +158,25 @@ static gfloat sharpen_matrix [25] = 0, 0, 0, 0, 0, }; +static GimpPaintToolClass *parent_class; -/* global functions */ + +/* public functions */ void -gimp_convolve_tool_register (Gimp *gimp) +gimp_convolve_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CONVOLVE_TOOL, - TRUE, - "gimp:convolve_tool", - _("Convolve"), - _("Blur or Sharpen"), - N_("/Tools/Paint Tools/Convolve"), "B", - NULL, "tools/convolve.html", - GIMP_STOCK_TOOL_BLUR); + (* callback) (gimp, + GIMP_TYPE_CONVOLVE_TOOL, + convolve_options_new, + TRUE, + "gimp:convolve_tool", + _("Convolve"), + _("Blur or Sharpen"), + N_("/Tools/Paint Tools/Convolve"), "B", + NULL, "tools/convolve.html", + GIMP_STOCK_TOOL_BLUR); } GType @@ -232,19 +229,9 @@ gimp_convolve_tool_class_init (GimpConvolveToolClass *klass) static void gimp_convolve_tool_init (GimpConvolveTool *convolve) { - GimpTool *tool; - GimpPaintTool *paint_tool; + GimpTool *tool; - tool = GIMP_TOOL (convolve); - paint_tool = GIMP_PAINT_TOOL (convolve); - - if (! convolve_options) - { - convolve_options = convolve_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CONVOLVE_TOOL, - (GimpToolOptions *) convolve_options); - } + tool = GIMP_TOOL (convolve); tool->tool_cursor = GIMP_BLUR_TOOL_CURSOR; } @@ -254,13 +241,18 @@ gimp_convolve_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + ConvolveOptions *options; + + options = (ConvolveOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + switch (state) { case MOTION_PAINT: - gimp_convolve_tool_motion (paint_tool, drawable, - convolve_options->paint_options.pressure_options, - convolve_options->type, - convolve_options->rate); + gimp_convolve_tool_motion (paint_tool, + drawable, + options->paint_options.pressure_options, + options->type, + options->rate); break; default: @@ -276,27 +268,29 @@ gimp_convolve_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + ConvolveOptions *options; + + options = (ConvolveOptions *) tool->tool_info->tool_options; + if ((key == GDK_CONTROL_MASK) && ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */ { - switch (convolve_options->type) + switch (options->type) { case BLUR_CONVOLVE: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), - TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[SHARPEN_CONVOLVE]), TRUE); break; case SHARPEN_CONVOLVE: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), - TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[BLUR_CONVOLVE]), TRUE); break; default: break; } } - tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); + tool->toggled = (options->type == SHARPEN_CONVOLVE); } static void @@ -305,7 +299,11 @@ gimp_convolve_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); + ConvolveOptions *options; + + options = (ConvolveOptions *) tool->tool_info->tool_options; + + tool->toggled = (options->type == SHARPEN_CONVOLVE); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp); } @@ -680,8 +678,8 @@ convolve_non_gui (GimpDrawable *drawable, #endif /* 0 - non-gui functions */ -static ConvolveOptions * -convolve_options_new (void) +static GimpToolOptions * +convolve_options_new (GimpToolInfo *tool_info) { ConvolveOptions *options; GtkWidget *vbox; @@ -692,9 +690,9 @@ convolve_options_new (void) options = g_new0 (ConvolveOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_CONVOLVE_TOOL, - convolve_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = convolve_options_reset; options->type = options->type_d = DEFAULT_CONVOLVE_TYPE; options->rate = options->rate_d = DEFAULT_CONVOLVE_RATE; @@ -737,7 +735,7 @@ convolve_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimpconvolve.h b/app/paint/gimpconvolve.h index d4b11f8fd7..9d545cd4e9 100644 --- a/app/paint/gimpconvolve.h +++ b/app/paint/gimpconvolve.h @@ -53,7 +53,8 @@ struct _GimpConvolveToolClass }; -void gimp_convolve_tool_register (Gimp *gimp); +void gimp_convolve_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_convolve_tool_get_type (void); diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c index bfe454c1d2..005136c091 100644 --- a/app/paint/gimpdodgeburn.c +++ b/app/paint/gimpdodgeburn.c @@ -36,11 +36,10 @@ #include "core/gimpdrawable.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimpdodgeburntool.h" -#include "gimppainttool.h" #include "paint_options.h" -#include "gimptool.h" #include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -119,32 +118,32 @@ static gfloat gimp_dodgeburn_tool_shadows_lut_func (gpointer user_dat gint channel, gfloat value); -static DodgeBurnOptions * gimp_dodgeburn_tool_options_new (void); -static void gimp_dodgeburn_tool_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * gimp_dodgeburn_tool_options_new (GimpToolInfo *tool_info); +static void gimp_dodgeburn_tool_options_reset (GimpToolOptions *tool_options); static gdouble non_gui_exposure; static GimpLut *non_gui_lut; -static DodgeBurnOptions * dodgeburn_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_dodgeburn_tool_register (Gimp *gimp) +gimp_dodgeburn_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_DODGEBURN_TOOL, - TRUE, - "gimp:dodgeburn_tool", - _("Dodge/Burn"), - _("Dodge or Burn strokes"), - N_("/Tools/Paint Tools/DodgeBurn"), "D", - NULL, "tools/dodgeburn.html", - GIMP_STOCK_TOOL_DODGE); + (* callback) (gimp, + GIMP_TYPE_DODGEBURN_TOOL, + gimp_dodgeburn_tool_options_new, + TRUE, + "gimp:dodgeburn_tool", + _("Dodge/Burn"), + _("Dodge or Burn strokes"), + N_("/Tools/Paint Tools/DodgeBurn"), "D", + NULL, "tools/dodgeburn.html", + GIMP_STOCK_TOOL_DODGE); } GType @@ -200,14 +199,6 @@ gimp_dodgeburn_tool_init (GimpDodgeBurnTool *dodgeburn) tool = GIMP_TOOL (dodgeburn); paint_tool = GIMP_PAINT_TOOL (dodgeburn); - - if (! dodgeburn_options) - { - dodgeburn_options = gimp_dodgeburn_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_DODGEBURN_TOOL, - (GimpToolOptions *) dodgeburn_options); - } tool->tool_cursor = GIMP_DODGE_TOOL_CURSOR; tool->toggle_cursor = GIMP_BURN_TOOL_CURSOR; @@ -261,25 +252,29 @@ gimp_dodgeburn_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + DodgeBurnOptions *options; + + options = (DodgeBurnOptions *) tool->tool_info->tool_options; + if (key == GDK_CONTROL_MASK && ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */ { - switch (dodgeburn_options->type) + switch (options->type) { case DODGE: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[BURN]), TRUE); break; case BURN: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[DODGE]), TRUE); break; default: break; } } - tool->toggled = (dodgeburn_options->type == BURN); + tool->toggled = (options->type == BURN); } static void @@ -288,7 +283,11 @@ gimp_dodgeburn_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - tool->toggled = (dodgeburn_options->type == BURN); + DodgeBurnOptions *options; + + options = (DodgeBurnOptions *) tool->tool_info->tool_options; + + tool->toggled = (options->type == BURN); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp); } @@ -298,15 +297,18 @@ gimp_dodgeburn_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + DodgeBurnOptions *options; PaintPressureOptions *pressure_options; gdouble exposure; GimpLut *lut; - if (dodgeburn_options) + options = (DodgeBurnOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (options) { - pressure_options = dodgeburn_options->paint_options.pressure_options; - exposure = dodgeburn_options->exposure; - lut = dodgeburn_options->lut; + pressure_options = options->paint_options.pressure_options; + exposure = options->exposure; + lut = options->lut; } else { @@ -318,17 +320,18 @@ gimp_dodgeburn_tool_paint (GimpPaintTool *paint_tool, switch (state) { case INIT_PAINT: - if (dodgeburn_options) + if (options) { - dodgeburn_options->lut = gimp_lut_new (); + options->lut = gimp_lut_new (); + gimp_dodgeburn_tool_make_luts (paint_tool, - dodgeburn_options->exposure, - dodgeburn_options->type, - dodgeburn_options->mode, - dodgeburn_options->lut, + options->exposure, + options->type, + options->mode, + options->lut, drawable); - lut = dodgeburn_options->lut; + lut = options->lut; } break; @@ -341,10 +344,10 @@ gimp_dodgeburn_tool_paint (GimpPaintTool *paint_tool, break; case FINISH_PAINT: - if (dodgeburn_options && dodgeburn_options->lut) + if (options && options->lut) { - gimp_lut_free (dodgeburn_options->lut); - dodgeburn_options->lut = NULL; + gimp_lut_free (options->lut); + options->lut = NULL; } break; @@ -533,16 +536,22 @@ gimp_dodgeburn_tool_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { + GimpToolInfo *tool_info; + DodgeBurnOptions *options; gdouble exposure = DODGEBURN_DEFAULT_EXPOSURE; DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; GimpTransferMode mode = DODGEBURN_DEFAULT_MODE; - DodgeBurnOptions *options = dodgeburn_options; + + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_DODGEBURN_TOOL); + + options = (DodgeBurnOptions *) tool_info->tool_options; if (options) { - exposure = dodgeburn_options->exposure; - type = dodgeburn_options->type; - mode = dodgeburn_options->mode; + exposure = options->exposure; + type = options->type; + mode = options->mode; } return gimp_dodgeburn_tool_non_gui (drawable, exposure, type, mode, @@ -612,8 +621,8 @@ gimp_dodgeburn_tool_non_gui (GimpDrawable *drawable, /* tool options stuff */ -static DodgeBurnOptions * -gimp_dodgeburn_tool_options_new (void) +static GimpToolOptions * +gimp_dodgeburn_tool_options_new (GimpToolInfo *tool_info) { DodgeBurnOptions *options; @@ -625,9 +634,9 @@ gimp_dodgeburn_tool_options_new (void) options = g_new0 (DodgeBurnOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_DODGEBURN_TOOL, - gimp_dodgeburn_tool_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = gimp_dodgeburn_tool_options_reset; options->type = options->type_d = DODGEBURN_DEFAULT_TYPE; options->exposure = options->exposure_d = DODGEBURN_DEFAULT_EXPOSURE; @@ -695,7 +704,7 @@ gimp_dodgeburn_tool_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimpdodgeburn.h b/app/paint/gimpdodgeburn.h index 496ba09893..c9f7f1ea12 100644 --- a/app/paint/gimpdodgeburn.h +++ b/app/paint/gimpdodgeburn.h @@ -51,9 +51,11 @@ struct _GimpDodgeBurnToolClass }; -void gimp_dodgeburn_tool_register (Gimp *gimp); +void gimp_dodgeburn_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_dodgeburn_tool_get_type (void); -GType gimp_dodgeburn_tool_get_type (void); gboolean gimp_dodgeburn_tool_non_gui (GimpDrawable *drawable, gdouble exposure, diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index 0b0f328fa3..3a94de36f1 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -21,6 +21,7 @@ #include #include +#include "libgimpcolor/gimpcolor.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -34,6 +35,7 @@ #include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimperasertool.h" #include "paint_options.h" @@ -41,9 +43,6 @@ #include "libgimp/gimpintl.h" -#include "libgimpcolor/gimpcolor.h" -#include "libgimpcolor/gimprgb.h" - #define ERASER_DEFAULT_HARD FALSE #define ERASER_DEFAULT_INCREMENTAL FALSE @@ -92,8 +91,8 @@ static void gimp_eraser_tool_motion (GimpPaintTool *paint_tool, gboolean anti_erase, gboolean color_erase); -static EraserOptions * gimp_eraser_tool_options_new (void); -static void gimp_eraser_tool_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * gimp_eraser_tool_options_new (GimpToolInfo *tool_info); +static void gimp_eraser_tool_options_reset (GimpToolOptions *tool_options); static void gimp_eraser_tool_colortoalpha (GimpRGB *src, const GimpRGB *color); @@ -104,25 +103,25 @@ static gboolean non_gui_incremental = ERASER_DEFAULT_INCREMENTAL; static gboolean non_gui_anti_erase = ERASER_DEFAULT_ANTI_ERASE; static gboolean non_gui_color_erase = ERASER_DEFAULT_COLOR_ERASE; -static EraserOptions *eraser_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_eraser_tool_register (Gimp *gimp) +gimp_eraser_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_ERASER_TOOL, - TRUE, - "gimp:eraser_tool", - _("Eraser"), - _("Paint fuzzy brush strokes"), - N_("/Tools/Paint Tools/Eraser"), "E", - NULL, "tools/eraser.html", - GIMP_STOCK_TOOL_ERASER); + (* callback) (gimp, + GIMP_TYPE_ERASER_TOOL, + gimp_eraser_tool_options_new, + TRUE, + "gimp:eraser_tool", + _("Eraser"), + _("Paint fuzzy brush strokes"), + N_("/Tools/Paint Tools/Eraser"), "E", + NULL, "tools/eraser.html", + GIMP_STOCK_TOOL_ERASER); } GType @@ -178,14 +177,6 @@ gimp_eraser_tool_init (GimpEraserTool *eraser) tool = GIMP_TOOL (eraser); paint_tool = GIMP_PAINT_TOOL (eraser); - if (! eraser_options) - { - eraser_options = gimp_eraser_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_ERASER_TOOL, - (GimpToolOptions *) eraser_options); - } - tool->tool_cursor = GIMP_ERASER_TOOL_CURSOR; paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; @@ -198,15 +189,18 @@ gimp_eraser_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + EraserOptions *options; + + options = (EraserOptions *) tool->tool_info->tool_options; + if ((key == GDK_CONTROL_MASK) && ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */ { gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (eraser_options->anti_erase_w), - ! eraser_options->anti_erase); + (GTK_TOGGLE_BUTTON (options->anti_erase_w), ! options->anti_erase); } - tool->toggled = eraser_options->anti_erase; + tool->toggled = options->anti_erase; } static void @@ -214,19 +208,22 @@ gimp_eraser_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + EraserOptions *options; PaintPressureOptions *pressure_options; gboolean hard; gboolean incremental; gboolean anti_erase; gboolean color_erase; - if (eraser_options) + options = (EraserOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (options) { - pressure_options = eraser_options->paint_options.pressure_options; - hard = eraser_options->hard; - incremental = eraser_options->paint_options.incremental; - anti_erase = eraser_options->anti_erase; - color_erase = eraser_options->color_erase; + pressure_options = options->paint_options.pressure_options; + hard = options->hard; + incremental = options->paint_options.incremental; + anti_erase = options->anti_erase; + color_erase = options->color_erase; } else { @@ -421,12 +418,17 @@ eraser_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { - gboolean hard = ERASER_DEFAULT_HARD; - gboolean incremental = ERASER_DEFAULT_INCREMENTAL; - gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE; - gboolean color_erase = ERASER_DEFAULT_COLOR_ERASE; + GimpToolInfo *tool_info; + EraserOptions *options; + gboolean hard = ERASER_DEFAULT_HARD; + gboolean incremental = ERASER_DEFAULT_INCREMENTAL; + gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE; + gboolean color_erase = ERASER_DEFAULT_COLOR_ERASE; - EraserOptions *options = eraser_options; + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_ERASER_TOOL); + + options = (EraserOptions *) tool_info->tool_options; if (options) { @@ -497,16 +499,17 @@ eraser_non_gui (GimpDrawable *drawable, /* tool options stuff */ -static EraserOptions * -gimp_eraser_tool_options_new (void) +static GimpToolOptions * +gimp_eraser_tool_options_new (GimpToolInfo *tool_info) { EraserOptions *options; GtkWidget *vbox; options = g_new0 (EraserOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_ERASER_TOOL, - gimp_eraser_tool_options_reset); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = gimp_eraser_tool_options_reset; options->hard = options->hard_d = ERASER_DEFAULT_HARD; options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE; @@ -545,7 +548,7 @@ gimp_eraser_tool_options_new (void) options->color_erase_d); gtk_widget_show (options->color_erase_w); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimperaser.h b/app/paint/gimperaser.h index 84ac304a05..70aea12164 100644 --- a/app/paint/gimperaser.h +++ b/app/paint/gimperaser.h @@ -45,7 +45,8 @@ struct _GimpEraserToolClass }; -void gimp_eraser_tool_register (Gimp *gimp); +void gimp_eraser_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_eraser_tool_get_type (void); diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index ede373ef2a..674af07d38 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -48,10 +48,10 @@ #include "gimpinktool.h" #include "gimpinktool-blob.h" -#include "gimptool.h" #include "paint_options.h" #include "tool_manager.h" +#include "app_procs.h" #include "gimprc.h" #include "undo.h" @@ -60,8 +60,6 @@ #define SUBSAMPLE 8 -/* the Ink structures */ - typedef Blob * (* BlobFunc) (gdouble, gdouble, gdouble, @@ -71,14 +69,16 @@ typedef Blob * (* BlobFunc) (gdouble, typedef struct _BrushWidget BrushWidget; +typedef struct _InkOptions InkOptions; struct _BrushWidget { - GtkWidget *widget; - gboolean state; -}; + GtkWidget *widget; + gboolean state; -typedef struct _InkOptions InkOptions; + /* EEK */ + InkOptions *ink_options; +}; struct _InkOptions { @@ -146,7 +146,8 @@ static void gimp_ink_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp); -static Blob * ink_pen_ellipse (gdouble x_center, +static Blob * ink_pen_ellipse (InkOptions *options, + gdouble x_center, gdouble y_center, gdouble pressure, gdouble xtilt, @@ -221,17 +222,14 @@ static void brush_widget_motion_notify (GtkWidget *widget, GdkEventMotion *event, BrushWidget *brush_widget); -static InkOptions * ink_options_new (void); -static void ink_options_reset (GimpToolOptions *tool_options); -static void ink_type_update (GtkWidget *radio_button, - BlobFunc function); +static GimpToolOptions * ink_options_new (GimpToolInfo *tool_info); +static void ink_options_reset (GimpToolOptions *tool_options); +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); /* local variables */ -/* the ink tool options */ -static InkOptions *ink_options = NULL; - /* undo blocks variables */ static TileManager *undo_tiles = NULL; @@ -243,23 +241,25 @@ static TileManager *canvas_tiles = NULL; */ static TempBuf *canvas_buf = NULL; -static GimpToolClass *parent_class = NULL; +static GimpToolClass *parent_class = NULL; /* public functions */ void -gimp_ink_tool_register (Gimp *gimp) +gimp_ink_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_INK_TOOL, - TRUE, - "gimp:ink_tool", - _("Ink Tool"), - _("Draw in ink"), - N_("/Tools/Paint Tools/Ink"), "K", - NULL, "tools/ink.html", - GIMP_STOCK_TOOL_INK); + (* callback) (gimp, + GIMP_TYPE_INK_TOOL, + ink_options_new, + TRUE, + "gimp:ink_tool", + _("Ink Tool"), + _("Draw in ink"), + N_("/Tools/Paint Tools/Ink"), "K", + NULL, "tools/ink.html", + GIMP_STOCK_TOOL_INK); } GType @@ -319,17 +319,6 @@ gimp_ink_tool_init (GimpInkTool *ink_tool) GimpTool *tool; tool = GIMP_TOOL (ink_tool); - - /* The tool options */ - if (! ink_options) - { - ink_options = ink_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_INK_TOOL, - (GimpToolOptions *) ink_options); - - ink_options_reset ((GimpToolOptions *) ink_options); - } tool->tool_cursor = GIMP_INK_TOOL_CURSOR; } @@ -386,12 +375,15 @@ gimp_ink_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpInkTool *ink_tool; + InkOptions *options; GimpDisplayShell *shell; GimpDrawable *drawable; Blob *b; ink_tool = GIMP_INK_TOOL (tool); + options = (InkOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); drawable = gimp_image_active_drawable (gdisp->gimage); @@ -422,7 +414,8 @@ gimp_ink_tool_button_press (GimpTool *tool, NULL, NULL, time); } - b = ink_pen_ellipse (coords->x, + b = ink_pen_ellipse (options, + coords->x, coords->y, coords->pressure, coords->xtilt, @@ -481,15 +474,18 @@ gimp_ink_tool_motion (GimpTool *tool, GimpDisplay *gdisp) { GimpInkTool *ink_tool; + InkOptions *options; GimpDrawable *drawable; Blob *b, *blob_union; gdouble velocity; gdouble dist; gdouble lasttime, thistime; - + ink_tool = GIMP_INK_TOOL (tool); + options = (InkOptions *) tool->tool_info->tool_options; + drawable = gimp_image_active_drawable (gdisp->gimage); lasttime = ink_tool->last_time; @@ -532,7 +528,8 @@ gimp_ink_tool_motion (GimpTool *tool, velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime)); - b = ink_pen_ellipse (coords->x, + b = ink_pen_ellipse (options, + coords->x, coords->y, coords->pressure, coords->xtilt, @@ -596,15 +593,15 @@ brush_widget_active_rect (BrushWidget *brush_widget, GtkWidget *widget, GdkRectangle *rect) { - int x,y; - int r; + gint x,y; + gint r; r = MIN (widget->allocation.width, widget->allocation.height) / 2; - x = widget->allocation.width / 2 + 0.85 * r * ink_options->aspect / 10.0 * - cos (ink_options->angle); - y = widget->allocation.height / 2 + 0.85 * r * ink_options->aspect / 10.0 * - sin (ink_options->angle); + x = widget->allocation.width / 2 + 0.85 * r * brush_widget->ink_options->aspect / 10.0 * + cos (brush_widget->ink_options->angle); + y = widget->allocation.height / 2 + 0.85 * r * brush_widget->ink_options->aspect / 10.0 * + sin (brush_widget->ink_options->angle); rect->x = x - 5; rect->y = y - 5; @@ -627,13 +624,13 @@ brush_widget_draw_brush (BrushWidget *brush_widget, { Blob *blob; - blob = ink_options->function (xc, yc, - radius * cos (ink_options->angle), - radius * sin (ink_options->angle), - (- (radius / ink_options->aspect) * - sin (ink_options->angle)), - ((radius / ink_options->aspect) * - cos (ink_options->angle))); + blob = brush_widget->ink_options->function (xc, yc, + radius * cos (brush_widget->ink_options->angle), + radius * sin (brush_widget->ink_options->angle), + (- (radius / brush_widget->ink_options->aspect) * + sin (brush_widget->ink_options->angle)), + ((radius / brush_widget->ink_options->aspect) * + cos (brush_widget->ink_options->angle))); paint_blob (widget->window, widget->style->fg_gc[widget->state], blob); g_free (blob); @@ -716,16 +713,16 @@ brush_widget_motion_notify (GtkWidget *widget, if (rsquare != 0) { - ink_options->angle = atan2 (y, x); + brush_widget->ink_options->angle = atan2 (y, x); r0 = MIN (widget->allocation.width, widget->allocation.height) / 2; - ink_options->aspect = - 10.0 * sqrt ((double) rsquare / (r0 * r0)) / 0.85; + brush_widget->ink_options->aspect = + 10.0 * sqrt ((gdouble) rsquare / (r0 * r0)) / 0.85; - if (ink_options->aspect < 1.0) - ink_options->aspect = 1.0; - if (ink_options->aspect > 10.0) - ink_options->aspect = 10.0; + if (brush_widget->ink_options->aspect < 1.0) + brush_widget->ink_options->aspect = 1.0; + if (brush_widget->ink_options->aspect > 10.0) + brush_widget->ink_options->aspect = 10.0; gtk_widget_draw (widget, NULL); } @@ -798,25 +795,26 @@ paint_blob (GdkDrawable *drawable, static Blob * -ink_pen_ellipse (gdouble x_center, - gdouble y_center, - gdouble pressure, - gdouble xtilt, - gdouble ytilt, - gdouble velocity) +ink_pen_ellipse (InkOptions *options, + gdouble x_center, + gdouble y_center, + gdouble pressure, + gdouble xtilt, + gdouble ytilt, + gdouble velocity) { - double size; - double tsin, tcos; - double aspect, radmin; - double x,y; - double tscale; - double tscale_c; - double tscale_s; - + gdouble size; + gdouble tsin, tcos; + gdouble aspect, radmin; + gdouble x,y; + gdouble tscale; + gdouble tscale_c; + gdouble tscale_s; + /* Adjust the size depending on pressure. */ - size = ink_options->size * (1.0 + ink_options->sensitivity * - (2.0 * pressure - 1.0) ); + size = options->size * (1.0 + options->sensitivity * + (2.0 * pressure - 1.0) ); /* Adjust the size further depending on pointer velocity and velocity-sensitivity. These 'magic constants' are @@ -829,9 +827,9 @@ ink_pen_ellipse (gdouble x_center, g_print("%f (%f) -> ", (float)size, (float)velocity); #endif - size = ink_options->vel_sensitivity * - ((4.5 * size) / (1.0 + ink_options->vel_sensitivity * (2.0*(velocity)))) - + (1.0 - ink_options->vel_sensitivity) * size; + size = options->vel_sensitivity * + ((4.5 * size) / (1.0 + options->vel_sensitivity * (2.0*(velocity)))) + + (1.0 - options->vel_sensitivity) * size; #ifdef VERBOSE g_print("%f\n", (float)size); @@ -839,8 +837,8 @@ ink_pen_ellipse (gdouble x_center, /* Clamp resulting size to sane limits */ - if (size > ink_options->size * (1.0 + ink_options->sensitivity)) - size = ink_options->size * (1.0 + ink_options->sensitivity); + if (size > options->size * (1.0 + options->sensitivity)) + size = options->size * (1.0 + options->sensitivity); if (size*SUBSAMPLE < 1.0) size = 1.0/SUBSAMPLE; @@ -850,16 +848,18 @@ ink_pen_ellipse (gdouble x_center, tilt info from the brush. My personal feeling is that representing both as affine transforms would make the most sense. -RLL */ - tscale = ink_options->tilt_sensitivity * 10.0; - tscale_c = tscale * cos (gimp_deg_to_rad (ink_options->tilt_angle)); - tscale_s = tscale * sin (gimp_deg_to_rad (ink_options->tilt_angle)); - x = ink_options->aspect*cos(ink_options->angle) + - xtilt * tscale_c - ytilt * tscale_s; - y = ink_options->aspect*sin(ink_options->angle) + - ytilt * tscale_c + xtilt * tscale_s; + tscale = options->tilt_sensitivity * 10.0; + tscale_c = tscale * cos (gimp_deg_to_rad (options->tilt_angle)); + tscale_s = tscale * sin (gimp_deg_to_rad (options->tilt_angle)); + + x = (options->aspect * cos (options->angle) + + xtilt * tscale_c - ytilt * tscale_s); + y = (options->aspect * sin (options->angle) + + ytilt * tscale_c + xtilt * tscale_s); + #ifdef VERBOSE g_print ("angle %g aspect %g; %g %g; %g %g\n", - ink_options->angle, ink_options->aspect, tscale_c, tscale_s, x, y); + options->angle, options->aspect, tscale_c, tscale_s, x, y); #endif aspect = sqrt(x*x+y*y); @@ -870,8 +870,8 @@ ink_pen_ellipse (gdouble x_center, } else { - tsin = sin(ink_options->angle); - tcos = cos(ink_options->angle); + tsin = sin (options->angle); + tcos = cos (options->angle); } if (aspect < 1.0) @@ -882,9 +882,12 @@ ink_pen_ellipse (gdouble x_center, radmin = SUBSAMPLE * size/aspect; if (radmin < 1.0) radmin = 1.0; - return ink_options->function (x_center * SUBSAMPLE, y_center * SUBSAMPLE, - radmin*aspect*tcos, radmin*aspect*tsin, - -radmin*tsin, radmin*tcos); + return options->function (x_center * SUBSAMPLE, + y_center * SUBSAMPLE, + radmin * aspect * tcos, + radmin * aspect * tsin, + -radmin * tsin, + radmin * tcos); } static void @@ -1422,8 +1425,8 @@ ink_set_canvas_tiles (gint x, /* tool options stuff */ -static InkOptions * -ink_options_new (void) +static GimpToolOptions * +ink_options_new (GimpToolInfo *tool_info) { InkOptions *options; GtkWidget *table; @@ -1438,9 +1441,10 @@ ink_options_new (void) GdkPixmap *pixmap; options = g_new0 (InkOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_INK_TOOL, - ink_options_reset); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = ink_options_reset; options->size = options->size_d = 4.4; options->sensitivity = options->sensitivity_d = 1.0; @@ -1643,7 +1647,8 @@ ink_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); options->brush_w = g_new (BrushWidget, 1); - options->brush_w->state = FALSE; + options->brush_w->state = FALSE; + options->brush_w->ink_options = options; darea = gtk_drawing_area_new(); options->brush_w->widget = darea; @@ -1673,7 +1678,9 @@ ink_options_new (void) gtk_widget_show_all (hbox); - return options; + ink_options_reset ((GimpToolOptions *) options); + + return (GimpToolOptions *) options; } static void @@ -1710,7 +1717,12 @@ static void ink_type_update (GtkWidget *radio_button, BlobFunc function) { - InkOptions *options = ink_options; + GimpToolInfo *tool_info; + InkOptions *options; + + tool_info = tool_manager_get_info_by_type (the_gimp, GIMP_TYPE_INK_TOOL); + + options = (InkOptions *) tool_info->tool_options; if (GTK_TOGGLE_BUTTON (radio_button)->active) options->function = function; diff --git a/app/paint/gimpink.h b/app/paint/gimpink.h index ae13cc54b0..9c94235006 100644 --- a/app/paint/gimpink.h +++ b/app/paint/gimpink.h @@ -68,7 +68,8 @@ struct _GimpInkToolClass }; -void gimp_ink_tool_register (Gimp *gimp); +void gimp_ink_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_ink_tool_get_type (void); diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c index 1973beb479..c203e292ac 100644 --- a/app/paint/gimppaintbrush.c +++ b/app/paint/gimppaintbrush.c @@ -37,10 +37,10 @@ #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimppaintbrushtool.h" #include "paint_options.h" -#include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -69,25 +69,25 @@ static void gimp_paintbrush_tool_motion (GimpPaintTool *paint_tool, /* local variables */ static gboolean non_gui_incremental = PAINTBRUSH_DEFAULT_INCREMENTAL; -static PaintOptions *paintbrush_options = NULL; - static GimpPaintToolClass *parent_class = NULL; -/* functions */ +/* public functions */ void -gimp_paintbrush_tool_register (Gimp *gimp) +gimp_paintbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_PAINTBRUSH_TOOL, - TRUE, - "gimp:paintbrush_tool", - _("Paintbrush"), - _("Paint fuzzy brush strokes"), - N_("/Tools/Paint Tools/Paintbrush"), "P", - NULL, "tools/paintbrush.html", - GIMP_STOCK_TOOL_PAINTBRUSH); + (* callback) (gimp, + GIMP_TYPE_PAINTBRUSH_TOOL, + paint_options_new, + TRUE, + "gimp:paintbrush_tool", + _("Paintbrush"), + _("Paint fuzzy brush strokes"), + N_("/Tools/Paint Tools/Paintbrush"), "P", + NULL, "tools/paintbrush.html", + GIMP_STOCK_TOOL_PAINTBRUSH); } GType @@ -118,6 +118,9 @@ gimp_paintbrush_tool_get_type (void) return tool_type; } + +/* private functions */ + static void gimp_paintbrush_tool_class_init (GimpPaintbrushToolClass *klass) { @@ -139,15 +142,6 @@ gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush) tool = GIMP_TOOL (paintbrush); paint_tool = GIMP_PAINT_TOOL (paintbrush); - if (! paintbrush_options) - { - paintbrush_options = paint_options_new (GIMP_TYPE_PAINTBRUSH_TOOL, - paint_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_PAINTBRUSH_TOOL, - (GimpToolOptions *) paintbrush_options); - } - tool->tool_cursor = GIMP_PAINTBRUSH_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -159,6 +153,7 @@ gimp_paintbrush_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + PaintOptions *paint_options; PaintPressureOptions *pressure_options; PaintGradientOptions *gradient_options; gboolean incremental; @@ -174,11 +169,13 @@ gimp_paintbrush_tool_paint (GimpPaintTool *paint_tool, if (! gimage) return; - if (paintbrush_options) + paint_options = (PaintOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (paint_options) { - pressure_options = paintbrush_options->pressure_options; - gradient_options = paintbrush_options->gradient_options; - incremental = paintbrush_options->incremental; + pressure_options = paint_options->pressure_options; + gradient_options = paint_options->gradient_options; + incremental = paint_options->incremental; } else { diff --git a/app/paint/gimppaintbrush.h b/app/paint/gimppaintbrush.h index 8b5e441bfd..c53eb3ec30 100644 --- a/app/paint/gimppaintbrush.h +++ b/app/paint/gimppaintbrush.h @@ -45,9 +45,11 @@ struct _GimpPaintbrushToolClass }; -void gimp_paintbrush_tool_register (Gimp *gimp); +void gimp_paintbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_paintbrush_tool_get_type (void); -GType gimp_paintbrush_tool_get_type (void); gboolean gimp_paintbrush_tool_non_gui (GimpDrawable *drawable, gint num_srokes, diff --git a/app/paint/gimppencil.c b/app/paint/gimppencil.c index aabc5fe1b3..af8c70b7dd 100644 --- a/app/paint/gimppencil.c +++ b/app/paint/gimppencil.c @@ -35,12 +35,10 @@ #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimppenciltool.h" -#include "gimppainttool.h" #include "paint_options.h" -#include "tool_options.h" -#include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -63,25 +61,25 @@ static void gimp_pencil_tool_motion (GimpPaintTool *paint_tool, /* private variables */ static gboolean non_gui_incremental = PENCIL_INCREMENTAL_DEFAULT; -static PaintOptions *pencil_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_pencil_tool_register (Gimp *gimp) +gimp_pencil_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_PENCIL_TOOL, - TRUE, - "gimp:pencil_tool", - _("Pencil"), - _("Paint hard edged pixels"), - N_("/Tools/Paint Tools/Pencil"), "P", - NULL, "tools/pencil.html", - GIMP_STOCK_TOOL_PENCIL); + (* callback) (gimp, + GIMP_TYPE_PENCIL_TOOL, + paint_options_new, + TRUE, + "gimp:pencil_tool", + _("Pencil"), + _("Paint hard edged pixels"), + N_("/Tools/Paint Tools/Pencil"), "P", + NULL, "tools/pencil.html", + GIMP_STOCK_TOOL_PENCIL); } GType @@ -133,19 +131,10 @@ gimp_pencil_tool_init (GimpPencilTool *pencil) tool = GIMP_TOOL (pencil); paint_tool = GIMP_PAINT_TOOL (pencil); - if (! pencil_options) - { - pencil_options = paint_options_new (GIMP_TYPE_PENCIL_TOOL, - paint_options_reset); + tool->tool_cursor = GIMP_PENCIL_TOOL_CURSOR; - tool_manager_register_tool_options (GIMP_TYPE_PENCIL_TOOL, - (GimpToolOptions *) pencil_options); - } - - tool->tool_cursor = GIMP_PENCIL_TOOL_CURSOR; - - paint_tool->pick_colors = TRUE; - paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; + paint_tool->pick_colors = TRUE; + paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; } static void @@ -153,13 +142,16 @@ gimp_pencil_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + PaintOptions *paint_options; PaintPressureOptions *pressure_options; gboolean incremental; - if (pencil_options) + paint_options = (PaintOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (paint_options) { - pressure_options = pencil_options->pressure_options; - incremental = pencil_options->incremental; + pressure_options = paint_options->pressure_options; + incremental = paint_options->incremental; } else { diff --git a/app/paint/gimppencil.h b/app/paint/gimppencil.h index f4fd946169..b3f00f5da9 100644 --- a/app/paint/gimppencil.h +++ b/app/paint/gimppencil.h @@ -48,14 +48,15 @@ struct _GimpPencilToolClass }; -void gimp_pencil_tool_register (Gimp *gimp); +void gimp_pencil_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_pencil_tool_get_type (void); -GType gimp_pencil_tool_get_type (void); /* FIXME: Get rid of this non_gui stuff someday. Preferably make * everything use it interally for ease of macro recording. */ - gboolean pencil_non_gui (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array); diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index 89a28c90f7..d0ecb9def4 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -41,7 +41,6 @@ #include "gimpsmudgetool.h" #include "paint_options.h" #include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -74,7 +73,7 @@ static void gimp_smudge_tool_paint (GimpPaintTool *paint_tool, static void gimp_smudge_tool_motion (GimpPaintTool *paint_tool, PaintPressureOptions *pressure_options, gdouble smudge_rate, - GimpDrawable *drawable); + GimpDrawable *drawable); static gboolean gimp_smudge_tool_start (GimpPaintTool *paint_tool, GimpDrawable *drawable); static void gimp_smudge_tool_finish (GimpPaintTool *paint_tool, @@ -90,36 +89,35 @@ static void gimp_smudge_tool_allocate_accum_buffer (gint w, gint bytes, guchar *do_fill); -static SmudgeOptions * smudge_options_new (void); -static void smudge_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * smudge_options_new (GimpToolInfo *tool_info); +static void smudge_options_reset (GimpToolOptions *tool_options); /* local variables */ static PixelRegion accumPR; static guchar *accum_data = NULL; -static GimpPaintToolClass *parent_class = NULL; - -/* the smudge tool options */ -static SmudgeOptions * smudge_options = NULL; - static gdouble non_gui_rate; +static GimpPaintToolClass *parent_class = NULL; + /* global functions */ void -gimp_smudge_tool_register (Gimp *gimp) +gimp_smudge_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_SMUDGE_TOOL, - TRUE, - "gimp:smudge_tool", - _("Smudge"), - _("Smudge image"), - N_("/Tools/Paint Tools/Smudge"), "S", - NULL, "tools/smudge.html", - GIMP_STOCK_TOOL_SMUDGE); + (* callback) (gimp, + GIMP_TYPE_SMUDGE_TOOL, + smudge_options_new, + TRUE, + "gimp:smudge_tool", + _("Smudge"), + _("Smudge image"), + N_("/Tools/Paint Tools/Smudge"), "S", + NULL, "tools/smudge.html", + GIMP_STOCK_TOOL_SMUDGE); } GType @@ -171,14 +169,6 @@ gimp_smudge_tool_init (GimpSmudgeTool *smudge) tool = GIMP_TOOL (smudge); paint_tool = GIMP_PAINT_TOOL (smudge); - if (! smudge_options) - { - smudge_options = smudge_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_SMUDGE_TOOL, - (GimpToolOptions *) smudge_options); - } - tool->tool_cursor = GIMP_SMUDGE_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -459,8 +449,14 @@ gimp_smudge_tool_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { - gdouble rate = SMUDGE_DEFAULT_RATE; - SmudgeOptions *options = smudge_options; + GimpToolInfo *tool_info; + SmudgeOptions *options; + gdouble rate = SMUDGE_DEFAULT_RATE; + + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_SMUDGE_TOOL); + + options = (SmudgeOptions *) tool_info->tool_options; if (options) rate = options->rate; @@ -521,8 +517,8 @@ gimp_smudge_tool_non_gui (GimpDrawable *drawable, return FALSE; } -static SmudgeOptions * -smudge_options_new (void) +static GimpToolOptions * +smudge_options_new (GimpToolInfo *tool_info) { SmudgeOptions *options; GtkWidget *vbox; @@ -532,9 +528,9 @@ smudge_options_new (void) options = g_new0 (SmudgeOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_SMUDGE_TOOL, - smudge_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = smudge_options_reset; options->rate = options->rate_d = SMUDGE_DEFAULT_RATE; @@ -562,7 +558,7 @@ smudge_options_new (void) gtk_widget_show (scale); gtk_widget_show (hbox); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimpsmudge.h b/app/paint/gimpsmudge.h index 4b8ba1397e..ec222b7d74 100644 --- a/app/paint/gimpsmudge.h +++ b/app/paint/gimpsmudge.h @@ -52,9 +52,10 @@ struct _GimpSmudgeToolClass }; -void gimp_smudge_tool_register (Gimp *gimp); +void gimp_smudge_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); -GType gimp_smudge_tool_get_type (void); +GType gimp_smudge_tool_get_type (void); /* FIXME: this antique code doesn't follow the coding style */ diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index 1d77cb2e1c..23867f75a2 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -46,8 +46,6 @@ #include "gimpclonetool.h" #include "paint_options.h" -#include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -125,16 +123,10 @@ static void gimp_clone_tool_line_pattern (GimpImage *dest, gint bytes, gint width); -static CloneOptions * clone_options_new (void); -static void clone_options_reset (GimpToolOptions *options); +static GimpToolOptions * clone_options_new (GimpToolInfo *tool_info); +static void clone_options_reset (GimpToolOptions *options); -/* The parent class */ -static GimpPaintToolClass *parent_class; - -/* the clone tool options */ -static CloneOptions *clone_options = NULL; - /* local variables */ static gint src_x = 0; /* */ static gint src_y = 0; /* position of clone src */ @@ -153,21 +145,25 @@ static gint non_gui_offset_x; static gint non_gui_offset_y; static CloneType non_gui_type; +static GimpPaintToolClass *parent_class; -/* global functions */ + +/* public functions */ void -gimp_clone_tool_register (Gimp *gimp) +gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CLONE_TOOL, - TRUE, - "gimp:clone_tool", - _("Clone"), - _("Paint using Patterns or Image Regions"), - N_("/Tools/Paint Tools/Clone"), "C", - NULL, "tools/clone.html", - GIMP_STOCK_TOOL_CLONE); + (* callback) (gimp, + GIMP_TYPE_CLONE_TOOL, + clone_options_new, + TRUE, + "gimp:clone_tool", + _("Clone"), + _("Paint using Patterns or Image Regions"), + N_("/Tools/Paint Tools/Clone"), "C", + NULL, "tools/clone.html", + GIMP_STOCK_TOOL_CLONE); } GType @@ -229,14 +225,6 @@ gimp_clone_tool_init (GimpCloneTool *clone) tool = GIMP_TOOL (clone); paint_tool = GIMP_PAINT_TOOL (clone); - if (! clone_options) - { - clone_options = clone_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CLONE_TOOL, - (GimpToolOptions *) clone_options); - } - tool->tool_cursor = GIMP_CLONE_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -818,18 +806,19 @@ gimp_clone_tool_non_gui (GimpDrawable *drawable, #endif /* 0 - non-gui functions */ -static CloneOptions * -clone_options_new (void) +static GimpToolOptions * +clone_options_new (GimpToolInfo *tool_info) { CloneOptions *options; GtkWidget *vbox; GtkWidget *frame; - /* the new clone tool options structure */ - options = g_new (CloneOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_CLONE_TOOL, - clone_options_reset); + options = g_new0 (CloneOptions, 1); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = clone_options_reset; + options->type = options->type_d = CLONE_DEFAULT_TYPE; options->aligned = options->aligned_d = CLONE_DEFAULT_ALIGNED; @@ -866,7 +855,7 @@ clone_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/paint/gimpsourcecore.h b/app/paint/gimpsourcecore.h index 8916580e25..016415557c 100644 --- a/app/paint/gimpsourcecore.h +++ b/app/paint/gimpsourcecore.h @@ -52,7 +52,8 @@ struct _GimpCloneToolClass }; -void gimp_clone_tool_register (Gimp *gimp); +void gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_clone_tool_get_type (void); diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c index dd7f497a47..e942923fca 100644 --- a/app/tools/gimpairbrushtool.c +++ b/app/tools/gimpairbrushtool.c @@ -35,6 +35,7 @@ #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -101,7 +102,7 @@ static void gimp_airbrush_tool_motion (GimpPaintTool *paint_tool, gboolean incremental); static gint airbrush_time_out (gpointer data); -static AirbrushOptions * airbrush_options_new (void); +static GimpToolOptions * airbrush_options_new (GimpToolInfo *tool_info); static void airbrush_options_reset (GimpToolOptions *tool_options); @@ -114,25 +115,25 @@ static gdouble non_gui_rate; static gdouble non_gui_pressure; static gboolean non_gui_incremental; -static AirbrushOptions *airbrush_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_airbrush_tool_register (Gimp *gimp) +gimp_airbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_AIRBRUSH_TOOL, - TRUE, - "gimp:airbrush_tool", - _("Airbrush"), - _("Airbrush with variable pressure"), - N_("/Tools/Paint Tools/Airbrush"), "A", - NULL, "tools/airbrush.html", - GIMP_STOCK_TOOL_AIRBRUSH); + (* callback) (gimp, + GIMP_TYPE_AIRBRUSH_TOOL, + airbrush_options_new, + TRUE, + "gimp:airbrush_tool", + _("Airbrush"), + _("Airbrush with variable pressure"), + N_("/Tools/Paint Tools/Airbrush"), "A", + NULL, "tools/airbrush.html", + GIMP_STOCK_TOOL_AIRBRUSH); } GType @@ -188,18 +189,10 @@ gimp_airbrush_tool_init (GimpAirbrushTool *airbrush) tool = GIMP_TOOL (airbrush); paint_tool = GIMP_PAINT_TOOL (airbrush); - if (! airbrush_options) - { - airbrush_options = airbrush_options_new (); + tool->tool_cursor = GIMP_AIRBRUSH_TOOL_CURSOR; - tool_manager_register_tool_options (GIMP_TYPE_AIRBRUSH_TOOL, - (GimpToolOptions *) airbrush_options); - } - - tool->tool_cursor = GIMP_AIRBRUSH_TOOL_CURSOR; - - paint_tool->pick_colors = TRUE; - paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; + paint_tool->pick_colors = TRUE; + paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; } static void @@ -219,21 +212,24 @@ gimp_airbrush_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + AirbrushOptions *options; PaintPressureOptions *pressure_options; gdouble pressure; gdouble rate; gboolean incremental; GimpBrush *brush; - if (!drawable) + if (! drawable) return; - if (airbrush_options) + options = (AirbrushOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (options) { - pressure_options = airbrush_options->paint_options.pressure_options; - pressure = airbrush_options->pressure; - rate = airbrush_options->rate; - incremental = airbrush_options->paint_options.incremental; + pressure_options = options->paint_options.pressure_options; + pressure = options->pressure; + rate = options->rate; + incremental = options->paint_options.incremental; } else { @@ -281,7 +277,7 @@ gimp_airbrush_tool_paint (GimpPaintTool *paint_tool, (10000 / (rate * 2.0 * paint_tool->cur_coords.pressure)) : (10000 / rate)); - timer = gtk_timeout_add (timeout, airbrush_time_out, NULL); + timer = gtk_timeout_add (timeout, airbrush_time_out, paint_tool); timer_state = ON; } break; @@ -302,17 +298,23 @@ gimp_airbrush_tool_paint (GimpPaintTool *paint_tool, static gint airbrush_time_out (gpointer client_data) { + GimpTool *tool; + AirbrushOptions *options; PaintPressureOptions *pressure_options; gdouble pressure; gdouble rate; gboolean incremental; - if (airbrush_options) + tool = GIMP_TOOL (client_data); + + options = (AirbrushOptions *) tool->tool_info->tool_options; + + if (options) { - pressure_options = airbrush_options->paint_options.pressure_options; - pressure = airbrush_options->pressure; - rate = airbrush_options->rate; - incremental = airbrush_options->paint_options.incremental; + pressure_options = options->paint_options.pressure_options; + pressure = options->pressure; + rate = options->rate; + incremental = options->paint_options.incremental; } else { @@ -427,10 +429,16 @@ airbrush_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { - AirbrushOptions *options = airbrush_options; + GimpToolInfo *tool_info; + AirbrushOptions *options; gdouble pressure = AIRBRUSH_DEFAULT_PRESSURE; + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_AIRBRUSH_TOOL); + + options = (AirbrushOptions *) tool_info->tool_options; + if (options) pressure = options->pressure; @@ -487,8 +495,8 @@ airbrush_non_gui (GimpDrawable *drawable, return FALSE; } -static AirbrushOptions * -airbrush_options_new (void) +static GimpToolOptions * +airbrush_options_new (GimpToolInfo *tool_info) { AirbrushOptions *options; GtkWidget *vbox; @@ -496,9 +504,10 @@ airbrush_options_new (void) GtkWidget *scale; options = g_new0 (AirbrushOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_AIRBRUSH_TOOL, - airbrush_options_reset); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = airbrush_options_reset; options->rate = options->rate_d = 80.0; options->pressure = options->pressure_d = AIRBRUSH_DEFAULT_PRESSURE; @@ -539,7 +548,7 @@ airbrush_options_new (void) gtk_widget_show (table); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpairbrushtool.h b/app/tools/gimpairbrushtool.h index a41f65bc20..6ab8c93f65 100644 --- a/app/tools/gimpairbrushtool.h +++ b/app/tools/gimpairbrushtool.h @@ -45,7 +45,8 @@ struct _GimpAirbrushToolClass }; -void gimp_airbrush_tool_register (Gimp *gimp); +void gimp_airbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_airbrush_tool_get_type (void); diff --git a/app/tools/gimpbezierselecttool.c b/app/tools/gimpbezierselecttool.c index 695722a50a..7a569a3af2 100644 --- a/app/tools/gimpbezierselecttool.c +++ b/app/tools/gimpbezierselecttool.c @@ -268,25 +268,25 @@ static GimpDisplay *curGdisp = NULL; static GimpDrawTool *curCore = NULL; static gint ModeEdit = EXTEND_NEW; -static SelectionOptions *bezier_options = NULL; - static GimpSelectionToolClass *parent_class = NULL; /* Public functions */ void -gimp_bezier_select_tool_register (Gimp *gimp) +gimp_bezier_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_BEZIER_SELECT_TOOL, - FALSE, - "gimp:bezier_select_tool", - _("Bezier Select"), - _("Select regions using Bezier curves"), - _("/Tools/Selection Tools/Bezier Select"), "B", - NULL, "tools/bezier_select.html", - GIMP_STOCK_TOOL_BEZIER_SELECT); + (* callback) (gimp, + GIMP_TYPE_BEZIER_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:bezier_select_tool", + _("Bezier Select"), + _("Select regions using Bezier curves"), + _("/Tools/Selection Tools/Bezier Select"), "B", + NULL, "tools/bezier_select.html", + GIMP_STOCK_TOOL_BEZIER_SELECT); } GType @@ -353,15 +353,6 @@ gimp_bezier_select_tool_init (GimpBezierSelectTool *bezier_select) draw_tool = GIMP_DRAW_TOOL (bezier_select); select_tool = GIMP_SELECTION_TOOL (bezier_select); - if (! bezier_options) - { - bezier_options = selection_options_new (GIMP_TYPE_BEZIER_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_BEZIER_SELECT_TOOL, - (GimpToolOptions *) bezier_options); - } - bezier_select->num_points = 0; bezier_select->mask = NULL; diff --git a/app/tools/gimpbezierselecttool.h b/app/tools/gimpbezierselecttool.h index 64f214b0bb..495f06ba3d 100644 --- a/app/tools/gimpbezierselecttool.h +++ b/app/tools/gimpbezierselecttool.h @@ -105,9 +105,11 @@ typedef struct /* Public functions */ -void gimp_bezier_select_tool_register (Gimp *gimp); +void gimp_bezier_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_bezier_select_tool_get_type (void); -GType gimp_bezier_select_tool_get_type (void); gboolean bezier_tool_selected (void); diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index 970c973d84..81be7e49c5 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -43,7 +43,6 @@ #include "gimpblendtool.h" #include "paint_options.h" -#include "tool_manager.h" #include "app_procs.h" #include "gimpprogress.h" @@ -120,9 +119,8 @@ static void gimp_blend_tool_cursor_update (GimpTool *tool, static void gimp_blend_tool_draw (GimpDrawTool *draw_tool); -static BlendOptions * blend_options_new (void); - -static void blend_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * blend_options_new (GimpToolInfo *tool_info); +static void blend_options_reset (GimpToolOptions *tool_options); static void gradient_type_callback (GtkWidget *widget, gpointer data); @@ -138,8 +136,6 @@ static void blend_options_drop_tool (GtkWidget *widget, static GimpDrawToolClass *parent_class = NULL; -static BlendOptions *blend_options = NULL; - static GtkTargetEntry blend_target_table[] = { GIMP_TARGET_GRADIENT, @@ -150,17 +146,19 @@ static GtkTargetEntry blend_target_table[] = /* public functions */ void -gimp_blend_tool_register (Gimp *gimp) +gimp_blend_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_BLEND_TOOL, - TRUE, - "gimp:blend_tool", - _("Blend"), - _("Fill with a color gradient"), - N_("/Tools/Paint Tools/Blend"), "L", - NULL, "tools/blend.html", - GIMP_STOCK_TOOL_BLEND); + (* callback) (gimp, + GIMP_TYPE_BLEND_TOOL, + blend_options_new, + TRUE, + "gimp:blend_tool", + _("Blend"), + _("Fill with a color gradient"), + N_("/Tools/Paint Tools/Blend"), "L", + NULL, "tools/blend.html", + GIMP_STOCK_TOOL_BLEND); } GType @@ -222,14 +220,6 @@ gimp_blend_tool_init (GimpBlendTool *blend_tool) tool = GIMP_TOOL (blend_tool); - if (! blend_options) - { - blend_options = blend_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_BLEND_TOOL, - (GimpToolOptions *) blend_options); - } - tool->tool_cursor = GIMP_BLEND_TOOL_CURSOR; tool->scroll_lock = TRUE; /* Disallow scrolling */ } @@ -529,8 +519,8 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool) TRUE); } -static BlendOptions * -blend_options_new (void) +static GimpToolOptions * +blend_options_new (GimpToolInfo *tool_info) { BlendOptions *options; @@ -542,9 +532,9 @@ blend_options_new (void) /* the new blend tool options structure */ options = g_new0 (BlendOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_BLEND_TOOL, - blend_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = blend_options_reset; options->offset = options->offset_d = 0.0; options->blend_mode = options->blend_mode_d = FG_BG_RGB_MODE; @@ -615,7 +605,7 @@ blend_options_new (void) options->gradient_type_w = gimp_option_menu_new2 (FALSE, G_CALLBACK (gradient_type_callback), - &options->gradient_type, + options, GINT_TO_POINTER (options->gradient_type_d), _("Linear"), GINT_TO_POINTER (LINEAR), NULL, @@ -722,7 +712,7 @@ blend_options_new (void) /* show the table */ gtk_widget_show (table); - return options; + return (GimpToolOptions *) options; } static void @@ -759,10 +749,14 @@ static void gradient_type_callback (GtkWidget *widget, gpointer data) { - gimp_menu_item_update (widget, data); + BlendOptions *options; - gtk_widget_set_sensitive (blend_options->repeat_w, - (blend_options->gradient_type < 6)); + options = (BlendOptions *) data; + + gimp_menu_item_update (widget, &options->gradient_type); + + gtk_widget_set_sensitive (options->repeat_w, + (options->gradient_type < 6)); } static void diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h index 917c526c78..c8cb9bb159 100644 --- a/app/tools/gimpblendtool.h +++ b/app/tools/gimpblendtool.h @@ -52,7 +52,8 @@ struct _GimpBlendToolClass }; -void gimp_blend_tool_register (Gimp *gimp); +void gimp_blend_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_blend_tool_get_type (void); diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index 60f4b2fa5f..7046518936 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -36,7 +36,6 @@ #include "gimpbrightnesscontrasttool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -106,10 +105,6 @@ static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *a gpointer data); -/* the brightness-contrast tool options */ -static GimpToolOptions *brightness_contrast_options = NULL; - -/* the brightness-contrast dialog */ static BrightnessContrastDialog *brightness_contrast_dialog = NULL; static GimpImageMapToolClass *parent_class = NULL; @@ -118,17 +113,19 @@ static GimpImageMapToolClass *parent_class = NULL; /* functions */ void -gimp_brightness_contrast_tool_register (Gimp *gimp) +gimp_brightness_contrast_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_BRIGHTNESS_CONTRAST_TOOL, - FALSE, - "gimp:brightness_contrast_tool", - _("Brightness-Contrast"), - _("Adjust brightness and contrast"), - N_("/Image/Colors/Brightness-Contrast..."), NULL, - NULL, "tools/brightness_contrast.html", - GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST); + (* callback) (gimp, + GIMP_TYPE_BRIGHTNESS_CONTRAST_TOOL, + NULL, + FALSE, + "gimp:brightness_contrast_tool", + _("Brightness-Contrast"), + _("Adjust brightness and contrast"), + N_("/Image/Colors/Brightness-Contrast..."), NULL, + NULL, "tools/brightness_contrast.html", + GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST); } GType @@ -175,17 +172,6 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass static void gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! brightness_contrast_options) - { - brightness_contrast_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_BRIGHTNESS_CONTRAST_TOOL, - (GimpToolOptions *) brightness_contrast_options); - } } static void diff --git a/app/tools/gimpbrightnesscontrasttool.h b/app/tools/gimpbrightnesscontrasttool.h index 13d1ada6dd..6b7627c047 100644 --- a/app/tools/gimpbrightnesscontrasttool.h +++ b/app/tools/gimpbrightnesscontrasttool.h @@ -45,7 +45,8 @@ struct _GimpBrightnessContrastToolClass }; -void gimp_brightness_contrast_tool_register (Gimp *gimp); +void gimp_brightness_contrast_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_brightness_contrast_tool_get_type (void); diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index 712baefe84..a22e5b30a9 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -41,7 +41,6 @@ #include "gimpbucketfilltool.h" #include "paint_options.h" -#include "tool_manager.h" #include "gimprc.h" #include "undo.h" @@ -69,9 +68,7 @@ struct _BucketOptions }; -static BucketOptions *bucket_options = NULL; - -static GimpToolClass *parent_class = NULL; +static GimpToolClass *parent_class = NULL; /* local function prototypes */ @@ -99,24 +96,26 @@ static void gimp_bucket_fill_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp); -static BucketOptions * bucket_options_new (void); -static void bucket_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * bucket_options_new (GimpToolInfo *tool_info); +static void bucket_options_reset (GimpToolOptions *tool_options); /* public functions */ void -gimp_bucket_fill_tool_register (Gimp *gimp) +gimp_bucket_fill_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_BUCKET_FILL_TOOL, - TRUE, - "gimp:bucket_fill_tool", - _("Bucket Fill"), - _("Fill with a color or pattern"), - N_("/Tools/Paint Tools/Bucket Fill"), "B", - NULL, "tools/bucket_fill.html", - GIMP_STOCK_TOOL_BUCKET_FILL); + (* callback) (gimp, + GIMP_TYPE_BUCKET_FILL_TOOL, + bucket_options_new, + TRUE, + "gimp:bucket_fill_tool", + _("Bucket Fill"), + _("Fill with a color or pattern"), + N_("/Tools/Paint Tools/Bucket Fill"), "B", + NULL, "tools/bucket_fill.html", + GIMP_STOCK_TOOL_BUCKET_FILL); } GType @@ -172,14 +171,6 @@ gimp_bucket_fill_tool_init (GimpBucketFillTool *bucket_fill_tool) tool = GIMP_TOOL (bucket_fill_tool); - if (! bucket_options) - { - bucket_options = bucket_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_BUCKET_FILL_TOOL, - (GimpToolOptions *) bucket_options); - } - tool->tool_cursor = GIMP_BUCKET_FILL_TOOL_CURSOR; tool->scroll_lock = TRUE; /* Disallow scrolling */ } @@ -362,8 +353,8 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool, cmodifier); } -static BucketOptions * -bucket_options_new (void) +static GimpToolOptions * +bucket_options_new (GimpToolInfo *tool_info) { BucketOptions *options; @@ -375,9 +366,9 @@ bucket_options_new (void) options = g_new0 (BucketOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_BUCKET_FILL_TOOL, - bucket_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = bucket_options_reset; options->sample_merged = options->sample_merged_d = FALSE; options->threshold = gimprc.default_threshold; @@ -441,7 +432,7 @@ bucket_options_new (void) bucket_options_reset ((GimpToolOptions *) options); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpbucketfilltool.h b/app/tools/gimpbucketfilltool.h index c1e4da50a5..963b634df8 100644 --- a/app/tools/gimpbucketfilltool.h +++ b/app/tools/gimpbucketfilltool.h @@ -48,7 +48,8 @@ struct _GimpBucketFillToolClass }; -void gimp_bucket_fill_tool_register (Gimp *gimp); +void gimp_bucket_fill_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_bucket_fill_tool_get_type (void); diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index 52f30cabfc..425227af02 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -145,10 +145,6 @@ static void by_color_select_preview_button_press (ByColorDialog *, static GimpSelectionToolClass *parent_class = NULL; -/* the by color selection tool options */ -static SelectionOptions *by_color_options = NULL; - -/* the by color selection dialog */ static ByColorDialog *by_color_dialog = NULL; /* dnd stuff */ @@ -161,17 +157,19 @@ static GtkTargetEntry by_color_select_targets[] = /* public functions */ void -gimp_by_color_select_tool_register (Gimp *gimp) +gimp_by_color_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_BY_COLOR_SELECT_TOOL, - FALSE, - "gimp:by_color_select_tool", - _("Select By Color"), - _("Select regions by color"), - _("/Tools/Selection Tools/By Color Select"), "C", - NULL, "tools/by_color_select.html", - GIMP_STOCK_TOOL_BY_COLOR_SELECT); + (* callback) (gimp, + GIMP_TYPE_BY_COLOR_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:by_color_select_tool", + _("Select By Color"), + _("Select regions by color"), + _("/Tools/Selection Tools/By Color Select"), "C", + NULL, "tools/by_color_select.html", + GIMP_STOCK_TOOL_BY_COLOR_SELECT); } GType @@ -242,15 +240,6 @@ gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select) tool = GIMP_TOOL (by_color_select); select_tool = GIMP_SELECTION_TOOL (by_color_select); - if (! by_color_options) - { - by_color_options = selection_options_new (GIMP_TYPE_BY_COLOR_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_BY_COLOR_SELECT_TOOL, - (GimpToolOptions *) by_color_options); - } - tool->tool_cursor = GIMP_RECT_SELECT_TOOL_CURSOR; tool->preserve = FALSE; /* Don't preserve on drawable change */ @@ -994,16 +983,23 @@ static void by_color_select_preview_button_press (ByColorDialog *bcd, GdkEventButton *bevent) { - gint x, y; - gboolean replace; - SelectOps operation; - GimpDrawable *drawable; - guchar *col; - GimpRGB color; + GimpToolInfo *tool_info; + SelectionOptions *sel_options; + gint x, y; + gboolean replace; + SelectOps operation; + GimpDrawable *drawable; + guchar *col; + GimpRGB color; if (! bcd->gimage) return; + tool_info = tool_manager_get_info_by_type (bcd->gimage->gimp, + GIMP_TYPE_BY_COLOR_SELECT_TOOL); + + sel_options = (SelectionOptions *) tool_info->tool_options; + drawable = gimp_image_active_drawable (bcd->gimage); /* check if the gimage associated to the drawable still exists */ @@ -1030,7 +1026,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd, /* Find x, y and modify selection */ /* Get the start color */ - if (by_color_options->sample_merged) + if (sel_options->sample_merged) { x = bcd->gimage->width * bevent->x / bcd->preview->requisition.width; y = bcd->gimage->height * bevent->y / bcd->preview->requisition.height; @@ -1063,15 +1059,15 @@ by_color_select_preview_button_press (ByColorDialog *bcd, g_free (col); gimp_image_mask_select_by_color (bcd->gimage, drawable, - by_color_options->sample_merged, + sel_options->sample_merged, &color, bcd->threshold, operation, - by_color_options->antialias, - by_color_options->feather, - by_color_options->feather_radius, - by_color_options->feather_radius); - + sel_options->antialias, + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); + /* show selection on all views */ gdisplays_flush (); @@ -1086,22 +1082,29 @@ by_color_select_color_drop (GtkWidget *widget, gpointer data) { - GimpDrawable *drawable; - ByColorDialog *bcd; + GimpToolInfo *tool_info; + SelectionOptions *sel_options; + GimpDrawable *drawable; + ByColorDialog *bcd; bcd = (ByColorDialog*) data; + tool_info = tool_manager_get_info_by_type (bcd->gimage->gimp, + GIMP_TYPE_BY_COLOR_SELECT_TOOL); + + sel_options = (SelectionOptions *) tool_info->tool_options; + drawable = gimp_image_active_drawable (bcd->gimage); gimp_image_mask_select_by_color (bcd->gimage, drawable, - by_color_options->sample_merged, + sel_options->sample_merged, color, bcd->threshold, bcd->operation, - by_color_options->antialias, - by_color_options->feather, - by_color_options->feather_radius, - by_color_options->feather_radius); + sel_options->antialias, + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); /* show selection on all views */ gdisplays_flush (); diff --git a/app/tools/gimpbycolorselecttool.h b/app/tools/gimpbycolorselecttool.h index 0b23c74b2d..ae81fbddcc 100644 --- a/app/tools/gimpbycolorselecttool.h +++ b/app/tools/gimpbycolorselecttool.h @@ -51,7 +51,8 @@ struct _GimpByColorSelectToolClass }; -void gimp_by_color_select_tool_register (Gimp *gimp); +void gimp_by_color_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_by_color_select_tool_get_type (void); diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index 1d77cb2e1c..23867f75a2 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -46,8 +46,6 @@ #include "gimpclonetool.h" #include "paint_options.h" -#include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -125,16 +123,10 @@ static void gimp_clone_tool_line_pattern (GimpImage *dest, gint bytes, gint width); -static CloneOptions * clone_options_new (void); -static void clone_options_reset (GimpToolOptions *options); +static GimpToolOptions * clone_options_new (GimpToolInfo *tool_info); +static void clone_options_reset (GimpToolOptions *options); -/* The parent class */ -static GimpPaintToolClass *parent_class; - -/* the clone tool options */ -static CloneOptions *clone_options = NULL; - /* local variables */ static gint src_x = 0; /* */ static gint src_y = 0; /* position of clone src */ @@ -153,21 +145,25 @@ static gint non_gui_offset_x; static gint non_gui_offset_y; static CloneType non_gui_type; +static GimpPaintToolClass *parent_class; -/* global functions */ + +/* public functions */ void -gimp_clone_tool_register (Gimp *gimp) +gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CLONE_TOOL, - TRUE, - "gimp:clone_tool", - _("Clone"), - _("Paint using Patterns or Image Regions"), - N_("/Tools/Paint Tools/Clone"), "C", - NULL, "tools/clone.html", - GIMP_STOCK_TOOL_CLONE); + (* callback) (gimp, + GIMP_TYPE_CLONE_TOOL, + clone_options_new, + TRUE, + "gimp:clone_tool", + _("Clone"), + _("Paint using Patterns or Image Regions"), + N_("/Tools/Paint Tools/Clone"), "C", + NULL, "tools/clone.html", + GIMP_STOCK_TOOL_CLONE); } GType @@ -229,14 +225,6 @@ gimp_clone_tool_init (GimpCloneTool *clone) tool = GIMP_TOOL (clone); paint_tool = GIMP_PAINT_TOOL (clone); - if (! clone_options) - { - clone_options = clone_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CLONE_TOOL, - (GimpToolOptions *) clone_options); - } - tool->tool_cursor = GIMP_CLONE_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -818,18 +806,19 @@ gimp_clone_tool_non_gui (GimpDrawable *drawable, #endif /* 0 - non-gui functions */ -static CloneOptions * -clone_options_new (void) +static GimpToolOptions * +clone_options_new (GimpToolInfo *tool_info) { CloneOptions *options; GtkWidget *vbox; GtkWidget *frame; - /* the new clone tool options structure */ - options = g_new (CloneOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_CLONE_TOOL, - clone_options_reset); + options = g_new0 (CloneOptions, 1); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = clone_options_reset; + options->type = options->type_d = CLONE_DEFAULT_TYPE; options->aligned = options->aligned_d = CLONE_DEFAULT_ALIGNED; @@ -866,7 +855,7 @@ clone_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpclonetool.h b/app/tools/gimpclonetool.h index 8916580e25..016415557c 100644 --- a/app/tools/gimpclonetool.h +++ b/app/tools/gimpclonetool.h @@ -52,7 +52,8 @@ struct _GimpCloneToolClass }; -void gimp_clone_tool_register (Gimp *gimp); +void gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_clone_tool_get_type (void); diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index c8ee54d54a..1c44bf34e6 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -37,7 +37,6 @@ #include "gimpcolorbalancetool.h" #include "gimpcolorbalancetool-transfer.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -88,10 +87,6 @@ static void color_balance_yb_adjustment_update (GtkAdjustment *adj, gpointer data); -/* the color balance tool options */ -static GimpToolOptions *color_balance_options = NULL; - -/* the color balance dialog */ static ColorBalanceDialog *color_balance_dialog = NULL; static GimpImageMapToolClass *parent_class = NULL; @@ -100,17 +95,19 @@ static GimpImageMapToolClass *parent_class = NULL; /* functions */ void -gimp_color_balance_tool_register (Gimp *gimp) +gimp_color_balance_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_COLOR_BALANCE_TOOL, - FALSE, - "gimp:color_balance_tool", - _("Color Balance"), - _("Adjust color balance"), - N_("/Image/Colors/Color Balance..."), NULL, - NULL, "tools/color_balance.html", - GIMP_STOCK_TOOL_COLOR_BALANCE); + (* callback) (gimp, + GIMP_TYPE_COLOR_BALANCE_TOOL, + NULL, + FALSE, + "gimp:color_balance_tool", + _("Color Balance"), + _("Adjust color balance"), + N_("/Image/Colors/Color Balance..."), NULL, + NULL, "tools/color_balance.html", + GIMP_STOCK_TOOL_COLOR_BALANCE); } GType @@ -159,17 +156,6 @@ gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass) static void gimp_color_balance_tool_init (GimpColorBalanceTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! color_balance_options) - { - color_balance_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_COLOR_BALANCE_TOOL, - (GimpToolOptions *) color_balance_options); - } } static void diff --git a/app/tools/gimpcolorbalancetool.h b/app/tools/gimpcolorbalancetool.h index 0b67c9d852..746f416102 100644 --- a/app/tools/gimpcolorbalancetool.h +++ b/app/tools/gimpcolorbalancetool.h @@ -73,9 +73,10 @@ struct _ColorBalanceDialog }; -void gimp_color_balance_tool_register (Gimp *gimp); +void gimp_color_balance_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); -GType gimp_color_balance_tool_get_type (void); +GType gimp_color_balance_tool_get_type (void); void color_balance (PixelRegion *srcPR, diff --git a/app/tools/gimpcolorpickertool.c b/app/tools/gimpcolorpickertool.c index 9d46adfe77..240d00c3ee 100644 --- a/app/tools/gimpcolorpickertool.c +++ b/app/tools/gimpcolorpickertool.c @@ -108,11 +108,9 @@ static void gimp_color_picker_tool_cursor_update (GimpTool *tool, static void gimp_color_picker_tool_draw (GimpDrawTool *draw_tool); +static GimpToolOptions * gimp_color_picker_tool_options_new (GimpToolInfo *tool_info); +static void gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options); - -static GimpColorPickerToolOptions * gimp_color_picker_tool_options_new (void); - -static void gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options); static void gimp_color_picker_tool_info_window_close_callback (GtkWidget *widget, gpointer data); static void gimp_color_picker_tool_info_update (GimpTool *tool, @@ -131,9 +129,6 @@ static gboolean pick_color_do (GimpImage *gimage, gint final); -/* the color picker tool options */ -static GimpColorPickerToolOptions * gimp_color_picker_tool_options = NULL; - /* the color value */ gint col_value[5] = { 0, 0, 0, 0, 0 }; @@ -154,17 +149,19 @@ static GimpDrawToolClass *parent_class = NULL; void -gimp_color_picker_tool_register (Gimp *gimp) +gimp_color_picker_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_COLOR_PICKER_TOOL, - FALSE, - "gimp:color_picker_tool", - _("Color Picker"), - _("Pick colors from the image"), - N_("/Tools/Color Picker"), "O", - NULL, "tools/color_picker.html", - GIMP_STOCK_TOOL_COLOR_PICKER); + (* callback) (gimp, + GIMP_TYPE_COLOR_PICKER_TOOL, + gimp_color_picker_tool_options_new, + FALSE, + "gimp:color_picker_tool", + _("Color Picker"), + _("Pick colors from the image"), + N_("/Tools/Color Picker"), "O", + NULL, "tools/color_picker.html", + GIMP_STOCK_TOOL_COLOR_PICKER); } GtkType @@ -226,14 +223,6 @@ gimp_color_picker_tool_init (GimpColorPickerTool *color_picker_tool) tool = GIMP_TOOL (color_picker_tool); - if (! gimp_color_picker_tool_options) - { - gimp_color_picker_tool_options = gimp_color_picker_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_COLOR_PICKER_TOOL, - (GimpToolOptions *) gimp_color_picker_tool_options); - } - tool->tool_cursor = GIMP_COLOR_PICKER_TOOL_CURSOR; tool->preserve = FALSE; /* Don't preserve on drawable change */ @@ -788,8 +777,8 @@ gimp_color_picker_tool_info_window_close_callback (GtkWidget *widget, /* tool options stuff */ -static GimpColorPickerToolOptions * -gimp_color_picker_tool_options_new (void) +static GimpToolOptions * +gimp_color_picker_tool_options_new (GimpToolInfo *tool_info) { GimpColorPickerToolOptions *options; @@ -800,8 +789,10 @@ gimp_color_picker_tool_options_new (void) GtkWidget *scale; options = g_new0 (GimpColorPickerToolOptions, 1); - tool_options_init ((GimpToolOptions *) options, - gimp_color_picker_tool_options_reset); + + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = gimp_color_picker_tool_options_reset; options->sample_merged = options->sample_merged_d = FALSE; options->sample_average = options->sample_average_d = FALSE; @@ -880,7 +871,7 @@ gimp_color_picker_tool_options_new (void) &options->update_active); gtk_widget_show (options->update_active_w); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpcolorpickertool.h b/app/tools/gimpcolorpickertool.h index 23945b5a3c..268686450c 100644 --- a/app/tools/gimpcolorpickertool.h +++ b/app/tools/gimpcolorpickertool.h @@ -51,19 +51,20 @@ struct _GimpColorPickerToolClass /* FIXME: Whats this doing here? */ extern gint col_value[5]; -void gimp_color_picker_tool_register (Gimp *gimp); +void gimp_color_picker_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_color_picker_tool_get_type (void); -gboolean pick_color (GimpImage *gimage, - GimpDrawable *drawable, - gint x, - gint y, - gboolean sample_merged, - gboolean sample_average, - double average_radius, - gint final); +gboolean pick_color (GimpImage *gimage, + GimpDrawable *drawable, + gint x, + gint y, + gboolean sample_merged, + gboolean sample_average, + double average_radius, + gint final); #endif /* __GIMP_COLOR_PICKER_TOOL_H__ */ diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c index 324808c16c..174ef93a70 100644 --- a/app/tools/gimpconvolvetool.c +++ b/app/tools/gimpconvolvetool.c @@ -28,18 +28,17 @@ #include "base/pixel-region.h" #include "base/temp-buf.h" +#include "paint-funcs/paint-funcs.h" + #include "core/gimp.h" #include "core/gimpbrush.h" #include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" - -#include "paint-funcs/paint-funcs.h" +#include "core/gimptoolinfo.h" #include "gimpconvolvetool.h" #include "paint_options.h" -#include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -120,16 +119,10 @@ static void copy_matrix (gfloat *src, static gint sum_matrix (gint *matrix, gint size); -static ConvolveOptions * convolve_options_new (void); +static GimpToolOptions * convolve_options_new (GimpToolInfo *tool_info); static void convolve_options_reset (GimpToolOptions *options); -/* The parent class */ -static GimpPaintToolClass *parent_class; - -/* the convolve tool options */ -static ConvolveOptions * convolve_options = NULL; - /* local variables */ static gint matrix [25]; static gint matrix_size; @@ -165,21 +158,25 @@ static gfloat sharpen_matrix [25] = 0, 0, 0, 0, 0, }; +static GimpPaintToolClass *parent_class; -/* global functions */ + +/* public functions */ void -gimp_convolve_tool_register (Gimp *gimp) +gimp_convolve_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CONVOLVE_TOOL, - TRUE, - "gimp:convolve_tool", - _("Convolve"), - _("Blur or Sharpen"), - N_("/Tools/Paint Tools/Convolve"), "B", - NULL, "tools/convolve.html", - GIMP_STOCK_TOOL_BLUR); + (* callback) (gimp, + GIMP_TYPE_CONVOLVE_TOOL, + convolve_options_new, + TRUE, + "gimp:convolve_tool", + _("Convolve"), + _("Blur or Sharpen"), + N_("/Tools/Paint Tools/Convolve"), "B", + NULL, "tools/convolve.html", + GIMP_STOCK_TOOL_BLUR); } GType @@ -232,19 +229,9 @@ gimp_convolve_tool_class_init (GimpConvolveToolClass *klass) static void gimp_convolve_tool_init (GimpConvolveTool *convolve) { - GimpTool *tool; - GimpPaintTool *paint_tool; + GimpTool *tool; - tool = GIMP_TOOL (convolve); - paint_tool = GIMP_PAINT_TOOL (convolve); - - if (! convolve_options) - { - convolve_options = convolve_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CONVOLVE_TOOL, - (GimpToolOptions *) convolve_options); - } + tool = GIMP_TOOL (convolve); tool->tool_cursor = GIMP_BLUR_TOOL_CURSOR; } @@ -254,13 +241,18 @@ gimp_convolve_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + ConvolveOptions *options; + + options = (ConvolveOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + switch (state) { case MOTION_PAINT: - gimp_convolve_tool_motion (paint_tool, drawable, - convolve_options->paint_options.pressure_options, - convolve_options->type, - convolve_options->rate); + gimp_convolve_tool_motion (paint_tool, + drawable, + options->paint_options.pressure_options, + options->type, + options->rate); break; default: @@ -276,27 +268,29 @@ gimp_convolve_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + ConvolveOptions *options; + + options = (ConvolveOptions *) tool->tool_info->tool_options; + if ((key == GDK_CONTROL_MASK) && ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */ { - switch (convolve_options->type) + switch (options->type) { case BLUR_CONVOLVE: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), - TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[SHARPEN_CONVOLVE]), TRUE); break; case SHARPEN_CONVOLVE: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), - TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[BLUR_CONVOLVE]), TRUE); break; default: break; } } - tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); + tool->toggled = (options->type == SHARPEN_CONVOLVE); } static void @@ -305,7 +299,11 @@ gimp_convolve_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); + ConvolveOptions *options; + + options = (ConvolveOptions *) tool->tool_info->tool_options; + + tool->toggled = (options->type == SHARPEN_CONVOLVE); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp); } @@ -680,8 +678,8 @@ convolve_non_gui (GimpDrawable *drawable, #endif /* 0 - non-gui functions */ -static ConvolveOptions * -convolve_options_new (void) +static GimpToolOptions * +convolve_options_new (GimpToolInfo *tool_info) { ConvolveOptions *options; GtkWidget *vbox; @@ -692,9 +690,9 @@ convolve_options_new (void) options = g_new0 (ConvolveOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_CONVOLVE_TOOL, - convolve_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = convolve_options_reset; options->type = options->type_d = DEFAULT_CONVOLVE_TYPE; options->rate = options->rate_d = DEFAULT_CONVOLVE_RATE; @@ -737,7 +735,7 @@ convolve_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpconvolvetool.h b/app/tools/gimpconvolvetool.h index d4b11f8fd7..9d545cd4e9 100644 --- a/app/tools/gimpconvolvetool.h +++ b/app/tools/gimpconvolvetool.h @@ -53,7 +53,8 @@ struct _GimpConvolveToolClass }; -void gimp_convolve_tool_register (Gimp *gimp); +void gimp_convolve_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_convolve_tool_get_type (void); diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index 82ccb1dcb4..3a17411bcd 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -41,10 +41,8 @@ #include "gui/info-dialog.h" #include "gimpcroptool.h" -#include "gimpdrawtool.h" -#include "gimptool.h" -#include "tool_options.h" #include "tool_manager.h" +#include "tool_options.h" #include "app_procs.h" #include "gimprc.h" @@ -88,16 +86,6 @@ struct _CropOptions }; -static CropOptions *crop_options = NULL; -static InfoDialog *crop_info = NULL; - -static gdouble orig_vals[2]; -static gdouble size_vals[2]; - -static GtkWidget *origin_sizeentry; -static GtkWidget *size_sizeentry; - - static void gimp_crop_tool_class_init (GimpCropToolClass *klass); static void gimp_crop_tool_init (GimpCropTool *crop_tool); @@ -170,27 +158,37 @@ static void crop_origin_changed (GtkWidget *widget, static void crop_size_changed (GtkWidget *widget, gpointer data); -static CropOptions * crop_options_new (void); -static void crop_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * crop_options_new (GimpToolInfo *tool_info); +static void crop_options_reset (GimpToolOptions *tool_options); +static InfoDialog *crop_info = NULL; + +static gdouble orig_vals[2]; +static gdouble size_vals[2]; + +static GtkWidget *origin_sizeentry; +static GtkWidget *size_sizeentry; + static GimpDrawToolClass *parent_class = NULL; -/* Functions */ +/* public functions */ void -gimp_crop_tool_register (Gimp *gimp) +gimp_crop_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CROP_TOOL, - FALSE, - "gimp:crop_tool", - _("Crop Tool"), - _("Crop or Resize an image"), - N_("/Tools/Transform Tools/Crop Tool"), "C", - NULL, "tools/crop_tool.html", - GIMP_STOCK_TOOL_CROP); + (* callback) (gimp, + GIMP_TYPE_CROP_TOOL, + crop_options_new, + FALSE, + "gimp:crop_tool", + _("Crop Tool"), + _("Crop or Resize an image"), + N_("/Tools/Transform Tools/Crop Tool"), "C", + NULL, "tools/crop_tool.html", + GIMP_STOCK_TOOL_CROP); } GType @@ -254,14 +252,6 @@ gimp_crop_tool_init (GimpCropTool *crop_tool) tool = GIMP_TOOL (crop_tool); - if (! crop_options) - { - crop_options = crop_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CROP_TOOL, - (GimpToolOptions *) crop_options); - } - tool->tool_cursor = GIMP_CROP_TOOL_CURSOR; tool->preserve = FALSE; /* Don't preserve on drawable change */ } @@ -1380,16 +1370,18 @@ crop_size_changed (GtkWidget *widget, /* tool options stuff */ -static CropOptions * -crop_options_new (void) +static GimpToolOptions * +crop_options_new (GimpToolInfo *tool_info) { CropOptions *options; GtkWidget *vbox; GtkWidget *frame; options = g_new0 (CropOptions, 1); - tool_options_init ((GimpToolOptions *) options, - crop_options_reset); + + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = crop_options_reset; options->layer_only = options->layer_only_d = FALSE; options->allow_enlarge = options->allow_enlarge_d = FALSE; @@ -1436,7 +1428,7 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpcroptool.h b/app/tools/gimpcroptool.h index 041b965eb1..3c994d2113 100644 --- a/app/tools/gimpcroptool.h +++ b/app/tools/gimpcroptool.h @@ -70,7 +70,8 @@ struct _GimpCropToolClass }; -void gimp_crop_tool_register (Gimp *gimp); +void gimp_crop_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_crop_tool_get_type (void); diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 0c682adb60..290f553a6f 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -43,7 +43,6 @@ #include "gimpcurvestool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -177,14 +176,8 @@ static gboolean curves_read_from_file (FILE *f); static void curves_write_to_file (FILE *f); -/* the curves tool options */ -static GimpToolOptions * curves_options = NULL; - -/* the curves dialog */ static CurvesDialog * curves_dialog = NULL; -static GimpImageMapToolClass *parent_class = NULL; - /* the curves file dialog */ static GtkWidget *file_dlg = NULL; static gboolean load_save; @@ -199,21 +192,25 @@ static CRMatrix CR_basis = { 0.0, 1.0, 0.0, 0.0 }, }; +static GimpImageMapToolClass *parent_class = NULL; -/* functions */ + +/* public functions */ void -gimp_curves_tool_register (Gimp *gimp) +gimp_curves_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CURVES_TOOL, - FALSE, - "gimp:curves_tool", - _("Curves"), - _("Adjust color curves"), - N_("/Image/Colors/Curves..."), NULL, - NULL, "tools/curves.html", - GIMP_STOCK_TOOL_CURVES); + (* callback) (gimp, + GIMP_TYPE_CURVES_TOOL, + NULL, + FALSE, + "gimp:curves_tool", + _("Curves"), + _("Adjust color curves"), + N_("/Image/Colors/Curves..."), NULL, + NULL, "tools/curves.html", + GIMP_STOCK_TOOL_CURVES); } GType @@ -263,17 +260,6 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass) static void gimp_curves_tool_init (GimpCurvesTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! curves_options) - { - curves_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CURVES_TOOL, - (GimpToolOptions *) curves_options); - } } static void diff --git a/app/tools/gimpcurvestool.h b/app/tools/gimpcurvestool.h index 3dd5bc098a..4a9e96ec9c 100644 --- a/app/tools/gimpcurvestool.h +++ b/app/tools/gimpcurvestool.h @@ -85,7 +85,8 @@ struct _CurvesDialog }; -void gimp_curves_tool_register (Gimp *gimp); +void gimp_curves_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_curves_tool_get_type (void); diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c index bfe454c1d2..005136c091 100644 --- a/app/tools/gimpdodgeburntool.c +++ b/app/tools/gimpdodgeburntool.c @@ -36,11 +36,10 @@ #include "core/gimpdrawable.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimpdodgeburntool.h" -#include "gimppainttool.h" #include "paint_options.h" -#include "gimptool.h" #include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -119,32 +118,32 @@ static gfloat gimp_dodgeburn_tool_shadows_lut_func (gpointer user_dat gint channel, gfloat value); -static DodgeBurnOptions * gimp_dodgeburn_tool_options_new (void); -static void gimp_dodgeburn_tool_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * gimp_dodgeburn_tool_options_new (GimpToolInfo *tool_info); +static void gimp_dodgeburn_tool_options_reset (GimpToolOptions *tool_options); static gdouble non_gui_exposure; static GimpLut *non_gui_lut; -static DodgeBurnOptions * dodgeburn_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_dodgeburn_tool_register (Gimp *gimp) +gimp_dodgeburn_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_DODGEBURN_TOOL, - TRUE, - "gimp:dodgeburn_tool", - _("Dodge/Burn"), - _("Dodge or Burn strokes"), - N_("/Tools/Paint Tools/DodgeBurn"), "D", - NULL, "tools/dodgeburn.html", - GIMP_STOCK_TOOL_DODGE); + (* callback) (gimp, + GIMP_TYPE_DODGEBURN_TOOL, + gimp_dodgeburn_tool_options_new, + TRUE, + "gimp:dodgeburn_tool", + _("Dodge/Burn"), + _("Dodge or Burn strokes"), + N_("/Tools/Paint Tools/DodgeBurn"), "D", + NULL, "tools/dodgeburn.html", + GIMP_STOCK_TOOL_DODGE); } GType @@ -200,14 +199,6 @@ gimp_dodgeburn_tool_init (GimpDodgeBurnTool *dodgeburn) tool = GIMP_TOOL (dodgeburn); paint_tool = GIMP_PAINT_TOOL (dodgeburn); - - if (! dodgeburn_options) - { - dodgeburn_options = gimp_dodgeburn_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_DODGEBURN_TOOL, - (GimpToolOptions *) dodgeburn_options); - } tool->tool_cursor = GIMP_DODGE_TOOL_CURSOR; tool->toggle_cursor = GIMP_BURN_TOOL_CURSOR; @@ -261,25 +252,29 @@ gimp_dodgeburn_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + DodgeBurnOptions *options; + + options = (DodgeBurnOptions *) tool->tool_info->tool_options; + if (key == GDK_CONTROL_MASK && ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */ { - switch (dodgeburn_options->type) + switch (options->type) { case DODGE: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[BURN]), TRUE); break; case BURN: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[DODGE]), TRUE); break; default: break; } } - tool->toggled = (dodgeburn_options->type == BURN); + tool->toggled = (options->type == BURN); } static void @@ -288,7 +283,11 @@ gimp_dodgeburn_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - tool->toggled = (dodgeburn_options->type == BURN); + DodgeBurnOptions *options; + + options = (DodgeBurnOptions *) tool->tool_info->tool_options; + + tool->toggled = (options->type == BURN); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp); } @@ -298,15 +297,18 @@ gimp_dodgeburn_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + DodgeBurnOptions *options; PaintPressureOptions *pressure_options; gdouble exposure; GimpLut *lut; - if (dodgeburn_options) + options = (DodgeBurnOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (options) { - pressure_options = dodgeburn_options->paint_options.pressure_options; - exposure = dodgeburn_options->exposure; - lut = dodgeburn_options->lut; + pressure_options = options->paint_options.pressure_options; + exposure = options->exposure; + lut = options->lut; } else { @@ -318,17 +320,18 @@ gimp_dodgeburn_tool_paint (GimpPaintTool *paint_tool, switch (state) { case INIT_PAINT: - if (dodgeburn_options) + if (options) { - dodgeburn_options->lut = gimp_lut_new (); + options->lut = gimp_lut_new (); + gimp_dodgeburn_tool_make_luts (paint_tool, - dodgeburn_options->exposure, - dodgeburn_options->type, - dodgeburn_options->mode, - dodgeburn_options->lut, + options->exposure, + options->type, + options->mode, + options->lut, drawable); - lut = dodgeburn_options->lut; + lut = options->lut; } break; @@ -341,10 +344,10 @@ gimp_dodgeburn_tool_paint (GimpPaintTool *paint_tool, break; case FINISH_PAINT: - if (dodgeburn_options && dodgeburn_options->lut) + if (options && options->lut) { - gimp_lut_free (dodgeburn_options->lut); - dodgeburn_options->lut = NULL; + gimp_lut_free (options->lut); + options->lut = NULL; } break; @@ -533,16 +536,22 @@ gimp_dodgeburn_tool_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { + GimpToolInfo *tool_info; + DodgeBurnOptions *options; gdouble exposure = DODGEBURN_DEFAULT_EXPOSURE; DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; GimpTransferMode mode = DODGEBURN_DEFAULT_MODE; - DodgeBurnOptions *options = dodgeburn_options; + + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_DODGEBURN_TOOL); + + options = (DodgeBurnOptions *) tool_info->tool_options; if (options) { - exposure = dodgeburn_options->exposure; - type = dodgeburn_options->type; - mode = dodgeburn_options->mode; + exposure = options->exposure; + type = options->type; + mode = options->mode; } return gimp_dodgeburn_tool_non_gui (drawable, exposure, type, mode, @@ -612,8 +621,8 @@ gimp_dodgeburn_tool_non_gui (GimpDrawable *drawable, /* tool options stuff */ -static DodgeBurnOptions * -gimp_dodgeburn_tool_options_new (void) +static GimpToolOptions * +gimp_dodgeburn_tool_options_new (GimpToolInfo *tool_info) { DodgeBurnOptions *options; @@ -625,9 +634,9 @@ gimp_dodgeburn_tool_options_new (void) options = g_new0 (DodgeBurnOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_DODGEBURN_TOOL, - gimp_dodgeburn_tool_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = gimp_dodgeburn_tool_options_reset; options->type = options->type_d = DODGEBURN_DEFAULT_TYPE; options->exposure = options->exposure_d = DODGEBURN_DEFAULT_EXPOSURE; @@ -695,7 +704,7 @@ gimp_dodgeburn_tool_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpdodgeburntool.h b/app/tools/gimpdodgeburntool.h index 496ba09893..c9f7f1ea12 100644 --- a/app/tools/gimpdodgeburntool.h +++ b/app/tools/gimpdodgeburntool.h @@ -51,9 +51,11 @@ struct _GimpDodgeBurnToolClass }; -void gimp_dodgeburn_tool_register (Gimp *gimp); +void gimp_dodgeburn_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_dodgeburn_tool_get_type (void); -GType gimp_dodgeburn_tool_get_type (void); gboolean gimp_dodgeburn_tool_non_gui (GimpDrawable *drawable, gdouble exposure, diff --git a/app/tools/gimpellipseselecttool.c b/app/tools/gimpellipseselecttool.c index b7b4ba780d..138085be9a 100644 --- a/app/tools/gimpellipseselecttool.c +++ b/app/tools/gimpellipseselecttool.c @@ -36,7 +36,6 @@ #include "gimpellipseselecttool.h" #include "selection_options.h" -#include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -55,23 +54,23 @@ static void gimp_ellipse_select_tool_rect_select (GimpRectSelectTool *rect_too static GimpRectSelectToolClass *parent_class = NULL; -static SelectionOptions *ellipse_options = NULL; - /* public functions */ void -gimp_ellipse_select_tool_register (Gimp *gimp) +gimp_ellipse_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_ELLIPSE_SELECT_TOOL, - FALSE, - "gimp:ellipse_select_tool", - _("Ellipse Select"), - _("Select elliptical regions"), - _("/Tools/Selection Tools/Ellipse Select"), "E", - NULL, "tools/ellipse_select.html", - GIMP_STOCK_TOOL_ELLIPSE_SELECT); + (* callback) (gimp, + GIMP_TYPE_ELLIPSE_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:ellipse_select_tool", + _("Ellipse Select"), + _("Select elliptical regions"), + _("/Tools/Selection Tools/Ellipse Select"), "E", + NULL, "tools/ellipse_select.html", + GIMP_STOCK_TOOL_ELLIPSE_SELECT); } GType @@ -130,15 +129,6 @@ gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select) tool = GIMP_TOOL (ellipse_select); select_tool = GIMP_SELECTION_TOOL (ellipse_select); - if (! ellipse_options) - { - ellipse_options = selection_options_new (GIMP_TYPE_ELLIPSE_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_ELLIPSE_SELECT_TOOL, - (GimpToolOptions *) ellipse_options); - } - tool->tool_cursor = GIMP_ELLIPSE_SELECT_TOOL_CURSOR; tool->preserve = FALSE; /* Don't preserve on drawable change */ } diff --git a/app/tools/gimpellipseselecttool.h b/app/tools/gimpellipseselecttool.h index b8a4a8da64..e63091c32f 100644 --- a/app/tools/gimpellipseselecttool.h +++ b/app/tools/gimpellipseselecttool.h @@ -45,7 +45,8 @@ struct _GimpEllipseSelectToolClass }; -void gimp_ellipse_select_tool_register (Gimp *gimp); +void gimp_ellipse_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_ellipse_select_tool_get_type (void); diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c index 0b0f328fa3..3a94de36f1 100644 --- a/app/tools/gimperasertool.c +++ b/app/tools/gimperasertool.c @@ -21,6 +21,7 @@ #include #include +#include "libgimpcolor/gimpcolor.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -34,6 +35,7 @@ #include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimperasertool.h" #include "paint_options.h" @@ -41,9 +43,6 @@ #include "libgimp/gimpintl.h" -#include "libgimpcolor/gimpcolor.h" -#include "libgimpcolor/gimprgb.h" - #define ERASER_DEFAULT_HARD FALSE #define ERASER_DEFAULT_INCREMENTAL FALSE @@ -92,8 +91,8 @@ static void gimp_eraser_tool_motion (GimpPaintTool *paint_tool, gboolean anti_erase, gboolean color_erase); -static EraserOptions * gimp_eraser_tool_options_new (void); -static void gimp_eraser_tool_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * gimp_eraser_tool_options_new (GimpToolInfo *tool_info); +static void gimp_eraser_tool_options_reset (GimpToolOptions *tool_options); static void gimp_eraser_tool_colortoalpha (GimpRGB *src, const GimpRGB *color); @@ -104,25 +103,25 @@ static gboolean non_gui_incremental = ERASER_DEFAULT_INCREMENTAL; static gboolean non_gui_anti_erase = ERASER_DEFAULT_ANTI_ERASE; static gboolean non_gui_color_erase = ERASER_DEFAULT_COLOR_ERASE; -static EraserOptions *eraser_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_eraser_tool_register (Gimp *gimp) +gimp_eraser_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_ERASER_TOOL, - TRUE, - "gimp:eraser_tool", - _("Eraser"), - _("Paint fuzzy brush strokes"), - N_("/Tools/Paint Tools/Eraser"), "E", - NULL, "tools/eraser.html", - GIMP_STOCK_TOOL_ERASER); + (* callback) (gimp, + GIMP_TYPE_ERASER_TOOL, + gimp_eraser_tool_options_new, + TRUE, + "gimp:eraser_tool", + _("Eraser"), + _("Paint fuzzy brush strokes"), + N_("/Tools/Paint Tools/Eraser"), "E", + NULL, "tools/eraser.html", + GIMP_STOCK_TOOL_ERASER); } GType @@ -178,14 +177,6 @@ gimp_eraser_tool_init (GimpEraserTool *eraser) tool = GIMP_TOOL (eraser); paint_tool = GIMP_PAINT_TOOL (eraser); - if (! eraser_options) - { - eraser_options = gimp_eraser_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_ERASER_TOOL, - (GimpToolOptions *) eraser_options); - } - tool->tool_cursor = GIMP_ERASER_TOOL_CURSOR; paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; @@ -198,15 +189,18 @@ gimp_eraser_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + EraserOptions *options; + + options = (EraserOptions *) tool->tool_info->tool_options; + if ((key == GDK_CONTROL_MASK) && ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */ { gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (eraser_options->anti_erase_w), - ! eraser_options->anti_erase); + (GTK_TOGGLE_BUTTON (options->anti_erase_w), ! options->anti_erase); } - tool->toggled = eraser_options->anti_erase; + tool->toggled = options->anti_erase; } static void @@ -214,19 +208,22 @@ gimp_eraser_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + EraserOptions *options; PaintPressureOptions *pressure_options; gboolean hard; gboolean incremental; gboolean anti_erase; gboolean color_erase; - if (eraser_options) + options = (EraserOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (options) { - pressure_options = eraser_options->paint_options.pressure_options; - hard = eraser_options->hard; - incremental = eraser_options->paint_options.incremental; - anti_erase = eraser_options->anti_erase; - color_erase = eraser_options->color_erase; + pressure_options = options->paint_options.pressure_options; + hard = options->hard; + incremental = options->paint_options.incremental; + anti_erase = options->anti_erase; + color_erase = options->color_erase; } else { @@ -421,12 +418,17 @@ eraser_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { - gboolean hard = ERASER_DEFAULT_HARD; - gboolean incremental = ERASER_DEFAULT_INCREMENTAL; - gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE; - gboolean color_erase = ERASER_DEFAULT_COLOR_ERASE; + GimpToolInfo *tool_info; + EraserOptions *options; + gboolean hard = ERASER_DEFAULT_HARD; + gboolean incremental = ERASER_DEFAULT_INCREMENTAL; + gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE; + gboolean color_erase = ERASER_DEFAULT_COLOR_ERASE; - EraserOptions *options = eraser_options; + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_ERASER_TOOL); + + options = (EraserOptions *) tool_info->tool_options; if (options) { @@ -497,16 +499,17 @@ eraser_non_gui (GimpDrawable *drawable, /* tool options stuff */ -static EraserOptions * -gimp_eraser_tool_options_new (void) +static GimpToolOptions * +gimp_eraser_tool_options_new (GimpToolInfo *tool_info) { EraserOptions *options; GtkWidget *vbox; options = g_new0 (EraserOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_ERASER_TOOL, - gimp_eraser_tool_options_reset); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = gimp_eraser_tool_options_reset; options->hard = options->hard_d = ERASER_DEFAULT_HARD; options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE; @@ -545,7 +548,7 @@ gimp_eraser_tool_options_new (void) options->color_erase_d); gtk_widget_show (options->color_erase_w); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimperasertool.h b/app/tools/gimperasertool.h index 84ac304a05..70aea12164 100644 --- a/app/tools/gimperasertool.h +++ b/app/tools/gimperasertool.h @@ -45,7 +45,8 @@ struct _GimpEraserToolClass }; -void gimp_eraser_tool_register (Gimp *gimp); +void gimp_eraser_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_eraser_tool_get_type (void); diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c index 1eab9c5750..b1d1c0f3d1 100644 --- a/app/tools/gimpfliptool.c +++ b/app/tools/gimpfliptool.c @@ -37,7 +37,6 @@ #include "display/gimpdisplayshell.h" #include "gimpfliptool.h" -#include "tool_manager.h" #include "tool_options.h" #include "path_transform.h" @@ -80,29 +79,29 @@ static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool, GimpDisplay *gdisp, TransformState state); -static FlipOptions * flip_options_new (void); -static void flip_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * flip_options_new (GimpToolInfo *tool_info); +static void flip_options_reset (GimpToolOptions *tool_options); -static FlipOptions *flip_options = NULL; - static GimpTransformToolClass *parent_class = NULL; /* public functions */ void -gimp_flip_tool_register (Gimp *gimp) +gimp_flip_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_FLIP_TOOL, - FALSE, - "gimp:flip_tool", - _("Flip Tool"), - _("Flip the layer or selection"), - N_("/Tools/Transform Tools/Flip"), "F", - NULL, "tools/flip.html", - GIMP_STOCK_TOOL_FLIP); + (* callback) (gimp, + GIMP_TYPE_FLIP_TOOL, + flip_options_new, + FALSE, + "gimp:flip_tool", + _("Flip Tool"), + _("Flip the layer or selection"), + N_("/Tools/Transform Tools/Flip"), "F", + NULL, "tools/flip.html", + GIMP_STOCK_TOOL_FLIP); } GType @@ -166,15 +165,6 @@ gimp_flip_tool_init (GimpFlipTool *flip_tool) tool = GIMP_TOOL (flip_tool); transform_tool = GIMP_TRANSFORM_TOOL (flip_tool); - /* The tool options */ - if (! flip_options) - { - flip_options = flip_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_FLIP_TOOL, - (GimpToolOptions *) flip_options); - } - tool->tool_cursor = GIMP_FLIP_HORIZONTAL_TOOL_CURSOR; tool->toggle_cursor = GIMP_FLIP_VERTICAL_TOOL_CURSOR; @@ -295,16 +285,21 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool, return NULL; } -static FlipOptions * -flip_options_new (void) + +/* tool options stuff */ + +static GimpToolOptions * +flip_options_new (GimpToolInfo *tool_info) { FlipOptions *options; GtkWidget *vbox; GtkWidget *frame; options = g_new0 (FlipOptions, 1); - tool_options_init ((GimpToolOptions *) options, - flip_options_reset); + + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = flip_options_reset; options->type = options->type_d = ORIENTATION_HORIZONTAL; @@ -330,7 +325,7 @@ flip_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void @@ -340,5 +335,6 @@ flip_options_reset (GimpToolOptions *tool_options) options = (FlipOptions *) tool_options; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d - 1]), TRUE); + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (options->type_w[options->type_d - 1]), TRUE); } diff --git a/app/tools/gimpfliptool.h b/app/tools/gimpfliptool.h index 2ba13bd0d2..3135d53113 100644 --- a/app/tools/gimpfliptool.h +++ b/app/tools/gimpfliptool.h @@ -45,7 +45,8 @@ struct _GimpFlipToolClass }; -void gimp_flip_tool_register (Gimp *gimp); +void gimp_flip_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_flip_tool_get_type (void); diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index 392bf4bd1a..60a6f9a69b 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -42,9 +42,7 @@ #include "gimpeditselectiontool.h" #include "gimpfreeselecttool.h" #include "selection_options.h" -#include "tool_manager.h" -#include "errors.h" #include "floating_sel.h" #include "libgimp/gimpintl.h" @@ -82,23 +80,23 @@ static void gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel static GimpSelectionToolClass *parent_class = NULL; -static SelectionOptions * free_options = NULL; - /* public functions */ void -gimp_free_select_tool_register (Gimp *gimp) +gimp_free_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_FREE_SELECT_TOOL, - FALSE, - "gimp:free_select_tool", - _("Free Select"), - _("Select hand-drawn regions"), - _("/Tools/Selection Tools/Free Select"), "F", - NULL, "tools/free_select.html", - GIMP_STOCK_TOOL_FREE_SELECT); + (* callback) (gimp, + GIMP_TYPE_FREE_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:free_select_tool", + _("Free Select"), + _("Select hand-drawn regions"), + _("/Tools/Selection Tools/Free Select"), "F", + NULL, "tools/free_select.html", + GIMP_STOCK_TOOL_FREE_SELECT); } GType @@ -162,15 +160,6 @@ gimp_free_select_tool_init (GimpFreeSelectTool *free_select) tool = GIMP_TOOL (free_select); select_tool = GIMP_SELECTION_TOOL (free_select); - if (! free_options) - { - free_options = selection_options_new (GIMP_TYPE_FREE_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_FREE_SELECT_TOOL, - (GimpToolOptions *) free_options); - } - tool->tool_cursor = GIMP_FREE_SELECT_TOOL_CURSOR; tool->scroll_lock = TRUE; /* Do not allow scrolling */ diff --git a/app/tools/gimpfreeselecttool.h b/app/tools/gimpfreeselecttool.h index 15be379639..38920fc07a 100644 --- a/app/tools/gimpfreeselecttool.h +++ b/app/tools/gimpfreeselecttool.h @@ -49,7 +49,8 @@ struct _GimpFreeSelectToolClass }; -void gimp_free_select_tool_register (Gimp *gimp); +void gimp_free_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_free_select_tool_get_type (void); diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index 3e7d6aad98..417fbde164 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -49,7 +49,6 @@ #include "gimpeditselectiontool.h" #include "gimpfuzzyselecttool.h" #include "selection_options.h" -#include "tool_manager.h" #include "gimprc.h" @@ -84,30 +83,29 @@ static GdkSegment * fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, gint *nsegs); -static GimpSelectionToolClass *parent_class = NULL; - -/* the fuzzy selection tool options */ -static SelectionOptions *fuzzy_options = NULL; - /* XSegments which make up the fuzzy selection boundary */ static GdkSegment *segs = NULL; static gint num_segs = 0; +static GimpSelectionToolClass *parent_class = NULL; + /* public functions */ void -gimp_fuzzy_select_tool_register (Gimp *gimp) +gimp_fuzzy_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_FUZZY_SELECT_TOOL, - FALSE, - "gimp:fuzzy_select_tool", - _("Fuzzy Select"), - _("Select contiguous regions"), - _("/Tools/Selection Tools/Fuzzy Select"), "Z", - NULL, "tools/fuzzy_select.html", - GIMP_STOCK_TOOL_FUZZY_SELECT); + (* callback) (gimp, + GIMP_TYPE_FUZZY_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:fuzzy_select_tool", + _("Fuzzy Select"), + _("Select contiguous regions"), + _("/Tools/Selection Tools/Fuzzy Select"), "Z", + NULL, "tools/fuzzy_select.html", + GIMP_STOCK_TOOL_FUZZY_SELECT); } GType @@ -172,15 +170,6 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select) tool = GIMP_TOOL (fuzzy_select); select_tool = GIMP_SELECTION_TOOL (fuzzy_select); - if (! fuzzy_options) - { - fuzzy_options = selection_options_new (GIMP_TYPE_FUZZY_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_FUZZY_SELECT_TOOL, - (GimpToolOptions *) fuzzy_options); - } - tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR; tool->scroll_lock = TRUE; /* Do not allow scrolling */ diff --git a/app/tools/gimpfuzzyselecttool.h b/app/tools/gimpfuzzyselecttool.h index 2daf916677..73a5c1fee9 100644 --- a/app/tools/gimpfuzzyselecttool.h +++ b/app/tools/gimpfuzzyselecttool.h @@ -52,7 +52,8 @@ struct _GimpFuzzySelectToolClass }; -void gimp_fuzzy_select_tool_register (Gimp *gimp); +void gimp_fuzzy_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_fuzzy_select_tool_get_type (void); diff --git a/app/tools/gimphistogramtool.c b/app/tools/gimphistogramtool.c index 09bfc58429..6988e67f31 100644 --- a/app/tools/gimphistogramtool.c +++ b/app/tools/gimphistogramtool.c @@ -37,7 +37,6 @@ #include "gimphistogramtool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" @@ -104,29 +103,27 @@ static void histogram_tool_histogram_range (GimpHistogramView *view, gpointer data); -/* the histogram tool options */ -static GimpToolOptions * histogram_options = NULL; - -/* the histogram tool dialog */ static HistogramToolDialog * histogram_dialog = NULL; static GimpToolClass *parent_class = NULL; -/* functions */ +/* public functions */ void -gimp_histogram_tool_register (Gimp *gimp) +gimp_histogram_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_HISTOGRAM_TOOL, - FALSE, - "gimp:histogram_tool", - _("Histogram"), - _("View image histogram"), - N_("/Image/Histogram..."), NULL, - NULL, "tools/histogram.html", - GIMP_STOCK_TOOL_HISTOGRAM); + (* callback) (gimp, + GIMP_TYPE_HISTOGRAM_TOOL, + NULL, + FALSE, + "gimp:histogram_tool", + _("Histogram"), + _("View image histogram"), + N_("/Image/Histogram..."), NULL, + NULL, "tools/histogram.html", + GIMP_STOCK_TOOL_HISTOGRAM); } GType @@ -177,14 +174,6 @@ gimp_histogram_tool_init (GimpHistogramTool *bc_tool) tool = GIMP_TOOL (bc_tool); - if (! histogram_options) - { - histogram_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_HISTOGRAM_TOOL, - (GimpToolOptions *) histogram_options); - } - tool->scroll_lock = TRUE; /* Disallow scrolling */ tool->preserve = FALSE; /* Don't preserve on drawable change */ } diff --git a/app/tools/gimphistogramtool.h b/app/tools/gimphistogramtool.h index c0a5951dc4..2bb33796ce 100644 --- a/app/tools/gimphistogramtool.h +++ b/app/tools/gimphistogramtool.h @@ -49,7 +49,8 @@ struct _GimpHistogramToolClass }; -void gimp_histogram_tool_register (Gimp *gimp); +void gimp_histogram_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_histogram_tool_get_type (void); diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index f7364e9904..a87deda1c2 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -37,7 +37,6 @@ #include "gimphuesaturationtool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -97,15 +96,6 @@ static gint hue_saturation_hue_partition_events (GtkWidget *, HueSaturationDialog *hsd); -/* the hue-saturation tool options */ -static GimpToolOptions *hue_saturation_options = NULL; - -/* the hue-saturation tool dialog */ -static HueSaturationDialog *hue_saturation_dialog = NULL; - -static GimpImageMapToolClass *parent_class = NULL; - - /* Local variables */ static gint hue_transfer[6][256]; static gint lightness_transfer[6][256]; @@ -120,21 +110,27 @@ static gint default_colors[6][3] = { 255, 0, 255 } }; +static HueSaturationDialog *hue_saturation_dialog = NULL; -/* functions */ +static GimpImageMapToolClass *parent_class = NULL; + + +/* public functions */ void -gimp_hue_saturation_tool_register (Gimp *gimp) +gimp_hue_saturation_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_HUE_SATURATION_TOOL, - FALSE, - "gimp:hue_saturation_tool", - _("Hue-Saturation"), - _("Adjust hue and saturation"), - N_("/Image/Colors/Hue-Saturation..."), NULL, - NULL, "tools/hue_saturation.html", - GIMP_STOCK_TOOL_HUE_SATURATION); + (* callback) (gimp, + GIMP_TYPE_HUE_SATURATION_TOOL, + NULL, + FALSE, + "gimp:hue_saturation_tool", + _("Hue-Saturation"), + _("Adjust hue and saturation"), + N_("/Image/Colors/Hue-Saturation..."), NULL, + NULL, "tools/hue_saturation.html", + GIMP_STOCK_TOOL_HUE_SATURATION); } GType @@ -181,17 +177,6 @@ gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass) static void gimp_hue_saturation_tool_init (GimpHueSaturationTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! hue_saturation_options) - { - hue_saturation_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_HUE_SATURATION_TOOL, - (GimpToolOptions *) hue_saturation_options); - } } static void diff --git a/app/tools/gimphuesaturationtool.h b/app/tools/gimphuesaturationtool.h index 20c0cfb5b9..c5765fd478 100644 --- a/app/tools/gimphuesaturationtool.h +++ b/app/tools/gimphuesaturationtool.h @@ -81,7 +81,8 @@ struct _HueSaturationDialog }; -void gimp_hue_saturation_tool_register (Gimp *gimp); +void gimp_hue_saturation_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_hue_saturation_tool_get_type (void); diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index ede373ef2a..674af07d38 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -48,10 +48,10 @@ #include "gimpinktool.h" #include "gimpinktool-blob.h" -#include "gimptool.h" #include "paint_options.h" #include "tool_manager.h" +#include "app_procs.h" #include "gimprc.h" #include "undo.h" @@ -60,8 +60,6 @@ #define SUBSAMPLE 8 -/* the Ink structures */ - typedef Blob * (* BlobFunc) (gdouble, gdouble, gdouble, @@ -71,14 +69,16 @@ typedef Blob * (* BlobFunc) (gdouble, typedef struct _BrushWidget BrushWidget; +typedef struct _InkOptions InkOptions; struct _BrushWidget { - GtkWidget *widget; - gboolean state; -}; + GtkWidget *widget; + gboolean state; -typedef struct _InkOptions InkOptions; + /* EEK */ + InkOptions *ink_options; +}; struct _InkOptions { @@ -146,7 +146,8 @@ static void gimp_ink_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp); -static Blob * ink_pen_ellipse (gdouble x_center, +static Blob * ink_pen_ellipse (InkOptions *options, + gdouble x_center, gdouble y_center, gdouble pressure, gdouble xtilt, @@ -221,17 +222,14 @@ static void brush_widget_motion_notify (GtkWidget *widget, GdkEventMotion *event, BrushWidget *brush_widget); -static InkOptions * ink_options_new (void); -static void ink_options_reset (GimpToolOptions *tool_options); -static void ink_type_update (GtkWidget *radio_button, - BlobFunc function); +static GimpToolOptions * ink_options_new (GimpToolInfo *tool_info); +static void ink_options_reset (GimpToolOptions *tool_options); +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); /* local variables */ -/* the ink tool options */ -static InkOptions *ink_options = NULL; - /* undo blocks variables */ static TileManager *undo_tiles = NULL; @@ -243,23 +241,25 @@ static TileManager *canvas_tiles = NULL; */ static TempBuf *canvas_buf = NULL; -static GimpToolClass *parent_class = NULL; +static GimpToolClass *parent_class = NULL; /* public functions */ void -gimp_ink_tool_register (Gimp *gimp) +gimp_ink_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_INK_TOOL, - TRUE, - "gimp:ink_tool", - _("Ink Tool"), - _("Draw in ink"), - N_("/Tools/Paint Tools/Ink"), "K", - NULL, "tools/ink.html", - GIMP_STOCK_TOOL_INK); + (* callback) (gimp, + GIMP_TYPE_INK_TOOL, + ink_options_new, + TRUE, + "gimp:ink_tool", + _("Ink Tool"), + _("Draw in ink"), + N_("/Tools/Paint Tools/Ink"), "K", + NULL, "tools/ink.html", + GIMP_STOCK_TOOL_INK); } GType @@ -319,17 +319,6 @@ gimp_ink_tool_init (GimpInkTool *ink_tool) GimpTool *tool; tool = GIMP_TOOL (ink_tool); - - /* The tool options */ - if (! ink_options) - { - ink_options = ink_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_INK_TOOL, - (GimpToolOptions *) ink_options); - - ink_options_reset ((GimpToolOptions *) ink_options); - } tool->tool_cursor = GIMP_INK_TOOL_CURSOR; } @@ -386,12 +375,15 @@ gimp_ink_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpInkTool *ink_tool; + InkOptions *options; GimpDisplayShell *shell; GimpDrawable *drawable; Blob *b; ink_tool = GIMP_INK_TOOL (tool); + options = (InkOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); drawable = gimp_image_active_drawable (gdisp->gimage); @@ -422,7 +414,8 @@ gimp_ink_tool_button_press (GimpTool *tool, NULL, NULL, time); } - b = ink_pen_ellipse (coords->x, + b = ink_pen_ellipse (options, + coords->x, coords->y, coords->pressure, coords->xtilt, @@ -481,15 +474,18 @@ gimp_ink_tool_motion (GimpTool *tool, GimpDisplay *gdisp) { GimpInkTool *ink_tool; + InkOptions *options; GimpDrawable *drawable; Blob *b, *blob_union; gdouble velocity; gdouble dist; gdouble lasttime, thistime; - + ink_tool = GIMP_INK_TOOL (tool); + options = (InkOptions *) tool->tool_info->tool_options; + drawable = gimp_image_active_drawable (gdisp->gimage); lasttime = ink_tool->last_time; @@ -532,7 +528,8 @@ gimp_ink_tool_motion (GimpTool *tool, velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime)); - b = ink_pen_ellipse (coords->x, + b = ink_pen_ellipse (options, + coords->x, coords->y, coords->pressure, coords->xtilt, @@ -596,15 +593,15 @@ brush_widget_active_rect (BrushWidget *brush_widget, GtkWidget *widget, GdkRectangle *rect) { - int x,y; - int r; + gint x,y; + gint r; r = MIN (widget->allocation.width, widget->allocation.height) / 2; - x = widget->allocation.width / 2 + 0.85 * r * ink_options->aspect / 10.0 * - cos (ink_options->angle); - y = widget->allocation.height / 2 + 0.85 * r * ink_options->aspect / 10.0 * - sin (ink_options->angle); + x = widget->allocation.width / 2 + 0.85 * r * brush_widget->ink_options->aspect / 10.0 * + cos (brush_widget->ink_options->angle); + y = widget->allocation.height / 2 + 0.85 * r * brush_widget->ink_options->aspect / 10.0 * + sin (brush_widget->ink_options->angle); rect->x = x - 5; rect->y = y - 5; @@ -627,13 +624,13 @@ brush_widget_draw_brush (BrushWidget *brush_widget, { Blob *blob; - blob = ink_options->function (xc, yc, - radius * cos (ink_options->angle), - radius * sin (ink_options->angle), - (- (radius / ink_options->aspect) * - sin (ink_options->angle)), - ((radius / ink_options->aspect) * - cos (ink_options->angle))); + blob = brush_widget->ink_options->function (xc, yc, + radius * cos (brush_widget->ink_options->angle), + radius * sin (brush_widget->ink_options->angle), + (- (radius / brush_widget->ink_options->aspect) * + sin (brush_widget->ink_options->angle)), + ((radius / brush_widget->ink_options->aspect) * + cos (brush_widget->ink_options->angle))); paint_blob (widget->window, widget->style->fg_gc[widget->state], blob); g_free (blob); @@ -716,16 +713,16 @@ brush_widget_motion_notify (GtkWidget *widget, if (rsquare != 0) { - ink_options->angle = atan2 (y, x); + brush_widget->ink_options->angle = atan2 (y, x); r0 = MIN (widget->allocation.width, widget->allocation.height) / 2; - ink_options->aspect = - 10.0 * sqrt ((double) rsquare / (r0 * r0)) / 0.85; + brush_widget->ink_options->aspect = + 10.0 * sqrt ((gdouble) rsquare / (r0 * r0)) / 0.85; - if (ink_options->aspect < 1.0) - ink_options->aspect = 1.0; - if (ink_options->aspect > 10.0) - ink_options->aspect = 10.0; + if (brush_widget->ink_options->aspect < 1.0) + brush_widget->ink_options->aspect = 1.0; + if (brush_widget->ink_options->aspect > 10.0) + brush_widget->ink_options->aspect = 10.0; gtk_widget_draw (widget, NULL); } @@ -798,25 +795,26 @@ paint_blob (GdkDrawable *drawable, static Blob * -ink_pen_ellipse (gdouble x_center, - gdouble y_center, - gdouble pressure, - gdouble xtilt, - gdouble ytilt, - gdouble velocity) +ink_pen_ellipse (InkOptions *options, + gdouble x_center, + gdouble y_center, + gdouble pressure, + gdouble xtilt, + gdouble ytilt, + gdouble velocity) { - double size; - double tsin, tcos; - double aspect, radmin; - double x,y; - double tscale; - double tscale_c; - double tscale_s; - + gdouble size; + gdouble tsin, tcos; + gdouble aspect, radmin; + gdouble x,y; + gdouble tscale; + gdouble tscale_c; + gdouble tscale_s; + /* Adjust the size depending on pressure. */ - size = ink_options->size * (1.0 + ink_options->sensitivity * - (2.0 * pressure - 1.0) ); + size = options->size * (1.0 + options->sensitivity * + (2.0 * pressure - 1.0) ); /* Adjust the size further depending on pointer velocity and velocity-sensitivity. These 'magic constants' are @@ -829,9 +827,9 @@ ink_pen_ellipse (gdouble x_center, g_print("%f (%f) -> ", (float)size, (float)velocity); #endif - size = ink_options->vel_sensitivity * - ((4.5 * size) / (1.0 + ink_options->vel_sensitivity * (2.0*(velocity)))) - + (1.0 - ink_options->vel_sensitivity) * size; + size = options->vel_sensitivity * + ((4.5 * size) / (1.0 + options->vel_sensitivity * (2.0*(velocity)))) + + (1.0 - options->vel_sensitivity) * size; #ifdef VERBOSE g_print("%f\n", (float)size); @@ -839,8 +837,8 @@ ink_pen_ellipse (gdouble x_center, /* Clamp resulting size to sane limits */ - if (size > ink_options->size * (1.0 + ink_options->sensitivity)) - size = ink_options->size * (1.0 + ink_options->sensitivity); + if (size > options->size * (1.0 + options->sensitivity)) + size = options->size * (1.0 + options->sensitivity); if (size*SUBSAMPLE < 1.0) size = 1.0/SUBSAMPLE; @@ -850,16 +848,18 @@ ink_pen_ellipse (gdouble x_center, tilt info from the brush. My personal feeling is that representing both as affine transforms would make the most sense. -RLL */ - tscale = ink_options->tilt_sensitivity * 10.0; - tscale_c = tscale * cos (gimp_deg_to_rad (ink_options->tilt_angle)); - tscale_s = tscale * sin (gimp_deg_to_rad (ink_options->tilt_angle)); - x = ink_options->aspect*cos(ink_options->angle) + - xtilt * tscale_c - ytilt * tscale_s; - y = ink_options->aspect*sin(ink_options->angle) + - ytilt * tscale_c + xtilt * tscale_s; + tscale = options->tilt_sensitivity * 10.0; + tscale_c = tscale * cos (gimp_deg_to_rad (options->tilt_angle)); + tscale_s = tscale * sin (gimp_deg_to_rad (options->tilt_angle)); + + x = (options->aspect * cos (options->angle) + + xtilt * tscale_c - ytilt * tscale_s); + y = (options->aspect * sin (options->angle) + + ytilt * tscale_c + xtilt * tscale_s); + #ifdef VERBOSE g_print ("angle %g aspect %g; %g %g; %g %g\n", - ink_options->angle, ink_options->aspect, tscale_c, tscale_s, x, y); + options->angle, options->aspect, tscale_c, tscale_s, x, y); #endif aspect = sqrt(x*x+y*y); @@ -870,8 +870,8 @@ ink_pen_ellipse (gdouble x_center, } else { - tsin = sin(ink_options->angle); - tcos = cos(ink_options->angle); + tsin = sin (options->angle); + tcos = cos (options->angle); } if (aspect < 1.0) @@ -882,9 +882,12 @@ ink_pen_ellipse (gdouble x_center, radmin = SUBSAMPLE * size/aspect; if (radmin < 1.0) radmin = 1.0; - return ink_options->function (x_center * SUBSAMPLE, y_center * SUBSAMPLE, - radmin*aspect*tcos, radmin*aspect*tsin, - -radmin*tsin, radmin*tcos); + return options->function (x_center * SUBSAMPLE, + y_center * SUBSAMPLE, + radmin * aspect * tcos, + radmin * aspect * tsin, + -radmin * tsin, + radmin * tcos); } static void @@ -1422,8 +1425,8 @@ ink_set_canvas_tiles (gint x, /* tool options stuff */ -static InkOptions * -ink_options_new (void) +static GimpToolOptions * +ink_options_new (GimpToolInfo *tool_info) { InkOptions *options; GtkWidget *table; @@ -1438,9 +1441,10 @@ ink_options_new (void) GdkPixmap *pixmap; options = g_new0 (InkOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_INK_TOOL, - ink_options_reset); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = ink_options_reset; options->size = options->size_d = 4.4; options->sensitivity = options->sensitivity_d = 1.0; @@ -1643,7 +1647,8 @@ ink_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); options->brush_w = g_new (BrushWidget, 1); - options->brush_w->state = FALSE; + options->brush_w->state = FALSE; + options->brush_w->ink_options = options; darea = gtk_drawing_area_new(); options->brush_w->widget = darea; @@ -1673,7 +1678,9 @@ ink_options_new (void) gtk_widget_show_all (hbox); - return options; + ink_options_reset ((GimpToolOptions *) options); + + return (GimpToolOptions *) options; } static void @@ -1710,7 +1717,12 @@ static void ink_type_update (GtkWidget *radio_button, BlobFunc function) { - InkOptions *options = ink_options; + GimpToolInfo *tool_info; + InkOptions *options; + + tool_info = tool_manager_get_info_by_type (the_gimp, GIMP_TYPE_INK_TOOL); + + options = (InkOptions *) tool_info->tool_options; if (GTK_TOGGLE_BUTTON (radio_button)->active) options->function = function; diff --git a/app/tools/gimpinktool.h b/app/tools/gimpinktool.h index ae13cc54b0..9c94235006 100644 --- a/app/tools/gimpinktool.h +++ b/app/tools/gimpinktool.h @@ -68,7 +68,8 @@ struct _GimpInkToolClass }; -void gimp_ink_tool_register (Gimp *gimp); +void gimp_ink_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_ink_tool_get_type (void); diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index e3e4e86f7a..c15a965a46 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -68,7 +68,6 @@ #include "gimpiscissorstool.h" #include "gimpeditselectiontool.h" #include "selection_options.h" -#include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -112,14 +111,6 @@ struct _ICurve }; -typedef struct _IScissorsOptions IScissorsOptions; - -struct _IScissorsOptions -{ - SelectionOptions selection_options; -}; - - /* local function prototypes */ static void gimp_iscissors_tool_class_init (GimpIscissorsToolClass *klass); @@ -158,8 +149,6 @@ static void gimp_iscissors_tool_reset (GimpIscissorsTool *iscissors); static void gimp_iscissors_tool_draw (GimpDrawTool *draw_tool); -static IScissorsOptions * iscissors_options_new (void); - static void iscissors_convert (GimpIscissorsTool *iscissors, GimpDisplay *gdisp); static TileManager * gradient_map_new (GimpImage *gimage); @@ -263,24 +252,24 @@ static gint direction_value[256][4]; static gboolean initialized = FALSE; static Tile *cur_tile = NULL; -static IScissorsOptions *iscissors_options = NULL; - static GimpDrawTool *parent_class = NULL; void -gimp_iscissors_tool_register (Gimp *gimp) +gimp_iscissors_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_ISCISSORS_TOOL, - FALSE, - "gimp:iscissors_tool", - _("Intelligent Scissors"), - _("Select shapes from image"), - N_("/Tools/Selection Tools/Intelligent Scissors"), - "I", - NULL, "tools/iscissors.html", - GIMP_STOCK_TOOL_ISCISSORS); + (* callback) (gimp, + GIMP_TYPE_ISCISSORS_TOOL, + selection_options_new, + FALSE, + "gimp:iscissors_tool", + _("Intelligent Scissors"), + _("Select shapes from image"), + N_("/Tools/Selection Tools/Intelligent Scissors"), + "I", + NULL, "tools/iscissors.html", + GIMP_STOCK_TOOL_ISCISSORS); } GType @@ -342,14 +331,6 @@ gimp_iscissors_tool_init (GimpIscissorsTool *iscissors) GimpTool *tool; tool = GIMP_TOOL (iscissors); - - if (! iscissors_options) - { - iscissors_options = iscissors_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_ISCISSORS_TOOL, - (GimpToolOptions *) iscissors_options); - } iscissors->op = -1; iscissors->curves = NULL; @@ -378,21 +359,6 @@ gimp_iscissors_tool_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static IScissorsOptions * -iscissors_options_new (void) -{ - IScissorsOptions *options; - - /* the new intelligent scissors tool options structure */ - options = g_new0 (IScissorsOptions, 1); - - selection_options_init ((SelectionOptions *) options, - GIMP_TYPE_ISCISSORS_TOOL, - selection_options_reset); - - return options; -} - static void gimp_iscissors_tool_control (GimpTool *tool, ToolAction action, diff --git a/app/tools/gimpiscissorstool.h b/app/tools/gimpiscissorstool.h index 454017dccf..05c3c98e34 100644 --- a/app/tools/gimpiscissorstool.h +++ b/app/tools/gimpiscissorstool.h @@ -94,7 +94,8 @@ struct _GimpIscissorsToolClass }; -void gimp_iscissors_tool_register (Gimp *gimp); +void gimp_iscissors_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_iscissors_tool_get_type (void); diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index 1de13871ec..1f0f102b9e 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -46,7 +46,6 @@ #include "gimplevelstool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -183,35 +182,33 @@ static gboolean levels_read_from_file (FILE *f); static void levels_write_to_file (FILE *f); -/* the levels tool options */ -static GimpToolOptions *levels_options = NULL; - -/* the levels tool dialog */ -static LevelsDialog *levels_dialog = NULL; - -static GimpImageMapToolClass *parent_class = NULL; - /* the levels file dialog */ static GtkWidget *file_dlg = NULL; static gboolean load_save; static GtkWidget *color_option_items[5]; +static LevelsDialog *levels_dialog = NULL; + +static GimpImageMapToolClass *parent_class = NULL; + /* functions */ void -gimp_levels_tool_register (Gimp *gimp) +gimp_levels_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_LEVELS_TOOL, - FALSE, - "gimp:levels_tool", - _("Levels"), - _("Adjust color levels"), - N_("/Image/Colors/Levels..."), NULL, - NULL, "tools/levels.html", - GIMP_STOCK_TOOL_LEVELS); + (* callback) (gimp, + GIMP_TYPE_LEVELS_TOOL, + NULL, + FALSE, + "gimp:levels_tool", + _("Levels"), + _("Adjust color levels"), + N_("/Image/Colors/Levels..."), NULL, + NULL, "tools/levels.html", + GIMP_STOCK_TOOL_LEVELS); } GType @@ -258,17 +255,6 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass) static void gimp_levels_tool_init (GimpLevelsTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! levels_options) - { - levels_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_LEVELS_TOOL, - (GimpToolOptions *) levels_options); - } } static void diff --git a/app/tools/gimplevelstool.h b/app/tools/gimplevelstool.h index 9bbedbd109..4b9cc3cf58 100644 --- a/app/tools/gimplevelstool.h +++ b/app/tools/gimplevelstool.h @@ -45,7 +45,8 @@ struct _GimpLevelsToolClass }; -void gimp_levels_tool_register (Gimp *gimp); +void gimp_levels_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_levels_tool_get_type (void); diff --git a/app/tools/gimpmagnifytool.c b/app/tools/gimpmagnifytool.c index ae90384c4c..99bf176d17 100644 --- a/app/tools/gimpmagnifytool.c +++ b/app/tools/gimpmagnifytool.c @@ -35,7 +35,6 @@ #include "gimpmagnifytool.h" #include "tool_options.h" -#include "tool_manager.h" #include "gimprc.h" @@ -96,29 +95,29 @@ static void zoom_out (gint *src, gint *dest, gint scale); -static MagnifyOptions * magnify_options_new (void); -static void magnify_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * magnify_options_new (GimpToolInfo *tool_info); +static void magnify_options_reset (GimpToolOptions *tool_options); -static MagnifyOptions *magnify_options = NULL; - static GimpDrawToolClass *parent_class = NULL; /* public functions */ void -gimp_magnify_tool_register (Gimp *gimp) +gimp_magnify_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_MAGNIFY_TOOL, - FALSE, - "gimp:magnify_tool", - _("Magnify"), - _("Zoom in & out"), - N_("/Tools/Magnify"), NULL, - NULL, "tools/magnify.html", - GIMP_STOCK_TOOL_ZOOM); + (* callback) (gimp, + GIMP_TYPE_MAGNIFY_TOOL, + magnify_options_new, + FALSE, + "gimp:magnify_tool", + _("Magnify"), + _("Zoom in & out"), + N_("/Tools/Magnify"), NULL, + NULL, "tools/magnify.html", + GIMP_STOCK_TOOL_ZOOM); } GType @@ -179,14 +178,6 @@ gimp_magnify_tool_init (GimpMagnifyTool *magnify_tool) tool = GIMP_TOOL (magnify_tool); - if (! magnify_options) - { - magnify_options = magnify_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_MAGNIFY_TOOL, - (GimpToolOptions *) magnify_options); - } - magnify_tool->x = 0; magnify_tool->y = 0; magnify_tool->w = 0; @@ -442,19 +433,18 @@ zoom_out (gint *src, /* magnify tool options functions */ -static MagnifyOptions * -magnify_options_new (void) +static GimpToolOptions * +magnify_options_new (GimpToolInfo *tool_info) { MagnifyOptions *options; + GtkWidget *vbox; + GtkWidget *frame; - GtkWidget *vbox; - GtkWidget *frame; - - /* the new magnify tool options structure */ options = g_new0 (MagnifyOptions, 1); - tool_options_init ((GimpToolOptions *) options, - magnify_options_reset); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = magnify_options_reset; options->allow_resize_d = gimprc.resize_windows_on_zoom; options->type_d = options->type = GIMP_ZOOM_IN; @@ -491,7 +481,7 @@ magnify_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpmagnifytool.h b/app/tools/gimpmagnifytool.h index 4a5ead1377..a658e8e650 100644 --- a/app/tools/gimpmagnifytool.h +++ b/app/tools/gimpmagnifytool.h @@ -50,7 +50,8 @@ struct _GimpMagnifyToolClass }; -void gimp_magnify_tool_register (Gimp *gimp); +void gimp_magnify_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_magnify_tool_get_type (void); diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index 50d3ba415a..e796174fa8 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -41,7 +41,6 @@ #include "gui/info-dialog.h" -#include "gimpdrawtool.h" #include "gimpmeasuretool.h" #include "tool_manager.h" #include "tool_options.h" @@ -108,14 +107,14 @@ static gdouble measure_get_angle (gint dx, gint dy, gdouble xres, gdouble yres); -static MeasureOptions * measure_tool_options_new (void); -static void measure_tool_options_reset (GimpToolOptions *tool_options); + static void measure_tool_info_window_close_callback (GtkWidget *widget, gpointer data); static void measure_tool_info_update (void); +static GimpToolOptions * measure_tool_options_new (GimpToolInfo *tool_info); +static void measure_tool_options_reset (GimpToolOptions *tool_options); -static MeasureOptions *measure_tool_options = NULL; /* the measure tool info window */ static InfoDialog *measure_tool_info = NULL; @@ -126,17 +125,19 @@ static GimpDrawToolClass *parent_class = NULL; void -gimp_measure_tool_register (Gimp *gimp) +gimp_measure_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_MEASURE_TOOL, - FALSE, - "gimp:measure_tool", - _("Measure Tool"), - _("Measure angles and lengths"), - N_("/Tools/Measure"), NULL, - NULL, "tools/measure.html", - GIMP_STOCK_TOOL_MEASURE); + (* callback) (gimp, + GIMP_TYPE_MEASURE_TOOL, + measure_tool_options_new, + FALSE, + "gimp:measure_tool", + _("Measure Tool"), + _("Measure angles and lengths"), + N_("/Tools/Measure"), NULL, + NULL, "tools/measure.html", + GIMP_STOCK_TOOL_MEASURE); } GType @@ -193,15 +194,6 @@ gimp_measure_tool_init (GimpMeasureTool *measure_tool) GimpTool *tool; tool = GIMP_TOOL (measure_tool); - - /* The tool options */ - if (! measure_tool_options) - { - measure_tool_options = measure_tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_MEASURE_TOOL, - (GimpToolOptions *) measure_tool_options); - } tool->tool_cursor = GIMP_MEASURE_TOOL_CURSOR; @@ -846,48 +838,6 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) } } -static void -measure_tool_options_reset (GimpToolOptions *tool_options) -{ - MeasureOptions *options; - - options = (MeasureOptions *) tool_options; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_info_window_w), - options->use_info_window_d); -} - -static MeasureOptions * -measure_tool_options_new (void) -{ - MeasureOptions *options; - GtkWidget *vbox; - - options = g_new0 (MeasureOptions, 1); - tool_options_init ((GimpToolOptions *) options, - measure_tool_options_reset); - - options->use_info_window = options->use_info_window_d = FALSE; - - /* the main vbox */ - vbox = options->tool_options.main_vbox; - - /* the use_info_window toggle button */ - options->use_info_window_w = - gtk_check_button_new_with_label (_("Use Info Window")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_info_window_w), - options->use_info_window_d); - gtk_box_pack_start (GTK_BOX (vbox), options->use_info_window_w, - FALSE, FALSE, 0); - gtk_widget_show (options->use_info_window_w); - - g_signal_connect (G_OBJECT (options->use_info_window_w), "toggled", - G_CALLBACK (gimp_toggle_button_update), - &options->use_info_window); - - return options; -} - static gdouble measure_get_angle (gint dx, gint dy, @@ -933,3 +883,47 @@ measure_tool_info_window_close_callback (GtkWidget *widget, info_dialog_free (measure_tool_info); measure_tool_info = NULL; } + +static GimpToolOptions * +measure_tool_options_new (GimpToolInfo *tool_info) +{ + MeasureOptions *options; + GtkWidget *vbox; + + options = g_new0 (MeasureOptions, 1); + + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = measure_tool_options_reset; + + options->use_info_window = options->use_info_window_d = FALSE; + + /* the main vbox */ + vbox = options->tool_options.main_vbox; + + /* the use_info_window toggle button */ + options->use_info_window_w = + gtk_check_button_new_with_label (_("Use Info Window")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_info_window_w), + options->use_info_window_d); + gtk_box_pack_start (GTK_BOX (vbox), options->use_info_window_w, + FALSE, FALSE, 0); + gtk_widget_show (options->use_info_window_w); + + g_signal_connect (G_OBJECT (options->use_info_window_w), "toggled", + G_CALLBACK (gimp_toggle_button_update), + &options->use_info_window); + + return (GimpToolOptions *) options; +} + +static void +measure_tool_options_reset (GimpToolOptions *tool_options) +{ + MeasureOptions *options; + + options = (MeasureOptions *) tool_options; + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_info_window_w), + options->use_info_window_d); +} diff --git a/app/tools/gimpmeasuretool.h b/app/tools/gimpmeasuretool.h index 9727336ba1..69a4c7a839 100644 --- a/app/tools/gimpmeasuretool.h +++ b/app/tools/gimpmeasuretool.h @@ -68,7 +68,8 @@ struct _GimpMeasureToolClass }; -void gimp_measure_tool_register (Gimp *gimp); +void gimp_measure_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_measure_tool_get_type (void); diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index e998bb9e1a..6a12119b54 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -36,8 +36,6 @@ #include "gimpeditselectiontool.h" #include "gimpmovetool.h" -#include "tool_manager.h" -#include "tool_options.h" #include "colormaps.h" #include "floating_sel.h" @@ -75,23 +73,23 @@ static void gimp_move_tool_cursor_update (GimpTool *tool, static void gimp_move_tool_draw (GimpDrawTool *draw_tool); -static GimpToolOptions *move_options = NULL; - static GimpDrawToolClass *parent_class = NULL; void -gimp_move_tool_register (Gimp *gimp) +gimp_move_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_MOVE_TOOL, - FALSE, - "gimp:move_tool", - _("Move Tool"), - _("Move layers & selections"), - N_("/Tools/Transform Tools/Move"), "M", - NULL, "tools/move.html", - GIMP_STOCK_TOOL_MOVE); + (* callback) (gimp, + GIMP_TYPE_MOVE_TOOL, + NULL, + FALSE, + "gimp:move_tool", + _("Move Tool"), + _("Move layers & selections"), + N_("/Tools/Transform Tools/Move"), "M", + NULL, "tools/move.html", + GIMP_STOCK_TOOL_MOVE); } GType @@ -150,15 +148,6 @@ gimp_move_tool_init (GimpMoveTool *move_tool) tool = GIMP_TOOL (move_tool); - /* The tool options */ - if (! move_options) - { - move_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_MOVE_TOOL, - (GimpToolOptions *) move_options); - } - move_tool->layer = NULL; move_tool->guide = NULL; move_tool->disp = NULL; diff --git a/app/tools/gimpmovetool.h b/app/tools/gimpmovetool.h index bd29f60e92..aa36868410 100644 --- a/app/tools/gimpmovetool.h +++ b/app/tools/gimpmovetool.h @@ -49,9 +49,11 @@ struct _GimpMoveToolClass }; -void gimp_move_tool_register (Gimp *gimp); +void gimp_move_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_move_tool_get_type (void); -GType gimp_move_tool_get_type (void); void gimp_move_tool_start_hguide (GimpTool *tool, GimpDisplay *gdisp); diff --git a/app/tools/gimppaintbrushtool.c b/app/tools/gimppaintbrushtool.c index 1973beb479..c203e292ac 100644 --- a/app/tools/gimppaintbrushtool.c +++ b/app/tools/gimppaintbrushtool.c @@ -37,10 +37,10 @@ #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimppaintbrushtool.h" #include "paint_options.h" -#include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -69,25 +69,25 @@ static void gimp_paintbrush_tool_motion (GimpPaintTool *paint_tool, /* local variables */ static gboolean non_gui_incremental = PAINTBRUSH_DEFAULT_INCREMENTAL; -static PaintOptions *paintbrush_options = NULL; - static GimpPaintToolClass *parent_class = NULL; -/* functions */ +/* public functions */ void -gimp_paintbrush_tool_register (Gimp *gimp) +gimp_paintbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_PAINTBRUSH_TOOL, - TRUE, - "gimp:paintbrush_tool", - _("Paintbrush"), - _("Paint fuzzy brush strokes"), - N_("/Tools/Paint Tools/Paintbrush"), "P", - NULL, "tools/paintbrush.html", - GIMP_STOCK_TOOL_PAINTBRUSH); + (* callback) (gimp, + GIMP_TYPE_PAINTBRUSH_TOOL, + paint_options_new, + TRUE, + "gimp:paintbrush_tool", + _("Paintbrush"), + _("Paint fuzzy brush strokes"), + N_("/Tools/Paint Tools/Paintbrush"), "P", + NULL, "tools/paintbrush.html", + GIMP_STOCK_TOOL_PAINTBRUSH); } GType @@ -118,6 +118,9 @@ gimp_paintbrush_tool_get_type (void) return tool_type; } + +/* private functions */ + static void gimp_paintbrush_tool_class_init (GimpPaintbrushToolClass *klass) { @@ -139,15 +142,6 @@ gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush) tool = GIMP_TOOL (paintbrush); paint_tool = GIMP_PAINT_TOOL (paintbrush); - if (! paintbrush_options) - { - paintbrush_options = paint_options_new (GIMP_TYPE_PAINTBRUSH_TOOL, - paint_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_PAINTBRUSH_TOOL, - (GimpToolOptions *) paintbrush_options); - } - tool->tool_cursor = GIMP_PAINTBRUSH_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -159,6 +153,7 @@ gimp_paintbrush_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + PaintOptions *paint_options; PaintPressureOptions *pressure_options; PaintGradientOptions *gradient_options; gboolean incremental; @@ -174,11 +169,13 @@ gimp_paintbrush_tool_paint (GimpPaintTool *paint_tool, if (! gimage) return; - if (paintbrush_options) + paint_options = (PaintOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (paint_options) { - pressure_options = paintbrush_options->pressure_options; - gradient_options = paintbrush_options->gradient_options; - incremental = paintbrush_options->incremental; + pressure_options = paint_options->pressure_options; + gradient_options = paint_options->gradient_options; + incremental = paint_options->incremental; } else { diff --git a/app/tools/gimppaintbrushtool.h b/app/tools/gimppaintbrushtool.h index 8b5e441bfd..c53eb3ec30 100644 --- a/app/tools/gimppaintbrushtool.h +++ b/app/tools/gimppaintbrushtool.h @@ -45,9 +45,11 @@ struct _GimpPaintbrushToolClass }; -void gimp_paintbrush_tool_register (Gimp *gimp); +void gimp_paintbrush_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_paintbrush_tool_get_type (void); -GType gimp_paintbrush_tool_get_type (void); gboolean gimp_paintbrush_tool_non_gui (GimpDrawable *drawable, gint num_srokes, diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c index 3ac666781b..78dfe94aca 100644 --- a/app/tools/gimppaintoptions-gui.c +++ b/app/tools/gimppaintoptions-gui.c @@ -118,26 +118,17 @@ static GSList *paint_options_list = NULL; void -paint_options_init (PaintOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func) +paint_options_init (PaintOptions *options, + GimpToolInfo *tool_info) { - GimpToolInfo *tool_info; - GtkWidget *vbox; - GtkWidget *table; - GtkWidget *scale; - - tool_info = tool_manager_get_info_by_type (the_gimp, tool_type); - - if (! tool_info) - { - g_warning ("%s(): no tool info registered for %s", - G_GNUC_FUNCTION, g_type_name (tool_type)); - } + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *scale; /* initialize the tool options structure */ - tool_options_init ((GimpToolOptions *) options, - reset_func); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = paint_options_reset; /* initialize the paint options structure */ options->global = NULL; @@ -180,13 +171,13 @@ paint_options_init (PaintOptions *options, options->opacity_w); /* the paint mode menu */ - if (tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || - tool_type == GIMP_TYPE_BLEND_TOOL || - tool_type == GIMP_TYPE_PENCIL_TOOL || - tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || - tool_type == GIMP_TYPE_AIRBRUSH_TOOL || - tool_type == GIMP_TYPE_CLONE_TOOL || - tool_type == GIMP_TYPE_INK_TOOL) + if (tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || + tool_info->tool_type == GIMP_TYPE_BLEND_TOOL || + tool_info->tool_type == GIMP_TYPE_PENCIL_TOOL || + tool_info->tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_AIRBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_CLONE_TOOL || + tool_info->tool_type == GIMP_TYPE_INK_TOOL) { gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); @@ -208,8 +199,8 @@ paint_options_init (PaintOptions *options, gtk_widget_show (table); /* a separator after the common paint options which can be global */ - if (tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || - tool_type == GIMP_TYPE_BLEND_TOOL) + if (tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || + tool_info->tool_type == GIMP_TYPE_BLEND_TOOL) { GtkWidget *separator; @@ -222,10 +213,10 @@ paint_options_init (PaintOptions *options, gtk_widget_show (vbox); /* the "incremental" toggle */ - if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL || - tool_type == GIMP_TYPE_ERASER_TOOL || - tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || - tool_type == GIMP_TYPE_PENCIL_TOOL) + if (tool_info->tool_type == GIMP_TYPE_AIRBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_ERASER_TOOL || + tool_info->tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_PENCIL_TOOL) { options->incremental_w = gtk_check_button_new_with_label (_("Incremental")); @@ -239,7 +230,8 @@ paint_options_init (PaintOptions *options, gtk_widget_show (options->incremental_w); } - options->pressure_options = paint_pressure_options_new (tool_type, options); + options->pressure_options = paint_pressure_options_new (tool_info->tool_type, + options); if (options->pressure_options->frame) { @@ -248,7 +240,8 @@ paint_options_init (PaintOptions *options, gtk_widget_show (options->pressure_options->frame); } - options->gradient_options = paint_gradient_options_new (tool_type, options); + options->gradient_options = paint_gradient_options_new (tool_info->tool_type, + options); if (options->gradient_options->frame) { @@ -261,19 +254,19 @@ paint_options_init (PaintOptions *options, paint_options_list = g_slist_prepend (paint_options_list, options); } -PaintOptions * -paint_options_new (GType tool_type, - ToolOptionsResetFunc reset_func) +GimpToolOptions * +paint_options_new (GimpToolInfo *tool_info) { PaintOptions *options; - options = g_new (PaintOptions, 1); - paint_options_init (options, tool_type, reset_func); + options = g_new0 (PaintOptions, 1); + + paint_options_init (options, tool_info); if (gimprc.global_paint_options && options->global) gtk_widget_show (options->global); - return options; + return (GimpToolOptions *) options; } void diff --git a/app/tools/gimppaintoptions-gui.h b/app/tools/gimppaintoptions-gui.h index bc22ae512d..f9b3d508c1 100644 --- a/app/tools/gimppaintoptions-gui.h +++ b/app/tools/gimppaintoptions-gui.h @@ -130,22 +130,20 @@ extern PaintGradientOptions non_gui_gradient_options; /* paint tool options functions */ -PaintOptions * paint_options_new (GType tool_type, - ToolOptionsResetFunc reset_func); +GimpToolOptions * paint_options_new (GimpToolInfo *tool_info); -void paint_options_reset (GimpToolOptions *tool_options); +void paint_options_reset (GimpToolOptions *tool_options); /* to be used by "derived" paint options only */ -void paint_options_init (PaintOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func); +void paint_options_init (PaintOptions *options, + GimpToolInfo *tool_info); /* functions for the global paint options */ /* switch between global and per-tool paint options */ -void paint_options_set_global (gboolean global); +void paint_options_set_global (gboolean global); #endif /* __PAINT_OPTIONS_H__ */ diff --git a/app/tools/gimppathtool.c b/app/tools/gimppathtool.c index fa0cc97d7b..53b6daa231 100644 --- a/app/tools/gimppathtool.c +++ b/app/tools/gimppathtool.c @@ -31,10 +31,7 @@ #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" -#include "gimpdrawtool.h" #include "gimppathtool.h" -#include "tool_manager.h" -#include "tool_options.h" #include "path_tool.h" #include "gimprc.h" @@ -107,21 +104,21 @@ static void gimp_path_tool_draw (GimpDrawTool *draw_tool); static GimpDrawToolClass *parent_class = NULL; -static GimpToolOptions *path_options = NULL; - void -gimp_path_tool_register (Gimp *gimp) +gimp_path_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_PATH_TOOL, - FALSE, - "gimp:path_tool", - _("Path Tool"), - _("Path tool prototype"), - N_("/Tools/Path"), NULL, - NULL, "tools/path.html", - GIMP_STOCK_TOOL_PATH); + (* callback) (gimp, + GIMP_TYPE_PATH_TOOL, + NULL, + FALSE, + "gimp:path_tool", + _("Path Tool"), + _("Path tool prototype"), + N_("/Tools/Path"), NULL, + NULL, "tools/path.html", + GIMP_STOCK_TOOL_PATH); } GType @@ -182,18 +179,6 @@ gimp_path_tool_init (GimpPathTool *path_tool) GimpTool *tool; tool = GIMP_TOOL (path_tool); - - /* The tool options */ - if (! path_options) - { - path_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_PATH_TOOL, - (GimpToolOptions *) path_options); - } - - - tool->preserve = TRUE; /* Preserve on drawable change */ path_tool->click_type = ON_CANVAS; path_tool->click_x = 0; @@ -210,17 +195,18 @@ gimp_path_tool_init (GimpPathTool *path_tool) path_tool->state = 0; path_tool->draw = PATH_TOOL_REDRAW_ALL; - path_tool->cur_path = g_new0(NPath, 1); + path_tool->cur_path = g_new0 (NPath, 1); path_tool->scanlines = NULL; /* Initial Path */ path_tool->cur_path->curves = NULL; path_tool->cur_path->cur_curve = NULL; - path_tool->cur_path->name = g_string_new("Path 0"); + path_tool->cur_path->name = g_string_new ("Path 0"); path_tool->cur_path->state = 0; /* path_tool->cur_path->path_tool = path_tool; */ + tool->preserve = TRUE; /* Preserve on drawable change */ } static void diff --git a/app/tools/gimppathtool.h b/app/tools/gimppathtool.h index 86968f30ec..5a1ce85cf9 100644 --- a/app/tools/gimppathtool.h +++ b/app/tools/gimppathtool.h @@ -70,7 +70,8 @@ struct _GimpPathToolClass }; -void gimp_path_tool_register (Gimp *gimp); +void gimp_path_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_path_tool_get_type (void); diff --git a/app/tools/gimppenciltool.c b/app/tools/gimppenciltool.c index aabc5fe1b3..af8c70b7dd 100644 --- a/app/tools/gimppenciltool.c +++ b/app/tools/gimppenciltool.c @@ -35,12 +35,10 @@ #include "core/gimpdrawable.h" #include "core/gimpgradient.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimppenciltool.h" -#include "gimppainttool.h" #include "paint_options.h" -#include "tool_options.h" -#include "tool_manager.h" #include "libgimp/gimpintl.h" @@ -63,25 +61,25 @@ static void gimp_pencil_tool_motion (GimpPaintTool *paint_tool, /* private variables */ static gboolean non_gui_incremental = PENCIL_INCREMENTAL_DEFAULT; -static PaintOptions *pencil_options = NULL; - static GimpPaintToolClass *parent_class = NULL; /* functions */ void -gimp_pencil_tool_register (Gimp *gimp) +gimp_pencil_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_PENCIL_TOOL, - TRUE, - "gimp:pencil_tool", - _("Pencil"), - _("Paint hard edged pixels"), - N_("/Tools/Paint Tools/Pencil"), "P", - NULL, "tools/pencil.html", - GIMP_STOCK_TOOL_PENCIL); + (* callback) (gimp, + GIMP_TYPE_PENCIL_TOOL, + paint_options_new, + TRUE, + "gimp:pencil_tool", + _("Pencil"), + _("Paint hard edged pixels"), + N_("/Tools/Paint Tools/Pencil"), "P", + NULL, "tools/pencil.html", + GIMP_STOCK_TOOL_PENCIL); } GType @@ -133,19 +131,10 @@ gimp_pencil_tool_init (GimpPencilTool *pencil) tool = GIMP_TOOL (pencil); paint_tool = GIMP_PAINT_TOOL (pencil); - if (! pencil_options) - { - pencil_options = paint_options_new (GIMP_TYPE_PENCIL_TOOL, - paint_options_reset); + tool->tool_cursor = GIMP_PENCIL_TOOL_CURSOR; - tool_manager_register_tool_options (GIMP_TYPE_PENCIL_TOOL, - (GimpToolOptions *) pencil_options); - } - - tool->tool_cursor = GIMP_PENCIL_TOOL_CURSOR; - - paint_tool->pick_colors = TRUE; - paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; + paint_tool->pick_colors = TRUE; + paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; } static void @@ -153,13 +142,16 @@ gimp_pencil_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + PaintOptions *paint_options; PaintPressureOptions *pressure_options; gboolean incremental; - if (pencil_options) + paint_options = (PaintOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + + if (paint_options) { - pressure_options = pencil_options->pressure_options; - incremental = pencil_options->incremental; + pressure_options = paint_options->pressure_options; + incremental = paint_options->incremental; } else { diff --git a/app/tools/gimppenciltool.h b/app/tools/gimppenciltool.h index f4fd946169..b3f00f5da9 100644 --- a/app/tools/gimppenciltool.h +++ b/app/tools/gimppenciltool.h @@ -48,14 +48,15 @@ struct _GimpPencilToolClass }; -void gimp_pencil_tool_register (Gimp *gimp); +void gimp_pencil_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); + +GType gimp_pencil_tool_get_type (void); -GType gimp_pencil_tool_get_type (void); /* FIXME: Get rid of this non_gui stuff someday. Preferably make * everything use it interally for ease of macro recording. */ - gboolean pencil_non_gui (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array); diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c index 7815ef9ab9..6ccc202bde 100644 --- a/app/tools/gimpperspectivetool.c +++ b/app/tools/gimpperspectivetool.c @@ -36,7 +36,6 @@ #include "gui/info-dialog.h" #include "gimpperspectivetool.h" -#include "tool_manager.h" #include "transform_options.h" #include "libgimp/gimpintl.h" @@ -63,23 +62,23 @@ static gchar matrix_row_buf [3][MAX_INFO_BUF]; static GimpTransformToolClass *parent_class = NULL; -static TransformOptions *perspective_options = NULL; - /* public functions */ void -gimp_perspective_tool_register (Gimp *gimp) +gimp_perspective_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_PERSPECTIVE_TOOL, - FALSE, - "gimp:perspective_tool", - _("Perspective Tool"), - _("Change perspective of the layer or selection"), - N_("/Tools/Transform Tools/Perspective"), "P", - NULL, "tools/perspective.html", - GIMP_STOCK_TOOL_PERSPECTIVE); + (* callback) (gimp, + GIMP_TYPE_PERSPECTIVE_TOOL, + transform_options_new, + FALSE, + "gimp:perspective_tool", + _("Perspective Tool"), + _("Change perspective of the layer or selection"), + N_("/Tools/Transform Tools/Perspective"), "P", + NULL, "tools/perspective.html", + GIMP_STOCK_TOOL_PERSPECTIVE); } GType @@ -125,20 +124,9 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass) static void gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool) { - GimpTool *tool; - GimpTransformTool *transform_tool; + GimpTool *tool; - tool = GIMP_TOOL (perspective_tool); - transform_tool = GIMP_TRANSFORM_TOOL (perspective_tool); - - if (! perspective_options) - { - perspective_options = transform_options_new (GIMP_TYPE_PERSPECTIVE_TOOL, - transform_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_PERSPECTIVE_TOOL, - (GimpToolOptions *) perspective_options); - } + tool = GIMP_TOOL (perspective_tool); tool->tool_cursor = GIMP_PERSPECTIVE_TOOL_CURSOR; } diff --git a/app/tools/gimpperspectivetool.h b/app/tools/gimpperspectivetool.h index d1bc5fe8f6..f766201716 100644 --- a/app/tools/gimpperspectivetool.h +++ b/app/tools/gimpperspectivetool.h @@ -45,7 +45,8 @@ struct _GimpPerspectiveToolClass }; -void gimp_perspective_tool_register (Gimp *gimp); +void gimp_perspective_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_perspective_tool_get_type (void); diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index 81ab4924b0..3fa35988bd 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -35,7 +35,6 @@ #include "gimpposterizetool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -89,10 +88,6 @@ static void posterize_levels_adjustment_update (GtkAdjustment *adjustment, gpointer data); -/* the posterize tool options */ -static GimpToolOptions *posterize_options = NULL; - -/* the posterize tool dialog */ static PosterizeDialog *posterize_dialog = NULL; static GimpImageMapToolClass *parent_class = NULL; @@ -101,17 +96,19 @@ static GimpImageMapToolClass *parent_class = NULL; /* functions */ void -gimp_posterize_tool_register (Gimp *gimp) +gimp_posterize_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_POSTERIZE_TOOL, - FALSE, - "gimp:posterize_tool", - _("Posterize"), - _("Reduce image to a fixed numer of colors"), - N_("/Image/Colors/Posterize..."), NULL, - NULL, "tools/posterize.html", - GIMP_STOCK_TOOL_POSTERIZE); + (* callback) (gimp, + GIMP_TYPE_POSTERIZE_TOOL, + NULL, + FALSE, + "gimp:posterize_tool", + _("Posterize"), + _("Reduce image to a fixed numer of colors"), + N_("/Image/Colors/Posterize..."), NULL, + NULL, "tools/posterize.html", + GIMP_STOCK_TOOL_POSTERIZE); } GType @@ -158,17 +155,6 @@ gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass) static void gimp_posterize_tool_init (GimpPosterizeTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! posterize_options) - { - posterize_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_POSTERIZE_TOOL, - (GimpToolOptions *) posterize_options); - } } static void diff --git a/app/tools/gimpposterizetool.h b/app/tools/gimpposterizetool.h index 79ef221156..a973bd5810 100644 --- a/app/tools/gimpposterizetool.h +++ b/app/tools/gimpposterizetool.h @@ -45,7 +45,8 @@ struct _GimpPosterizeToolClass }; -void gimp_posterize_tool_register (Gimp *gimp); +void gimp_posterize_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_posterize_tool_get_type (void); diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index a918a7d3ee..7d634c185b 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -43,7 +43,6 @@ #include "gimpeditselectiontool.h" #include "gimprectselecttool.h" #include "selection_options.h" -#include "tool_manager.h" #include "floating_sel.h" @@ -83,23 +82,23 @@ static void gimp_rect_select_tool_real_rect_select (GimpRectSelectTool *rect_t static GimpSelectionToolClass *parent_class = NULL; -static SelectionOptions *rect_options = NULL; - /* public functions */ void -gimp_rect_select_tool_register (Gimp *gimp) +gimp_rect_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_RECT_SELECT_TOOL, - FALSE, - "gimp:rect_select_tool", - _("Rect Select"), - _("Select rectangular regions"), - _("/Tools/Selection Tools/Rect Select"), "R", - NULL, "tools/rect_select.html", - GIMP_STOCK_TOOL_RECT_SELECT); + (* callback) (gimp, + GIMP_TYPE_RECT_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:rect_select_tool", + _("Rect Select"), + _("Select rectangular regions"), + _("/Tools/Selection Tools/Rect Select"), "R", + NULL, "tools/rect_select.html", + GIMP_STOCK_TOOL_RECT_SELECT); } GType @@ -156,20 +155,9 @@ gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass) static void gimp_rect_select_tool_init (GimpRectSelectTool *rect_select) { - GimpTool *tool; - GimpSelectionTool *select_tool; + GimpTool *tool; - tool = GIMP_TOOL (rect_select); - select_tool = GIMP_SELECTION_TOOL (rect_select); - - if (! rect_options) - { - rect_options = selection_options_new (GIMP_TYPE_RECT_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_RECT_SELECT_TOOL, - (GimpToolOptions *) rect_options); - } + tool = GIMP_TOOL (rect_select); tool->tool_cursor = GIMP_RECT_SELECT_TOOL_CURSOR; diff --git a/app/tools/gimprectselecttool.h b/app/tools/gimprectselecttool.h index 791dd80e75..4a8d0b21d9 100644 --- a/app/tools/gimprectselecttool.h +++ b/app/tools/gimprectselecttool.h @@ -64,15 +64,16 @@ struct _GimpRectSelectToolClass }; -void gimp_rect_select_tool_register (Gimp *gimp); +void gimp_rect_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_rect_select_tool_get_type (void); -void gimp_rect_select_tool_rect_select (GimpRectSelectTool *rect_tool, - gint x, - gint y, - gint w, - gint h); +void gimp_rect_select_tool_rect_select (GimpRectSelectTool *rect_tool, + gint x, + gint y, + gint w, + gint h); #endif /* __GIMP_RECT_SELECT_TOOL_H__ */ diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index 3e7d6aad98..417fbde164 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -49,7 +49,6 @@ #include "gimpeditselectiontool.h" #include "gimpfuzzyselecttool.h" #include "selection_options.h" -#include "tool_manager.h" #include "gimprc.h" @@ -84,30 +83,29 @@ static GdkSegment * fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, gint *nsegs); -static GimpSelectionToolClass *parent_class = NULL; - -/* the fuzzy selection tool options */ -static SelectionOptions *fuzzy_options = NULL; - /* XSegments which make up the fuzzy selection boundary */ static GdkSegment *segs = NULL; static gint num_segs = 0; +static GimpSelectionToolClass *parent_class = NULL; + /* public functions */ void -gimp_fuzzy_select_tool_register (Gimp *gimp) +gimp_fuzzy_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_FUZZY_SELECT_TOOL, - FALSE, - "gimp:fuzzy_select_tool", - _("Fuzzy Select"), - _("Select contiguous regions"), - _("/Tools/Selection Tools/Fuzzy Select"), "Z", - NULL, "tools/fuzzy_select.html", - GIMP_STOCK_TOOL_FUZZY_SELECT); + (* callback) (gimp, + GIMP_TYPE_FUZZY_SELECT_TOOL, + selection_options_new, + FALSE, + "gimp:fuzzy_select_tool", + _("Fuzzy Select"), + _("Select contiguous regions"), + _("/Tools/Selection Tools/Fuzzy Select"), "Z", + NULL, "tools/fuzzy_select.html", + GIMP_STOCK_TOOL_FUZZY_SELECT); } GType @@ -172,15 +170,6 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select) tool = GIMP_TOOL (fuzzy_select); select_tool = GIMP_SELECTION_TOOL (fuzzy_select); - if (! fuzzy_options) - { - fuzzy_options = selection_options_new (GIMP_TYPE_FUZZY_SELECT_TOOL, - selection_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_FUZZY_SELECT_TOOL, - (GimpToolOptions *) fuzzy_options); - } - tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR; tool->scroll_lock = TRUE; /* Do not allow scrolling */ diff --git a/app/tools/gimpregionselecttool.h b/app/tools/gimpregionselecttool.h index 2daf916677..73a5c1fee9 100644 --- a/app/tools/gimpregionselecttool.h +++ b/app/tools/gimpregionselecttool.h @@ -52,7 +52,8 @@ struct _GimpFuzzySelectToolClass }; -void gimp_fuzzy_select_tool_register (Gimp *gimp); +void gimp_fuzzy_select_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_fuzzy_select_tool_get_type (void); diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 3f670f6462..6e41ced515 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -36,7 +36,6 @@ #include "gui/info-dialog.h" #include "gimprotatetool.h" -#include "tool_manager.h" #include "transform_options.h" #include "libgimp/gimpintl.h" @@ -82,23 +81,23 @@ static GtkWidget *sizeentry = NULL; static GimpTransformToolClass *parent_class = NULL; -static TransformOptions *rotate_options = NULL; - /* public functions */ void -gimp_rotate_tool_register (Gimp *gimp) +gimp_rotate_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_ROTATE_TOOL, - FALSE, - "gimp:rotate_tool", - _("Rotate Tool"), - _("Rotate the layer or selection"), - N_("/Tools/Transform Tools/Rotate"), "R", - NULL, "tools/rotate.html", - GIMP_STOCK_TOOL_ROTATE); + (* callback) (gimp, + GIMP_TYPE_ROTATE_TOOL, + transform_options_new, + FALSE, + "gimp:rotate_tool", + _("Rotate Tool"), + _("Rotate the layer or selection"), + N_("/Tools/Transform Tools/Rotate"), "R", + NULL, "tools/rotate.html", + GIMP_STOCK_TOOL_ROTATE); } GType @@ -147,20 +146,9 @@ gimp_rotate_tool_class_init (GimpRotateToolClass *klass) static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool) { - GimpTool *tool; - GimpTransformTool *transform_tool; + GimpTool *tool; - tool = GIMP_TOOL (rotate_tool); - transform_tool = GIMP_TRANSFORM_TOOL (rotate_tool); - - if (! rotate_options) - { - rotate_options = transform_options_new (GIMP_TYPE_ROTATE_TOOL, - transform_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_ROTATE_TOOL, - (GimpToolOptions *) rotate_options); - } + tool = GIMP_TOOL (rotate_tool); tool->tool_cursor = GIMP_ROTATE_TOOL_CURSOR; } diff --git a/app/tools/gimprotatetool.h b/app/tools/gimprotatetool.h index 37d67056ab..4f606c3621 100644 --- a/app/tools/gimprotatetool.h +++ b/app/tools/gimprotatetool.h @@ -45,7 +45,8 @@ struct _GimpRotateToolClass }; -void gimp_rotate_tool_register (Gimp *gimp); +void gimp_rotate_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_rotate_tool_get_type (void); diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index fedcef5bfa..8b88b9199a 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -37,7 +37,6 @@ #include "gui/info-dialog.h" #include "gimpscaletool.h" -#include "tool_manager.h" #include "transform_options.h" #include "libgimp/gimpintl.h" @@ -77,23 +76,23 @@ static GtkWidget *sizeentry = NULL; static GimpTransformToolClass *parent_class = NULL; -static TransformOptions *scale_options = NULL; - /* public functions */ void -gimp_scale_tool_register (Gimp *gimp) +gimp_scale_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_SCALE_TOOL, - FALSE, - "gimp:scale_tool", - _("Scale Tool"), - _("Scale the layer or selection"), - N_("/Tools/Transform Tools/Scale"), "T", - NULL, "tools/transform.html", - GIMP_STOCK_TOOL_SCALE); + (* callback) (gimp, + GIMP_TYPE_SCALE_TOOL, + transform_options_new, + FALSE, + "gimp:scale_tool", + _("Scale Tool"), + _("Scale the layer or selection"), + N_("/Tools/Transform Tools/Scale"), "T", + NULL, "tools/transform.html", + GIMP_STOCK_TOOL_SCALE); } GType @@ -146,20 +145,9 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass) static void gimp_scale_tool_init (GimpScaleTool *scale_tool) { - GimpTool *tool; - GimpTransformTool *transform_tool; + GimpTool *tool; - tool = GIMP_TOOL (scale_tool); - transform_tool = GIMP_TRANSFORM_TOOL (scale_tool); - - if (! scale_options) - { - scale_options = transform_options_new (GIMP_TYPE_SCALE_TOOL, - transform_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_SCALE_TOOL, - (GimpToolOptions *) scale_options); - } + tool = GIMP_TOOL (scale_tool); tool->tool_cursor = GIMP_RESIZE_TOOL_CURSOR; } diff --git a/app/tools/gimpscaletool.h b/app/tools/gimpscaletool.h index 120a7b178c..78d3de5728 100644 --- a/app/tools/gimpscaletool.h +++ b/app/tools/gimpscaletool.h @@ -44,7 +44,8 @@ struct _GimpScaleToolClass }; -void gimp_scale_tool_register (Gimp *gimp); +void gimp_scale_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_scale_tool_get_type (void); diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c index 8f2cbd0b63..61610f043d 100644 --- a/app/tools/gimpselectionoptions.c +++ b/app/tools/gimpselectionoptions.c @@ -42,9 +42,8 @@ void -selection_options_init (SelectionOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func) +selection_options_init (SelectionOptions *options, + GimpToolInfo *tool_info) { GtkWidget *vbox; GtkWidget *abox; @@ -53,8 +52,9 @@ selection_options_init (SelectionOptions *options, GtkWidget *scale; /* initialize the tool options structure */ - tool_options_init ((GimpToolOptions *) options, - reset_func); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = selection_options_reset; /* the main vbox */ vbox = options->tool_options.main_vbox; @@ -135,7 +135,7 @@ selection_options_init (SelectionOptions *options, gtk_widget_show (table); /* the antialias toggle button */ - if (tool_type != GIMP_TYPE_RECT_SELECT_TOOL) + if (tool_info->tool_type != GIMP_TYPE_RECT_SELECT_TOOL) { options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), @@ -150,11 +150,11 @@ selection_options_init (SelectionOptions *options, #if 0 /* a separator between the common and tool-specific selection options */ - if (tool_type == GIMP_TYPE_ISCISSORS_TOOL || - tool_type == GIMP_TYPE_RECT_SELECT_TOOL || - tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL || - tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || - tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) + if (tool_info->tool_type == GIMP_TYPE_ISCISSORS_TOOL || + tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) { GtkWidget *separator; @@ -165,7 +165,7 @@ selection_options_init (SelectionOptions *options, #endif /* selection tool with an interactive boundary that can be toggled */ - if (tool_type == GIMP_TYPE_ISCISSORS_TOOL) + if (tool_info->tool_type == GIMP_TYPE_ISCISSORS_TOOL) { options->interactive_w = gtk_check_button_new_with_label (_("Show Interactive Boundary")); @@ -181,8 +181,8 @@ selection_options_init (SelectionOptions *options, } /* selection tools which operate on colors or contiguous regions */ - if (tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || - tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) + if (tool_info->tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) { GtkWidget *hbox; @@ -223,8 +223,8 @@ selection_options_init (SelectionOptions *options, } /* widgets for fixed size select */ - if (tool_type == GIMP_TYPE_RECT_SELECT_TOOL || - tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL) + if (tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL) { GtkWidget *frame; GtkWidget *vbox2; @@ -346,16 +346,16 @@ selection_options_init (SelectionOptions *options, } } -SelectionOptions * -selection_options_new (GType tool_type, - ToolOptionsResetFunc reset_func) +GimpToolOptions * +selection_options_new (GimpToolInfo *tool_info) { SelectionOptions *options; - options = g_new (SelectionOptions, 1); - selection_options_init (options, tool_type, reset_func); + options = g_new0 (SelectionOptions, 1); - return options; + selection_options_init (options, tool_info); + + return (GimpToolOptions *) options; } void diff --git a/app/tools/gimpselectionoptions.h b/app/tools/gimpselectionoptions.h index 51ee873f06..3817681c92 100644 --- a/app/tools/gimpselectionoptions.h +++ b/app/tools/gimpselectionoptions.h @@ -86,17 +86,15 @@ struct _SelectionOptions /* selection tool options functions */ -SelectionOptions * selection_options_new (GType tool_type, - ToolOptionsResetFunc reset_func); +GimpToolOptions * selection_options_new (GimpToolInfo *tool_info); -void selection_options_reset (GimpToolOptions *tool_options); +void selection_options_reset (GimpToolOptions *tool_options); /* to be used by "derived" selection options only */ -void selection_options_init (SelectionOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func); +void selection_options_init (SelectionOptions *options, + GimpToolInfo *tool_info); #endif /* __SELCTION_OPTIONS_H__ */ diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c index 62c241b871..ddc9ab9cd7 100644 --- a/app/tools/gimpsheartool.c +++ b/app/tools/gimpsheartool.c @@ -38,7 +38,6 @@ #include "gui/info-dialog.h" #include "gimpsheartool.h" -#include "tool_manager.h" #include "transform_options.h" #include "libgimp/gimpintl.h" @@ -80,23 +79,23 @@ static gdouble yshear_val; static GimpTransformToolClass *parent_class = NULL; -static TransformOptions *shear_options = NULL; - /* Public functions */ void -gimp_shear_tool_register (Gimp *gimp) +gimp_shear_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_SHEAR_TOOL, - FALSE, - "gimp:shear_tool", - _("Shear Tool"), - _("Shear the layer or selection"), - N_("/Tools/Transform Tools/Shear"), "F", - NULL, "tools/shear.html", - GIMP_STOCK_TOOL_SHEAR); + (* callback) (gimp, + GIMP_TYPE_SHEAR_TOOL, + transform_options_new, + FALSE, + "gimp:shear_tool", + _("Shear Tool"), + _("Shear the layer or selection"), + N_("/Tools/Transform Tools/Shear"), "F", + NULL, "tools/shear.html", + GIMP_STOCK_TOOL_SHEAR); } GType @@ -142,20 +141,9 @@ gimp_shear_tool_class_init (GimpShearToolClass *klass) static void gimp_shear_tool_init (GimpShearTool *shear_tool) { - GimpTool *tool; - GimpTransformTool *transform_tool; + GimpTool *tool; - tool = GIMP_TOOL (shear_tool); - transform_tool = GIMP_TRANSFORM_TOOL (shear_tool); - - if (! shear_options) - { - shear_options = transform_options_new (GIMP_TYPE_SHEAR_TOOL, - transform_options_reset); - - tool_manager_register_tool_options (GIMP_TYPE_SHEAR_TOOL, - (GimpToolOptions *) shear_options); - } + tool = GIMP_TOOL (shear_tool); tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR; } diff --git a/app/tools/gimpsheartool.h b/app/tools/gimpsheartool.h index c506e971c4..027df2bd5b 100644 --- a/app/tools/gimpsheartool.h +++ b/app/tools/gimpsheartool.h @@ -45,7 +45,8 @@ struct _GimpShearToolClass }; -void gimp_shear_tool_register (Gimp *gimp); +void gimp_shear_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_shear_tool_get_type (void); diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c index 89a28c90f7..d0ecb9def4 100644 --- a/app/tools/gimpsmudgetool.c +++ b/app/tools/gimpsmudgetool.c @@ -41,7 +41,6 @@ #include "gimpsmudgetool.h" #include "paint_options.h" #include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -74,7 +73,7 @@ static void gimp_smudge_tool_paint (GimpPaintTool *paint_tool, static void gimp_smudge_tool_motion (GimpPaintTool *paint_tool, PaintPressureOptions *pressure_options, gdouble smudge_rate, - GimpDrawable *drawable); + GimpDrawable *drawable); static gboolean gimp_smudge_tool_start (GimpPaintTool *paint_tool, GimpDrawable *drawable); static void gimp_smudge_tool_finish (GimpPaintTool *paint_tool, @@ -90,36 +89,35 @@ static void gimp_smudge_tool_allocate_accum_buffer (gint w, gint bytes, guchar *do_fill); -static SmudgeOptions * smudge_options_new (void); -static void smudge_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * smudge_options_new (GimpToolInfo *tool_info); +static void smudge_options_reset (GimpToolOptions *tool_options); /* local variables */ static PixelRegion accumPR; static guchar *accum_data = NULL; -static GimpPaintToolClass *parent_class = NULL; - -/* the smudge tool options */ -static SmudgeOptions * smudge_options = NULL; - static gdouble non_gui_rate; +static GimpPaintToolClass *parent_class = NULL; + /* global functions */ void -gimp_smudge_tool_register (Gimp *gimp) +gimp_smudge_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_SMUDGE_TOOL, - TRUE, - "gimp:smudge_tool", - _("Smudge"), - _("Smudge image"), - N_("/Tools/Paint Tools/Smudge"), "S", - NULL, "tools/smudge.html", - GIMP_STOCK_TOOL_SMUDGE); + (* callback) (gimp, + GIMP_TYPE_SMUDGE_TOOL, + smudge_options_new, + TRUE, + "gimp:smudge_tool", + _("Smudge"), + _("Smudge image"), + N_("/Tools/Paint Tools/Smudge"), "S", + NULL, "tools/smudge.html", + GIMP_STOCK_TOOL_SMUDGE); } GType @@ -171,14 +169,6 @@ gimp_smudge_tool_init (GimpSmudgeTool *smudge) tool = GIMP_TOOL (smudge); paint_tool = GIMP_PAINT_TOOL (smudge); - if (! smudge_options) - { - smudge_options = smudge_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_SMUDGE_TOOL, - (GimpToolOptions *) smudge_options); - } - tool->tool_cursor = GIMP_SMUDGE_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -459,8 +449,14 @@ gimp_smudge_tool_non_gui_default (GimpDrawable *drawable, gint num_strokes, gdouble *stroke_array) { - gdouble rate = SMUDGE_DEFAULT_RATE; - SmudgeOptions *options = smudge_options; + GimpToolInfo *tool_info; + SmudgeOptions *options; + gdouble rate = SMUDGE_DEFAULT_RATE; + + tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp, + GIMP_TYPE_SMUDGE_TOOL); + + options = (SmudgeOptions *) tool_info->tool_options; if (options) rate = options->rate; @@ -521,8 +517,8 @@ gimp_smudge_tool_non_gui (GimpDrawable *drawable, return FALSE; } -static SmudgeOptions * -smudge_options_new (void) +static GimpToolOptions * +smudge_options_new (GimpToolInfo *tool_info) { SmudgeOptions *options; GtkWidget *vbox; @@ -532,9 +528,9 @@ smudge_options_new (void) options = g_new0 (SmudgeOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_SMUDGE_TOOL, - smudge_options_reset); + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = smudge_options_reset; options->rate = options->rate_d = SMUDGE_DEFAULT_RATE; @@ -562,7 +558,7 @@ smudge_options_new (void) gtk_widget_show (scale); gtk_widget_show (hbox); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpsmudgetool.h b/app/tools/gimpsmudgetool.h index 4b8ba1397e..ec222b7d74 100644 --- a/app/tools/gimpsmudgetool.h +++ b/app/tools/gimpsmudgetool.h @@ -52,9 +52,10 @@ struct _GimpSmudgeToolClass }; -void gimp_smudge_tool_register (Gimp *gimp); +void gimp_smudge_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); -GType gimp_smudge_tool_get_type (void); +GType gimp_smudge_tool_get_type (void); /* FIXME: this antique code doesn't follow the coding style */ diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index 1d77cb2e1c..23867f75a2 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -46,8 +46,6 @@ #include "gimpclonetool.h" #include "paint_options.h" -#include "tool_manager.h" -#include "tool_options.h" #include "libgimp/gimpintl.h" @@ -125,16 +123,10 @@ static void gimp_clone_tool_line_pattern (GimpImage *dest, gint bytes, gint width); -static CloneOptions * clone_options_new (void); -static void clone_options_reset (GimpToolOptions *options); +static GimpToolOptions * clone_options_new (GimpToolInfo *tool_info); +static void clone_options_reset (GimpToolOptions *options); -/* The parent class */ -static GimpPaintToolClass *parent_class; - -/* the clone tool options */ -static CloneOptions *clone_options = NULL; - /* local variables */ static gint src_x = 0; /* */ static gint src_y = 0; /* position of clone src */ @@ -153,21 +145,25 @@ static gint non_gui_offset_x; static gint non_gui_offset_y; static CloneType non_gui_type; +static GimpPaintToolClass *parent_class; -/* global functions */ + +/* public functions */ void -gimp_clone_tool_register (Gimp *gimp) +gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_CLONE_TOOL, - TRUE, - "gimp:clone_tool", - _("Clone"), - _("Paint using Patterns or Image Regions"), - N_("/Tools/Paint Tools/Clone"), "C", - NULL, "tools/clone.html", - GIMP_STOCK_TOOL_CLONE); + (* callback) (gimp, + GIMP_TYPE_CLONE_TOOL, + clone_options_new, + TRUE, + "gimp:clone_tool", + _("Clone"), + _("Paint using Patterns or Image Regions"), + N_("/Tools/Paint Tools/Clone"), "C", + NULL, "tools/clone.html", + GIMP_STOCK_TOOL_CLONE); } GType @@ -229,14 +225,6 @@ gimp_clone_tool_init (GimpCloneTool *clone) tool = GIMP_TOOL (clone); paint_tool = GIMP_PAINT_TOOL (clone); - if (! clone_options) - { - clone_options = clone_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_CLONE_TOOL, - (GimpToolOptions *) clone_options); - } - tool->tool_cursor = GIMP_CLONE_TOOL_CURSOR; paint_tool->pick_colors = TRUE; @@ -818,18 +806,19 @@ gimp_clone_tool_non_gui (GimpDrawable *drawable, #endif /* 0 - non-gui functions */ -static CloneOptions * -clone_options_new (void) +static GimpToolOptions * +clone_options_new (GimpToolInfo *tool_info) { CloneOptions *options; GtkWidget *vbox; GtkWidget *frame; - /* the new clone tool options structure */ - options = g_new (CloneOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_CLONE_TOOL, - clone_options_reset); + options = g_new0 (CloneOptions, 1); + + paint_options_init ((PaintOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = clone_options_reset; + options->type = options->type_d = CLONE_DEFAULT_TYPE; options->aligned = options->aligned_d = CLONE_DEFAULT_ALIGNED; @@ -866,7 +855,7 @@ clone_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - return options; + return (GimpToolOptions *) options; } static void diff --git a/app/tools/gimpsourcetool.h b/app/tools/gimpsourcetool.h index 8916580e25..016415557c 100644 --- a/app/tools/gimpsourcetool.h +++ b/app/tools/gimpsourcetool.h @@ -52,7 +52,8 @@ struct _GimpCloneToolClass }; -void gimp_clone_tool_register (Gimp *gimp); +void gimp_clone_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_clone_tool_get_type (void); diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index c7030dc356..ceac17adb2 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -24,6 +24,7 @@ #include #include +#include "libgimpbase/gimpbase.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -38,6 +39,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimplayer.h" +#include "core/gimptoolinfo.h" #include "widgets/gimpfontselection.h" @@ -47,13 +49,9 @@ #include "gimpeditselectiontool.h" #include "gimptexttool.h" -#include "gimptool.h" -#include "tool_manager.h" #include "tool_options.h" -#include "libgimp_glue.h" #include "floating_sel.h" -#include "undo_types.h" #include "undo.h" #include "libgimp/gimpintl.h" @@ -88,6 +86,8 @@ struct _TextOptions }; +/* local function prototypes */ + static void gimp_text_tool_class_init (GimpTextToolClass *klass); static void gimp_text_tool_init (GimpTextTool *tool); @@ -113,30 +113,31 @@ static void text_tool_cursor_update (GimpTool *tool, static void text_tool_render (GimpTextTool *text_tool); -static TextOptions * text_tool_options_new (GimpTextTool *text_tool); -static void text_tool_options_reset (GimpToolOptions *tool_options); +static GimpToolOptions * text_tool_options_new (GimpToolInfo *tool_info); +static void text_tool_options_reset (GimpToolOptions *tool_options); /* local variables */ -static TextOptions *text_tool_options = NULL; -static GimpToolClass *parent_class = NULL; +static GimpToolClass *parent_class = NULL; -/* functions */ +/* public functions */ void -gimp_text_tool_register (Gimp *gimp) +gimp_text_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_TEXT_TOOL, - FALSE, - "gimp:text_tool", - _("Text Tool"), - _("Add text to the image"), - N_("/Tools/Text"), "T", - NULL, "tools/text.html", - GIMP_STOCK_TOOL_TEXT); + (* callback) (gimp, + GIMP_TYPE_TEXT_TOOL, + text_tool_options_new, + FALSE, + "gimp:text_tool", + _("Text Tool"), + _("Add text to the image"), + N_("/Tools/Text"), "T", + NULL, "tools/text.html", + GIMP_STOCK_TOOL_TEXT); } GType @@ -167,6 +168,9 @@ gimp_text_tool_get_type (void) return tool_type; } + +/* private functions */ + static void gimp_text_tool_class_init (GimpTextToolClass *klass) { @@ -195,15 +199,6 @@ gimp_text_tool_init (GimpTextTool *text_tool) text_tool->pango_context = pango_ft2_get_context (); - /* The tool options */ - if (! text_tool_options) - { - text_tool_options = text_tool_options_new (text_tool); - - tool_manager_register_tool_options (GIMP_TYPE_TEXT_TOOL, - (GimpToolOptions *) text_tool_options); - } - tool->tool_cursor = GIMP_TEXT_TOOL_CURSOR; tool->scroll_lock = TRUE; /* Disallow scrolling */ } @@ -221,111 +216,7 @@ gimp_text_tool_finalize (GObject *object) text_tool->pango_context = NULL; } - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -text_tool_options_reset (GimpToolOptions *tool_options) -{ - TextOptions *options; - GtkWidget *spinbutton; - - options = (TextOptions *) tool_options; - - gimp_font_selection_set_fontname - (GIMP_FONT_SELECTION (options->font_selection), options->fontname_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->size_w), - options->size_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->border_w), - options->border_d); - - /* resetting the unit menu is a bit tricky ... */ - options->unit = options->unit_d; - gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->unit_w), - options->unit_d); - spinbutton = - g_object_get_data (G_OBJECT (options->unit_w), "set_digits"); - while (spinbutton) - { - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), 0); - spinbutton = - g_object_get_data (G_OBJECT (spinbutton), "set_digits"); - } -} - -static TextOptions * -text_tool_options_new (GimpTextTool *text_tool) -{ - TextOptions *options; - GtkWidget *vbox; - GtkWidget *table; - GtkWidget *size_spinbutton; - GtkWidget *border_spinbutton; - - options = g_new0 (TextOptions, 1); - tool_options_init ((GimpToolOptions *) options, text_tool_options_reset); - - options->fontname_d = DEFAULT_FONT; - options->border = options->border_d = 0; - options->size = options->size_d = DEFAULT_FONT_SIZE; - options->unit = options->unit_d = GIMP_UNIT_PIXEL; - - /* the main vbox */ - vbox = options->tool_options.main_vbox; - - options->font_selection = gimp_font_selection_new (text_tool->pango_context); - gimp_font_selection_set_fontname - (GIMP_FONT_SELECTION (options->font_selection), DEFAULT_FONT); - gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (options->font_selection), - FALSE, FALSE, 0); - gtk_widget_show (options->font_selection); - - /* the size entries */ - table = gtk_table_new (3, 2, FALSE); - gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4); - gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), FALSE, FALSE, 0); - - options->size_w = gtk_adjustment_new (options->size_d, 1e-5, 32767.0, - 1.0, 50.0, 0.0); - size_spinbutton = - gtk_spin_button_new (GTK_ADJUSTMENT (options->size_w), 1.0, 0.0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (size_spinbutton), TRUE); - g_signal_connect (G_OBJECT (options->size_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->size); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("Size:"), 1.0, 0.5, - size_spinbutton, 1, FALSE); - - options->border_w = gtk_adjustment_new (options->border_d, 1e-5, 32767.0, - 1.0, 50.0, 0.0); - border_spinbutton = - gtk_spin_button_new (GTK_ADJUSTMENT (options->border_w), 1.0, 0.0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (border_spinbutton), TRUE); - g_signal_connect (G_OBJECT (options->border_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->border); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, - _("Border:"), 1.0, 0.5, - border_spinbutton, 1, FALSE); - - options->unit_w = - gimp_unit_menu_new ("%a", options->unit_d, TRUE, FALSE, TRUE); - g_signal_connect (G_OBJECT (options->unit_w), "unit_changed", - G_CALLBACK (gimp_unit_menu_update), - &options->unit); - g_object_set_data (G_OBJECT (options->unit_w), "set_digits", - size_spinbutton); - g_object_set_data (G_OBJECT (size_spinbutton), "set_digits", - border_spinbutton); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, - _("Unit:"), 1.0, 0.5, - options->unit_w, 1, FALSE); - - gtk_widget_show (table); - - return options; + G_OBJECT_CLASS (parent_class)->finalize (object); } static void @@ -347,6 +238,8 @@ text_tool_control (GimpTool *tool, default: break; } + + GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp); } static void @@ -426,6 +319,7 @@ text_tool_cursor_update (GimpTool *tool, static void text_tool_render (GimpTextTool *text_tool) { + TextOptions *options; GimpDisplay *gdisp; PangoFontDescription *font_desc; gchar *fontname; @@ -434,10 +328,12 @@ text_tool_render (GimpTextTool *text_tool) gdouble size; gdouble factor; + options = (TextOptions *) GIMP_TOOL (text_tool)->tool_info->tool_options; + gdisp = text_tool->gdisp; font_desc = gimp_font_selection_get_font_desc - (GIMP_FONT_SELECTION (text_tool_options->font_selection)); + (GIMP_FONT_SELECTION (options->font_selection)); if (!font_desc) { @@ -445,16 +341,16 @@ text_tool_render (GimpTextTool *text_tool) return; } - size = text_tool_options->size; - border = text_tool_options->border; + size = options->size; + border = options->border; - switch (text_tool_options->unit) + switch (options->unit) { case GIMP_UNIT_PIXEL: break; default: - factor = (gdisp->gimage->xresolution / - gimp_unit_get_factor (text_tool_options->unit)); + factor = (gdisp->gimage->xresolution / + gimp_unit_get_factor (options->unit)); size *= factor; border *= factor; break; @@ -668,3 +564,119 @@ text_get_extents (const gchar *fontname, return TRUE; } + + +/* tool options stuff */ + +static GimpToolOptions * +text_tool_options_new (GimpToolInfo *tool_info) +{ + TextOptions *options; + PangoContext *pango_context; + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *size_spinbutton; + GtkWidget *border_spinbutton; + + options = g_new0 (TextOptions, 1); + + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = text_tool_options_reset; + + options->fontname_d = DEFAULT_FONT; + options->border = options->border_d = 0; + options->size = options->size_d = DEFAULT_FONT_SIZE; + options->unit = options->unit_d = GIMP_UNIT_PIXEL; + + /* the main vbox */ + vbox = options->tool_options.main_vbox; + + pango_context = pango_ft2_get_context (gimprc.monitor_xres, + gimprc.monitor_yres); + + options->font_selection = gimp_font_selection_new (pango_context); + + g_object_unref (G_OBJECT (pango_context)); + + gimp_font_selection_set_fontname + (GIMP_FONT_SELECTION (options->font_selection), DEFAULT_FONT); + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (options->font_selection), + FALSE, FALSE, 0); + gtk_widget_show (options->font_selection); + + /* the size entries */ + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4); + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), FALSE, FALSE, 0); + + options->size_w = gtk_adjustment_new (options->size_d, 1e-5, 32767.0, + 1.0, 50.0, 0.0); + size_spinbutton = + gtk_spin_button_new (GTK_ADJUSTMENT (options->size_w), 1.0, 0.0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (size_spinbutton), TRUE); + g_signal_connect (G_OBJECT (options->size_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->size); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Size:"), 1.0, 0.5, + size_spinbutton, 1, FALSE); + + options->border_w = gtk_adjustment_new (options->border_d, 1e-5, 32767.0, + 1.0, 50.0, 0.0); + border_spinbutton = + gtk_spin_button_new (GTK_ADJUSTMENT (options->border_w), 1.0, 0.0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (border_spinbutton), TRUE); + g_signal_connect (G_OBJECT (options->border_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->border); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Border:"), 1.0, 0.5, + border_spinbutton, 1, FALSE); + + options->unit_w = + gimp_unit_menu_new ("%a", options->unit_d, TRUE, FALSE, TRUE); + g_signal_connect (G_OBJECT (options->unit_w), "unit_changed", + G_CALLBACK (gimp_unit_menu_update), + &options->unit); + g_object_set_data (G_OBJECT (options->unit_w), "set_digits", + size_spinbutton); + g_object_set_data (G_OBJECT (size_spinbutton), "set_digits", + border_spinbutton); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Unit:"), 1.0, 0.5, + options->unit_w, 1, FALSE); + + gtk_widget_show (table); + + return (GimpToolOptions *) options; +} + +static void +text_tool_options_reset (GimpToolOptions *tool_options) +{ + TextOptions *options; + GtkWidget *spinbutton; + + options = (TextOptions *) tool_options; + + gimp_font_selection_set_fontname + (GIMP_FONT_SELECTION (options->font_selection), options->fontname_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->size_w), + options->size_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->border_w), + options->border_d); + + /* resetting the unit menu is a bit tricky ... */ + options->unit = options->unit_d; + gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->unit_w), + options->unit_d); + spinbutton = + g_object_get_data (G_OBJECT (options->unit_w), "set_digits"); + while (spinbutton) + { + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), 0); + spinbutton = + g_object_get_data (G_OBJECT (spinbutton), "set_digits"); + } +} diff --git a/app/tools/gimptexttool.h b/app/tools/gimptexttool.h index 9ee7ae4e17..19546f9b7d 100644 --- a/app/tools/gimptexttool.h +++ b/app/tools/gimptexttool.h @@ -57,9 +57,10 @@ struct _GimpTextToolClass }; -void gimp_text_tool_register (Gimp *gimp); +void gimp_text_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); -GType gimp_text_tool_get_type (void); +GType gimp_text_tool_get_type (void); gboolean text_get_extents (const gchar *fontname, diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c index 8e1a0ba43c..ee1862e71f 100644 --- a/app/tools/gimpthresholdtool.c +++ b/app/tools/gimpthresholdtool.c @@ -40,7 +40,6 @@ #include "gimpthresholdtool.h" #include "tool_manager.h" -#include "tool_options.h" #include "app_procs.h" #include "image_map.h" @@ -96,10 +95,6 @@ static void threshold_histogram_range (GimpHistogramView *, gpointer ); -/* the threshold tool options */ -static GimpToolOptions *threshold_options = NULL; - -/* the threshold tool dialog */ static ThresholdDialog *threshold_dialog = NULL; static GimpImageMapToolClass *parent_class = NULL; @@ -108,17 +103,19 @@ static GimpImageMapToolClass *parent_class = NULL; /* functions */ void -gimp_threshold_tool_register (Gimp *gimp) +gimp_threshold_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback) { - tool_manager_register_tool (gimp, - GIMP_TYPE_THRESHOLD_TOOL, - FALSE, - "gimp:threshold_tool", - _("Threshold"), - _("Reduce image to two colors using a threshold"), - N_("/Image/Colors/Threshold..."), NULL, - NULL, "tools/threshold.html", - GIMP_STOCK_TOOL_THRESHOLD); + (* callback) (gimp, + GIMP_TYPE_THRESHOLD_TOOL, + NULL, + FALSE, + "gimp:threshold_tool", + _("Threshold"), + _("Reduce image to two colors using a threshold"), + N_("/Image/Colors/Threshold..."), NULL, + NULL, "tools/threshold.html", + GIMP_STOCK_TOOL_THRESHOLD); } GType @@ -165,17 +162,6 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass) static void gimp_threshold_tool_init (GimpThresholdTool *bc_tool) { - GimpTool *tool; - - tool = GIMP_TOOL (bc_tool); - - if (! threshold_options) - { - threshold_options = tool_options_new (); - - tool_manager_register_tool_options (GIMP_TYPE_THRESHOLD_TOOL, - (GimpToolOptions *) threshold_options); - } } static void diff --git a/app/tools/gimpthresholdtool.h b/app/tools/gimpthresholdtool.h index dedb174759..767dc43983 100644 --- a/app/tools/gimpthresholdtool.h +++ b/app/tools/gimpthresholdtool.h @@ -68,7 +68,8 @@ struct _ThresholdDialog }; -void gimp_threshold_tool_register (Gimp *gimp); +void gimp_threshold_tool_register (Gimp *gimp, + GimpToolRegisterCallback callback); GType gimp_threshold_tool_get_type (void); diff --git a/app/tools/gimptransformoptions.c b/app/tools/gimptransformoptions.c index 1b794b5fd4..f00046760d 100644 --- a/app/tools/gimptransformoptions.c +++ b/app/tools/gimptransformoptions.c @@ -49,22 +49,21 @@ static void gimp_transform_tool_show_path_update (GtkWidget *widget, /* public functions */ -TransformOptions * -transform_options_new (GType tool_type, - ToolOptionsResetFunc reset_func) +GimpToolOptions * +transform_options_new (GimpToolInfo *tool_info) { TransformOptions *options; options = g_new (TransformOptions, 1); - transform_options_init (options, tool_type, reset_func); - return options; + transform_options_init (options, tool_info); + + return (GimpToolOptions *) options; } void -transform_options_init (TransformOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func) +transform_options_init (TransformOptions *options, + GimpToolInfo *tool_info) { GtkWidget *vbox; GtkWidget *hbox; @@ -73,8 +72,9 @@ transform_options_init (TransformOptions *options, GtkWidget *fbox; GtkWidget *grid_density; - tool_options_init ((GimpToolOptions *) options, - reset_func); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = transform_options_reset; /* the main vbox */ vbox = options->tool_options.main_vbox; diff --git a/app/tools/gimptransformoptions.h b/app/tools/gimptransformoptions.h index ed54e87c35..0f593c1d79 100644 --- a/app/tools/gimptransformoptions.h +++ b/app/tools/gimptransformoptions.h @@ -55,13 +55,11 @@ struct _TransformOptions }; -TransformOptions * transform_options_new (GType tool_type, - ToolOptionsResetFunc reset_func); +GimpToolOptions * transform_options_new (GimpToolInfo *tool_info); -void transform_options_init (TransformOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func); -void transform_options_reset (GimpToolOptions *tool_options); +void transform_options_init (TransformOptions *options, + GimpToolInfo *tool_info); +void transform_options_reset (GimpToolOptions *tool_options); #endif /* __TRANSFORM_OPTIONS_H__ */ diff --git a/app/tools/paint_options.c b/app/tools/paint_options.c index 3ac666781b..78dfe94aca 100644 --- a/app/tools/paint_options.c +++ b/app/tools/paint_options.c @@ -118,26 +118,17 @@ static GSList *paint_options_list = NULL; void -paint_options_init (PaintOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func) +paint_options_init (PaintOptions *options, + GimpToolInfo *tool_info) { - GimpToolInfo *tool_info; - GtkWidget *vbox; - GtkWidget *table; - GtkWidget *scale; - - tool_info = tool_manager_get_info_by_type (the_gimp, tool_type); - - if (! tool_info) - { - g_warning ("%s(): no tool info registered for %s", - G_GNUC_FUNCTION, g_type_name (tool_type)); - } + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *scale; /* initialize the tool options structure */ - tool_options_init ((GimpToolOptions *) options, - reset_func); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = paint_options_reset; /* initialize the paint options structure */ options->global = NULL; @@ -180,13 +171,13 @@ paint_options_init (PaintOptions *options, options->opacity_w); /* the paint mode menu */ - if (tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || - tool_type == GIMP_TYPE_BLEND_TOOL || - tool_type == GIMP_TYPE_PENCIL_TOOL || - tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || - tool_type == GIMP_TYPE_AIRBRUSH_TOOL || - tool_type == GIMP_TYPE_CLONE_TOOL || - tool_type == GIMP_TYPE_INK_TOOL) + if (tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || + tool_info->tool_type == GIMP_TYPE_BLEND_TOOL || + tool_info->tool_type == GIMP_TYPE_PENCIL_TOOL || + tool_info->tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_AIRBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_CLONE_TOOL || + tool_info->tool_type == GIMP_TYPE_INK_TOOL) { gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2); @@ -208,8 +199,8 @@ paint_options_init (PaintOptions *options, gtk_widget_show (table); /* a separator after the common paint options which can be global */ - if (tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || - tool_type == GIMP_TYPE_BLEND_TOOL) + if (tool_info->tool_type == GIMP_TYPE_BUCKET_FILL_TOOL || + tool_info->tool_type == GIMP_TYPE_BLEND_TOOL) { GtkWidget *separator; @@ -222,10 +213,10 @@ paint_options_init (PaintOptions *options, gtk_widget_show (vbox); /* the "incremental" toggle */ - if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL || - tool_type == GIMP_TYPE_ERASER_TOOL || - tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || - tool_type == GIMP_TYPE_PENCIL_TOOL) + if (tool_info->tool_type == GIMP_TYPE_AIRBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_ERASER_TOOL || + tool_info->tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || + tool_info->tool_type == GIMP_TYPE_PENCIL_TOOL) { options->incremental_w = gtk_check_button_new_with_label (_("Incremental")); @@ -239,7 +230,8 @@ paint_options_init (PaintOptions *options, gtk_widget_show (options->incremental_w); } - options->pressure_options = paint_pressure_options_new (tool_type, options); + options->pressure_options = paint_pressure_options_new (tool_info->tool_type, + options); if (options->pressure_options->frame) { @@ -248,7 +240,8 @@ paint_options_init (PaintOptions *options, gtk_widget_show (options->pressure_options->frame); } - options->gradient_options = paint_gradient_options_new (tool_type, options); + options->gradient_options = paint_gradient_options_new (tool_info->tool_type, + options); if (options->gradient_options->frame) { @@ -261,19 +254,19 @@ paint_options_init (PaintOptions *options, paint_options_list = g_slist_prepend (paint_options_list, options); } -PaintOptions * -paint_options_new (GType tool_type, - ToolOptionsResetFunc reset_func) +GimpToolOptions * +paint_options_new (GimpToolInfo *tool_info) { PaintOptions *options; - options = g_new (PaintOptions, 1); - paint_options_init (options, tool_type, reset_func); + options = g_new0 (PaintOptions, 1); + + paint_options_init (options, tool_info); if (gimprc.global_paint_options && options->global) gtk_widget_show (options->global); - return options; + return (GimpToolOptions *) options; } void diff --git a/app/tools/paint_options.h b/app/tools/paint_options.h index bc22ae512d..f9b3d508c1 100644 --- a/app/tools/paint_options.h +++ b/app/tools/paint_options.h @@ -130,22 +130,20 @@ extern PaintGradientOptions non_gui_gradient_options; /* paint tool options functions */ -PaintOptions * paint_options_new (GType tool_type, - ToolOptionsResetFunc reset_func); +GimpToolOptions * paint_options_new (GimpToolInfo *tool_info); -void paint_options_reset (GimpToolOptions *tool_options); +void paint_options_reset (GimpToolOptions *tool_options); /* to be used by "derived" paint options only */ -void paint_options_init (PaintOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func); +void paint_options_init (PaintOptions *options, + GimpToolInfo *tool_info); /* functions for the global paint options */ /* switch between global and per-tool paint options */ -void paint_options_set_global (gboolean global); +void paint_options_set_global (gboolean global); #endif /* __PAINT_OPTIONS_H__ */ diff --git a/app/tools/selection_options.c b/app/tools/selection_options.c index 8f2cbd0b63..61610f043d 100644 --- a/app/tools/selection_options.c +++ b/app/tools/selection_options.c @@ -42,9 +42,8 @@ void -selection_options_init (SelectionOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func) +selection_options_init (SelectionOptions *options, + GimpToolInfo *tool_info) { GtkWidget *vbox; GtkWidget *abox; @@ -53,8 +52,9 @@ selection_options_init (SelectionOptions *options, GtkWidget *scale; /* initialize the tool options structure */ - tool_options_init ((GimpToolOptions *) options, - reset_func); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = selection_options_reset; /* the main vbox */ vbox = options->tool_options.main_vbox; @@ -135,7 +135,7 @@ selection_options_init (SelectionOptions *options, gtk_widget_show (table); /* the antialias toggle button */ - if (tool_type != GIMP_TYPE_RECT_SELECT_TOOL) + if (tool_info->tool_type != GIMP_TYPE_RECT_SELECT_TOOL) { options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), @@ -150,11 +150,11 @@ selection_options_init (SelectionOptions *options, #if 0 /* a separator between the common and tool-specific selection options */ - if (tool_type == GIMP_TYPE_ISCISSORS_TOOL || - tool_type == GIMP_TYPE_RECT_SELECT_TOOL || - tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL || - tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || - tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) + if (tool_info->tool_type == GIMP_TYPE_ISCISSORS_TOOL || + tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) { GtkWidget *separator; @@ -165,7 +165,7 @@ selection_options_init (SelectionOptions *options, #endif /* selection tool with an interactive boundary that can be toggled */ - if (tool_type == GIMP_TYPE_ISCISSORS_TOOL) + if (tool_info->tool_type == GIMP_TYPE_ISCISSORS_TOOL) { options->interactive_w = gtk_check_button_new_with_label (_("Show Interactive Boundary")); @@ -181,8 +181,8 @@ selection_options_init (SelectionOptions *options, } /* selection tools which operate on colors or contiguous regions */ - if (tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || - tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) + if (tool_info->tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_BY_COLOR_SELECT_TOOL) { GtkWidget *hbox; @@ -223,8 +223,8 @@ selection_options_init (SelectionOptions *options, } /* widgets for fixed size select */ - if (tool_type == GIMP_TYPE_RECT_SELECT_TOOL || - tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL) + if (tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL || + tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL) { GtkWidget *frame; GtkWidget *vbox2; @@ -346,16 +346,16 @@ selection_options_init (SelectionOptions *options, } } -SelectionOptions * -selection_options_new (GType tool_type, - ToolOptionsResetFunc reset_func) +GimpToolOptions * +selection_options_new (GimpToolInfo *tool_info) { SelectionOptions *options; - options = g_new (SelectionOptions, 1); - selection_options_init (options, tool_type, reset_func); + options = g_new0 (SelectionOptions, 1); - return options; + selection_options_init (options, tool_info); + + return (GimpToolOptions *) options; } void diff --git a/app/tools/selection_options.h b/app/tools/selection_options.h index 51ee873f06..3817681c92 100644 --- a/app/tools/selection_options.h +++ b/app/tools/selection_options.h @@ -86,17 +86,15 @@ struct _SelectionOptions /* selection tool options functions */ -SelectionOptions * selection_options_new (GType tool_type, - ToolOptionsResetFunc reset_func); +GimpToolOptions * selection_options_new (GimpToolInfo *tool_info); -void selection_options_reset (GimpToolOptions *tool_options); +void selection_options_reset (GimpToolOptions *tool_options); /* to be used by "derived" selection options only */ -void selection_options_init (SelectionOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func); +void selection_options_init (SelectionOptions *options, + GimpToolInfo *tool_info); #endif /* __SELCTION_OPTIONS_H__ */ diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c index 66d1526f69..bed06b0445 100644 --- a/app/tools/tool_manager.c +++ b/app/tools/tool_manager.c @@ -533,17 +533,18 @@ tool_manager_cursor_update_active (Gimp *gimp, } void -tool_manager_register_tool (Gimp *gimp, - GType tool_type, - gboolean tool_context, - const gchar *identifier, - const gchar *blurb, - const gchar *help, - const gchar *menu_path, - const gchar *menu_accel, - const gchar *help_domain, - const gchar *help_data, - const gchar *stock_id) +tool_manager_register_tool (Gimp *gimp, + GType tool_type, + GimpToolOptionsNewFunc options_new_func, + gboolean tool_context, + const gchar *identifier, + const gchar *blurb, + const gchar *help, + const gchar *menu_path, + const gchar *menu_accel, + const gchar *help_domain, + const gchar *help_data, + const gchar *stock_id) { GimpToolManager *tool_manager; GimpToolInfo *tool_info; @@ -623,28 +624,16 @@ tool_manager_register_tool (Gimp *gimp, g_object_unref (G_OBJECT (pixbuf)); - gimp_container_add (gimp->tool_info_list, GIMP_OBJECT (tool_info)); -} - -void -tool_manager_register_tool_options (GType tool_type, - GimpToolOptions *tool_options) -{ - GimpToolInfo *tool_info; - - g_return_if_fail (g_type_is_a (tool_type, GIMP_TYPE_TOOL)); - g_return_if_fail (tool_options != NULL); - - tool_info = tool_manager_get_info_by_type (the_gimp, tool_type); - - if (! tool_info) + if (options_new_func) { - g_warning ("%s(): no tool info registered for %s", - G_GNUC_FUNCTION, g_type_name (tool_type)); - return; + tool_info->tool_options = options_new_func (tool_info); + } + else + { + tool_info->tool_options = tool_options_new (tool_info); } - tool_info->tool_options = tool_options; + gimp_container_add (gimp->tool_info_list, GIMP_OBJECT (tool_info)); } GimpToolInfo * @@ -679,10 +668,12 @@ tool_manager_active_get_help_data (Gimp *gimp) tool_manager = tool_manager_get (gimp); - if (! tool_manager->active_tool) - return NULL; + if (tool_manager->active_tool) + { + return tool_manager->active_tool->tool_info->help_data; + } - return tool_manager->active_tool->tool_info->help_data; + return NULL; } void diff --git a/app/tools/tool_manager.h b/app/tools/tool_manager.h index 26665c1734..4b46bda474 100644 --- a/app/tools/tool_manager.h +++ b/app/tools/tool_manager.h @@ -79,6 +79,7 @@ const gchar * tool_manager_active_get_help_data (Gimp *gimp); void tool_manager_register_tool (Gimp *gimp, GType tool_type, + GimpToolOptionsNewFunc options_new_func, gboolean tool_context, const gchar *identifier, const gchar *blurb, @@ -89,9 +90,6 @@ void tool_manager_register_tool (Gimp *gimp, const gchar *help_data, const gchar *stock_id); -void tool_manager_register_tool_options (GType tool_type, - GimpToolOptions *tool_options); - GimpToolInfo * tool_manager_get_info_by_type (Gimp *gimp, GType tool_type); diff --git a/app/tools/tool_options.c b/app/tools/tool_options.c index 1494cf7e1f..3bd4b8ced1 100644 --- a/app/tools/tool_options.c +++ b/app/tools/tool_options.c @@ -28,21 +28,21 @@ void -tool_options_init (GimpToolOptions *options, - ToolOptionsResetFunc reset_func) +tool_options_init (GimpToolOptions *options, + GimpToolInfo *tool_info) { - options->main_vbox = gtk_vbox_new (FALSE, 2); - options->reset_func = reset_func; + options->main_vbox = gtk_vbox_new (FALSE, 2); + options->tool_info = tool_info; } GimpToolOptions * -tool_options_new (void) +tool_options_new (GimpToolInfo *tool_info) { GimpToolOptions *options; GtkWidget *label; options = g_new0 (GimpToolOptions, 1); - tool_options_init (options, NULL); + tool_options_init (options, tool_info); label = gtk_label_new (_("This tool has no options.")); gtk_box_pack_start (GTK_BOX (options->main_vbox), label, FALSE, FALSE, 6); diff --git a/app/tools/tool_options.h b/app/tools/tool_options.h index 30a022a6e8..9b23729fe9 100644 --- a/app/tools/tool_options.h +++ b/app/tools/tool_options.h @@ -24,21 +24,22 @@ struct _GimpToolOptions { - GtkWidget *main_vbox; + GtkWidget *main_vbox; - ToolOptionsResetFunc reset_func; + GimpToolInfo *tool_info; + GimpToolOptionsResetFunc reset_func; }; /* create a dummy tool options structure * (to be used by tools without options) */ -GimpToolOptions * tool_options_new (void); +GimpToolOptions * tool_options_new (GimpToolInfo *tool_info); /* initialize an already allocated ToolOptions structure * (to be used by derived tool options only) */ -void tool_options_init (GimpToolOptions *options, - ToolOptionsResetFunc reset_func); +void tool_options_init (GimpToolOptions *options, + GimpToolInfo *tool_info); #endif /* __TOOL_OPTIONS_H__ */ diff --git a/app/tools/tools-types.h b/app/tools/tools-types.h index f0ddd7d243..587a1b85fd 100644 --- a/app/tools/tools-types.h +++ b/app/tools/tools-types.h @@ -45,7 +45,25 @@ typedef struct _SelectionOptions SelectionOptions; /* functions */ -typedef void (* ToolOptionsResetFunc) (GimpToolOptions *tool_options); +typedef GimpToolOptions * (* GimpToolOptionsNewFunc) (GimpToolInfo *tool_info); + +typedef void (* GimpToolOptionsResetFunc) (GimpToolOptions *tool_options); + +typedef void (* GimpToolRegisterCallback) (Gimp *gimp, + GType tool_type, + GimpToolOptionsNewFunc options_new_func, + gboolean tool_context, + const gchar *identifier, + const gchar *blurb, + const gchar *help, + const gchar *menu_path, + const gchar *menu_accel, + const gchar *help_domain, + const gchar *help_data, + const gchar *stock_id); + +typedef void (* GimpToolRegisterFunc) (Gimp *gimp, + GimpToolRegisterCallback callback); /* enums */ diff --git a/app/tools/tools.c b/app/tools/tools.c index 44f315d9cf..687dbb2083 100644 --- a/app/tools/tools.c +++ b/app/tools/tools.c @@ -68,59 +68,69 @@ void tools_init (Gimp *gimp) { - /* register tools in reverse order */ + GimpToolRegisterFunc register_funcs[] = + { + /* register tools in reverse order */ - /* color tools */ - gimp_posterize_tool_register (gimp); - gimp_curves_tool_register (gimp); - gimp_levels_tool_register (gimp); - gimp_threshold_tool_register (gimp); - gimp_brightness_contrast_tool_register (gimp); - gimp_hue_saturation_tool_register (gimp); - gimp_color_balance_tool_register (gimp); + /* color tools */ + gimp_posterize_tool_register, + gimp_curves_tool_register, + gimp_levels_tool_register, + gimp_threshold_tool_register, + gimp_brightness_contrast_tool_register, + gimp_hue_saturation_tool_register, + gimp_color_balance_tool_register, - /* paint tools */ + /* paint tools */ - gimp_smudge_tool_register (gimp); - gimp_dodgeburn_tool_register (gimp); - gimp_convolve_tool_register (gimp); - gimp_clone_tool_register (gimp); - gimp_ink_tool_register (gimp); - gimp_airbrush_tool_register (gimp); - gimp_eraser_tool_register (gimp); - gimp_paintbrush_tool_register (gimp); - gimp_pencil_tool_register (gimp); - gimp_blend_tool_register (gimp); - gimp_bucket_fill_tool_register (gimp); - gimp_text_tool_register (gimp); + gimp_smudge_tool_register, + gimp_dodgeburn_tool_register, + gimp_convolve_tool_register, + gimp_clone_tool_register, + gimp_ink_tool_register, + gimp_airbrush_tool_register, + gimp_eraser_tool_register, + gimp_paintbrush_tool_register, + gimp_pencil_tool_register, + gimp_blend_tool_register, + gimp_bucket_fill_tool_register, + gimp_text_tool_register, - /* transform tools */ + /* transform tools */ - gimp_flip_tool_register (gimp); - gimp_perspective_tool_register (gimp); - gimp_shear_tool_register (gimp); - gimp_scale_tool_register (gimp); - gimp_rotate_tool_register (gimp); - gimp_crop_tool_register (gimp); - gimp_move_tool_register (gimp); + gimp_flip_tool_register, + gimp_perspective_tool_register, + gimp_shear_tool_register, + gimp_scale_tool_register, + gimp_rotate_tool_register, + gimp_crop_tool_register, + gimp_move_tool_register, - /* non-modifying tools */ + /* non-modifying tools */ - gimp_path_tool_register (gimp); - gimp_measure_tool_register (gimp); - gimp_magnify_tool_register (gimp); - gimp_histogram_tool_register (gimp); - gimp_color_picker_tool_register (gimp); + gimp_path_tool_register, + gimp_measure_tool_register, + gimp_magnify_tool_register, + gimp_histogram_tool_register, + gimp_color_picker_tool_register, - /* selection tools */ + /* selection tools */ - gimp_bezier_select_tool_register (gimp); - gimp_iscissors_tool_register (gimp); - gimp_by_color_select_tool_register (gimp); - gimp_fuzzy_select_tool_register (gimp); - gimp_free_select_tool_register (gimp); - gimp_ellipse_select_tool_register (gimp); - gimp_rect_select_tool_register (gimp); + gimp_bezier_select_tool_register, + gimp_iscissors_tool_register, + gimp_by_color_select_tool_register, + gimp_fuzzy_select_tool_register, + gimp_free_select_tool_register, + gimp_ellipse_select_tool_register, + gimp_rect_select_tool_register + }; + + gint i; + + for (i = 0; i < G_N_ELEMENTS (register_funcs); i++) + { + register_funcs[i] (gimp, tool_manager_register_tool); + } } void diff --git a/app/tools/transform_options.c b/app/tools/transform_options.c index 1b794b5fd4..f00046760d 100644 --- a/app/tools/transform_options.c +++ b/app/tools/transform_options.c @@ -49,22 +49,21 @@ static void gimp_transform_tool_show_path_update (GtkWidget *widget, /* public functions */ -TransformOptions * -transform_options_new (GType tool_type, - ToolOptionsResetFunc reset_func) +GimpToolOptions * +transform_options_new (GimpToolInfo *tool_info) { TransformOptions *options; options = g_new (TransformOptions, 1); - transform_options_init (options, tool_type, reset_func); - return options; + transform_options_init (options, tool_info); + + return (GimpToolOptions *) options; } void -transform_options_init (TransformOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func) +transform_options_init (TransformOptions *options, + GimpToolInfo *tool_info) { GtkWidget *vbox; GtkWidget *hbox; @@ -73,8 +72,9 @@ transform_options_init (TransformOptions *options, GtkWidget *fbox; GtkWidget *grid_density; - tool_options_init ((GimpToolOptions *) options, - reset_func); + tool_options_init ((GimpToolOptions *) options, tool_info); + + ((GimpToolOptions *) options)->reset_func = transform_options_reset; /* the main vbox */ vbox = options->tool_options.main_vbox; diff --git a/app/tools/transform_options.h b/app/tools/transform_options.h index ed54e87c35..0f593c1d79 100644 --- a/app/tools/transform_options.h +++ b/app/tools/transform_options.h @@ -55,13 +55,11 @@ struct _TransformOptions }; -TransformOptions * transform_options_new (GType tool_type, - ToolOptionsResetFunc reset_func); +GimpToolOptions * transform_options_new (GimpToolInfo *tool_info); -void transform_options_init (TransformOptions *options, - GType tool_type, - ToolOptionsResetFunc reset_func); -void transform_options_reset (GimpToolOptions *tool_options); +void transform_options_init (TransformOptions *options, + GimpToolInfo *tool_info); +void transform_options_reset (GimpToolOptions *tool_options); #endif /* __TRANSFORM_OPTIONS_H__ */