Lessen code bloat by removing code that manages center-[xy] properies of

2007-11-11  Martin Nordholts  <martinn@svn.gnome.org>

	* app/tools/gimprectangletool.c: Lessen code bloat by removing
	code that manages center-[xy] properies of GimpRectangleOptions.
	Instead use x1, y1 and x2, y2 when working with the rectangle
	center.

	* app/tools/gimprectangleoptions.[ch]: Removed "center-x" and
	"center-y" properties.

svn path=/trunk/; revision=24115
This commit is contained in:
Martin Nordholts 2007-11-11 07:44:17 +00:00 committed by Martin Nordholts
parent c558c7ed84
commit e157ac06b1
4 changed files with 15 additions and 75 deletions

View File

@ -1,3 +1,13 @@
2007-11-11 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimprectangletool.c: Lessen code bloat by removing
code that manages center-[xy] properies of GimpRectangleOptions.
Instead use x1, y1 and x2, y2 when working with the rectangle
center.
* app/tools/gimprectangleoptions.[ch]: Removed "center-x" and
"center-y" properties.
2007-11-10 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimppageselector.c: formatting.

View File

@ -311,24 +311,6 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("center-x",
NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("center-y",
NULL, NULL,
-GIMP_MAX_IMAGE_SIZE,
GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
initialized = TRUE;
}
}
@ -475,12 +457,6 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
"fixed-center");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X,
"center-x");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y,
"center-y");
}
void
@ -580,12 +556,6 @@ gimp_rectangle_options_set_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
private->fixed_center = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
private->center_x = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y:
private->center_y = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -690,12 +660,6 @@ gimp_rectangle_options_get_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
g_value_set_boolean (value, private->fixed_center);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
g_value_set_double (value, private->center_x);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y:
g_value_set_double (value, private->center_y);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);

View File

@ -52,12 +52,9 @@ typedef enum
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_ASPECT,
GIMP_RECTANGLE_OPTIONS_PROP_USE_STRING_CURRENT,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_UNIT,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X,
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y,
GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y
GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER
} GimpRectangleOptionsProp;
@ -114,6 +111,8 @@ struct _GimpRectangleOptionsPrivate
gdouble default_aspect_denominator;
gboolean overridden_fixed_aspect;
gboolean fixed_center;
/* This gboolean is not part of the actual rectangle tool options,
* and should be refactored out along with the pointers to widgets.
*/
@ -121,10 +120,6 @@ struct _GimpRectangleOptionsPrivate
GimpUnit fixed_unit;
gboolean fixed_center;
gdouble center_x;
gdouble center_y;
/* options gui */
GtkWidget *auto_shrink_button;

View File

@ -169,8 +169,6 @@ struct _GimpRectangleToolPrivate
gint saved_y1;
gint saved_x2;
gint saved_y2;
gdouble saved_center_x;
gdouble saved_center_y;
gint suppress_updates;
@ -766,17 +764,9 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
private->saved_x2 = private->x2;
private->saved_y2 = private->y2;
private->saved_center_x = options_private->center_x;
private->saved_center_y = options_private->center_y;
switch (private->function)
{
case RECT_CREATING:
g_object_set (options,
"center-x", (gdouble) x,
"center-y", (gdouble) y,
NULL);
g_object_set (rect_tool,
"x1", x,
"y1", y,
@ -879,8 +869,8 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
}
else
{
private->center_x_on_fixed_center = options_private->center_x;
private->center_y_on_fixed_center = options_private->center_y;
private->center_x_on_fixed_center = (private->x1 + private->x2) / 2;
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
}
/* When the user toggles modifier keys, we want to keep track of what
@ -947,11 +937,6 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
break;
case GIMP_BUTTON_RELEASE_CANCEL:
g_object_set (options,
"center-x", private->saved_center_x,
"center-y", private->saved_center_y,
NULL);
g_object_set (rect_tool,
"x1", private->saved_x1,
"y1", private->saved_y1,
@ -1206,11 +1191,6 @@ gimp_rectangle_tool_active_modifier_key (GimpTool *tool,
if (options_private->fixed_center)
{
g_object_set (options,
"center-x", (gdouble) private->center_x_on_fixed_center,
"center-y", (gdouble) private->center_y_on_fixed_center,
NULL);
gimp_rectangle_tool_update_with_coord (rect_tool,
private->lastx,
private->lasty);
@ -2086,7 +2066,6 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rect_tool,
gdouble y;
gdouble width;
gdouble height;
gdouble center_x, center_y;
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (rect_tool);
@ -2096,9 +2075,6 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rect_tool,
width = private->x2 - private->x1;
height = private->y2 - private->y1;
center_x = (private->x1 + private->x2) / 2.0;
center_y = (private->y1 + private->y2) / 2.0;
g_signal_handlers_block_by_func (options,
gimp_rectangle_tool_options_notify,
rect_tool);
@ -2116,11 +2092,6 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rect_tool,
"height", height,
NULL);
g_object_set (options,
"center-x", center_x,
"center-y", center_y,
NULL);
g_signal_handlers_unblock_by_func (options,
gimp_rectangle_tool_options_notify,
rect_tool);