Bill Skaggs <weskaggs@primate.ucdavis.edu>

* app/tools/gimpcroptool.c
	* app/tools/gimpnewrectselecttool.c
	* app/tools/gimprectangletool.c
	* app/tools/gimprectangletool.h: move tool_control out of rectangle
	tool and into users of it, and make rect select execute on leaving
	but crop tool not.  Also rename functions and clean up formatting
	a bit.
This commit is contained in:
William Skaggs 2005-10-19 21:13:25 +00:00
parent 92e1eb1691
commit 4d8dae4f0b
6 changed files with 219 additions and 128 deletions

View File

@ -1,3 +1,13 @@
2005-10-19 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimpcroptool.c
* app/tools/gimpnewrectselecttool.c
* app/tools/gimprectangletool.c
* app/tools/gimprectangletool.h: move tool_control out of rectangle
tool and into users of it, and make rect select execute on leaving
but crop tool not. Also rename functions and clean up formatting
a bit.
2005-10-19 Sven Neumann <sven@gimp.org>
* plug-ins/common/plugin-browser.c: strip ellipsis from menu labels.

View File

@ -53,21 +53,26 @@ static void gimp_crop_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_crop_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_crop_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static gboolean gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gint x,
gint y,
gint w,
gint h);
static gboolean gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gint x,
gint y,
gint w,
gint h);
static GimpDrawToolClass *parent_class = NULL;
@ -146,7 +151,7 @@ gimp_crop_tool_class_init (GimpCropToolClass *klass)
tool_class->initialize = gimp_rectangle_tool_initialize;
tool_class->control = gimp_crop_tool_control;
tool_class->button_press = gimp_rectangle_tool_button_press;
tool_class->button_press = gimp_crop_tool_button_press;
tool_class->button_release = gimp_crop_tool_button_release;
tool_class->motion = gimp_rectangle_tool_motion;
tool_class->key_press = gimp_rectangle_tool_key_press;
@ -196,11 +201,43 @@ gimp_crop_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp)
{
gimp_rectangle_tool_control (tool, action, gdisp);
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
switch (action)
{
case PAUSE:
break;
case RESUME:
gimp_rectangle_tool_configure (rectangle);
break;
case HALT:
gimp_rectangle_tool_response (NULL, GTK_RESPONSE_CANCEL,
rectangle);
break;
default:
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
}
static void
gimp_crop_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
{
if (tool->gdisp && gdisp != tool->gdisp)
gimp_rectangle_tool_response (NULL, GTK_RESPONSE_CANCEL,
GIMP_RECTANGLE_TOOL (tool));
gimp_rectangle_tool_button_press (tool, coords, time, state, gdisp);
}
static void
gimp_crop_tool_button_release (GimpTool *tool,
GimpCoords *coords,

View File

@ -64,6 +64,11 @@ static void gimp_new_rect_select_tool_finalize (GObject *object);
static void gimp_new_rect_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_new_rect_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_new_rect_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
@ -156,7 +161,7 @@ gimp_new_rect_select_tool_class_init (GimpNewRectSelectToolClass *klass)
tool_class->initialize = gimp_rectangle_tool_initialize;
tool_class->control = gimp_new_rect_select_tool_control;
tool_class->button_press = gimp_rectangle_tool_button_press;
tool_class->button_press = gimp_new_rect_select_tool_button_press;
tool_class->button_release = gimp_new_rect_select_tool_button_release;
tool_class->motion = gimp_rectangle_tool_motion;
tool_class->key_press = gimp_rectangle_tool_key_press;
@ -206,11 +211,43 @@ gimp_new_rect_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp)
{
gimp_rectangle_tool_control (tool, action, gdisp);
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
switch (action)
{
case PAUSE:
break;
case RESUME:
gimp_rectangle_tool_configure (rectangle);
break;
case HALT:
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE,
rectangle);
break;
default:
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
}
static void
gimp_new_rect_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
{
if (tool->gdisp && gdisp != tool->gdisp)
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE,
GIMP_RECTANGLE_TOOL (tool));
gimp_rectangle_tool_button_press (tool, coords, time, state, gdisp);
}
static void
gimp_new_rect_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,

View File

