formatting.

2006-06-05  Sven Neumann  <sven@gimp.org>

	* app/tools/gimprectangletool.c: formatting.
This commit is contained in:
Sven Neumann 2006-06-05 11:18:43 +00:00 committed by Sven Neumann
parent 005f3b0713
commit 84bac48c7c
2 changed files with 62 additions and 48 deletions

View File

@ -1,3 +1,7 @@
2006-06-05 Sven Neumann <sven@gimp.org>
* app/tools/gimprectangletool.c: formatting.
2006-06-04 Seth Burgess <sjburges@gimp.org> 2006-06-04 Seth Burgess <sjburges@gimp.org>
* plug-ins/common/png.c: fixed file_png_set_defaults; wrong # of * plug-ins/common/png.c: fixed file_png_set_defaults; wrong # of
@ -10,7 +14,7 @@
* app/tools/gimprectangletool.c: * app/tools/gimprectangletool.c:
* app/tools/gimpnewrectselecttool.c: enable canceling of * app/tools/gimpnewrectselecttool.c: enable canceling of
current action by holding down mouse button 3. current action by holding down mouse button 3.
2006-06-04 Michael Natterer <mitch@gimp.org> 2006-06-04 Michael Natterer <mitch@gimp.org>
* app/tools/gimpscaletool.c (gimp_scale_tool_size_notify): * app/tools/gimpscaletool.c (gimp_scale_tool_size_notify):
@ -24,8 +28,8 @@
2006-06-04 Bill Skaggs <weskaggs@primate.ucdavis.edu> 2006-06-04 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimpnewrectselectoptions.c: turn highlighting * app/tools/gimpnewrectselectoptions.c: turn highlighting off by
off by default. default.
2006-06-04 Bill Skaggs <weskaggs@primate.ucdavis.edu> 2006-06-04 Bill Skaggs <weskaggs@primate.ucdavis.edu>

View File

