Commit 855c4efe authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

cleaned up and reordered instance struct and functions. Renamed functions

2005-11-23  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimptoolcontrol.[ch]: cleaned up and reordered
	instance struct and functions. Renamed functions so getters and
	setters actually have "get" and "set" in their names.

	* app/display/gimpdisplayshell-autoscroll.c
	* app/display/gimpdisplayshell-callbacks.c
	* app/tools/gimpaligntool.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimperasertool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimpforegroundselecttool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimpvectortool.c
	* app/tools/tool_manager.c: changed accordingly.
parent b0194064
2005-11-23 Michael Natterer <mitch@gimp.org>
* app/tools/gimptoolcontrol.[ch]: cleaned up and reordered
instance struct and functions. Renamed functions so getters and
setters actually have "get" and "set" in their names.
* app/display/gimpdisplayshell-autoscroll.c
* app/display/gimpdisplayshell-callbacks.c
* app/tools/gimpaligntool.c
* app/tools/gimpconvolvetool.c
* app/tools/gimpdodgeburntool.c
* app/tools/gimperasertool.c
* app/tools/gimpfliptool.c
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/tools/gimpvectortool.c
* app/tools/tool_manager.c: changed accordingly.
2005-11-23 Sven Neumann <sven@gimp.org>
* plug-ins/sel2path/sel2path.[ch]: set a translatable name for the
......
......@@ -145,12 +145,12 @@ gimp_display_shell_autoscroll_timeout (gpointer data)
&device_coords,
&image_coords);
if (gimp_tool_control_auto_snap_to (active_tool->control))
if (gimp_tool_control_get_snap_to (active_tool->control))
{
gint x, y, width, height;
gimp_tool_control_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_tool_control_get_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_display_shell_snap_coords (shell,
&image_coords,
......
......@@ -499,12 +499,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
active_tool = tool_manager_get_active (gimp);
if (active_tool && gimp_tool_control_auto_snap_to (active_tool->control))
if (active_tool && gimp_tool_control_get_snap_to (active_tool->control))
{
gint x, y, width, height;
gimp_tool_control_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_tool_control_get_snap_offsets (active_tool->control,
&x, &y, &width, &height);
if (gimp_display_shell_snap_coords (shell,
&image_coords,
......@@ -632,7 +632,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (active_tool)
{
if ((! gimp_image_is_empty (gimage) ||
gimp_tool_control_handles_empty_image (active_tool->control)) &&
gimp_tool_control_get_handle_empty_image (active_tool->control)) &&
(bevent->button == 1 ||
bevent->button == 2 ||
bevent->button == 3))
......@@ -642,7 +642,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gdisp);
}
else if (gimp_image_is_empty (gimage) &&
! gimp_tool_control_handles_empty_image (active_tool->control))
! gimp_tool_control_get_handle_empty_image (active_tool->control))
{
gimp_display_shell_set_cursor (shell,
GIMP_CURSOR_BAD,
......@@ -681,7 +681,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (active_tool &&
(! GIMP_DISPLAY_CONFIG (gimp->config)->perfect_mouse ||
(gimp_tool_control_motion_mode (active_tool->control) !=
(gimp_tool_control_get_motion_mode (active_tool->control) !=
GIMP_MOTION_MODE_EXACT)))
{
/* don't request motion hins for XInput devices because
......@@ -703,7 +703,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (active_tool &&
(! gimp_image_is_empty (gimage) ||
gimp_tool_control_handles_empty_image (active_tool->control)))
gimp_tool_control_get_handle_empty_image (active_tool->control)))
{
gboolean initialized = TRUE;
......@@ -715,7 +715,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
else if ((active_tool->drawable !=
gimp_image_active_drawable (gimage)) &&
! gimp_tool_control_preserve (active_tool->control))
! gimp_tool_control_get_preserve (active_tool->control))
{
/* create a new one, deleting the current
*/
......@@ -787,7 +787,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (active_tool &&
(! gimp_image_is_empty (gimage) ||
gimp_tool_control_handles_empty_image (active_tool->control)))
gimp_tool_control_get_handle_empty_image (active_tool->control)))
{
if (gimp_tool_control_is_active (active_tool->control))
{
......@@ -932,12 +932,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
active_tool = tool_manager_get_active (gimp);
if (active_tool &&
gimp_tool_control_auto_snap_to (active_tool->control))
gimp_tool_control_get_snap_to (active_tool->control))
{
gint x, y, width, height;
gimp_tool_control_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_tool_control_get_snap_offsets (active_tool->control,
&x, &y, &width, &height);
if (gimp_display_shell_snap_coords (shell,
&image_coords,
......@@ -967,7 +967,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
active_tool = tool_manager_get_active (gimp);
if (active_tool &&
gimp_tool_control_motion_mode (active_tool->control) ==
gimp_tool_control_get_motion_mode (active_tool->control) ==
GIMP_MOTION_MODE_COMPRESS)
{
compressed_motion = gimp_display_shell_compress_motion (shell);
......@@ -989,12 +989,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
&image_coords);
if (active_tool &&
gimp_tool_control_auto_snap_to (active_tool->control))
gimp_tool_control_get_snap_to (active_tool->control))
{
gint x, y, width, height;
gimp_tool_control_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_tool_control_get_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_display_shell_snap_coords (shell,
&image_coords,
......@@ -1026,7 +1026,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (active_tool &&
gimp_tool_control_is_active (active_tool->control) &&
(! gimp_image_is_empty (gimage) ||
gimp_tool_control_handles_empty_image (active_tool->control)))
gimp_tool_control_get_handle_empty_image (active_tool->control)))
{
GdkTimeCoord **history_events;
gint n_history_events;
......@@ -1038,12 +1038,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
mevent->y < 0 ||
mevent->x > shell->disp_width ||
mevent->y > shell->disp_height) &&
! gimp_tool_control_scroll_lock (active_tool->control))
! gimp_tool_control_get_scroll_lock (active_tool->control))
{
gimp_display_shell_autoscroll_start (shell, state, mevent);
}
if (gimp_tool_control_motion_mode (active_tool->control) ==
if (gimp_tool_control_get_motion_mode (active_tool->control) ==
GIMP_MOTION_MODE_EXACT &&
gdk_device_get_history (mevent->device, mevent->window,
shell->last_motion_time,
......@@ -1067,12 +1067,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
&display_coords,
&image_coords);
if (gimp_tool_control_auto_snap_to (active_tool->control))
if (gimp_tool_control_get_snap_to (active_tool->control))
{
gint x, y, width, height;
gimp_tool_control_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_tool_control_get_snap_offsets (active_tool->control,
&x, &y, &width, &height);
gimp_display_shell_snap_coords (shell,
&image_coords,
......@@ -1320,7 +1320,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (active_tool)
{
if ((! gimp_image_is_empty (gimage) ||
gimp_tool_control_handles_empty_image (active_tool->control)) &&
gimp_tool_control_get_handle_empty_image (active_tool->control)) &&
! (state & (GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK)))
......@@ -1330,7 +1330,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gdisp);
}
else if (gimp_image_is_empty (gimage) &&
! gimp_tool_control_handles_empty_image (active_tool->control))
! gimp_tool_control_get_handle_empty_image (active_tool->control))
{
gimp_display_shell_set_cursor (shell,
GIMP_CURSOR_BAD,
......
......@@ -227,9 +227,8 @@ gimp_align_tool_init (GimpAlignTool *align_tool)
align_tool->horz_offset = 0;
align_tool->vert_offset = 0;
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_MOVE);
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_MOVE);
}
......
......@@ -164,8 +164,8 @@ gimp_convolve_tool_cursor_update (GimpTool *tool,
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
gimp_tool_control_set_toggle (tool->control,
(options->type == GIMP_SHARPEN_CONVOLVE));
gimp_tool_control_set_toggled (tool->control,
(options->type == GIMP_SHARPEN_CONVOLVE));
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
}
......
......@@ -166,7 +166,7 @@ gimp_dodge_burn_tool_cursor_update (GimpTool *tool,
options = GIMP_DODGE_BURN_OPTIONS (tool->tool_info->tool_options);
gimp_tool_control_set_toggle (tool->control, (options->type == GIMP_BURN));
gimp_tool_control_set_toggled (tool->control, (options->type == GIMP_BURN));
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
}
......
......@@ -158,7 +158,7 @@ gimp_eraser_tool_cursor_update (GimpTool *tool,
options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
gimp_tool_control_set_toggle (tool->control, options->anti_erase);
gimp_tool_control_set_toggled (tool->control, options->anti_erase);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
}
......
......@@ -212,8 +212,8 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
gimp_tool_control_set_toggle_cursor (tool->control, GIMP_CURSOR_MOUSE);
}
gimp_tool_control_set_toggle (tool->control,
options->flip_type == GIMP_ORIENTATION_VERTICAL);
gimp_tool_control_set_toggled (tool->control,
options->flip_type == GIMP_ORIENTATION_VERTICAL);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
}
......
......@@ -370,7 +370,7 @@ gimp_foreground_select_tool_cursor_update (GimpTool *tool,
options = GIMP_FOREGROUND_SELECT_OPTIONS (tool->tool_info->tool_options);
gimp_tool_control_set_toggle (tool->control, options->background);
gimp_tool_control_set_toggled (tool->control, options->background);
switch (GIMP_SELECTION_TOOL (tool)->op)
{
......@@ -720,7 +720,7 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
gimp_tool_control_set_toggle_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_ERASER);
gimp_tool_control_set_toggle (tool->control, options->background);
gimp_tool_control_set_toggled (tool->control, options->background);
}
else
{
......@@ -729,7 +729,7 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
gimp_tool_control_set_toggle_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_FREE_SELECT);
gimp_tool_control_set_toggle (tool->control, FALSE);
gimp_tool_control_set_toggled (tool->control, FALSE);
}
}
......
......@@ -159,7 +159,7 @@ gimp_magnify_tool_init (GimpMagnifyTool *magnify_tool)
magnify_tool->h = 0;
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
gimp_tool_control_set_handles_empty_image (tool->control, TRUE);
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_cursor (tool->control,
......@@ -336,8 +336,8 @@ gimp_magnify_tool_cursor_update (GimpTool *tool,
options = GIMP_MAGNIFY_OPTIONS (tool->tool_info->tool_options);
gimp_tool_control_set_toggle (tool->control,
options->zoom_type == GIMP_ZOOM_OUT);
gimp_tool_control_set_toggled (tool->control,
options->zoom_type == GIMP_ZOOM_OUT);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
}
......
......@@ -174,9 +174,9 @@ gimp_measure_tool_init (GimpMeasureTool *measure_tool)
{
GimpTool *tool = GIMP_TOOL (measure_tool);
gimp_tool_control_set_handles_empty_image (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_MEASURE);
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_MEASURE);
}
static void
......
......@@ -186,10 +186,10 @@ gimp_move_tool_init (GimpMoveTool *move_tool)
move_tool->old_active_layer = NULL;
move_tool->old_active_vectors = NULL;
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_handles_empty_image (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_MOVE);
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_MOVE);
}
static void
......
......@@ -44,18 +44,18 @@ gimp_tool_control_get_type (void)
static const GTypeInfo tool_control_info =
{
sizeof (GimpToolControlClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_tool_control_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpToolControl),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_tool_control_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_tool_control_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpToolControl),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_tool_control_init,
};
tool_control_type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpToolControl",
"GimpToolControl",
&tool_control_info, 0);
}
......@@ -78,19 +78,20 @@ gimp_tool_control_init (GimpToolControl *control)
control->active = FALSE;
control->paused_count = 0;
control->toggled = FALSE;
control->preserve = TRUE;
control->scroll_lock = FALSE;
control->handle_empty_image = FALSE;
control->dirty_mask = GIMP_DIRTY_NONE;
control->motion_mode = GIMP_MOTION_MODE_HINT;
control->auto_snap_to = TRUE;
control->snap_offset_x = 0;
control->snap_offset_y = 0;
control->snap_width = 0;
control->snap_height = 0;
control->preserve = TRUE;
control->dirty_mask = GIMP_DIRTY_NONE;
control->handle_empty_image = FALSE;
control->motion_mode = GIMP_MOTION_MODE_HINT;
control->toggled = FALSE;
control->cursor = GIMP_CURSOR_MOUSE;
control->tool_cursor = GIMP_TOOL_CURSOR_NONE;
......@@ -127,6 +128,36 @@ gimp_tool_control_finalize (GObject *object)
/* public functions */
void
gimp_tool_control_activate (GimpToolControl *control)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
#ifdef GIMP_UNSTABLE
g_return_if_fail (control->active == FALSE);
#endif
control->active = TRUE;
}
void
gimp_tool_control_halt (GimpToolControl *control)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
#ifdef GIMP_UNSTABLE
g_return_if_fail (control->active == TRUE);
#endif
control->active = FALSE;
}
gboolean
gimp_tool_control_is_active (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), FALSE);
return control->active;
}
void
gimp_tool_control_pause (GimpToolControl *control)
{
......@@ -152,51 +183,88 @@ gimp_tool_control_is_paused (GimpToolControl *control)
}
void
gimp_tool_control_activate (GimpToolControl *control)
gimp_tool_control_set_preserve (GimpToolControl *control,
gboolean preserve)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
#ifdef GIMP_UNSTABLE
g_return_if_fail (control->active == FALSE);
#endif
control->active = TRUE;
control->preserve = preserve ? TRUE : FALSE;
}
gboolean
gimp_tool_control_get_preserve (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), FALSE);
return control->preserve;
}
void
gimp_tool_control_halt (GimpToolControl *control)
gimp_tool_control_set_scroll_lock (GimpToolControl *control,
gboolean scroll_lock)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
#ifdef GIMP_UNSTABLE
g_return_if_fail (control->active == TRUE);
#endif
control->active = FALSE;
control->scroll_lock = scroll_lock ? TRUE : FALSE;
}
gboolean
gimp_tool_control_is_active (GimpToolControl *control)
gimp_tool_control_get_scroll_lock (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), FALSE);
return control->active;
return control->scroll_lock;
}
void
gimp_tool_control_set_toggle (GimpToolControl *control,
gboolean toggled)
gimp_tool_control_set_handle_empty_image (GimpToolControl *control,
gboolean handle_empty)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->toggled = toggled ? TRUE : FALSE;
control->handle_empty_image = handle_empty ? TRUE : FALSE;
}
gboolean
gimp_tool_control_get_handle_empty_image (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), FALSE);
return control->handle_empty_image;
}
void
gimp_tool_control_set_handles_empty_image (GimpToolControl *control,
gboolean handle_empty)
gimp_tool_control_set_dirty_mask (GimpToolControl *control,
GimpDirtyMask dirty_mask)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->handle_empty_image = handle_empty ? TRUE : FALSE;
control->dirty_mask = dirty_mask;
}
GimpDirtyMask
gimp_tool_control_get_dirty_mask (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), GIMP_DIRTY_NONE);
return control->dirty_mask;
}
void
gimp_tool_control_set_motion_mode (GimpToolControl *control,
GimpMotionMode motion_mode)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->motion_mode = motion_mode;
}
GimpMotionMode
gimp_tool_control_get_motion_mode (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), GIMP_MOTION_MODE_HINT);
return control->motion_mode;
}
void
......@@ -208,6 +276,14 @@ gimp_tool_control_set_snap_to (GimpToolControl *control,
control->auto_snap_to = snap_to ? TRUE : FALSE;
}
gboolean
gimp_tool_control_get_snap_to (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), FALSE);
return control->auto_snap_to;
}
void
gimp_tool_control_set_snap_offsets (GimpToolControl *control,
gint offset_x,
......@@ -224,30 +300,35 @@ gimp_tool_control_set_snap_offsets (GimpToolControl *control,
}
void
gimp_tool_control_set_motion_mode (GimpToolControl *control,
GimpMotionMode motion_mode)
gimp_tool_control_get_snap_offsets (GimpToolControl *control,
gint *offset_x,
gint *offset_y,
gint *width,
gint *height)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->motion_mode = motion_mode;
if (offset_x) *offset_x = control->snap_offset_x;
if (offset_y) *offset_y = control->snap_offset_y;
if (width) *width = control->snap_width;
if (height) *height = control->snap_height;
}
void
gimp_tool_control_set_preserve (GimpToolControl *control,
gboolean preserve)
gimp_tool_control_set_toggled (GimpToolControl *control,
gboolean toggled)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->preserve = preserve ? TRUE : FALSE;
control->toggled = toggled ? TRUE : FALSE;
}
void
gimp_tool_control_set_dirty_mask (GimpToolControl *control,
GimpDirtyMask dirty_mask)
gboolean
gimp_tool_control_get_toggled (GimpToolControl *control)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), FALSE);
control->dirty_mask = dirty_mask;
return control->toggled;
}
void
......@@ -304,87 +385,6 @@ gimp_tool_control_set_toggle_cursor_modifier (GimpToolControl *control,
control->toggle_cursor_modifier = cmodifier;
}
void
gimp_tool_control_set_scroll_lock (GimpToolControl *control,
gboolean scroll_lock)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->scroll_lock = scroll_lock ? TRUE : FALSE;
}
GimpMotionMode
gimp_tool_control_motion_mode (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), GIMP_MOTION_MODE_HINT);
return control->motion_mode;