@ -64,6 +64,11 @@ static void gimp_new_rect_select_tool_finalize (GObject *object);
static void gimp_new_rect_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_new_rect_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_new_rect_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
@ -156,7 +161,7 @@ gimp_new_rect_select_tool_class_init (GimpNewRectSelectToolClass *klass)
tool_class->initialize = gimp_rectangle_tool_initialize;
tool_class->control = gimp_new_rect_select_tool_control;
tool_class->button_press = gimp_rectangle_tool_button_press;
tool_class->button_press = gimp_new_rect_select_tool_button_press;
tool_class->button_release = gimp_new_rect_select_tool_button_release;
tool_class->motion = gimp_rectangle_tool_motion;
tool_class->key_press = gimp_rectangle_tool_key_press;
@ -206,11 +211,43 @@ gimp_new_rect_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp)
{
gimp_rectangle_tool_control (tool, action, gdisp);
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
switch (action)
{
case PAUSE:
break;
case RESUME:
gimp_rectangle_tool_configure (rectangle);
break;
case HALT:
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE,
rectangle);
break;
default:
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
}
static void
gimp_new_rect_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp)
{
if (tool->gdisp && gdisp != tool->gdisp)
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE,
GIMP_RECTANGLE_TOOL (tool));
gimp_rectangle_tool_button_press (tool, coords, time, state, gdisp);
}
static void
gimp_new_rect_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,

View File

@ -89,14 +89,10 @@ static GimpRectangleToolPrivate *
/* Rectangle helper functions */
static void rectangle_recalc (GimpRectangleTool *rectangle);
static void rectangle_tool_start (GimpRectangleTool *rectangle);
/* Rectangle dialog functions */
static void rectangle_info_update (GimpRectangleTool *rectangle);
static void rectangle_response (GtkWidget *widget,
gint response_id,
GimpRectangleTool *rectangle);
static void rectangle_selection_callback (GtkWidget *widget,
GimpRectangleTool *rectangle);
@ -1258,31 +1254,6 @@ gimp_rectangle_tool_initialize (GimpTool *tool,
return TRUE;
}
void
gimp_rectangle_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp)
{
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
switch (action)
{
case PAUSE:
break;
case RESUME:
rectangle_recalc (rectangle);
break;
case HALT:
rectangle_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE, rectangle);
break;
default:
break;
}
}
void
gimp_rectangle_tool_button_press (GimpTool *tool,
GimpCoords *coords,
@ -1297,9 +1268,6 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
if (gdisp != tool->gdisp)
{
if (tool->gdisp)
rectangle_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE, rectangle);
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
@ -1360,7 +1328,8 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
NULL);
if (lastx == pressx && lasty == pressy)
{
rectangle_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE, rectangle);
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE,
rectangle);
}
rectangle_info_update (rectangle);
@ -1752,7 +1721,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
}
/* recalculate the coordinates for rectangle_draw based on the new values */
rectangle_recalc (rectangle);
gimp_rectangle_tool_configure (rectangle);
g_object_get (rectangle,
"x1", &rx1,
@ -1889,11 +1858,11 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
case GDK_KP_Enter:
case GDK_Return:
rectangle_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE, rectangle);
gimp_rectangle_tool_response (NULL, GIMP_RECTANGLE_MODE_EXECUTE, rectangle);
return TRUE;
case GDK_Escape:
rectangle_response (NULL, GTK_RESPONSE_CANCEL, rectangle);
gimp_rectangle_tool_response (NULL, GTK_RESPONSE_CANCEL, rectangle);
return TRUE;
default:
@ -1927,7 +1896,7 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
"y2", y2 + inc_y,
NULL);
rectangle_recalc (rectangle);
gimp_rectangle_tool_configure (rectangle);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
@ -2182,8 +2151,8 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw)
dx2, dy1);
}
static void
rectangle_recalc (GimpRectangleTool *rectangle)
void
gimp_rectangle_tool_configure (GimpRectangleTool *rectangle)
{
GimpTool *tool = GIMP_TOOL (rectangle);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
@ -2254,7 +2223,7 @@ rectangle_tool_start (GimpRectangleTool *rectangle)
{
GimpTool *tool = GIMP_TOOL (rectangle);
rectangle_recalc (rectangle);
gimp_rectangle_tool_configure (rectangle);
/* initialize the statusbar display */
gimp_tool_push_status_coords (tool, tool->gdisp,
@ -2289,10 +2258,10 @@ rectangle_info_update (GimpRectangleTool *rectangle)
NULL);
}
static void
rectangle_response (GtkWidget *widget,
gint response_id,
GimpRectangleTool *rectangle)
void
gimp_rectangle_tool_response (GtkWidget *widget,
gint response_id,
GimpRectangleTool *rectangle)
{
GimpTool *tool = GIMP_TOOL (rectangle);
gboolean finish = TRUE;
@ -2314,7 +2283,7 @@ rectangle_response (GtkWidget *widget,
x2 - x1,
y2 - y1);
rectangle_recalc (rectangle);
gimp_rectangle_tool_configure (rectangle);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rectangle));
}
@ -2371,7 +2340,7 @@ rectangle_selection_callback (GtkWidget *widget,
NULL);
}
rectangle_recalc (rectangle);
gimp_rectangle_tool_configure (rectangle);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rectangle));
}
@ -2426,7 +2395,7 @@ rectangle_automatic_callback (GtkWidget *widget,
"y2", offset_y + shrunk_y2,
NULL);
rectangle_recalc (rectangle);
gimp_rectangle_tool_configure (rectangle);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (rectangle));
}

View File

@ -92,128 +92,129 @@ struct _GimpRectangleToolInterface
GType gimp_rectangle_tool_interface_get_type (void) G_GNUC_CONST;
void gimp_rectangle_tool_set_controls (GimpRectangleTool *tool,
GtkWidget *controls);
GtkWidget *controls);
GtkWidget * gimp_rectangle_tool_get_controls (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_entry (GimpRectangleTool *tool,
GtkWidget *entry);
GtkWidget *entry);
GtkWidget * gimp_rectangle_tool_get_entry (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_startx (GimpRectangleTool *tool,
gint startx);
gint startx);
gint gimp_rectangle_tool_get_startx (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_starty (GimpRectangleTool *tool,
gint starty);
gint starty);
gint gimp_rectangle_tool_get_starty (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_lastx (GimpRectangleTool *tool,
gint lastx);
gint lastx);
gint gimp_rectangle_tool_get_lastx (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_lasty (GimpRectangleTool *tool,
gint lasty);
gint lasty);
gint gimp_rectangle_tool_get_lasty (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_pressx (GimpRectangleTool *tool,
gint pressx);
gint pressx);
gint gimp_rectangle_tool_get_pressx (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_pressy (GimpRectangleTool *tool,
gint pressy);
gint pressy);
gint gimp_rectangle_tool_get_pressy (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_x1 (GimpRectangleTool *tool,
gint x1);
gint x1);
gint gimp_rectangle_tool_get_x1 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_y1 (GimpRectangleTool *tool,
gint y1);
gint y1);
gint gimp_rectangle_tool_get_y1 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_x2 (GimpRectangleTool *tool,
gint x2);
gint x2);
gint gimp_rectangle_tool_get_x2 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_y2 (GimpRectangleTool *tool,
gint y2);
gint y2);
gint gimp_rectangle_tool_get_y2 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_function (GimpRectangleTool *tool,
guint function);
guint function);
guint gimp_rectangle_tool_get_function (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_dx1 (GimpRectangleTool *tool,
gint dx1);
gint dx1);
gint gimp_rectangle_tool_get_dx1 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_dy1 (GimpRectangleTool *tool,
gint dy1);
gint dy1);
gint gimp_rectangle_tool_get_dy1 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_dx2 (GimpRectangleTool *tool,
gint dx2);
gint dx2);
gint gimp_rectangle_tool_get_dx2 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_dy2 (GimpRectangleTool *tool,
gint dy2);
gint dy2);
gint gimp_rectangle_tool_get_dy2 (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_dcw (GimpRectangleTool *tool,
gint dcw);
gint dcw);
gint gimp_rectangle_tool_get_dcw (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_dch (GimpRectangleTool *tool,
gint dch);
gint dch);
gint gimp_rectangle_tool_get_dch (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_origx (GimpRectangleTool *tool,
gdouble origx);
gdouble origx);
gdouble gimp_rectangle_tool_get_origx (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_origy (GimpRectangleTool *tool,
gdouble origy);
gdouble origy);
gdouble gimp_rectangle_tool_get_origy (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_sizew (GimpRectangleTool *tool,
gdouble sizew);
gdouble sizew);
gdouble gimp_rectangle_tool_get_sizew (GimpRectangleTool *tool);
void gimp_rectangle_tool_set_sizeh (GimpRectangleTool *tool,
gdouble sizeh);
gdouble sizeh);
gdouble gimp_rectangle_tool_get_sizeh (GimpRectangleTool *tool);
void gimp_rectangle_tool_constructor (GObject *object);
void gimp_rectangle_tool_dispose (GObject *object);
gboolean gimp_rectangle_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
void gimp_rectangle_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
void gimp_rectangle_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
gboolean gimp_rectangle_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
void gimp_rectangle_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_draw (GimpDrawTool *draw);
void gimp_rectangle_tool_constructor (GObject *object);
void gimp_rectangle_tool_dispose (GObject *object);
gboolean gimp_rectangle_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
void gimp_rectangle_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
gboolean gimp_rectangle_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
void gimp_rectangle_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_rectangle_tool_draw (GimpDrawTool *draw);
gboolean gimp_rectangle_tool_execute (GimpRectangleTool *rect_tool,
gint x,
gint y,
gint w,
gint h);
gint x,
gint y,
gint w,
gint h);
void gimp_rectangle_tool_response (GtkWidget *widget,
gint response_id,
GimpRectangleTool *rectangle);
void gimp_rectangle_tool_configure (GimpRectangleTool *rectangle);
/* convenience functions */