@ -55,7 +55,9 @@ enum
#define ARROW_VELOCITY 25 #define ARROW_VELOCITY 25
#define GIMP_RECTANGLE_TOOL_GET_PRIVATE(obj) (gimp_rectangle_tool_get_private ((GimpRectangleTool *) (obj))) #define GIMP_RECTANGLE_TOOL_GET_PRIVATE(obj) \
(gimp_rectangle_tool_get_private ((GimpRectangleTool *) (obj)))
typedef struct _GimpRectangleToolPrivate GimpRectangleToolPrivate; typedef struct _GimpRectangleToolPrivate GimpRectangleToolPrivate;
@ -149,6 +151,9 @@ static void gimp_rectangle_tool_notify_dimensions (GimpRectangleOptions *op
GimpRectangleTool *rectangle); GimpRectangleTool *rectangle);
static guint gimp_rectangle_tool_signals[LAST_SIGNAL] = { 0 };
GType GType
gimp_rectangle_tool_interface_get_type (void) gimp_rectangle_tool_interface_get_type (void)
{ {
@ -163,17 +168,16 @@ gimp_rectangle_tool_interface_get_type (void)
(GBaseFinalizeFunc) NULL, (GBaseFinalizeFunc) NULL,
}; };
rectangle_tool_iface_type = g_type_register_static (G_TYPE_INTERFACE, rectangle_tool_iface_type =
"GimpRectangleToolInterface", g_type_register_static (G_TYPE_INTERFACE,
&rectangle_tool_iface_info, "GimpRectangleToolInterface",
0); &rectangle_tool_iface_info,
0);
} }
return rectangle_tool_iface_type; return rectangle_tool_iface_type;
} }
static guint gimp_rectangle_tool_signals[LAST_SIGNAL] = { 0 };
static void static void
gimp_rectangle_tool_iface_base_init (GimpRectangleToolInterface *iface) gimp_rectangle_tool_iface_base_init (GimpRectangleToolInterface *iface)
{ {
@ -267,23 +271,22 @@ gimp_rectangle_tool_private_finalize (GimpRectangleToolPrivate *private)
static GimpRectangleToolPrivate * static GimpRectangleToolPrivate *
gimp_rectangle_tool_get_private (GimpRectangleTool *tool) gimp_rectangle_tool_get_private (GimpRectangleTool *tool)
{ {
GimpRectangleToolPrivate *private;
static GQuark private_key = 0; static GQuark private_key = 0;
g_return_val_if_fail (GIMP_IS_RECTANGLE_TOOL (tool), NULL); GimpRectangleToolPrivate *private;
if (! private_key) if (G_UNLIKELY (private_key == 0))
private_key = g_quark_from_static_string ("gimp-rectangle-tool-private"); private_key = g_quark_from_static_string ("gimp-rectangle-tool-private");
private = g_object_get_qdata ((GObject *) tool, private_key); private = g_object_get_qdata (G_OBJECT (tool), private_key);
if (! private) if (! private)
{ {
private = g_new0 (GimpRectangleToolPrivate, 1); private = g_new0 (GimpRectangleToolPrivate, 1);
g_object_set_qdata_full ((GObject *) tool, private_key, private, g_object_set_qdata_full (G_OBJECT (tool), private_key, private,
(GDestroyNotify) gimp_rectangle_tool_private_finalize); (GDestroyNotify)
gimp_rectangle_tool_private_finalize);
} }
return private; return private;
@ -340,6 +343,7 @@ gimp_rectangle_tool_set_pressx (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->pressx = pressx; private->pressx = pressx;
g_object_notify (G_OBJECT (tool), "pressx"); g_object_notify (G_OBJECT (tool), "pressx");
} }
@ -366,6 +370,7 @@ gimp_rectangle_tool_set_pressy (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->pressy = pressy; private->pressy = pressy;
g_object_notify (G_OBJECT (tool), "pressy"); g_object_notify (G_OBJECT (tool), "pressy");
} }
@ -392,6 +397,7 @@ gimp_rectangle_tool_set_x1 (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->x1 = x1; private->x1 = x1;
g_object_notify (G_OBJECT (tool), "x1"); g_object_notify (G_OBJECT (tool), "x1");
} }
@ -418,6 +424,7 @@ gimp_rectangle_tool_set_y1 (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->y1 = y1; private->y1 = y1;
g_object_notify (G_OBJECT (tool), "y1"); g_object_notify (G_OBJECT (tool), "y1");
} }
@ -444,6 +451,7 @@ gimp_rectangle_tool_set_x2 (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->x2 = x2; private->x2 = x2;
g_object_notify (G_OBJECT (tool), "x2"); g_object_notify (G_OBJECT (tool), "x2");
} }
@ -470,6 +478,7 @@ gimp_rectangle_tool_set_y2 (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->y2 = y2; private->y2 = y2;
g_object_notify (G_OBJECT (tool), "y2"); g_object_notify (G_OBJECT (tool), "y2");
} }
@ -496,6 +505,7 @@ gimp_rectangle_tool_set_function (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->function = function; private->function = function;
g_object_notify (G_OBJECT (tool), "function"); g_object_notify (G_OBJECT (tool), "function");
} }
@ -521,7 +531,8 @@ gimp_rectangle_tool_set_constrain (GimpRectangleTool *tool,
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
private->constrain = constrain? TRUE : FALSE; private->constrain = constrain ? TRUE : FALSE;
g_object_notify (G_OBJECT (tool), "constrain"); g_object_notify (G_OBJECT (tool), "constrain");
} }
@ -620,13 +631,10 @@ gimp_rectangle_tool_get_property (GObject *object,
void void
gimp_rectangle_tool_constructor (GObject *object) gimp_rectangle_tool_constructor (GObject *object)
{ {
GimpTool *tool; GimpTool *tool = GIMP_TOOL (object);
GimpRectangleTool *rectangle; GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (object);
GObject *options; GObject *options;
tool = GIMP_TOOL (object);
rectangle = GIMP_RECTANGLE_TOOL (object);
tool->display = NULL; tool->display = NULL;
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info)); g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
@ -680,8 +688,8 @@ gboolean
gimp_rectangle_tool_initialize (GimpTool *tool, gimp_rectangle_tool_initialize (GimpTool *tool,
GimpDisplay *display) GimpDisplay *display)
{ {
GimpSizeEntry *entry; GimpSizeEntry *entry;
GObject *options; GObject *options;
options = G_OBJECT (tool->tool_info->tool_options); options = G_OBJECT (tool->tool_info->tool_options);
@ -946,7 +954,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
switch (function) switch (function)
{ {
case RECT_INACTIVE: case RECT_INACTIVE:
g_printerr ("function is RECT_INACTIVE while mouse is moving; should not happen\n"); g_warning ("function is RECT_INACTIVE while mouse is moving");
break; break;
case RECT_CREATING: case RECT_CREATING:
@ -1144,12 +1152,10 @@ gimp_rectangle_tool_motion (GimpTool *tool,
if (fixed_aspect) if (fixed_aspect)
{ {
gdouble aspect; gdouble aspect;
g_object_get (options, "aspect", &aspect, NULL); g_object_get (options, "aspect", &aspect, NULL);
if (aspect < 1.0 / max_y) aspect = CLAMP (aspect, 1.0 / max_y, max_x);
aspect = 1.0 / max_y;
if (aspect > max_x)
aspect = max_x;
switch (function) switch (function)
{ {
@ -1241,6 +1247,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
"x2", MAX (x1, x2), "x2", MAX (x1, x2),
"y2", MAX (y1, y2), "y2", MAX (y1, y2),
NULL); NULL);
private->lastx = curx; private->lastx = curx;
private->lasty = cury; private->lasty = cury;
@ -1396,11 +1403,13 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
case GDK_KP_Enter: case GDK_KP_Enter:
case GDK_Return: case GDK_Return:
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE, rectangle); gimp_rectangle_tool_response (NULL,
GIMP_RECTANGLE_MODE_EXECUTE, rectangle);
return TRUE; return TRUE;
case GDK_Escape: case GDK_Escape:
gimp_rectangle_tool_response (NULL, GTK_RESPONSE_CANCEL, rectangle); gimp_rectangle_tool_response (NULL,
GTK_RESPONSE_CANCEL, rectangle);
return TRUE; return TRUE;
default: default:
@ -1465,6 +1474,7 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
gboolean inside_y; gboolean inside_y;
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool)); g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
if (tool->display != display) if (tool->display != display)
@ -1655,7 +1665,7 @@ gimp_rectangle_tool_cursor_update (GimpTool *tool,
void void
gimp_rectangle_tool_draw (GimpDrawTool *draw_tool) gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
{ {
GimpTool *tool = GIMP_TOOL (draw_tool); GimpTool *tool = GIMP_TOOL (draw_tool);
GimpRectangleToolPrivate *private; GimpRectangleToolPrivate *private;
gint x1, x2, y1, y2; gint x1, x2, y1, y2;
guint function; guint function;
@ -1663,6 +1673,7 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool)); g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
g_object_get (GIMP_RECTANGLE_TOOL (tool), "function", &function, NULL); g_object_get (GIMP_RECTANGLE_TOOL (tool), "function", &function, NULL);
if (function == RECT_INACTIVE) if (function == RECT_INACTIVE)
return; return;
@ -1691,8 +1702,8 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
void void
gimp_rectangle_tool_configure (GimpRectangleTool *rectangle) gimp_rectangle_tool_configure (GimpRectangleTool *rectangle)
{ {
GimpTool *tool = GIMP_TOOL (rectangle); GimpTool *tool = GIMP_TOOL (rectangle);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell); GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell);
GimpRectangleToolPrivate *private; GimpRectangleToolPrivate *private;
GimpRectangleOptions *options; GimpRectangleOptions *options;
gboolean highlight; gboolean highlight;
@ -1859,23 +1870,20 @@ static void
rectangle_automatic_callback (GtkWidget *widget, rectangle_automatic_callback (GtkWidget *widget,
GimpRectangleTool *rectangle) GimpRectangleTool *rectangle)
{ {
GimpDisplay *display; GimpDisplay *display = GIMP_TOOL (rectangle)->display;
gint offset_x, offset_y; gint width = display->image->width;
gint width, height; gint height = display->image->height;
gint rx1, ry1, rx2, ry2; gint offset_x = 0;
gint x1, y1, x2, y2; gint offset_y = 0;
gint rx1, ry1;
gint rx2, ry2;
gint x1, y1;
gint x2, y2;
gint shrunk_x1; gint shrunk_x1;
gint shrunk_y1; gint shrunk_y1;
gint shrunk_x2; gint shrunk_x2;
gint shrunk_y2; gint shrunk_y2;
display = GIMP_TOOL (rectangle)->display;
width = display->image->width;
height = display->image->height;
offset_x = 0;
offset_y = 0;
g_object_get (rectangle, g_object_get (rectangle,
"x1", &rx1, "x1", &rx1,
"y1", &ry1, "y1", &ry1,
@ -1959,7 +1967,9 @@ gimp_rectangle_tool_update_options (GimpRectangleTool *rectangle,
"y2", &y2, "y2", &y2,
NULL); NULL);
options = GIMP_RECTANGLE_OPTIONS (GIMP_TOOL (rectangle)->tool_info->tool_options); options =
GIMP_RECTANGLE_OPTIONS (GIMP_TOOL (rectangle)->tool_info->tool_options);
g_object_get (options, g_object_get (options,
"new-fixed-width", &fixed_width, "new-fixed-width", &fixed_width,
"new-fixed-height", &fixed_height, "new-fixed-height", &fixed_height,