app/tools/gimpcropoptions.c app/tools/gimprectangleoptions.[ch] moved

2006-03-26  Karine Delvare  <edhel@gimp.org>

	* 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.
This commit is contained in:
Karine Delvare
2006-03-26 13:50:13 +00:00
committed by Karine Delvare
parent 2ed407b54f
commit c82adc2231
13 changed files with 390 additions and 404 deletions

View File

@ -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");
}