Commit 6c7f0c68 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added gimp_tool_get_options() so tools don't need to incude

2006-09-05  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimptool.[ch]: added gimp_tool_get_options() so tools
	don't need to incude "core/gimptoolinfo.h" just to get to
	their options.

	* app/tools/gimp*tool.h: added macros GIMP_FOO_TOOL_GET_OPTIONS()
	which return specific tool options types and do all casting
	themselves.

	* app/tools/*.c: use the new macros and don't include
	"core/gimptoolinfo.h" in most files.

	* app/tools/gimpcolorpickertool.c (gimp_color_picker_tool_register):
	make it use the parent context's FG and BG.

	* app/tools/gimpcolortool.c (gimp_color_tool_real_picked): set the
	color on the tool's options, not on the user context.
parent a76e59de
2006-09-05 Michael Natterer <mitch@gimp.org>
* app/tools/gimptool.[ch]: added gimp_tool_get_options() so tools
don't need to incude "core/gimptoolinfo.h" just to get to
their options.
* app/tools/gimp*tool.h: added macros GIMP_FOO_TOOL_GET_OPTIONS()
which return specific tool options types and do all casting
themselves.
* app/tools/*.c: use the new macros and don't include
"core/gimptoolinfo.h" in most files.
* app/tools/gimpcolorpickertool.c (gimp_color_picker_tool_register):
make it use the parent context's FG and BG.
* app/tools/gimpcolortool.c (gimp_color_tool_real_picked): set the
color on the tool's options, not on the user context.
2006-09-05 Michael Natterer <mitch@gimp.org>
 
* app/widgets/gimpmenudock.c: don't #include "core/gimptoolinfo.h"
......
......@@ -24,8 +24,6 @@
#include "tools-types.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpairbrushoptions.h"
#include "widgets/gimphelp-ids.h"
......
......@@ -33,7 +33,6 @@
#include "core/gimpimage-guides.h"
#include "core/gimpimage-undo.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
#include "core/gimplist.h"
#include "widgets/gimphelp-ids.h"
......@@ -177,10 +176,7 @@ gimp_align_tool_constructor (GType type,
tool = GIMP_TOOL (object);
align_tool = GIMP_ALIGN_TOOL (object);
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
options = G_OBJECT (tool->tool_info->tool_options);
options = G_OBJECT (gimp_tool_get_options (tool));
container = GTK_CONTAINER (g_object_get_data (options,
"controls-container"));
......
......@@ -27,7 +27,6 @@
#include "core/gimp.h"
#include "core/gimpdatafactory.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpwidgets-utils.h"
......
......@@ -33,7 +33,6 @@
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimpprogress.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
......@@ -180,17 +179,11 @@ gimp_blend_tool_button_release (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
GimpPaintOptions *paint_options;
GimpBlendOptions *options;
GimpContext *context;
GimpImage *image;
paint_options = GIMP_PAINT_OPTIONS (tool->tool_info->tool_options);
options = GIMP_BLEND_OPTIONS (paint_options);
context = GIMP_CONTEXT (options);
image = display->image;
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
GimpContext *context = GIMP_CONTEXT (options);
GimpImage *image = display->image;
gimp_tool_pop_status (tool, display);
......
......@@ -30,6 +30,8 @@
#define GIMP_IS_BLEND_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BLEND_TOOL))
#define GIMP_BLEND_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BLEND_TOOL, GimpBlendToolClass))
#define GIMP_BLEND_TOOL_GET_OPTIONS(t) (GIMP_BLEND_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpBlendTool GimpBlendTool;
typedef struct _GimpBlendToolClass GimpBlendToolClass;
......
......@@ -150,7 +150,7 @@ gimp_brush_tool_constructor (GType type,
G_CALLBACK (gimp_brush_tool_notify_brush),
brush_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options, "brush-changed",
g_signal_connect_object (gimp_tool_get_options (tool), "brush-changed",
G_CALLBACK (gimp_brush_tool_brush_changed),
brush_tool, 0);
......@@ -194,10 +194,8 @@ gimp_brush_tool_oper_update (GimpTool *tool,
gboolean proximity,
GimpDisplay *display)
{
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (tool);
GimpPaintOptions *paint_options;
paint_options = GIMP_PAINT_OPTIONS (tool->tool_info->tool_options);
GimpBrushTool *brush_tool = GIMP_BRUSH_TOOL (tool);
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
......@@ -294,7 +292,7 @@ gimp_brush_tool_draw (GimpDrawTool *draw_tool)
GimpPaintOptions *paint_options;
gdouble brush_x, brush_y;
paint_options = GIMP_PAINT_OPTIONS (tool->tool_info->tool_options);
paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (draw_tool);
brush_x = (brush_tool->brush_x -
((gdouble) brush_core->brush_bound_width / 2.0));
......
......@@ -32,7 +32,6 @@
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpimage.h"
#include "core/gimppickable.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
......@@ -127,9 +126,7 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
GimpDisplay *display)
{
GimpBucketFillTool *bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
GimpBucketFillOptions *options;
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
bucket_tool->target_x = coords->x;
bucket_tool->target_y = coords->y;
......@@ -157,11 +154,8 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
GimpDisplay *display)
{
GimpBucketFillTool *bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
GimpBucketFillOptions *options;
GimpContext *context;
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
context = GIMP_CONTEXT (options);
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
GimpContext *context = GIMP_CONTEXT (options);
/* if the 3rd button isn't pressed, fill the selected region */
if (! (state & GDK_BUTTON3_MASK))
......@@ -192,9 +186,7 @@ gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpBucketFillOptions *options;
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
if (key == GDK_CONTROL_MASK)
{
......@@ -224,11 +216,9 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpBucketFillOptions *options;
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD;
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
if (gimp_image_coords_in_active_pickable (display->image, coords,
options->sample_merged, TRUE))
{
......
......@@ -30,6 +30,8 @@
#define GIMP_IS_BUCKET_FILL_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BUCKET_FILL_TOOL))
#define GIMP_BUCKET_FILL_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BUCKET_FILL_TOOL, GimpBucketFillToolClass))
#define GIMP_BUCKET_FILL_TOOL_GET_OPTIONS(t) (GIMP_BUCKET_FILL_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpBucketFillTool GimpBucketFillTool;
typedef struct _GimpBucketFillToolClass GimpBucketFillToolClass;
......
......@@ -31,7 +31,6 @@
#include "core/gimpimage-contiguous-region.h"
#include "core/gimpitem.h"
#include "core/gimppickable.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
......@@ -94,15 +93,13 @@ static GimpChannel *
gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (region_select);
GimpSelectionOptions *options;
GimpTool *tool = GIMP_TOOL (region_select);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpDrawable *drawable;
GimpPickable *pickable;
guchar *col;
gint x, y;
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
drawable = gimp_image_active_drawable (display->image);
x = region_select->x;
......
......@@ -24,8 +24,6 @@
#include "tools-types.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpclone.h"
#include "paint/gimpcloneoptions.h"
......
......@@ -29,7 +29,6 @@
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpcolorframe.h"
#include "widgets/gimphelp-ids.h"
......@@ -95,7 +94,7 @@ gimp_color_picker_tool_register (GimpToolRegisterCallback callback,
(* callback) (GIMP_TYPE_COLOR_PICKER_TOOL,
GIMP_TYPE_COLOR_PICKER_OPTIONS,
gimp_color_picker_options_gui,
0,
GIMP_CONTEXT_FOREGROUND_MASK | GIMP_CONTEXT_BACKGROUND_MASK,
"gimp-color-picker-tool",
_("Color Picker"),
_("Pick colors from the image"),
......@@ -143,7 +142,7 @@ gimp_color_picker_tool_constructor (GType type,
tool = GIMP_TOOL (object);
gimp_color_tool_enable (GIMP_COLOR_TOOL (object),
GIMP_COLOR_OPTIONS (tool->tool_info->tool_options));
GIMP_COLOR_TOOL_GET_OPTIONS (tool));
return object;
}
......@@ -190,9 +189,7 @@ gimp_color_picker_tool_modifier_key (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpColorPickerOptions *options;
options = GIMP_COLOR_PICKER_OPTIONS (tool->tool_info->tool_options);
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
if (key == GDK_SHIFT_MASK)
{
......@@ -227,9 +224,7 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
gboolean proximity,
GimpDisplay *display)
{
GimpColorPickerOptions *options;
options = GIMP_COLOR_PICKER_OPTIONS (tool->tool_info->tool_options);
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
GIMP_COLOR_TOOL (tool)->pick_mode = options->pick_mode;
......@@ -247,7 +242,7 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (color_tool);
GimpColorPickerOptions *options;
options = GIMP_COLOR_PICKER_OPTIONS (color_tool->options);
options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (color_tool);
if (options->use_info_window && ! picker_tool->dialog)
gimp_color_picker_tool_info_create (picker_tool);
......@@ -284,7 +279,7 @@ gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool)
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (picker_tool->dialog),
GIMP_VIEWABLE (tool->drawable),
GIMP_CONTEXT (tool->tool_info->tool_options));
GIMP_CONTEXT (gimp_tool_get_options (tool)));
g_signal_connect (picker_tool->dialog, "response",
G_CALLBACK (gimp_color_picker_tool_info_response),
......
......@@ -30,6 +30,8 @@
#define GIMP_IS_COLOR_PICKER_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PICKER_TOOL))
#define GIMP_COLOR_PICKER_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_PICKER_TOOL, GimpColorPickerToolClass))
#define GIMP_COLOR_PICKER_TOOL_GET_OPTIONS(t) (GIMP_COLOR_PICKER_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpColorPickerTool GimpColorPickerTool;
typedef struct _GimpColorPickerToolClass GimpColorPickerToolClass;
......
......@@ -611,10 +611,12 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
gint color_index)
{
GimpTool *tool = GIMP_TOOL (color_tool);
GimpContext *user_context;
GimpContext *context;
GimpDialogFactory *dialog_factory;
user_context = gimp_get_user_context (tool->display->image->gimp);
/* use this tool's own options here (NOT color_tool->options) */
context = GIMP_CONTEXT (gimp_tool_get_options (tool));
dialog_factory = gimp_dialog_factory_from_name ("dock");
if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND ||
......@@ -660,11 +662,11 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
break;
case GIMP_COLOR_PICK_MODE_FOREGROUND:
gimp_context_set_foreground (user_context, color);
gimp_context_set_foreground (context, color);
break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
gimp_context_set_background (user_context, color);
gimp_context_set_background (context, color);
break;
case GIMP_COLOR_PICK_MODE_PALETTE:
......@@ -691,7 +693,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
if (! data)
{
data = GIMP_DATA (gimp_context_get_palette (user_context));
data = GIMP_DATA (gimp_context_get_palette (context));
gimp_data_editor_set_data (GIMP_DATA_EDITOR (palette_editor),
data);
......
......@@ -30,6 +30,8 @@
#define GIMP_IS_COLOR_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_TOOL))
#define GIMP_COLOR_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_TOOL, GimpColorToolClass))
#define GIMP_COLOR_TOOL_GET_OPTIONS(t) (GIMP_COLOR_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpColorToolClass GimpColorToolClass;
......
......@@ -24,8 +24,6 @@
#include "tools-types.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpconvolveoptions.h"
#include "widgets/gimphelp-ids.h"
......@@ -110,9 +108,7 @@ gimp_convolve_tool_modifier_key (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpConvolveOptions *options;
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
if ((key == GDK_CONTROL_MASK) &&
! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
......@@ -139,9 +135,7 @@ gimp_convolve_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpConvolveOptions *options;
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
gimp_tool_control_set_toggled (tool->control,
(options->type == GIMP_SHARPEN_CONVOLVE));
......@@ -156,9 +150,7 @@ gimp_convolve_tool_oper_update (GimpTool *tool,
gboolean proximity,
GimpDisplay *display)
{
GimpConvolveOptions *options;
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
gimp_convolve_tool_status_update (tool, options->type);
......
......@@ -30,6 +30,8 @@
#define GIMP_IS_CONVOLVE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONVOLVE_TOOL))
#define GIMP_CONVOLVE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONVOLVE_TOOL, GimpConvolveToolClass))
#define GIMP_CONVOLVE_TOOL_GET_OPTIONS(t) (GIMP_CONVOLVE_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpConvolveTool GimpConvolveTool;
typedef struct _GimpConvolveToolClass GimpConvolveToolClass;
......
......@@ -26,7 +26,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-crop.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
......@@ -199,7 +198,7 @@ gimp_crop_tool_button_release (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpCropOptions *options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options);
GimpCropOptions *options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
if (options->crop_mode == GIMP_CROP_MODE_CROP)
gimp_tool_push_status (tool, display,
......@@ -243,14 +242,12 @@ gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gint w,
gint h)
{
GimpTool *tool = GIMP_TOOL (rectangle);
GimpCropOptions *options;
GimpTool *tool = GIMP_TOOL (rectangle);
GimpCropOptions *options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
GimpImage *image;
gint max_x, max_y;
gboolean rectangle_exists;
options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options);
gimp_tool_pop_status (tool, tool->display);
image = tool->display->image;
......
......@@ -29,6 +29,8 @@
#define GIMP_IS_CROP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CROP_TOOL))
#define GIMP_CROP_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CROP_TOOL, GimpCropToolClass))
#define GIMP_CROP_TOOL_GET_OPTIONS(t) (GIMP_CROP_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpCropTool GimpCropTool;
typedef struct _GimpCropToolClass GimpCropToolClass;
......
......@@ -275,7 +275,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
/* always pick colors */
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (tool->tool_info->tool_options));
GIMP_COLOR_TOOL_GET_OPTIONS (tool));
gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (c_tool->channel_menu),
curves_menu_sensitivity, c_tool, NULL);
......@@ -535,8 +535,8 @@ gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
static void
gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
GimpToolOptions *tool_options;
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
GtkListStore *store;
GtkWidget *vbox;
GtkWidget *vbox2;
......@@ -551,8 +551,6 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *bar;
gint padding;
tool_options = GIMP_TOOL (tool)->tool_info->tool_options;
vbox = image_map_tool->main_vbox;
/* The option menu for selecting channels */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment