* app/tools/gimpcropoptions.c: clean up code.

	* app/tools/gimpnewrectselecttool.c: really remove some
	commented-out code.

	* app/tools/gimprectangleoptions.[ch]: add "aspect-square"
	and "controls-expanded" properties.  Show "Make square" and
	"Expand from center" in options so that we don't need modifier
	keys to do this.  Place numerical entries inside an expander
	and hide them by default.
This commit is contained in:
William Skaggs
2006-06-10 01:39:10 +00:00
parent e732c769c9
commit c4ffc27293
6 changed files with 137 additions and 69 deletions

View File

@ -49,6 +49,7 @@ struct _GimpRectangleOptionsPrivate
gboolean fixed_aspect;
gdouble aspect;
gboolean aspect_square; /* if set, overrides fixed-aspect setting */
gboolean fixed_center;
gdouble center_x;
@ -56,6 +57,8 @@ struct _GimpRectangleOptionsPrivate
GimpUnit unit;
gboolean controls_expanded; /* show entries for width, height, etc */
GtkWidget *dimensions_entry;
};
@ -92,6 +95,9 @@ gboolean gimp_rectangle_options_get_fixed_aspect (GimpRectangleOptions *op
void gimp_rectangle_options_set_aspect (GimpRectangleOptions *options,
gdouble aspect);
gdouble gimp_rectangle_options_get_aspect (GimpRectangleOptions *options);
void gimp_rectangle_options_set_aspect_square (GimpRectangleOptions *options,
gboolean square);
gboolean gimp_rectangle_options_get_aspect_square (GimpRectangleOptions *options);
void gimp_rectangle_options_set_fixed_center (GimpRectangleOptions *options,
gboolean fixed_center);
@ -107,6 +113,10 @@ void gimp_rectangle_options_set_unit (GimpRectangleOptions *op
GimpUnit unit);
GimpUnit gimp_rectangle_options_get_unit (GimpRectangleOptions *options);
void gimp_rectangle_options_set_controls_expanded (GimpRectangleOptions *options,
gboolean expanded);
gboolean gimp_rectangle_options_get_controls_expanded (GimpRectangleOptions *options);
void gimp_rectangle_options_set_entry (GimpRectangleOptions *options,
GtkWidget *entry);
GtkWidget * gimp_rectangle_options_get_entry (GimpRectangleOptions *options);
@ -195,6 +205,12 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *options_i
0.0,
GIMP_PARAM_READWRITE));
g_object_interface_install_property (options_iface,
g_param_spec_boolean ("aspect-square",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_object_interface_install_property (options_iface,
g_param_spec_boolean ("fixed-center",
NULL, NULL,
@ -224,6 +240,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_boolean ("controls-expanded",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_object_interface_install_property (options_iface,
g_param_spec_object ("dimensions-entry",
NULL, NULL,
@ -317,6 +339,9 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT,
"aspect");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE,
"aspect-square");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
"fixed-center");
@ -329,6 +354,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_CONTROLS_EXPANDED,
"controls-expanded");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY,
"dimensions-entry");
@ -542,6 +570,32 @@ gimp_rectangle_options_get_aspect (GimpRectangleOptions *options)
return private->aspect;
}
void
gimp_rectangle_options_set_aspect_square (GimpRectangleOptions *options,
gboolean square)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->aspect_square = square;
g_object_notify (G_OBJECT (options), "aspect-square");
}
gboolean
gimp_rectangle_options_get_aspect_square (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->aspect_square;
}
void
gimp_rectangle_options_set_fixed_center (GimpRectangleOptions *options,
gboolean fixed_center)
@ -646,6 +700,32 @@ gimp_rectangle_options_get_unit (GimpRectangleOptions *options)
return private->unit;
}
void
gimp_rectangle_options_set_controls_expanded (GimpRectangleOptions *options,
gboolean expanded)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->controls_expanded = expanded;
g_object_notify (G_OBJECT (options), "controls-expanded");
}
gboolean
gimp_rectangle_options_get_controls_expanded (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->controls_expanded;
}
void
gimp_rectangle_options_set_entry (GimpRectangleOptions *options,
GtkWidget *entry)
@ -706,6 +786,9 @@ gimp_rectangle_options_set_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT:
gimp_rectangle_options_set_aspect (options, g_value_get_double (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE:
gimp_rectangle_options_set_aspect_square (options, g_value_get_boolean (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
gimp_rectangle_options_set_fixed_center (options, g_value_get_boolean (value));
break;
@ -718,6 +801,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_CONTROLS_EXPANDED:
gimp_rectangle_options_set_controls_expanded (options, g_value_get_boolean (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY:
gimp_rectangle_options_set_entry (options, g_value_get_object (value));
break;
@ -761,6 +847,9 @@ gimp_rectangle_options_get_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT:
g_value_set_double (value, gimp_rectangle_options_get_aspect (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_SQUARE:
g_value_set_boolean (value, gimp_rectangle_options_get_aspect_square (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
g_value_set_boolean (value, gimp_rectangle_options_get_fixed_center (options));
break;
@ -773,6 +862,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_CONTROLS_EXPANDED:
g_value_set_boolean (value, gimp_rectangle_options_get_controls_expanded (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DIMENSIONS_ENTRY:
g_value_set_object (value, gimp_rectangle_options_get_entry (options));
break;
@ -794,10 +886,22 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *spinbutton;
GtkWidget *vbox2;
GtkWidget *expander;
GtkObject *adjustment;
vbox = gimp_tool_options_gui (tool_options);
button = gimp_prop_check_button_new (config, "fixed-center",
_("Expand from center"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
button = gimp_prop_check_button_new (config, "aspect-square",
_("Make square"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
button = gimp_prop_check_button_new (config, "highlight",
_("Highlight"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
@ -807,8 +911,17 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
expander = gimp_prop_expander_new (config, "controls-expanded",
_("Rectangle Controls"));
gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
gtk_widget_show (expander);
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (expander), vbox2);
gtk_widget_show (vbox2);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
table = gtk_table_new (4, 3, FALSE);
@ -876,7 +989,7 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
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);
gtk_box_pack_start (GTK_BOX (vbox2), entry, FALSE, FALSE, 0);
g_signal_connect (entry, "value-changed",
G_CALLBACK (rectangle_dimensions_changed),