From c82adc223119ab8beafcaa5a398c99af577e80a0 Mon Sep 17 00:00:00 2001 From: Karine Delvare Date: Sun, 26 Mar 2006 13:50:13 +0000 Subject: [PATCH] app/tools/gimpcropoptions.c app/tools/gimprectangleoptions.[ch] moved 2006-03-26 Karine Delvare * app/tools/gimpcropoptions.c * app/tools/gimprectangleoptions.[ch] * app/tools/gimprectangletool.[ch]: moved options gui creation from the tool to the options. * app/tools/gimpselectionoptions.c * app/tools/gimpnewrectselecttool.[ch] * app/tools/gimpellipseselecttool.[ch]: ported ellipse selection tool to the new rectangle interface. --- ChangeLog | 12 + app/tools/gimpcropoptions.c | 2 + app/tools/gimpellipseselecttool.c | 53 ++-- app/tools/gimpellipseselecttool.h | 6 +- app/tools/gimpnewrectselecttool.c | 60 +++-- app/tools/gimpnewrectselecttool.h | 8 +- app/tools/gimprectangleoptions.c | 103 +++++++- app/tools/gimprectangleoptions.h | 3 +- app/tools/gimprectangleselecttool.c | 60 +++-- app/tools/gimprectangleselecttool.h | 8 +- app/tools/gimprectangletool.c | 388 ++++++++-------------------- app/tools/gimprectangletool.h | 16 +- app/tools/gimpselectionoptions.c | 75 +++--- 13 files changed, 390 insertions(+), 404 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1b537f476..647099affa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-03-26 Karine Delvare + + * app/tools/gimpcropoptions.c + * app/tools/gimprectangleoptions.[ch] + * app/tools/gimprectangletool.[ch]: moved options gui creation + from the tool to the options. + + * app/tools/gimpselectionoptions.c + * app/tools/gimpnewrectselecttool.[ch] + * app/tools/gimpellipseselecttool.[ch]: ported ellipse selection + tool to the new rectangle interface. + 2006-03-25 Michael Natterer * app/tools/gimptool.[ch] diff --git a/app/tools/gimpcropoptions.c b/app/tools/gimpcropoptions.c index e5d097c770..5977fcd9b2 100644 --- a/app/tools/gimpcropoptions.c +++ b/app/tools/gimpcropoptions.c @@ -112,6 +112,7 @@ gimp_crop_options_set_property (GObject *object, case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X: case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y: case GIMP_RECTANGLE_OPTIONS_PROP_UNIT: + case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY: gimp_rectangle_options_set_property (object, property_id, value, pspec); break; case PROP_LAYER_ONLY: @@ -147,6 +148,7 @@ gimp_crop_options_get_property (GObject *object, case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X: case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y: case GIMP_RECTANGLE_OPTIONS_PROP_UNIT: + case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY: gimp_rectangle_options_get_property (object, property_id, value, pspec); break; case PROP_LAYER_ONLY: diff --git a/app/tools/gimpellipseselecttool.c b/app/tools/gimpellipseselecttool.c index e6c22b987d..4575c2698a 100644 --- a/app/tools/gimpellipseselecttool.c +++ b/app/tools/gimpellipseselecttool.c @@ -36,7 +36,7 @@ #include "display/gimpdisplay.h" #include "gimpellipseselecttool.h" -#include "gimpselectionoptions.h" +#include "gimpnewrectselectoptions.h" #include "gimptoolcontrol.h" #include "gimp-intl.h" @@ -44,15 +44,15 @@ static void gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool); -static void gimp_ellipse_select_tool_rect_select (GimpRectSelectTool *rect_tool, - gint x, - gint y, - gint w, - gint h); +static void gimp_ellipse_select_tool_rect_select (GimpNewRectSelectTool *rect_tool, + gint x, + gint y, + gint w, + gint h); G_DEFINE_TYPE (GimpEllipseSelectTool, gimp_ellipse_select_tool, - GIMP_TYPE_RECT_SELECT_TOOL); + GIMP_TYPE_NEW_RECT_SELECT_TOOL); #define parent_class gimp_ellipse_select_tool_parent_class @@ -64,8 +64,8 @@ gimp_ellipse_select_tool_register (GimpToolRegisterCallback callback, gpointer data) { (* callback) (GIMP_TYPE_ELLIPSE_SELECT_TOOL, - GIMP_TYPE_SELECTION_OPTIONS, - gimp_selection_options_gui, + GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, + gimp_new_rect_select_options_gui, 0, "gimp-ellipse-select-tool", _("Ellipse Select"), @@ -82,11 +82,11 @@ gimp_ellipse_select_tool_register (GimpToolRegisterCallback callback, static void gimp_ellipse_select_tool_class_init (GimpEllipseSelectToolClass *klass) { - GimpDrawToolClass *draw_tool_class; - GimpRectSelectToolClass *rect_tool_class; + GimpDrawToolClass *draw_tool_class; + GimpNewRectSelectToolClass *rect_tool_class; draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass); - rect_tool_class = GIMP_RECT_SELECT_TOOL_CLASS (klass); + rect_tool_class = GIMP_NEW_RECT_SELECT_TOOL_CLASS (klass); draw_tool_class->draw = gimp_ellipse_select_tool_draw; @@ -105,34 +105,41 @@ gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select) static void gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool) { - GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool); + GimpNewRectSelectTool *rect_sel = GIMP_NEW_RECT_SELECT_TOOL (draw_tool); + gint x1, y1; + gint x2, y2; + + g_object_get (rect_sel, + "x1", &x1, + "y1", &y1, + "x2", &x2, + "y2", &y2, + NULL); gimp_draw_tool_draw_arc (draw_tool, FALSE, - rect_sel->x, rect_sel->y, - rect_sel->w, rect_sel->h, + x1, y1, + x2 - x1, y2 - y1, 0, 23040, FALSE); } static void -gimp_ellipse_select_tool_rect_select (GimpRectSelectTool *rect_tool, - gint x, - gint y, - gint w, - gint h) +gimp_ellipse_select_tool_rect_select (GimpNewRectSelectTool *rect_tool, + gint x, + gint y, + gint w, + gint h) { GimpTool *tool; - GimpSelectionTool *sel_tool; GimpSelectionOptions *options; tool = GIMP_TOOL (rect_tool); - sel_tool = GIMP_SELECTION_TOOL (rect_tool); options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options); gimp_channel_select_ellipse (gimp_image_get_mask (tool->gdisp->gimage), x, y, w, h, - sel_tool->op, + options->operation, options->antialias, options->feather, options->feather_radius, diff --git a/app/tools/gimpellipseselecttool.h b/app/tools/gimpellipseselecttool.h index 1e7e0e7ac6..0ab700461a 100644 --- a/app/tools/gimpellipseselecttool.h +++ b/app/tools/gimpellipseselecttool.h @@ -20,7 +20,7 @@ #define __GIMP_ELLIPSE_SELECT_TOOL_H__ -#include "gimprectselecttool.h" +#include "gimpnewrectselecttool.h" #define GIMP_TYPE_ELLIPSE_SELECT_TOOL (gimp_ellipse_select_tool_get_type ()) @@ -36,12 +36,12 @@ typedef struct _GimpEllipseSelectToolClass GimpEllipseSelectToolClass; struct _GimpEllipseSelectTool { - GimpRectSelectTool parent_instance; + GimpNewRectSelectTool parent_instance; }; struct _GimpEllipseSelectToolClass { - GimpRectSelectToolClass parent_class; + GimpNewRectSelectToolClass parent_class; }; diff --git a/app/tools/gimpnewrectselecttool.c b/app/tools/gimpnewrectselecttool.c index 61020034b5..de5bdf58cf 100644 --- a/app/tools/gimpnewrectselecttool.c +++ b/app/tools/gimpnewrectselecttool.c @@ -85,6 +85,11 @@ static gboolean gimp_new_rect_select_tool_execute (GimpRectangleTool *rec gint y, gint w, gint h); +static void gimp_new_rect_select_tool_real_rect_select (GimpNewRectSelectTool *rect_select, + gint x, + gint y, + gint w, + gint h); G_DEFINE_TYPE_WITH_CODE (GimpNewRectSelectTool, gimp_new_rect_select_tool, @@ -138,6 +143,8 @@ gimp_new_rect_select_tool_class_init (GimpNewRectSelectToolClass *klass) tool_class->cursor_update = gimp_rectangle_tool_cursor_update; draw_tool_class->draw = gimp_rectangle_tool_draw; + + klass->rect_select = gimp_new_rect_select_tool_real_rect_select; } static void @@ -263,18 +270,19 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle, gint w, gint h) { - GimpTool *tool = GIMP_TOOL (rectangle); - GimpSelectionOptions *options; - GimpImage *gimage; - gint max_x, max_y; - gboolean rectangle_exists; - gboolean selected; - gint val; - GimpChannel *selection_mask; - gint x1, y1; - gint x2, y2; - gint pressx, pressy; - guchar *val_ptr; + GimpTool *tool = GIMP_TOOL (rectangle); + GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle); + GimpSelectionOptions *options; + GimpImage *gimage; + gint max_x, max_y; + gboolean rectangle_exists; + gboolean selected; + gint val; + GimpChannel *selection_mask; + gint x1, y1; + gint x2, y2; + gint pressx, pressy; + guchar *val_ptr; options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options); @@ -310,14 +318,8 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle, /* if rectangle exists, turn it into a selection */ if (rectangle_exists) { - GimpChannel *selection_mask = gimp_image_get_mask (gimage); + GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS (rect_select)->rect_select (rect_select, x, y, w, h); - gimp_channel_select_rectangle (selection_mask, - x, y, w, h, - options->operation, - options->feather, - options->feather_radius, - options->feather_radius); return TRUE; } @@ -396,3 +398,23 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle, return TRUE; } + +static void +gimp_new_rect_select_tool_real_rect_select (GimpNewRectSelectTool *rect_select, + gint x, + gint y, + gint w, + gint h) +{ + GimpTool *tool = GIMP_TOOL (rect_select); + GimpSelectionOptions *options; + + options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options); + + gimp_channel_select_rectangle (gimp_image_get_mask (tool->gdisp->gimage), + x, y, w, h, + options->operation, + options->feather, + options->feather_radius, + options->feather_radius); +} diff --git a/app/tools/gimpnewrectselecttool.h b/app/tools/gimpnewrectselecttool.h index 379c3a5134..ea3cfbf381 100644 --- a/app/tools/gimpnewrectselecttool.h +++ b/app/tools/gimpnewrectselecttool.h @@ -26,7 +26,7 @@ #define GIMP_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectTool)) #define GIMP_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass)) #define GIMP_IS_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL)) -#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL)) +#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL)) #define GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass)) @@ -41,6 +41,12 @@ struct _GimpNewRectSelectTool struct _GimpNewRectSelectToolClass { GimpSelectionToolClass parent_class; + + void (* rect_select) (GimpNewRectSelectTool *rect_select, + gint x, + gint y, + gint w, + gint h); }; diff --git a/app/tools/gimprectangleoptions.c b/app/tools/gimprectangleoptions.c index 0825541a1b..9d9def6e33 100644 --- a/app/tools/gimprectangleoptions.c +++ b/app/tools/gimprectangleoptions.c @@ -54,6 +54,8 @@ struct _GimpRectangleOptionsPrivate gdouble center_y; GimpUnit unit; + + GtkWidget *dimensions_entry; }; static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface); @@ -100,6 +102,13 @@ void gimp_rectangle_options_set_unit (GimpRectangleOptions *op GimpUnit unit); GimpUnit gimp_rectangle_options_get_unit (GimpRectangleOptions *options); +void gimp_rectangle_options_set_entry (GimpRectangleOptions *options, + GtkWidget *entry); +GtkWidget * gimp_rectangle_options_get_entry (GimpRectangleOptions *options); + +static void rectangle_dimensions_changed (GtkWidget *widget, + GimpRectangleOptions *options); + GType gimp_rectangle_options_interface_get_type (void) @@ -204,6 +213,12 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *options_i GIMP_UNIT_PIXEL, GIMP_PARAM_READWRITE)); + g_object_interface_install_property (options_iface, + g_param_spec_object ("dimensions-entry", + NULL, NULL, + GTK_TYPE_WIDGET, + GIMP_PARAM_READWRITE)); + initialized = TRUE; } } @@ -300,6 +315,9 @@ gimp_rectangle_options_install_properties (GObjectClass *klass) g_object_class_override_property (klass, GIMP_RECTANGLE_OPTIONS_PROP_UNIT, "unit"); + g_object_class_override_property (klass, + GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY, + "dimensions-entry"); } void @@ -588,6 +606,32 @@ gimp_rectangle_options_get_unit (GimpRectangleOptions *options) return private->unit; } +void +gimp_rectangle_options_set_entry (GimpRectangleOptions *options, + GtkWidget *entry) +{ + GimpRectangleOptionsPrivate *private; + + g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options)); + + private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options); + + private->dimensions_entry = entry; + g_object_notify (G_OBJECT (options), "dimensions-entry"); +} + +GtkWidget * +gimp_rectangle_options_get_entry (GimpRectangleOptions *options) +{ + GimpRectangleOptionsPrivate *private; + + g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), NULL); + + private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options); + + return private->dimensions_entry; +} + void gimp_rectangle_options_set_property (GObject *object, guint property_id, @@ -631,6 +675,9 @@ gimp_rectangle_options_set_property (GObject *object, case GIMP_RECTANGLE_OPTIONS_PROP_UNIT: gimp_rectangle_options_set_unit (options, g_value_get_int (value)); break; + case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY: + gimp_rectangle_options_set_entry (options, g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -680,6 +727,9 @@ gimp_rectangle_options_get_property (GObject *object, case GIMP_RECTANGLE_OPTIONS_PROP_UNIT: g_value_set_int (value, gimp_rectangle_options_get_unit (options)); break; + case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY: + g_value_set_object (value, gimp_rectangle_options_get_entry (options)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -692,12 +742,12 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options) GObject *config = G_OBJECT (tool_options); GtkWidget *vbox; GtkWidget *button; - GtkWidget *controls_container; GtkWidget *table; GtkWidget *entry; GtkWidget *hbox; GtkWidget *label; GtkWidget *spinbutton; + GtkObject *adjustment; vbox = gimp_tool_options_gui (tool_options); @@ -748,11 +798,52 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options) gtk_widget_show (table); - controls_container = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), controls_container, FALSE, FALSE, 0); - gtk_widget_show (controls_container); - g_object_set_data (G_OBJECT (tool_options), - "controls-container", controls_container); + entry = gimp_size_entry_new (2, GIMP_UNIT_PIXEL, "%a", + TRUE, TRUE, FALSE, 4, + GIMP_SIZE_ENTRY_UPDATE_SIZE); + g_object_set (tool_options, "dimensions-entry", entry, NULL); + + gtk_table_set_row_spacings (GTK_TABLE (entry), 3); + gtk_table_set_col_spacings (GTK_TABLE (entry), 3); + + spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2); + gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 4); + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (spinbutton), NULL); + gtk_table_attach_defaults (GTK_TABLE (entry), spinbutton, 1, 2, 2, 3); + gtk_widget_show (spinbutton); + + spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2); + gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 4); + gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), + GTK_SPIN_BUTTON (spinbutton), NULL); + gtk_table_attach_defaults (GTK_TABLE (entry), spinbutton, 2, 3, 2, 3); + gtk_widget_show (spinbutton); + + gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("1 "), 1, 0, 0.0); + gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("2 "), 2, 0, 0.0); + gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("X"), 0, 1, 0.5); + gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("Y"), 0, 2, 0.5); + + gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + + g_signal_connect (entry, "value-changed", + G_CALLBACK (rectangle_dimensions_changed), + tool_options); + + gtk_widget_show (entry); + + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 0, 0); + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 1, 0); + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 2, 0); + gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (entry), 3, 0); return vbox; } + +static void +rectangle_dimensions_changed (GtkWidget *widget, + GimpRectangleOptions *options) +{ + g_object_notify (G_OBJECT (options), "dimensions-entry"); +} diff --git a/app/tools/gimprectangleoptions.h b/app/tools/gimprectangleoptions.h index 3cc4a25e13..eae82def1d 100644 --- a/app/tools/gimprectangleoptions.h +++ b/app/tools/gimprectangleoptions.h @@ -34,7 +34,8 @@ typedef enum GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X, GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y, GIMP_RECTANGLE_OPTIONS_PROP_UNIT, - GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_UNIT + GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY, + GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY } GimpRectangleOptionsProp; diff --git a/app/tools/gimprectangleselecttool.c b/app/tools/gimprectangleselecttool.c index 61020034b5..de5bdf58cf 100644 --- a/app/tools/gimprectangleselecttool.c +++ b/app/tools/gimprectangleselecttool.c @@ -85,6 +85,11 @@ static gboolean gimp_new_rect_select_tool_execute (GimpRectangleTool *rec gint y, gint w, gint h); +static void gimp_new_rect_select_tool_real_rect_select (GimpNewRectSelectTool *rect_select, + gint x, + gint y, + gint w, + gint h); G_DEFINE_TYPE_WITH_CODE (GimpNewRectSelectTool, gimp_new_rect_select_tool, @@ -138,6 +143,8 @@ gimp_new_rect_select_tool_class_init (GimpNewRectSelectToolClass *klass) tool_class->cursor_update = gimp_rectangle_tool_cursor_update; draw_tool_class->draw = gimp_rectangle_tool_draw; + + klass->rect_select = gimp_new_rect_select_tool_real_rect_select; } static void @@ -263,18 +270,19 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle, gint w, gint h) { - GimpTool *tool = GIMP_TOOL (rectangle); - GimpSelectionOptions *options; - GimpImage *gimage; - gint max_x, max_y; - gboolean rectangle_exists; - gboolean selected; - gint val; - GimpChannel *selection_mask; - gint x1, y1; - gint x2, y2; - gint pressx, pressy; - guchar *val_ptr; + GimpTool *tool = GIMP_TOOL (rectangle); + GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle); + GimpSelectionOptions *options; + GimpImage *gimage; + gint max_x, max_y; + gboolean rectangle_exists; + gboolean selected; + gint val; + GimpChannel *selection_mask; + gint x1, y1; + gint x2, y2; + gint pressx, pressy; + guchar *val_ptr; options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options); @@ -310,14 +318,8 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle, /* if rectangle exists, turn it into a selection */ if (rectangle_exists) { - GimpChannel *selection_mask = gimp_image_get_mask (gimage); + GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS (rect_select)->rect_select (rect_select, x, y, w, h); - gimp_channel_select_rectangle (selection_mask, - x, y, w, h, - options->operation, - options->feather, - options->feather_radius, - options->feather_radius); return TRUE; } @@ -396,3 +398,23 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle, return TRUE; } + +static void +gimp_new_rect_select_tool_real_rect_select (GimpNewRectSelectTool *rect_select, + gint x, + gint y, + gint w, + gint h) +{ + GimpTool *tool = GIMP_TOOL (rect_select); + GimpSelectionOptions *options; + + options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options); + + gimp_channel_select_rectangle (gimp_image_get_mask (tool->gdisp->gimage), + x, y, w, h, + options->operation, + options->feather, + options->feather_radius, + options->feather_radius); +} diff --git a/app/tools/gimprectangleselecttool.h b/app/tools/gimprectangleselecttool.h index 379c3a5134..ea3cfbf381 100644 --- a/app/tools/gimprectangleselecttool.h +++ b/app/tools/gimprectangleselecttool.h @@ -26,7 +26,7 @@ #define GIMP_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectTool)) #define GIMP_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass)) #define GIMP_IS_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL)) -#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL)) +#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL)) #define GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass)) @@ -41,6 +41,12 @@ struct _GimpNewRectSelectTool struct _GimpNewRectSelectToolClass { GimpSelectionToolClass parent_class; + + void (* rect_select) (GimpNewRectSelectTool *rect_select, + gint x, + gint y, + gint w, + gint h); }; diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c index 61bd3ab666..ce92573f0c 100644 --- a/app/tools/gimprectangletool.c +++ b/app/tools/gimprectangletool.c @@ -55,9 +55,6 @@ typedef struct _GimpRectangleToolPrivate GimpRectangleToolPrivate; struct _GimpRectangleToolPrivate { - GtkWidget *controls; - GtkWidget *dimensions_entry; - gint pressx; /* x where button pressed */ gint pressy; /* y where button pressed */ @@ -73,13 +70,6 @@ static void gimp_rectangle_tool_iface_base_init (GimpRectangleToolInterface static GimpRectangleToolPrivate * gimp_rectangle_tool_get_private (GimpRectangleTool *tool); -void gimp_rectangle_tool_set_controls (GimpRectangleTool *tool, - GtkWidget *controls); -GtkWidget * gimp_rectangle_tool_get_controls (GimpRectangleTool *tool); -void gimp_rectangle_tool_set_entry (GimpRectangleTool *tool, - GtkWidget *entry); -GtkWidget * gimp_rectangle_tool_get_entry (GimpRectangleTool *tool); - void gimp_rectangle_tool_set_pressx (GimpRectangleTool *tool, gint pressx); gint gimp_rectangle_tool_get_pressx (GimpRectangleTool *tool); @@ -113,26 +103,24 @@ static void rectangle_selection_callback (GtkWidget *widg static void rectangle_automatic_callback (GtkWidget *widget, GimpRectangleTool *rectangle); -static void rectangle_dimensions_changed (GtkWidget *widget, - GimpRectangleTool *rectangle); - static void gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle, GimpDisplay *gdisp); -static GtkWidget * - gimp_rectangle_controls (GimpRectangleTool *rectangle); -static void gimp_rectangle_tool_zero_controls (GimpRectangleTool *rectangle); -static void gimp_rectangle_tool_notify_width (GimpRectangleOptions *options, - GParamSpec *pspec, - GimpRectangleTool *rectangle); -static void gimp_rectangle_tool_notify_height (GimpRectangleOptions *options, - GParamSpec *pspec, - GimpRectangleTool *rectangle); -static void gimp_rectangle_tool_notify_aspect (GimpRectangleOptions *options, - GParamSpec *pspec, - GimpRectangleTool *rectangle); -static void gimp_rectangle_tool_notify_highlight (GimpRectangleOptions *options, - GParamSpec *pspec, - GimpRectangleTool *rectangle); + +static void gimp_rectangle_tool_notify_width (GimpRectangleOptions *options, + GParamSpec *pspec, + GimpRectangleTool *rectangle); +static void gimp_rectangle_tool_notify_height (GimpRectangleOptions *options, + GParamSpec *pspec, + GimpRectangleTool *rectangle); +static void gimp_rectangle_tool_notify_aspect (GimpRectangleOptions *options, + GParamSpec *pspec, + GimpRectangleTool *rectangle); +static void gimp_rectangle_tool_notify_highlight (GimpRectangleOptions *options, + GParamSpec *pspec, + GimpRectangleTool *rectangle); +static void gimp_rectangle_tool_notify_dimensions (GimpRectangleOptions *options, + GParamSpec *pspec, + GimpRectangleTool *rectangle); /* Internal state */ @@ -178,18 +166,6 @@ gimp_rectangle_tool_iface_base_init (GimpRectangleToolInterface *iface) if (! initialized) { - g_object_interface_install_property (iface, - g_param_spec_object ("controls", - NULL, NULL, - GTK_TYPE_WIDGET, - GIMP_PARAM_READWRITE)); - - g_object_interface_install_property (iface, - g_param_spec_object ("dimensions-entry", - NULL, NULL, - GTK_TYPE_WIDGET, - GIMP_PARAM_READWRITE)); - g_object_interface_install_property (iface, g_param_spec_int ("pressx", NULL, NULL, @@ -295,12 +271,6 @@ gimp_rectangle_tool_get_private (GimpRectangleTool *tool) void gimp_rectangle_tool_install_properties (GObjectClass *klass) { - g_object_class_override_property (klass, - GIMP_RECTANGLE_TOOL_PROP_CONTROLS, - "controls"); - g_object_class_override_property (klass, - GIMP_RECTANGLE_TOOL_PROP_DIMENSIONS_ENTRY, - "dimensions-entry"); g_object_class_override_property (klass, GIMP_RECTANGLE_TOOL_PROP_PRESSX, "pressx"); @@ -324,58 +294,6 @@ gimp_rectangle_tool_install_properties (GObjectClass *klass) "function"); } -void -gimp_rectangle_tool_set_controls (GimpRectangleTool *tool, - GtkWidget *controls) -{ - GimpRectangleToolPrivate *private; - - g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool)); - - private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); - - private->controls = controls; - g_object_notify (G_OBJECT (tool), "controls"); -} - -GtkWidget * -gimp_rectangle_tool_get_controls (GimpRectangleTool *tool) -{ - GimpRectangleToolPrivate *private; - - g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (tool), NULL); - - private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); - - return private->controls; -} - -void -gimp_rectangle_tool_set_entry (GimpRectangleTool *tool, - GtkWidget *entry) -{ - GimpRectangleToolPrivate *private; - - g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool)); - - private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); - - private->dimensions_entry = entry; - g_object_notify (G_OBJECT (tool), "dimensions-entry"); -} - -GtkWidget * -gimp_rectangle_tool_get_entry (GimpRectangleTool *tool) -{ - GimpRectangleToolPrivate *private; - - g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (tool), NULL); - - private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); - - return private->dimensions_entry; -} - void gimp_rectangle_tool_set_pressx (GimpRectangleTool *tool, gint pressx) @@ -568,12 +486,6 @@ gimp_rectangle_tool_set_property (GObject *object, switch (property_id) { - case GIMP_RECTANGLE_TOOL_PROP_CONTROLS: - gimp_rectangle_tool_set_controls (tool, g_value_get_object (value)); - break; - case GIMP_RECTANGLE_TOOL_PROP_DIMENSIONS_ENTRY: - gimp_rectangle_tool_set_entry (tool, g_value_get_object (value)); - break; case GIMP_RECTANGLE_TOOL_PROP_PRESSX: gimp_rectangle_tool_set_pressx (tool, g_value_get_int (value)); break; @@ -611,12 +523,6 @@ gimp_rectangle_tool_get_property (GObject *object, switch (property_id) { - case GIMP_RECTANGLE_TOOL_PROP_CONTROLS: - g_value_set_object (value, gimp_rectangle_tool_get_controls (tool)); - break; - case GIMP_RECTANGLE_TOOL_PROP_DIMENSIONS_ENTRY: - g_value_set_object (value, gimp_rectangle_tool_get_entry (tool)); - break; case GIMP_RECTANGLE_TOOL_PROP_PRESSX: g_value_set_int (value, gimp_rectangle_tool_get_pressx (tool)); break; @@ -649,8 +555,6 @@ gimp_rectangle_tool_constructor (GObject *object) { GimpTool *tool; GimpRectangleTool *rectangle; - GtkContainer *controls_container; - GtkWidget *controls; GObject *options; tool = GIMP_TOOL (object); @@ -674,14 +578,9 @@ gimp_rectangle_tool_constructor (GObject *object) g_signal_connect_object (options, "notify::highlight", G_CALLBACK (gimp_rectangle_tool_notify_highlight), rectangle, 0); - - - controls_container = GTK_CONTAINER (g_object_get_data (options, - "controls-container")); - - controls = gimp_rectangle_controls (rectangle); - g_object_set (tool, "controls", controls, NULL); - gtk_container_add (controls_container, controls); + g_signal_connect_object (options, "notify::dimensions-entry", + G_CALLBACK (gimp_rectangle_tool_notify_dimensions), + rectangle, 0); } void @@ -689,18 +588,10 @@ gimp_rectangle_tool_dispose (GObject *object) { GimpTool *tool = GIMP_TOOL (object); GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (object); - GtkWidget *controls; GObject *options; - g_object_get (rectangle, "controls", &controls, NULL); options = G_OBJECT (tool->tool_info->tool_options); - if (controls) - { - gtk_widget_destroy (controls); - g_object_set (rectangle, "controls", NULL, NULL); - } - g_signal_handlers_disconnect_by_func (options, G_CALLBACK (gimp_rectangle_tool_notify_width), rectangle); @@ -713,16 +604,21 @@ gimp_rectangle_tool_dispose (GObject *object) g_signal_handlers_disconnect_by_func (options, G_CALLBACK (gimp_rectangle_tool_notify_highlight), rectangle); + g_signal_handlers_disconnect_by_func (options, + G_CALLBACK (gimp_rectangle_tool_notify_dimensions), + rectangle); } gboolean gimp_rectangle_tool_initialize (GimpTool *tool, GimpDisplay *gdisp) { - GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool); GimpSizeEntry *entry; + GObject *options; - g_object_get (rectangle, "dimensions-entry", &entry, NULL); + options = G_OBJECT (tool->tool_info->tool_options); + + g_object_get (options, "dimensions-entry", &entry, NULL); if (gdisp != tool->gdisp) { @@ -1791,79 +1687,6 @@ rectangle_automatic_callback (GtkWidget *widget, } } -static void -rectangle_dimensions_changed (GtkWidget *widget, - GimpRectangleTool *rectangle) -{ - GimpSizeEntry *entry = GIMP_SIZE_ENTRY (widget); - gint rx1, ry1, rx2, ry2; - gdouble x1, y1, x2, y2; - GimpCoords coords; - - if (! GIMP_TOOL (rectangle)->gdisp) - return; - - g_object_get (rectangle, - "x1", &rx1, - "y1", &ry1, - "x2", &rx2, - "y2", &ry2, - NULL); - - x1 = gimp_size_entry_get_refval (entry, 2); - y1 = gimp_size_entry_get_refval (entry, 3); - x2 = gimp_size_entry_get_refval (entry, 1); - y2 = gimp_size_entry_get_refval (entry, 0); - - if (x1 != rx1) - { - coords.x = x1; - coords.y = y1; - g_object_set (rectangle, - "function", RECT_RESIZING_LEFT, - NULL); - startx = rx1; - starty = ry1; - } - else if (y1 != ry1) - { - coords.x = x1; - coords.y = y1; - g_object_set (rectangle, - "function", RECT_RESIZING_TOP, - NULL); - startx = rx1; - starty = ry1; - } - else if (x2 != rx2) - { - coords.x = x2; - coords.y = y2; - g_object_set (rectangle, - "function", RECT_RESIZING_RIGHT, - NULL); - startx = rx2; - starty = ry2; - } - else if (y2 != ry2) - { - coords.x = x2; - coords.y = y2; - g_object_set (rectangle, - "function", RECT_RESIZING_BOTTOM, - NULL); - startx = rx2; - starty = ry2; - } - else - return; - - /* use the motion handler to handle this, to avoid duplicating - a bunch of code */ - gimp_rectangle_tool_motion (GIMP_TOOL (rectangle), &coords, 0, 0, - GIMP_TOOL (rectangle)->gdisp); -} - gboolean gimp_rectangle_tool_execute (GimpRectangleTool *rectangle, gint x, @@ -1905,7 +1728,6 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle, shell = GIMP_DISPLAY_SHELL (gdisp->shell); g_object_get (rectangle, - "dimensions-entry", &entry, "x1", &x1, "y1", &y1, "x2", &x2, @@ -1917,6 +1739,7 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle, "new-fixed-width", &fixed_width, "new-fixed-height", &fixed_height, "fixed-aspect", &fixed_aspect, + "dimensions-entry", &entry, NULL); width = x2 - x1; @@ -1930,8 +1753,8 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle, center_x = (x1 + x2) / 2.0; center_y = (y1 + y2) / 2.0; - g_signal_handlers_block_by_func (entry, - rectangle_dimensions_changed, + g_signal_handlers_block_by_func (options, + gimp_rectangle_tool_notify_dimensions, rectangle); gimp_size_entry_set_refval (entry, 0, y2); @@ -1948,10 +1771,6 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle, g_signal_handlers_block_by_func (options, gimp_rectangle_tool_notify_aspect, rectangle); - g_signal_handlers_block_by_func (options, - gimp_rectangle_tool_notify_highlight, - rectangle); - if (! fixed_width) g_object_set (options, @@ -1977,86 +1796,17 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle, g_signal_handlers_unblock_by_func (options, gimp_rectangle_tool_notify_aspect, rectangle); - g_signal_handlers_unblock_by_func (options, - gimp_rectangle_tool_notify_highlight, - rectangle); - g_object_set (options, "center-x", center_x, "center-y", center_y, NULL); - g_signal_handlers_unblock_by_func (entry, - rectangle_dimensions_changed, + g_signal_handlers_unblock_by_func (options, + gimp_rectangle_tool_notify_dimensions, rectangle); } -static GtkWidget * -gimp_rectangle_controls (GimpRectangleTool *rectangle) -{ - GtkWidget *vbox; - GtkObject *adjustment; - GtkWidget *spinbutton; - GtkWidget *entry; - - vbox = gtk_vbox_new (FALSE, 0); - - entry = gimp_size_entry_new (2, GIMP_UNIT_PIXEL, "%a", - TRUE, TRUE, FALSE, 4, - GIMP_SIZE_ENTRY_UPDATE_SIZE); - g_object_set (rectangle, "dimensions-entry", entry, NULL); - - gtk_table_set_row_spacings (GTK_TABLE (entry), 3); - gtk_table_set_col_spacings (GTK_TABLE (entry), 3); - - spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2); - gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 4); - gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), - GTK_SPIN_BUTTON (spinbutton), NULL); - gtk_table_attach_defaults (GTK_TABLE (entry), spinbutton, 1, 2, 2, 3); - gtk_widget_show (spinbutton); - - spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2); - gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 4); - gimp_size_entry_add_field (GIMP_SIZE_ENTRY (entry), - GTK_SPIN_BUTTON (spinbutton), NULL); - gtk_table_attach_defaults (GTK_TABLE (entry), spinbutton, 2, 3, 2, 3); - gtk_widget_show (spinbutton); - - gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("1 "), 1, 0, 0.0); - gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("2 "), 2, 0, 0.0); - gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("X"), 0, 1, 0.5); - gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (entry), _("Y"), 0, 2, 0.5); - - gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); - - g_signal_connect (entry, "value-changed", - G_CALLBACK (rectangle_dimensions_changed), - rectangle); - - gtk_widget_show (entry); - - gimp_rectangle_tool_zero_controls (rectangle); - - gtk_widget_show (vbox); - - return vbox; -} - -static void -gimp_rectangle_tool_zero_controls (GimpRectangleTool *rectangle) -{ - GimpSizeEntry *entry; - - g_object_get (rectangle, "dimensions-entry", &entry, NULL); - - gimp_size_entry_set_refval (entry, 0, 0); - gimp_size_entry_set_refval (entry, 1, 0); - gimp_size_entry_set_refval (entry, 2, 0); - gimp_size_entry_set_refval (entry, 3, 0); -} - /* * we handle changes in width by treating them as movement of the right edge */ @@ -2206,3 +1956,79 @@ gimp_rectangle_tool_notify_highlight (GimpRectangleOptions *options, else gimp_display_shell_set_highlight (shell, NULL); } + +static void +gimp_rectangle_tool_notify_dimensions (GimpRectangleOptions *options, + GParamSpec *pspec, + GimpRectangleTool *rectangle) +{ + GimpSizeEntry *entry; + gint rx1, ry1, rx2, ry2; + gdouble x1, y1, x2, y2; + GimpCoords coords; + + g_object_get (options, "dimensions-entry", &entry, NULL); + + if (! GIMP_TOOL (rectangle)->gdisp) + return; + + g_object_get (rectangle, + "x1", &rx1, + "y1", &ry1, + "x2", &rx2, + "y2", &ry2, + NULL); + + x1 = gimp_size_entry_get_refval (entry, 2); + y1 = gimp_size_entry_get_refval (entry, 3); + x2 = gimp_size_entry_get_refval (entry, 1); + y2 = gimp_size_entry_get_refval (entry, 0); + + if (x1 != rx1) + { + coords.x = x1; + coords.y = y1; + g_object_set (rectangle, + "function", RECT_RESIZING_LEFT, + NULL); + startx = rx1; + starty = ry1; + } + else if (y1 != ry1) + { + coords.x = x1; + coords.y = y1; + g_object_set (rectangle, + "function", RECT_RESIZING_TOP, + NULL); + startx = rx1; + starty = ry1; + } + else if (x2 != rx2) + { + coords.x = x2; + coords.y = y2; + g_object_set (rectangle, + "function", RECT_RESIZING_RIGHT, + NULL); + startx = rx2; + starty = ry2; + } + else if (y2 != ry2) + { + coords.x = x2; + coords.y = y2; + g_object_set (rectangle, + "function", RECT_RESIZING_BOTTOM, + NULL); + startx = rx2; + starty = ry2; + } + else + return; + + /* use the motion handler to handle this, to avoid duplicating + a bunch of code */ + gimp_rectangle_tool_motion (GIMP_TOOL (rectangle), &coords, 0, 0, + GIMP_TOOL (rectangle)->gdisp); +} diff --git a/app/tools/gimprectangletool.h b/app/tools/gimprectangletool.h index 7828cf2ac1..8753d8a6be 100644 --- a/app/tools/gimprectangletool.h +++ b/app/tools/gimprectangletool.h @@ -27,10 +27,6 @@ typedef enum GIMP_RECTANGLE_TOOL_PROP_0, GIMP_RECTANGLE_TOOL_PROP_CONTROLS, GIMP_RECTANGLE_TOOL_PROP_DIMENSIONS_ENTRY, - GIMP_RECTANGLE_TOOL_PROP_STARTX, - GIMP_RECTANGLE_TOOL_PROP_STARTY, - GIMP_RECTANGLE_TOOL_PROP_LASTX, - GIMP_RECTANGLE_TOOL_PROP_LASTY, GIMP_RECTANGLE_TOOL_PROP_PRESSX, GIMP_RECTANGLE_TOOL_PROP_PRESSY, GIMP_RECTANGLE_TOOL_PROP_X1, @@ -38,17 +34,7 @@ typedef enum GIMP_RECTANGLE_TOOL_PROP_X2, GIMP_RECTANGLE_TOOL_PROP_Y2, GIMP_RECTANGLE_TOOL_PROP_FUNCTION, - GIMP_RECTANGLE_TOOL_PROP_DX1, - GIMP_RECTANGLE_TOOL_PROP_DY1, - GIMP_RECTANGLE_TOOL_PROP_DX2, - GIMP_RECTANGLE_TOOL_PROP_DY2, - GIMP_RECTANGLE_TOOL_PROP_DCW, - GIMP_RECTANGLE_TOOL_PROP_DCH, - GIMP_RECTANGLE_TOOL_PROP_ORIGX, - GIMP_RECTANGLE_TOOL_PROP_ORIGY, - GIMP_RECTANGLE_TOOL_PROP_SIZEW, - GIMP_RECTANGLE_TOOL_PROP_SIZEH, - GIMP_RECTANGLE_TOOL_PROP_LAST = GIMP_RECTANGLE_TOOL_PROP_SIZEH + GIMP_RECTANGLE_TOOL_PROP_LAST = GIMP_RECTANGLE_TOOL_PROP_FUNCTION } GimpRectangleToolProp; #define GIMP_TYPE_RECTANGLE_TOOL (gimp_rectangle_tool_interface_get_type ()) diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c index c0f5b6e943..b45b1b1a96 100644 --- a/app/tools/gimpselectionoptions.c +++ b/app/tools/gimpselectionoptions.c @@ -37,6 +37,7 @@ #include "gimpellipseselecttool.h" #include "gimpforegroundselecttool.h" #include "gimpnewrectselecttool.h" +#include "gimprectselecttool.h" #include "gimpfuzzyselecttool.h" #include "gimpiscissorstool.h" #include "gimpselectionoptions.h" @@ -504,6 +505,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options) /* widgets for fixed size select */ if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL || + tool_options->tool_info->tool_type == GIMP_TYPE_NEW_RECT_SELECT_TOOL || tool_options->tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL) { GtkWidget *frame; @@ -537,51 +539,54 @@ gimp_selection_options_gui (GimpToolOptions *tool_options) gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); - frame = gimp_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); + if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL) + { + frame = gimp_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - combo = gimp_prop_enum_combo_box_new (config, "fixed-mode", 0, 0); - gtk_frame_set_label_widget (GTK_FRAME (frame), combo); - gtk_widget_show (combo); + combo = gimp_prop_enum_combo_box_new (config, "fixed-mode", 0, 0); + gtk_frame_set_label_widget (GTK_FRAME (frame), combo); + gtk_widget_show (combo); - table = gtk_table_new (2, 3, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 2); - gtk_container_add (GTK_CONTAINER (frame), table); + table = gtk_table_new (2, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 2); + gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_set_sensitive (table, - options->fixed_mode != GIMP_RECT_SELECT_MODE_FREE); - g_signal_connect (config, "notify::fixed-mode", - G_CALLBACK (selection_options_fixed_mode_notify), - table); + gtk_widget_set_sensitive (table, + options->fixed_mode != GIMP_RECT_SELECT_MODE_FREE); + g_signal_connect (config, "notify::fixed-mode", + G_CALLBACK (selection_options_fixed_mode_notify), + table); - width_spinbutton = gimp_prop_spin_button_new (config, "fixed-width", - 1.0, 50.0, 0); - gtk_entry_set_width_chars (GTK_ENTRY (width_spinbutton), 6); + width_spinbutton = gimp_prop_spin_button_new (config, "fixed-width", + 1.0, 50.0, 0); + gtk_entry_set_width_chars (GTK_ENTRY (width_spinbutton), 6); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("Width:"), 0.0, 0.5, - width_spinbutton, 1, FALSE); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Width:"), 0.0, 0.5, + width_spinbutton, 1, FALSE); - height_spinbutton = gimp_prop_spin_button_new (config, "fixed-height", - 1.0, 50.0, 0); - gtk_entry_set_width_chars (GTK_ENTRY (height_spinbutton), 6); + height_spinbutton = gimp_prop_spin_button_new (config, "fixed-height", + 1.0, 50.0, 0); + gtk_entry_set_width_chars (GTK_ENTRY (height_spinbutton), 6); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, - _("Height:"), 0.0, 0.5, - height_spinbutton, 1, FALSE); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Height:"), 0.0, 0.5, + height_spinbutton, 1, FALSE); - menu = gimp_prop_unit_menu_new (config, "fixed-unit", "%a"); - gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 1, 2, - GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - gtk_widget_show (menu); + menu = gimp_prop_unit_menu_new (config, "fixed-unit", "%a"); + gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 1, 2, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (menu); - g_object_set_data (G_OBJECT (menu), "set_digits", width_spinbutton); - g_object_set_data (G_OBJECT (width_spinbutton), "set_digits", - height_spinbutton); - gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0); + g_object_set_data (G_OBJECT (menu), "set_digits", width_spinbutton); + g_object_set_data (G_OBJECT (width_spinbutton), "set_digits", + height_spinbutton); + gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0); - gtk_widget_show (table); + gtk_widget_show (table); + } } return vbox;