put all tool_manager variables into a struct which is attached to a

2001-07-07  Michael Natterer  <mitch@gimp.org>

	* app/tools/tool_manager.[ch]: put all tool_manager variables into
	a struct which is attached to a "Gimp". Pass a Gimp* to all
	tool_manager functions.

	* app/disp_callbacks.c
	* app/gdisplay.c
	* app/gimage.c
	* app/scale.c
	* app/scroll.c
	* app/undo.c
	* app/gui/convert-dialog.c
	* app/gui/edit-commands.c
	* app/gui/tool-options-dialog.c
	* app/gui/tools-commands.c: changed accordingly.

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimphistogramtool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimptexttool.c
	* app/tools/gimpthresholdtool.c
	* app/tools/gimptool.c
	* app/tools/gimptransformtool.c: mostly bad hacks for tool dialogs
	which exist without a real context. Needs some more review.
This commit is contained in:
Michael Natterer 2001-07-07 17:36:00 +00:00 committed by Michael Natterer
parent 5693956664
commit b70ee4b76d
51 changed files with 792 additions and 300 deletions

View File

@ -1,3 +1,38 @@
2001-07-07 Michael Natterer <mitch@gimp.org>
* app/tools/tool_manager.[ch]: put all tool_manager variables into
a struct which is attached to a "Gimp". Pass a Gimp* to all
tool_manager functions.
* app/disp_callbacks.c
* app/gdisplay.c
* app/gimage.c
* app/scale.c
* app/scroll.c
* app/undo.c
* app/gui/convert-dialog.c
* app/gui/edit-commands.c
* app/gui/tool-options-dialog.c
* app/gui/tools-commands.c: changed accordingly.
* app/tools/gimpbezierselecttool.c
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpclonetool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcroptool.c
* app/tools/gimpcurvestool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimphistogramtool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimptexttool.c
* app/tools/gimpthresholdtool.c
* app/tools/gimptool.c
* app/tools/gimptransformtool.c: mostly bad hacks for tool dialogs
which exist without a real context. Needs some more review.
2001-07-07 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am

View File

@ -92,7 +92,7 @@ edit_cut_cmd_callback (GtkWidget *widget,
return_if_no_display (gdisp);
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_cut (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage)))
@ -122,7 +122,7 @@ edit_paste_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
@ -145,7 +145,7 @@ edit_paste_into_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
@ -168,7 +168,7 @@ edit_paste_as_new_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
gimp_edit_paste_as_new (gdisp->gimage->gimp,
gdisp->gimage,
@ -186,7 +186,7 @@ edit_named_cut_cmd_callback (GtkWidget *widget,
return_if_no_display (gdisp);
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
qbox = gimp_query_string_box (_("Cut Named"),
gimp_standard_help_func,

View File

@ -87,6 +87,7 @@ tools_select_cmd_callback (GtkWidget *widget,
{
GtkType tool_type;
GimpToolInfo *tool_info;
GimpTool *active_tool;
GDisplay *gdisp;
tool_type = (GtkType) action;
@ -100,6 +101,8 @@ tools_select_cmd_callback (GtkWidget *widget,
#warning FIXME (let the tool manager to this stuff)
#endif
active_tool = tool_manager_get_active (the_gimp);
/* Paranoia */
active_tool->drawable = NULL;

View File

@ -38,6 +38,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -621,6 +622,10 @@ color_balance_create_lookup_tables (ColorBalanceDialog *cbd)
static void
color_balance_preview (ColorBalanceDialog *cbd)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (!cbd->image_map)
{
g_message ("color_balance_preview(): No image map");
@ -656,11 +661,14 @@ color_balance_ok_callback (GtkWidget *widget,
gpointer data)
{
ColorBalanceDialog *cbd;
GimpTool *active_tool;
cbd = (ColorBalanceDialog *) data;
gimp_dialog_hide (cbd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!cbd->preview)
@ -682,11 +690,14 @@ color_balance_cancel_callback (GtkWidget *widget,
gpointer data)
{
ColorBalanceDialog *cbd;
GimpTool *active_tool;
cbd = (ColorBalanceDialog *) data;
gimp_dialog_hide (cbd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (cbd->image_map)
{
active_tool->preserve = TRUE;
@ -738,6 +749,7 @@ color_balance_preview_update (GtkWidget *widget,
gpointer data)
{
ColorBalanceDialog *cbd;
GimpTool *active_tool;
cbd = (ColorBalanceDialog *) data;
@ -751,6 +763,8 @@ color_balance_preview_update (GtkWidget *widget,
cbd->preview = FALSE;
if (cbd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (cbd->image_map);
active_tool->preserve = FALSE;

View File

@ -43,6 +43,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -390,9 +391,9 @@ gimp_curves_tool_button_press (GimpTool *tool,
if (drawable != tool->drawable)
{
active_tool->preserve = TRUE;
tool->preserve = TRUE;
image_map_abort (curves_dialog->image_map);
active_tool->preserve = FALSE;
tool->preserve = FALSE;
tool->drawable = drawable;
@ -608,10 +609,14 @@ curves_dialog_hide (void)
void
curves_free (void)
{
GimpTool *active_tool;
if (curves_dialog)
{
if (curves_dialog->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_abort (curves_dialog->image_map);
active_tool->preserve = FALSE;
@ -1227,12 +1232,16 @@ curves_calculate_curve (CurvesDialog *cd)
static void
curves_preview (CurvesDialog *cd)
{
GimpTool *active_tool;
if (!cd->image_map)
{
g_message ("curves_preview(): No image map");
return;
}
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_apply (cd->image_map, (ImageMapApplyFunc)gimp_lut_process_2,
(void *) cd->lut);
@ -1361,11 +1370,14 @@ curves_ok_callback (GtkWidget *widget,
gpointer data)
{
CurvesDialog *cd;
GimpTool *active_tool;
cd = (CurvesDialog *) data;
gimp_dialog_hide (cd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE; /* We're about to dirty... */
if (!cd->preview)
@ -1388,11 +1400,14 @@ curves_cancel_callback (GtkWidget *widget,
gpointer data)
{
CurvesDialog *cd;
GimpTool *active_tool;
cd = (CurvesDialog *) data;
gimp_dialog_hide (cd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (cd->image_map)
{
active_tool->preserve = TRUE;
@ -1442,6 +1457,7 @@ curves_preview_update (GtkWidget *widget,
gpointer data)
{
CurvesDialog *cd;
GimpTool *active_tool;
cd = (CurvesDialog *) data;
@ -1455,6 +1471,8 @@ curves_preview_update (GtkWidget *widget,
cd->preview = FALSE;
if (cd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (cd->image_map);
active_tool->preserve = FALSE;

View File

@ -38,6 +38,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -399,6 +400,10 @@ hue_saturation_dialog_hide (void)
void
hue_saturation_free (void)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (hue_saturation_dialog)
{
if (hue_saturation_dialog->image_map)
@ -725,6 +730,10 @@ hue_saturation_update (HueSaturationDialog *hsd,
static void
hue_saturation_preview (HueSaturationDialog *hsd)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (!hsd->image_map)
{
g_warning ("hue_saturation_preview(): No image map");
@ -759,11 +768,14 @@ hue_saturation_ok_callback (GtkWidget *widget,
gpointer data)
{
HueSaturationDialog *hsd;
GimpTool *active_tool;
hsd = (HueSaturationDialog *) data;
gimp_dialog_hide (hsd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!hsd->preview)
@ -785,11 +797,14 @@ hue_saturation_cancel_callback (GtkWidget *widget,
gpointer data)
{
HueSaturationDialog *hsd;
GimpTool *active_tool;
hsd = (HueSaturationDialog *) data;
gimp_dialog_hide (hsd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (hsd->image_map)
{
active_tool->preserve = TRUE;
@ -825,6 +840,7 @@ hue_saturation_preview_update (GtkWidget *widget,
gpointer data)
{
HueSaturationDialog *hsd;
GimpTool *active_tool;
hsd = (HueSaturationDialog *) data;
@ -838,6 +854,8 @@ hue_saturation_preview_update (GtkWidget *widget,
hsd->preview = FALSE;
if (hsd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (hsd->image_map);
active_tool->preserve = FALSE;

View File

@ -40,6 +40,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -482,12 +483,16 @@ threshold_update (ThresholdDialog *td,
static void
threshold_preview (ThresholdDialog *td)
{
GimpTool *active_tool;
if (!td->image_map)
{
g_warning ("threshold_preview(): No image map");
return;
}
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_apply (td->image_map, threshold, td);
active_tool->preserve = FALSE;
@ -515,11 +520,14 @@ threshold_ok_callback (GtkWidget *widget,
gpointer data)
{
ThresholdDialog *td;
GimpTool *active_tool;
td = (ThresholdDialog *) data;
gimp_dialog_hide (td->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!td->preview)
@ -541,11 +549,14 @@ threshold_cancel_callback (GtkWidget *widget,
gpointer data)
{
ThresholdDialog *td;
GimpTool *active_tool;
td = (ThresholdDialog *) data;
gimp_dialog_hide (td->shell);
active_tool = tool_manager_get_active (the_gimp);
if (td->image_map)
{
active_tool->preserve = TRUE;
@ -565,6 +576,7 @@ threshold_preview_update (GtkWidget *widget,
gpointer data)
{
ThresholdDialog *td;
GimpTool *active_tool;
td = (ThresholdDialog *) data;
@ -578,6 +590,8 @@ threshold_preview_update (GtkWidget *widget,
td->preview = FALSE;
if (td->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (td->image_map);
active_tool->preserve = FALSE;

View File

@ -999,7 +999,9 @@ gimp_transform_tool_grid_density_changed (void)
GimpTransformTool *tr_tool;
GimpDrawTool *dr_tool;
tr_tool = GIMP_TRANSFORM_TOOL ( /* EEEEEEEK!!! */ active_tool);
/* EEEK!!! */
tr_tool = GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp));
dr_tool = GIMP_DRAW_TOOL (tr_tool);
if (tr_tool->function == TRANSFORM_CREATING)
@ -1018,7 +1020,8 @@ gimp_transform_tool_showpath_changed (gint type /* a truly undescriptive name */
{
GimpTransformTool *tr_tool;
tr_tool = GIMP_TRANSFORM_TOOL ( /* EEEEEEEK!!! */ active_tool);
/* EEEEEEEK!!! */
tr_tool = GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp));
if (tr_tool->function == TRANSFORM_CREATING)
return;
@ -1045,7 +1048,10 @@ gimp_transform_tool_grid_recalc (GimpTransformTool *tr_tool)
}
if (gimp_transform_tool_show_grid ())
gimp_transform_tool_setup_grid (GIMP_TRANSFORM_TOOL ( /* EEEEEEK!!! */ active_tool));
{
/* EEEEEEK!!! */
gimp_transform_tool_setup_grid (GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp)));
}
}
static void
@ -1208,7 +1214,8 @@ gimp_transform_tool_do (GimpImage *gimage,
y2 = y1 + tile_manager_height (float_tiles);
/* Find the bounding coordinates */
if (alpha == 0 || (active_tool && gimp_transform_tool_clip ()))
if (alpha == 0 || (tool_manager_get_active (gimage->gimp) &&
gimp_transform_tool_clip ()))
{
tx1 = x1;
ty1 = y1;
@ -1217,7 +1224,10 @@ gimp_transform_tool_do (GimpImage *gimage,
}
else
{
gdouble dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
gdouble dx1, dy1;
gdouble dx2, dy2;
gdouble dx3, dy3;
gdouble dx4, dy4;
gimp_matrix3_transform_point (matrix, x1, y1, &dx1, &dy1);
gimp_matrix3_transform_point (matrix, x2, y1, &dx2, &dy2);
@ -1230,6 +1240,7 @@ gimp_transform_tool_do (GimpImage *gimage,
ty1 = MIN (dy1, dy2);
ty1 = MIN (ty1, dy3);
ty1 = MIN (ty1, dy4);
tx2 = MAX (dx1, dx2);
tx2 = MAX (tx2, dx3);
tx2 = MAX (tx2, dx4);

View File

@ -999,7 +999,9 @@ gimp_transform_tool_grid_density_changed (void)
GimpTransformTool *tr_tool;
GimpDrawTool *dr_tool;
tr_tool = GIMP_TRANSFORM_TOOL ( /* EEEEEEEK!!! */ active_tool);
/* EEEK!!! */
tr_tool = GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp));
dr_tool = GIMP_DRAW_TOOL (tr_tool);
if (tr_tool->function == TRANSFORM_CREATING)
@ -1018,7 +1020,8 @@ gimp_transform_tool_showpath_changed (gint type /* a truly undescriptive name */
{
GimpTransformTool *tr_tool;
tr_tool = GIMP_TRANSFORM_TOOL ( /* EEEEEEEK!!! */ active_tool);
/* EEEEEEEK!!! */
tr_tool = GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp));
if (tr_tool->function == TRANSFORM_CREATING)
return;
@ -1045,7 +1048,10 @@ gimp_transform_tool_grid_recalc (GimpTransformTool *tr_tool)
}
if (gimp_transform_tool_show_grid ())
gimp_transform_tool_setup_grid (GIMP_TRANSFORM_TOOL ( /* EEEEEEK!!! */ active_tool));
{
/* EEEEEEK!!! */
gimp_transform_tool_setup_grid (GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp)));
}
}
static void
@ -1208,7 +1214,8 @@ gimp_transform_tool_do (GimpImage *gimage,
y2 = y1 + tile_manager_height (float_tiles);
/* Find the bounding coordinates */
if (alpha == 0 || (active_tool && gimp_transform_tool_clip ()))
if (alpha == 0 || (tool_manager_get_active (gimage->gimp) &&
gimp_transform_tool_clip ()))
{
tx1 = x1;
ty1 = y1;
@ -1217,7 +1224,10 @@ gimp_transform_tool_do (GimpImage *gimage,
}
else
{
gdouble dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
gdouble dx1, dy1;
gdouble dx2, dy2;
gdouble dx3, dy3;
gdouble dx4, dy4;
gimp_matrix3_transform_point (matrix, x1, y1, &dx1, &dy1);
gimp_matrix3_transform_point (matrix, x2, y1, &dx2, &dy2);
@ -1230,6 +1240,7 @@ gimp_transform_tool_do (GimpImage *gimage,
ty1 = MIN (dy1, dy2);
ty1 = MIN (ty1, dy3);
ty1 = MIN (ty1, dy4);
tx2 = MAX (dx1, dx2);
tx2 = MAX (tx2, dx3);
tx2 = MAX (tx2, dx4);

View File

@ -1272,12 +1272,15 @@ undo_pop_transform (GimpImage *gimage,
UndoType type,
gpointer tu_ptr)
{
GimpTool *active_tool;
GimpTransformTool *tt;
TransformUndo *tu;
TileManager *temp;
gdouble d;
gint i;
active_tool = tool_manager_get_active (gimage->gimp);
/* Can't have ANY tool selected - maybe a plugin running */
if (active_tool == NULL)
return TRUE;
@ -1363,10 +1366,13 @@ undo_pop_paint (GimpImage *gimage,
UndoType type,
gpointer pu_ptr)
{
GimpTool *active_tool;
GimpPaintTool *pt;
PaintUndo *pu;
gdouble tmp;
active_tool = tool_manager_get_active (gimage->gimp);
/* Can't have ANY tool selected - maybe a plugin running */
if (active_tool == NULL)
return TRUE;

View File

@ -411,15 +411,18 @@ gdisplay_format_title (GDisplay *gdisp,
static void
gdisplay_delete (GDisplay *gdisp)
{
GimpTool *active_tool;
g_hash_table_remove (display_ht, gdisp->shell);
g_hash_table_remove (display_ht, gdisp->canvas);
/* stop any active tool */
tool_manager_control_active (HALT, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* clear out the pointer to this gdisp from the active tool */
if (active_tool &&
active_tool->gdisp == gdisp)
if (active_tool && active_tool->gdisp == gdisp)
{
active_tool->drawable = NULL;
active_tool->gdisp = NULL;
@ -708,7 +711,7 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
if (list)
{
/* stop the currently active tool */
tool_manager_control_active (PAUSE, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
while (list)
{
@ -733,7 +736,7 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
selection_start (gdisp->select, TRUE);
/* start the currently active tool */
tool_manager_control_active (RESUME, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}
}

View File

@ -502,6 +502,7 @@ indexed_ok_callback (GtkWidget *widget,
IndexedDialog *dialog;
ConvertPaletteType palette_type;
ConvertDitherType dither_type;
GimpTool *active_tool;
dialog = (IndexedDialog *) data;
@ -528,8 +529,10 @@ indexed_ok_callback (GtkWidget *widget,
/* Close the dialogs when open because they're useless for indexed
* images and could crash the GIMP when used nevertheless
*/
active_tool = tool_manager_get_active (dialog->gimage->gimp);
if (active_tool)
tool_manager_control_active (HALT, active_tool->gdisp);
tool_manager_control_active (dialog->gimage->gimp, HALT, active_tool->gdisp);
/* Convert the image to indexed color */
gimp_image_convert (dialog->gimage, INDEXED, dialog->num_cols,

View File

@ -176,6 +176,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event)
{
GDisplay *gdisp;
GimpTool *active_tool;
GdkEventExpose *eevent;
GdkEventMotion *mevent;
GdkEventButton *bevent;
@ -193,6 +194,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
if (!canvas->window)
return FALSE;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* If this is the first event... */
if (!gdisp->select)
{
@ -294,9 +297,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
GTK_SIGNAL_FUNC (gtk_true),
NULL);
/* FIXME!!! This code is ugly, and active_tool shouldn't be referenced
* directly
*/
/* FIXME!!! This code is ugly */
if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) ||
! gimp_image_is_empty (gdisp->gimage)))
@ -322,6 +323,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
tool_manager_initialize_tool (gdisp->gimage->gimp,
active_tool, gdisp);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
}
/* otherwise set it's drawable if it has none */
@ -681,19 +684,32 @@ gdisplay_hruler_button_press (GtkWidget *widget,
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gimp_busy)
return TRUE;
if (event->button == 1)
{
gdisp = data;
GimpToolInfo *tool_info;
GimpTool *active_tool;
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL));
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
if (tool_info)
{
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if (active_tool)
{
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
}
}
}
return FALSE;
@ -706,19 +722,32 @@ gdisplay_vruler_button_press (GtkWidget *widget,
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gimp_busy)
return TRUE;
if (event->button == 1)
{
gdisp = data;
GimpToolInfo *tool_info;
GimpTool *active_tool;
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL));
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
if (tool_info)
{
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if (active_tool)
{
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
}
}
}
return FALSE;

View File

@ -176,6 +176,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event)
{
GDisplay *gdisp;
GimpTool *active_tool;
GdkEventExpose *eevent;
GdkEventMotion *mevent;
GdkEventButton *bevent;
@ -193,6 +194,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
if (!canvas->window)
return FALSE;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* If this is the first event... */
if (!gdisp->select)
{
@ -294,9 +297,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
GTK_SIGNAL_FUNC (gtk_true),
NULL);
/* FIXME!!! This code is ugly, and active_tool shouldn't be referenced
* directly
*/
/* FIXME!!! This code is ugly */
if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) ||
! gimp_image_is_empty (gdisp->gimage)))
@ -322,6 +323,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
tool_manager_initialize_tool (gdisp->gimage->gimp,
active_tool, gdisp);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
}
/* otherwise set it's drawable if it has none */
@ -681,19 +684,32 @@ gdisplay_hruler_button_press (GtkWidget *widget,
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gimp_busy)
return TRUE;
if (event->button == 1)
{
gdisp = data;
GimpToolInfo *tool_info;
GimpTool *active_tool;
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL));
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
if (tool_info)
{
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if (active_tool)
{
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
}
}
}
return FALSE;
@ -706,19 +722,32 @@ gdisplay_vruler_button_press (GtkWidget *widget,
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gimp_busy)
return TRUE;
if (event->button == 1)
{
gdisp = data;
GimpToolInfo *tool_info;
GimpTool *active_tool;
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL));
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
if (tool_info)
{
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if (active_tool)
{
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
}
}
}
return FALSE;

View File

@ -61,7 +61,7 @@ resize_display (GDisplay *gdisp,
gboolean redisplay)
{
/* freeze the active tool */
tool_manager_control_active (PAUSE, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
if (resize_window)
gdisplay_shrink_wrap (gdisp);
@ -78,7 +78,7 @@ resize_display (GDisplay *gdisp,
}
/* re-enable the active tool */
tool_manager_control_active (RESUME, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}
@ -86,7 +86,7 @@ void
shrink_wrap_display (GDisplay *gdisp)
{
/* freeze the active tool */
tool_manager_control_active (PAUSE, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
gdisplay_shrink_wrap (gdisp);
@ -97,7 +97,7 @@ shrink_wrap_display (GDisplay *gdisp)
gdisplays_flush ();
/* re-enable the active tool */
tool_manager_control_active (RESUME, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}

View File

@ -22,9 +22,10 @@
#include <gtk/gtk.h>
#include "core/core-types.h"
#include "tools/tools-types.h"
#include "core/gimpimage.h"
#include "widgets/gimpcursor.h"
#include "tools/gimptool.h"
@ -154,8 +155,8 @@ scroll_display (GDisplay *gdisp,
gdisp->offset_x = old_x;
gdisp->offset_y = old_y;
/* stop the currently active tool */
tool_manager_control_active (PAUSE, (void *) gdisp);
/* freeze the active tool */
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
/* set the offsets back to the new values */
gdisp->offset_x += x_offset;
@ -169,8 +170,8 @@ scroll_display (GDisplay *gdisp,
(gdisp->disp_width - abs (x_offset)),
(gdisp->disp_height - abs (y_offset)));
/* resume the currently active tool */
tool_manager_control_active (RESUME, (void *) gdisp);
/* re-enable the active tool */
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
/* scale the image into the exposed regions */
if (x_offset)

View File

@ -411,15 +411,18 @@ gdisplay_format_title (GDisplay *gdisp,
static void
gdisplay_delete (GDisplay *gdisp)
{
GimpTool *active_tool;
g_hash_table_remove (display_ht, gdisp->shell);
g_hash_table_remove (display_ht, gdisp->canvas);
/* stop any active tool */
tool_manager_control_active (HALT, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* clear out the pointer to this gdisp from the active tool */
if (active_tool &&
active_tool->gdisp == gdisp)
if (active_tool && active_tool->gdisp == gdisp)
{
active_tool->drawable = NULL;
active_tool->gdisp = NULL;
@ -708,7 +711,7 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
if (list)
{
/* stop the currently active tool */
tool_manager_control_active (PAUSE, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
while (list)
{
@ -733,7 +736,7 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
selection_start (gdisp->select, TRUE);
/* start the currently active tool */
tool_manager_control_active (RESUME, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}
}

View File

@ -176,6 +176,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event)
{
GDisplay *gdisp;
GimpTool *active_tool;
GdkEventExpose *eevent;
GdkEventMotion *mevent;
GdkEventButton *bevent;
@ -193,6 +194,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
if (!canvas->window)
return FALSE;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* If this is the first event... */
if (!gdisp->select)
{
@ -294,9 +297,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
GTK_SIGNAL_FUNC (gtk_true),
NULL);
/* FIXME!!! This code is ugly, and active_tool shouldn't be referenced
* directly
*/
/* FIXME!!! This code is ugly */
if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) ||
! gimp_image_is_empty (gdisp->gimage)))
@ -322,6 +323,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
tool_manager_initialize_tool (gdisp->gimage->gimp,
active_tool, gdisp);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
}
/* otherwise set it's drawable if it has none */
@ -681,19 +684,32 @@ gdisplay_hruler_button_press (GtkWidget *widget,
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gimp_busy)
return TRUE;
if (event->button == 1)
{
gdisp = data;
GimpToolInfo *tool_info;
GimpTool *active_tool;
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL));
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
if (tool_info)
{
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if (active_tool)
{
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
}
}
}
return FALSE;
@ -706,19 +722,32 @@ gdisplay_vruler_button_press (GtkWidget *widget,
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gimp_busy)
return TRUE;
if (event->button == 1)
{
gdisp = data;
GimpToolInfo *tool_info;
GimpTool *active_tool;
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL));
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
if (tool_info)
{
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if (active_tool)
{
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (gdisp->canvas);
}
}
}
return FALSE;

View File

@ -61,7 +61,7 @@ resize_display (GDisplay *gdisp,
gboolean redisplay)
{
/* freeze the active tool */
tool_manager_control_active (PAUSE, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
if (resize_window)
gdisplay_shrink_wrap (gdisp);
@ -78,7 +78,7 @@ resize_display (GDisplay *gdisp,
}
/* re-enable the active tool */
tool_manager_control_active (RESUME, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}
@ -86,7 +86,7 @@ void
shrink_wrap_display (GDisplay *gdisp)
{
/* freeze the active tool */
tool_manager_control_active (PAUSE, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
gdisplay_shrink_wrap (gdisp);
@ -97,7 +97,7 @@ shrink_wrap_display (GDisplay *gdisp)
gdisplays_flush ();
/* re-enable the active tool */
tool_manager_control_active (RESUME, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}

View File

@ -22,9 +22,10 @@
#include <gtk/gtk.h>
#include "core/core-types.h"
#include "tools/tools-types.h"
#include "core/gimpimage.h"
#include "widgets/gimpcursor.h"
#include "tools/gimptool.h"
@ -154,8 +155,8 @@ scroll_display (GDisplay *gdisp,
gdisp->offset_x = old_x;
gdisp->offset_y = old_y;
/* stop the currently active tool */
tool_manager_control_active (PAUSE, (void *) gdisp);
/* freeze the active tool */
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
/* set the offsets back to the new values */
gdisp->offset_x += x_offset;
@ -169,8 +170,8 @@ scroll_display (GDisplay *gdisp,
(gdisp->disp_width - abs (x_offset)),
(gdisp->disp_height - abs (y_offset)));
/* resume the currently active tool */
tool_manager_control_active (RESUME, (void *) gdisp);
/* re-enable the active tool */
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
/* scale the image into the exposed regions */
if (x_offset)

View File

@ -411,15 +411,18 @@ gdisplay_format_title (GDisplay *gdisp,
static void
gdisplay_delete (GDisplay *gdisp)
{
GimpTool *active_tool;
g_hash_table_remove (display_ht, gdisp->shell);
g_hash_table_remove (display_ht, gdisp->canvas);
/* stop any active tool */
tool_manager_control_active (HALT, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* clear out the pointer to this gdisp from the active tool */
if (active_tool &&
active_tool->gdisp == gdisp)
if (active_tool && active_tool->gdisp == gdisp)
{
active_tool->drawable = NULL;
active_tool->gdisp = NULL;
@ -708,7 +711,7 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
if (list)
{
/* stop the currently active tool */
tool_manager_control_active (PAUSE, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
while (list)
{
@ -733,7 +736,7 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
selection_start (gdisp->select, TRUE);
/* start the currently active tool */
tool_manager_control_active (RESUME, (void *) gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}
}

View File

@ -95,6 +95,10 @@ gimage_new (Gimp *gimp,
static void
gimage_dirty_handler (GimpImage *gimage)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (gimage->gimp);
if (active_tool && ! active_tool->preserve)
{
GDisplay* gdisp = active_tool->gdisp;

View File

@ -502,6 +502,7 @@ indexed_ok_callback (GtkWidget *widget,
IndexedDialog *dialog;
ConvertPaletteType palette_type;
ConvertDitherType dither_type;
GimpTool *active_tool;
dialog = (IndexedDialog *) data;
@ -528,8 +529,10 @@ indexed_ok_callback (GtkWidget *widget,
/* Close the dialogs when open because they're useless for indexed
* images and could crash the GIMP when used nevertheless
*/
active_tool = tool_manager_get_active (dialog->gimage->gimp);
if (active_tool)
tool_manager_control_active (HALT, active_tool->gdisp);
tool_manager_control_active (dialog->gimage->gimp, HALT, active_tool->gdisp);
/* Convert the image to indexed color */
gimp_image_convert (dialog->gimage, INDEXED, dialog->num_cols,

View File

@ -92,7 +92,7 @@ edit_cut_cmd_callback (GtkWidget *widget,
return_if_no_display (gdisp);
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_cut (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage)))
@ -122,7 +122,7 @@ edit_paste_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
@ -145,7 +145,7 @@ edit_paste_into_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
@ -168,7 +168,7 @@ edit_paste_as_new_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
gimp_edit_paste_as_new (gdisp->gimage->gimp,
gdisp->gimage,
@ -186,7 +186,7 @@ edit_named_cut_cmd_callback (GtkWidget *widget,
return_if_no_display (gdisp);
/* stop any active tool */
tool_manager_control_active (HALT, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
qbox = gimp_query_string_box (_("Cut Named"),
gimp_standard_help_func,

View File

@ -283,10 +283,13 @@ tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data)
{
GimpToolInfo *tool_info;
GimpTool *active_tool;
GtkWidget *shell;
shell = (GtkWidget *) data;
active_tool = tool_manager_get_active (the_gimp);
if (! active_tool)
return;

View File

@ -87,6 +87,7 @@ tools_select_cmd_callback (GtkWidget *widget,
{
GtkType tool_type;
GimpToolInfo *tool_info;
GimpTool *active_tool;
GDisplay *gdisp;
tool_type = (GtkType) action;
@ -100,6 +101,8 @@ tools_select_cmd_callback (GtkWidget *widget,
#warning FIXME (let the tool manager to this stuff)
#endif
active_tool = tool_manager_get_active (the_gimp);
/* Paranoia */
active_tool->drawable = NULL;

View File

@ -278,7 +278,8 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
GimpDrawTool *draw_tool;
GimpContext *context;
gdisp = (GDisplay *) active_tool->gdisp;
gdisp = (GDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp;
draw_tool = GIMP_DRAW_TOOL (paint_tool);
context = gimp_get_current_context (gdisp->gimage->gimp);

View File

@ -278,7 +278,8 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
GimpDrawTool *draw_tool;
GimpContext *context;
gdisp = (GDisplay *) active_tool->gdisp;
gdisp = (GDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp;
draw_tool = GIMP_DRAW_TOOL (paint_tool);
context = gimp_get_current_context (gdisp->gimage->gimp);

View File

@ -61,7 +61,7 @@ resize_display (GDisplay *gdisp,
gboolean redisplay)
{
/* freeze the active tool */
tool_manager_control_active (PAUSE, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
if (resize_window)
gdisplay_shrink_wrap (gdisp);
@ -78,7 +78,7 @@ resize_display (GDisplay *gdisp,
}
/* re-enable the active tool */
tool_manager_control_active (RESUME, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}
@ -86,7 +86,7 @@ void
shrink_wrap_display (GDisplay *gdisp)
{
/* freeze the active tool */
tool_manager_control_active (PAUSE, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
gdisplay_shrink_wrap (gdisp);
@ -97,7 +97,7 @@ shrink_wrap_display (GDisplay *gdisp)
gdisplays_flush ();
/* re-enable the active tool */
tool_manager_control_active (RESUME, gdisp);
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
}

View File

@ -22,9 +22,10 @@
#include <gtk/gtk.h>
#include "core/core-types.h"
#include "tools/tools-types.h"
#include "core/gimpimage.h"
#include "widgets/gimpcursor.h"
#include "tools/gimptool.h"
@ -154,8 +155,8 @@ scroll_display (GDisplay *gdisp,
gdisp->offset_x = old_x;
gdisp->offset_y = old_y;
/* stop the currently active tool */
tool_manager_control_active (PAUSE, (void *) gdisp);
/* freeze the active tool */
tool_manager_control_active (gdisp->gimage->gimp, PAUSE, gdisp);
/* set the offsets back to the new values */
gdisp->offset_x += x_offset;
@ -169,8 +170,8 @@ scroll_display (GDisplay *gdisp,
(gdisp->disp_width - abs (x_offset)),
(gdisp->disp_height - abs (y_offset)));
/* resume the currently active tool */
tool_manager_control_active (RESUME, (void *) gdisp);
/* re-enable the active tool */
tool_manager_control_active (gdisp->gimage->gimp, RESUME, gdisp);
/* scale the image into the exposed regions */
if (x_offset)

View File

@ -37,11 +37,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "undo.h"
#include "pdb/procedural_db.h"
#include "gui/paths-dialog.h"
@ -52,6 +47,12 @@
#include "tool_options.h"
#include "tool_manager.h"
#include "app_procs.h"
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
#define WANT_BEZIER_SELECT_BITS
@ -428,7 +429,7 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
&halfwidth, &dummy, TRUE, 0);
halfwidth -= x;
curTool = active_tool;
curTool = tool_manager_get_active (gdisp->gimage->gimp);
curSel = bezier_sel;
curGdisp = (GDisplay *) gdisp;
curCore = (GimpDrawTool *)bezier_sel;
@ -923,7 +924,8 @@ bezier_select_load (GDisplay *gdisp,
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type
(gdisp->gimage->gimp, GIMP_TYPE_BEZIER_SELECT_TOOL));
tool = active_tool;
tool = tool_manager_get_active (gdisp->gimage->gimp);
tool->state = ACTIVE;
tool->gdisp = gdisp;
bezier_sel = (GimpBezierSelectTool *) tool;
@ -1598,11 +1600,12 @@ bezier_select_button_press (GimpTool *tool,
&halfwidth, &dummy, TRUE, 0);
halfwidth -= x;
curTool = active_tool;
curSel = (GimpBezierSelectTool *) curTool;
curTool = tool_manager_get_active (gdisp->gimage->gimp);
curSel = (GimpBezierSelectTool *) curTool;
curGdisp = (GDisplay *) gdisp;
active_tool->gdisp = gdisp;
curCore = (GimpDrawTool *) bezier_sel;
curTool->gdisp = gdisp;
curCore = (GimpDrawTool *) bezier_sel;
switch (bezier_sel->state)
{
@ -3121,9 +3124,13 @@ bezier_insert_in_list (GSList *list,
gboolean
bezier_tool_selected (void)
{
return (active_tool &&
GIMP_IS_BEZIER_SELECT_TOOL (active_tool) &&
active_tool->state == ACTIVE);
GimpTool *tool;
tool = tool_manager_get_active (the_gimp);
return (tool &&
GIMP_IS_BEZIER_SELECT_TOOL (tool) &&
tool->state == ACTIVE);
}
void
@ -3131,21 +3138,24 @@ bezier_paste_bezierselect_to_current (GDisplay *gdisp,
GimpBezierSelectTool *bsel)
{
GimpBezierSelectPoint *pts;
gint i;
GimpTool *tool;
gint i;
GimpTool *tool;
GimpBezierSelectPoint *bpnt = NULL;
gint need_move = 0;
gint need_move = 0;
/* g_print ("bezier_paste_bezierselect_to_current::\n"); */
/* printSel(bsel); */
tool = tool_manager_get_active (gdisp->gimage->gimp);
/* If the tool was being used before clear it */
if (active_tool &&
GIMP_IS_BEZIER_SELECT_TOOL (active_tool) &&
active_tool->state == ACTIVE)
if (tool &&
GIMP_IS_BEZIER_SELECT_TOOL (tool) &&
tool->state == ACTIVE)
{
GimpBezierSelectTool *bezier_sel = (GimpBezierSelectTool *) active_tool;
if(bezier_sel)
GimpBezierSelectTool *bezier_sel = (GimpBezierSelectTool *) tool;
if (bezier_sel)
{
gimp_draw_tool_stop ((GimpDrawTool *) curSel);
bezier_select_reset (bezier_sel);
@ -3155,11 +3165,12 @@ bezier_paste_bezierselect_to_current (GDisplay *gdisp,
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
tool_manager_get_info_by_type
(gdisp->gimage->gimp, GIMP_TYPE_BEZIER_SELECT_TOOL));
active_tool->paused_count = 0;
active_tool->gdisp = gdisp;
active_tool->drawable = gimp_image_active_drawable (gdisp->gimage);
tool = active_tool;
tool = tool_manager_get_active (gdisp->gimage->gimp);
tool->paused_count = 0;
tool->gdisp = gdisp;
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
bezier_select_reset (curSel);

View File

@ -37,6 +37,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -425,13 +426,15 @@ brightness_contrast_preview (BrightnessContrastDialog *bcd)
return;
}
active_tool->preserve = TRUE;
tool_manager_get_active (the_gimp)->preserve = TRUE;
brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0,
bcd->contrast / 127.0,
gimp_drawable_bytes (bcd->drawable));
image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2,
(void *) bcd->lut);
active_tool->preserve = FALSE;
tool_manager_get_active (the_gimp)->preserve = FALSE;
}
static void
@ -456,11 +459,14 @@ brightness_contrast_ok_callback (GtkWidget *widget,
gpointer data)
{
BrightnessContrastDialog *bcd;
GimpTool *active_tool;
bcd = (BrightnessContrastDialog *) data;
gimp_dialog_hide (bcd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!bcd->preview)
@ -488,11 +494,14 @@ brightness_contrast_cancel_callback (GtkWidget *widget,
gpointer data)
{
BrightnessContrastDialog *bcd;
GimpTool *active_tool;
bcd = (BrightnessContrastDialog *) data;
gimp_dialog_hide (bcd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (bcd->image_map)
{
active_tool->preserve = TRUE;
@ -512,6 +521,7 @@ brightness_contrast_preview_update (GtkWidget *widget,
gpointer data)
{
BrightnessContrastDialog *bcd;
GimpTool *active_tool;
bcd = (BrightnessContrastDialog *) data;
@ -525,6 +535,8 @@ brightness_contrast_preview_update (GtkWidget *widget,
bcd->preview = FALSE;
if (bcd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (bcd->image_map);
active_tool->preserve = FALSE;

View File

@ -684,10 +684,10 @@ by_color_select_cursor_update (GimpTool *tool,
static void
by_color_select_update_op_state (GimpByColorSelectTool *by_col_sel,
gint state,
GDisplay *gdisp)
gint state,
GDisplay *gdisp)
{
if (active_tool->state == ACTIVE)
if (tool_manager_get_active (gdisp->gimage->gimp)->state == ACTIVE)
return;
if ((state & GDK_SHIFT_MASK) &&

View File

@ -278,7 +278,8 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
GimpDrawTool *draw_tool;
GimpContext *context;
gdisp = (GDisplay *) active_tool->gdisp;
gdisp = (GDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp;
draw_tool = GIMP_DRAW_TOOL (paint_tool);
context = gimp_get_current_context (gdisp->gimage->gimp);

View File

@ -38,6 +38,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -621,6 +622,10 @@ color_balance_create_lookup_tables (ColorBalanceDialog *cbd)
static void
color_balance_preview (ColorBalanceDialog *cbd)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (!cbd->image_map)
{
g_message ("color_balance_preview(): No image map");
@ -656,11 +661,14 @@ color_balance_ok_callback (GtkWidget *widget,
gpointer data)
{
ColorBalanceDialog *cbd;
GimpTool *active_tool;
cbd = (ColorBalanceDialog *) data;
gimp_dialog_hide (cbd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!cbd->preview)
@ -682,11 +690,14 @@ color_balance_cancel_callback (GtkWidget *widget,
gpointer data)
{
ColorBalanceDialog *cbd;
GimpTool *active_tool;
cbd = (ColorBalanceDialog *) data;
gimp_dialog_hide (cbd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (cbd->image_map)
{
active_tool->preserve = TRUE;
@ -738,6 +749,7 @@ color_balance_preview_update (GtkWidget *widget,
gpointer data)
{
ColorBalanceDialog *cbd;
GimpTool *active_tool;
cbd = (ColorBalanceDialog *) data;
@ -751,6 +763,8 @@ color_balance_preview_update (GtkWidget *widget,
cbd->preview = FALSE;
if (cbd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (cbd->image_map);
active_tool->preserve = FALSE;

View File

@ -977,8 +977,9 @@ crop_crop_callback (GtkWidget *widget,
GimpCropTool *crop;
/* XXX active_tool is bad */
tool = active_tool;
crop = GIMP_CROP_TOOL(tool);
tool = tool_manager_get_active (the_gimp);
crop = GIMP_CROP_TOOL (tool);
crop_tool_crop_image (tool->gdisp->gimage,
crop->tx1, crop->ty1,
@ -998,8 +999,9 @@ crop_resize_callback (GtkWidget *widget,
GimpCropTool *crop;
/* XXX active_tool is bad */
tool = active_tool;
crop = GIMP_CROP_TOOL(tool);
tool = tool_manager_get_active (the_gimp);
crop = GIMP_CROP_TOOL (tool);
crop_tool_crop_image (tool->gdisp->gimage,
crop->tx1, crop->ty1,
@ -1020,9 +1022,10 @@ crop_close_callback (GtkWidget *widget,
GimpDrawTool *draw;
/* XXX active_tool is bad */
tool = active_tool;
crop = GIMP_CROP_TOOL(tool);
draw = GIMP_DRAW_TOOL(tool);
tool = tool_manager_get_active (the_gimp);
crop = GIMP_CROP_TOOL (tool);
draw = GIMP_DRAW_TOOL (tool);
if (tool->state == ACTIVE)
gimp_draw_tool_stop (draw);
@ -1045,9 +1048,10 @@ crop_selection_callback (GtkWidget *widget,
GDisplay *gdisp;
/* XXX active_tool is bad */
tool = active_tool;
crop = GIMP_CROP_TOOL(tool);
draw = GIMP_DRAW_TOOL(tool);
tool = tool_manager_get_active (the_gimp);
crop = GIMP_CROP_TOOL (tool);
draw = GIMP_DRAW_TOOL (tool);
gdisp = tool->gdisp;
@ -1091,9 +1095,10 @@ crop_automatic_callback (GtkWidget *widget,
gint shrunk_y2;
/* FIXME: active_tool is bad */
tool = active_tool;
crop = GIMP_CROP_TOOL(tool);
draw = GIMP_DRAW_TOOL(tool);
tool = tool_manager_get_active (the_gimp);
crop = GIMP_CROP_TOOL (tool);
draw = GIMP_DRAW_TOOL (tool);
gdisp = tool->gdisp;
if (crop_options->layer_only)
@ -1153,7 +1158,7 @@ crop_orig_changed (GtkWidget *widget,
gint oy;
/* XXX active_tool is bad */
tool = active_tool;
tool = tool_manager_get_active (the_gimp);
if (tool && GIMP_IS_CROP_TOOL(tool))
{
@ -1189,12 +1194,12 @@ crop_size_changed (GtkWidget *widget,
gint sy;
/* XXX active_tool is bad */
tool = active_tool;
tool = tool_manager_get_active (the_gimp);
if (tool && GIMP_IS_CROP_TOOL(tool))
if (tool && GIMP_IS_CROP_TOOL (tool))
{
crop = GIMP_CROP_TOOL(tool);
draw = GIMP_DRAW_TOOL(tool);
crop = GIMP_CROP_TOOL (tool);
draw = GIMP_DRAW_TOOL (tool);
sx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
sy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);

View File

@ -43,6 +43,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -390,9 +391,9 @@ gimp_curves_tool_button_press (GimpTool *tool,
if (drawable != tool->drawable)
{
active_tool->preserve = TRUE;
tool->preserve = TRUE;
image_map_abort (curves_dialog->image_map);
active_tool->preserve = FALSE;
tool->preserve = FALSE;
tool->drawable = drawable;
@ -608,10 +609,14 @@ curves_dialog_hide (void)
void
curves_free (void)
{
GimpTool *active_tool;
if (curves_dialog)
{
if (curves_dialog->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_abort (curves_dialog->image_map);
active_tool->preserve = FALSE;
@ -1227,12 +1232,16 @@ curves_calculate_curve (CurvesDialog *cd)
static void
curves_preview (CurvesDialog *cd)
{
GimpTool *active_tool;
if (!cd->image_map)
{
g_message ("curves_preview(): No image map");
return;
}
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_apply (cd->image_map, (ImageMapApplyFunc)gimp_lut_process_2,
(void *) cd->lut);
@ -1361,11 +1370,14 @@ curves_ok_callback (GtkWidget *widget,
gpointer data)
{
CurvesDialog *cd;
GimpTool *active_tool;
cd = (CurvesDialog *) data;
gimp_dialog_hide (cd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE; /* We're about to dirty... */
if (!cd->preview)
@ -1388,11 +1400,14 @@ curves_cancel_callback (GtkWidget *widget,
gpointer data)
{
CurvesDialog *cd;
GimpTool *active_tool;
cd = (CurvesDialog *) data;
gimp_dialog_hide (cd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (cd->image_map)
{
active_tool->preserve = TRUE;
@ -1442,6 +1457,7 @@ curves_preview_update (GtkWidget *widget,
gpointer data)
{
CurvesDialog *cd;
GimpTool *active_tool;
cd = (CurvesDialog *) data;
@ -1455,6 +1471,8 @@ curves_preview_update (GtkWidget *widget,
cd->preview = FALSE;
if (cd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (cd->image_map);
active_tool->preserve = FALSE;

View File

@ -294,7 +294,8 @@ init_edit_selection (GimpTool *tool,
gtk_object_ref (GTK_OBJECT (edit_select));
tool_manager_push_tool (GIMP_TOOL (edit_select));
tool_manager_push_tool (gdisp->gimage->gimp,
GIMP_TOOL (edit_select));
/* pause the current selection */
gdisplay_selection_visibility (gdisp, SELECTION_PAUSE);
@ -335,9 +336,9 @@ gimp_edit_selection_tool_button_release (GimpTool *tool,
/* Stop and free the selection core */
gimp_draw_tool_stop (GIMP_DRAW_TOOL (edit_select));
tool_manager_pop_tool ();
tool_manager_pop_tool (gdisp->gimage->gimp);
active_tool->state = INACTIVE;
tool_manager_get_active (gdisp->gimage->gimp)->state = INACTIVE;
/* EDIT_MASK_TRANSLATE is performed here at movement end, not 'live' like
* the other translation types.

View File

@ -38,6 +38,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
@ -470,11 +471,14 @@ histogram_tool_close_callback (GtkWidget *widget,
gpointer data)
{
HistogramToolDialog *htd;
GimpTool *active_tool;
htd = (HistogramToolDialog *) data;
gimp_dialog_hide (htd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->gdisp = NULL;
active_tool->drawable = NULL;
}

View File

@ -38,6 +38,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -399,6 +400,10 @@ hue_saturation_dialog_hide (void)
void
hue_saturation_free (void)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (hue_saturation_dialog)
{
if (hue_saturation_dialog->image_map)
@ -725,6 +730,10 @@ hue_saturation_update (HueSaturationDialog *hsd,
static void
hue_saturation_preview (HueSaturationDialog *hsd)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (!hsd->image_map)
{
g_warning ("hue_saturation_preview(): No image map");
@ -759,11 +768,14 @@ hue_saturation_ok_callback (GtkWidget *widget,
gpointer data)
{
HueSaturationDialog *hsd;
GimpTool *active_tool;
hsd = (HueSaturationDialog *) data;
gimp_dialog_hide (hsd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!hsd->preview)
@ -785,11 +797,14 @@ hue_saturation_cancel_callback (GtkWidget *widget,
gpointer data)
{
HueSaturationDialog *hsd;
GimpTool *active_tool;
hsd = (HueSaturationDialog *) data;
gimp_dialog_hide (hsd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (hsd->image_map)
{
active_tool->preserve = TRUE;
@ -825,6 +840,7 @@ hue_saturation_preview_update (GtkWidget *widget,
gpointer data)
{
HueSaturationDialog *hsd;
GimpTool *active_tool;
hsd = (HueSaturationDialog *) data;
@ -838,6 +854,8 @@ hue_saturation_preview_update (GtkWidget *widget,
hsd->preview = FALSE;
if (hsd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (hsd->image_map);
active_tool->preserve = FALSE;

View File

@ -46,6 +46,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -385,6 +386,10 @@ levels_dialog_hide (void)
void
levels_free (void)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (levels_dialog)
{
if (levels_dialog->image_map)
@ -961,6 +966,10 @@ levels_update (LevelsDialog *ld,
static void
levels_preview (LevelsDialog *ld)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (!ld->image_map)
{
g_warning ("levels_preview: No Image Map");
@ -1083,6 +1092,9 @@ levels_ok_callback (GtkWidget *widget,
gpointer data)
{
LevelsDialog *ld;
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
ld = (LevelsDialog *) data;
@ -1115,11 +1127,14 @@ levels_cancel_callback (GtkWidget *widget,
gpointer data)
{
LevelsDialog *ld;
GimpTool *active_tool;
ld = (LevelsDialog *) data;
gimp_dialog_hide (ld->shell);
active_tool = tool_manager_get_active (the_gimp);
if (ld->image_map)
{
active_tool->preserve = TRUE;
@ -1198,6 +1213,7 @@ levels_preview_update (GtkWidget *widget,
gpointer data)
{
LevelsDialog *ld;
GimpTool *active_tool;
ld = (LevelsDialog *) data;
@ -1211,6 +1227,8 @@ levels_preview_update (GtkWidget *widget,
ld->preview = FALSE;
if (ld->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (ld->image_map);
active_tool->preserve = FALSE;

View File

@ -36,6 +36,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -341,6 +342,10 @@ posterize_dialog_new (void)
static void
posterize_preview (PosterizeDialog *pd)
{
GimpTool *active_tool;
active_tool = tool_manager_get_active (the_gimp);
if (!pd->image_map)
{
g_warning ("posterize_preview(): No image map");
@ -370,11 +375,14 @@ posterize_ok_callback (GtkWidget *widget,
gpointer data)
{
PosterizeDialog *pd;
GimpTool *active_tool;
pd = (PosterizeDialog *) data;
gimp_dialog_hide (pd->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!pd->preview)
@ -401,11 +409,14 @@ posterize_cancel_callback (GtkWidget *widget,
gpointer data)
{
PosterizeDialog *pd;
GimpTool *active_tool;
pd = (PosterizeDialog *) data;
gimp_dialog_hide (pd->shell);
active_tool = tool_manager_get_active (the_gimp);
if (pd->image_map)
{
active_tool->preserve = TRUE;
@ -425,6 +436,7 @@ posterize_preview_update (GtkWidget *widget,
gpointer data)
{
PosterizeDialog *pd;
GimpTool *active_tool;
pd = (PosterizeDialog *) data;
@ -438,6 +450,8 @@ posterize_preview_update (GtkWidget *widget,
pd->preview = FALSE;
if (pd->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (pd->image_map);
active_tool->preserve = FALSE;

View File

@ -278,7 +278,8 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
GimpDrawTool *draw_tool;
GimpContext *context;
gdisp = (GDisplay *) active_tool->gdisp;
gdisp = (GDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp;
draw_tool = GIMP_DRAW_TOOL (paint_tool);
context = gimp_get_current_context (gdisp->gimage->gimp);

View File

@ -51,18 +51,19 @@
#include "widgets/gimpwidgets-utils.h"
#include "errors.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "plug_in.h"
#include "undo.h"
#include "gimpeditselectiontool.h"
#include "gimptexttool.h"
#include "gimptool.h"
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "errors.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "plug_in.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
#define WANT_TEXT_BITS
@ -508,8 +509,12 @@ static void
text_dialog_ok_callback (GtkWidget *widget,
gpointer data)
{
GimpTool *active_tool;
gimp_dialog_hide (data);
active_tool = tool_manager_get_active (the_gimp);
if (active_tool && GIMP_IS_TEXT_TOOL (active_tool))
{
text_init_render (GIMP_TEXT_TOOL (active_tool));

View File

@ -40,6 +40,7 @@
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "drawable.h"
#include "gdisplay.h"
#include "image_map.h"
@ -482,12 +483,16 @@ threshold_update (ThresholdDialog *td,
static void
threshold_preview (ThresholdDialog *td)
{
GimpTool *active_tool;
if (!td->image_map)
{
g_warning ("threshold_preview(): No image map");
return;
}
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_apply (td->image_map, threshold, td);
active_tool->preserve = FALSE;
@ -515,11 +520,14 @@ threshold_ok_callback (GtkWidget *widget,
gpointer data)
{
ThresholdDialog *td;
GimpTool *active_tool;
td = (ThresholdDialog *) data;
gimp_dialog_hide (td->shell);
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
if (!td->preview)
@ -541,11 +549,14 @@ threshold_cancel_callback (GtkWidget *widget,
gpointer data)
{
ThresholdDialog *td;
GimpTool *active_tool;
td = (ThresholdDialog *) data;
gimp_dialog_hide (td->shell);
active_tool = tool_manager_get_active (the_gimp);
if (td->image_map)
{
active_tool->preserve = TRUE;
@ -565,6 +576,7 @@ threshold_preview_update (GtkWidget *widget,
gpointer data)
{
ThresholdDialog *td;
GimpTool *active_tool;
td = (ThresholdDialog *) data;
@ -578,6 +590,8 @@ threshold_preview_update (GtkWidget *widget,
td->preview = FALSE;
if (td->image_map)
{
active_tool = tool_manager_get_active (the_gimp);
active_tool->preserve = TRUE;
image_map_clear (td->image_map);
active_tool->preserve = FALSE;

View File

@ -26,11 +26,12 @@
#include "core/gimpimage.h"
#include "gdisplay.h"
#include "gimptool.h"
#include "tool_manager.h"
#include "app_procs.h"
#include "gdisplay.h"
#include "libgimp/gimpintl.h"
@ -469,7 +470,7 @@ gimp_tool_real_oper_update (GimpTool *tool,
void
gimp_tool_help_func (const gchar *help_data)
{
gimp_standard_help_func (tool_manager_active_get_help_data ());
gimp_standard_help_func (tool_manager_active_get_help_data (the_gimp));
}

View File

@ -999,7 +999,9 @@ gimp_transform_tool_grid_density_changed (void)
GimpTransformTool *tr_tool;
GimpDrawTool *dr_tool;
tr_tool = GIMP_TRANSFORM_TOOL ( /* EEEEEEEK!!! */ active_tool);
/* EEEK!!! */
tr_tool = GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp));
dr_tool = GIMP_DRAW_TOOL (tr_tool);
if (tr_tool->function == TRANSFORM_CREATING)
@ -1018,7 +1020,8 @@ gimp_transform_tool_showpath_changed (gint type /* a truly undescriptive name */
{
GimpTransformTool *tr_tool;
tr_tool = GIMP_TRANSFORM_TOOL ( /* EEEEEEEK!!! */ active_tool);
/* EEEEEEEK!!! */
tr_tool = GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp));
if (tr_tool->function == TRANSFORM_CREATING)
return;
@ -1045,7 +1048,10 @@ gimp_transform_tool_grid_recalc (GimpTransformTool *tr_tool)
}
if (gimp_transform_tool_show_grid ())
gimp_transform_tool_setup_grid (GIMP_TRANSFORM_TOOL ( /* EEEEEEK!!! */ active_tool));
{
/* EEEEEEK!!! */
gimp_transform_tool_setup_grid (GIMP_TRANSFORM_TOOL (tool_manager_get_active (the_gimp)));
}
}
static void
@ -1208,7 +1214,8 @@ gimp_transform_tool_do (GimpImage *gimage,
y2 = y1 + tile_manager_height (float_tiles);
/* Find the bounding coordinates */
if (alpha == 0 || (active_tool && gimp_transform_tool_clip ()))
if (alpha == 0 || (tool_manager_get_active (gimage->gimp) &&
gimp_transform_tool_clip ()))
{
tx1 = x1;
ty1 = y1;
@ -1217,7 +1224,10 @@ gimp_transform_tool_do (GimpImage *gimage,
}
else
{
gdouble dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
gdouble dx1, dy1;
gdouble dx2, dy2;
gdouble dx3, dy3;
gdouble dx4, dy4;
gimp_matrix3_transform_point (matrix, x1, y1, &dx1, &dy1);
gimp_matrix3_transform_point (matrix, x2, y1, &dx2, &dy2);
@ -1230,6 +1240,7 @@ gimp_transform_tool_do (GimpImage *gimage,
ty1 = MIN (dy1, dy2);
ty1 = MIN (ty1, dy3);
ty1 = MIN (ty1, dy4);
tx2 = MAX (dx1, dx2);
tx2 = MAX (tx2, dx3);
tx2 = MAX (tx2, dx4);

View File

@ -60,21 +60,25 @@
GIMP_CONTEXT_PAINT_MODE_MASK
/* Global Data */
typedef struct _GimpToolManager GimpToolManager;
GimpTool *active_tool = NULL;
struct _GimpToolManager
{
GimpTool *active_tool;
GSList *tool_stack;
static GSList *tool_stack = NULL;
static GimpContext *global_tool_context = NULL;
GimpContext *global_tool_context;
};
/* local function prototypes */
static void active_tool_unref (void);
static void tool_manager_tool_changed (GimpContext *user_context,
GimpToolInfo *tool_info,
gpointer data);
static GimpToolManager * tool_manager_get (Gimp *gimp);
static void tool_manager_set (Gimp *gimp,
GimpToolManager *tool_manager);
static void tool_manager_tool_changed (GimpContext *user_context,
GimpToolInfo *tool_info,
gpointer data);
/* public functions */
@ -82,37 +86,52 @@ static void tool_manager_tool_changed (GimpContext *user_context,
void
tool_manager_init (Gimp *gimp)
{
GimpContext *user_context;
GimpContext *tool_context;
GimpToolManager *tool_manager;
GimpContext *user_context;
GimpContext *tool_context;
tool_manager = g_new0 (GimpToolManager, 1);
tool_manager->active_tool = NULL;
tool_manager->tool_stack = NULL;
tool_manager->global_tool_context = NULL;
tool_manager_set (gimp, tool_manager);
user_context = gimp_get_user_context (gimp);
gtk_signal_connect (GTK_OBJECT (user_context), "tool_changed",
GTK_SIGNAL_FUNC (tool_manager_tool_changed),
NULL);
tool_manager);
/* Create a context to store the paint options of the
* global paint options mode
*/
global_tool_context = gimp_create_context (gimp,
"Global Tool Context",
user_context);
tool_manager->global_tool_context = gimp_create_context (gimp,
"Global Tool Context",
user_context);
/* TODO: add foreground, background, brush, pattern, gradient */
gimp_context_define_args (global_tool_context, PAINT_OPTIONS_MASK, FALSE);
gimp_context_define_args (tool_manager->global_tool_context,
PAINT_OPTIONS_MASK, FALSE);
/* register internal tools */
tools_init (gimp);
if (! gimprc.global_paint_options && active_tool &&
(tool_context = tool_manager_get_info_by_tool (gimp,
active_tool)->context))
if (! gimprc.global_paint_options && tool_manager->active_tool)
{
gimp_context_set_parent (tool_context, user_context);
tool_context =
tool_manager_get_info_by_tool (gimp,
tool_manager->active_tool)->context;
if (tool_context)
{
gimp_context_set_parent (tool_context, user_context);
}
}
else if (gimprc.global_paint_options)
{
gimp_context_set_parent (global_tool_context, user_context);
gimp_context_set_parent (tool_manager->global_tool_context, user_context);
}
gimp_container_thaw (gimp->tool_info_list);
@ -121,20 +140,29 @@ tool_manager_init (Gimp *gimp)
void
tool_manager_exit (Gimp *gimp)
{
gtk_object_unref (GTK_OBJECT (global_tool_context));
global_tool_context = NULL;
GimpToolManager *tool_manager;
tool_manager = tool_manager_get (gimp);
gtk_object_unref (GTK_OBJECT (tool_manager->global_tool_context));
g_free (tool_manager);
tool_manager_set (gimp, NULL);
}
void
tool_manager_set_global_paint_options (Gimp *gimp,
gboolean global)
{
GimpToolInfo *tool_info;
GimpContext *context;
GimpToolManager *tool_manager;
GimpToolInfo *tool_info;
if (global == gimprc.global_paint_options)
return;
tool_manager = tool_manager_get (gimp);
paint_options_set_global (global);
/* NULL is the main brush selection */
@ -144,66 +172,95 @@ tool_manager_set_global_paint_options (Gimp *gimp,
if (global)
{
if (tool_info && (context = tool_info->context))
if (tool_info && tool_info->context)
{
gimp_context_unset_parent (context);
gimp_context_unset_parent (tool_info->context);
}
gimp_context_copy_args (global_tool_context,
gimp_context_copy_args (tool_manager->global_tool_context,
gimp_get_user_context (gimp),
PAINT_OPTIONS_MASK);
gimp_context_set_parent (global_tool_context,
gimp_context_set_parent (tool_manager->global_tool_context,
gimp_get_user_context (gimp));
}
else
{
gimp_context_unset_parent (global_tool_context);
gimp_context_unset_parent (tool_manager->global_tool_context);
if (tool_info && (context = tool_info->context))
if (tool_info && tool_info->context)
{
gimp_context_copy_args (context, gimp_get_user_context (gimp),
gimp_context_copy_args (tool_info->context,
gimp_get_user_context (gimp),
GIMP_CONTEXT_PAINT_ARGS_MASK);
gimp_context_set_parent (context, gimp_get_user_context (gimp));
gimp_context_set_parent (tool_info->context,
gimp_get_user_context (gimp));
}
}
}
void
tool_manager_select_tool (GimpTool *tool)
GimpTool *
tool_manager_get_active (Gimp *gimp)
{
g_return_if_fail (tool != NULL);
g_return_if_fail (GIMP_IS_TOOL (tool));
GimpToolManager *tool_manager;
if (active_tool)
active_tool_unref ();
tool_manager = tool_manager_get (gimp);
active_tool = tool;
return tool_manager->active_tool;
}
void
tool_manager_push_tool (GimpTool *tool)
tool_manager_select_tool (Gimp *gimp,
GimpTool *tool)
{
GimpToolManager *tool_manager;
g_return_if_fail (tool != NULL);
g_return_if_fail (GIMP_IS_TOOL (tool));
if (active_tool)
{
gtk_object_ref (GTK_OBJECT (active_tool));
tool_manager = tool_manager_get (gimp);
tool_stack = g_slist_prepend (tool_stack, active_tool);
if (tool_manager->active_tool)
gtk_object_unref (GTK_OBJECT (tool_manager->active_tool));
tool_manager->active_tool = tool;
}
void
tool_manager_push_tool (Gimp *gimp,
GimpTool *tool)
{
GimpToolManager *tool_manager;
g_return_if_fail (tool != NULL);
g_return_if_fail (GIMP_IS_TOOL (tool));
tool_manager = tool_manager_get (gimp);
if (tool_manager->active_tool)
{
gtk_object_ref (GTK_OBJECT (tool_manager->active_tool));
tool_manager->tool_stack = g_slist_prepend (tool_manager->tool_stack,
tool_manager->active_tool);
}
tool_manager_select_tool (tool);
tool_manager_select_tool (gimp, tool);
}
void
tool_manager_pop_tool (void)
tool_manager_pop_tool (Gimp *gimp)
{
if (tool_stack)
{
tool_manager_select_tool (GIMP_TOOL (tool_stack->data));
GimpToolManager *tool_manager;
tool_stack = g_slist_remove (tool_stack, active_tool);
tool_manager = tool_manager_get (gimp);
if (tool_manager->tool_stack)
{
tool_manager_select_tool (gimp,
GIMP_TOOL (tool_manager->tool_stack->data));
tool_manager->tool_stack = g_slist_remove (tool_manager->tool_stack,
tool_manager->active_tool);
}
}
@ -213,7 +270,10 @@ tool_manager_initialize_tool (Gimp *gimp,
GimpTool *tool, /* FIXME: remove tool param */
GDisplay *gdisp)
{
GimpToolInfo *tool_info;
GimpToolManager *tool_manager;
GimpToolInfo *tool_info;
tool_manager = tool_manager_get (gimp);
/* Tools which have an init function have dialogs and
* cannot be initialized without a display
@ -253,62 +313,69 @@ tool_manager_initialize_tool (Gimp *gimp,
}
}
gimp_tool_initialize (active_tool, gdisp);
gimp_tool_initialize (tool_manager->active_tool, gdisp);
if (gdisp)
active_tool->drawable = gimp_image_active_drawable (gdisp->gimage);
tool_manager->active_tool->drawable =
gimp_image_active_drawable (gdisp->gimage);
/* don't set tool->gdisp here! (see commands.c) */
}
void
tool_manager_control_active (ToolAction action,
tool_manager_control_active (Gimp *gimp,
ToolAction action,
GDisplay *gdisp)
{
if (active_tool)
GimpToolManager *tool_manager;
tool_manager = tool_manager_get (gimp);
if (tool_manager->active_tool)
{
if (active_tool->gdisp == gdisp)
if (tool_manager->active_tool->gdisp == gdisp)
{
switch (action)
{
case PAUSE:
if (active_tool->state == ACTIVE)
if (tool_manager->active_tool->state == ACTIVE)
{
if (! active_tool->paused_count)
if (! tool_manager->active_tool->paused_count)
{
active_tool->state = PAUSED;
tool_manager->active_tool->state = PAUSED;
gimp_tool_control (active_tool, action, gdisp);
gimp_tool_control (tool_manager->active_tool,
action, gdisp);
}
}
active_tool->paused_count++;
tool_manager->active_tool->paused_count++;
break;
case RESUME:
active_tool->paused_count--;
if (active_tool->state == PAUSED)
{
if (! active_tool->paused_count)
{
active_tool->state = ACTIVE;
tool_manager->active_tool->paused_count--;
gimp_tool_control (active_tool, action, gdisp);
if (tool_manager->active_tool->state == PAUSED)
{
if (! tool_manager->active_tool->paused_count)
{
tool_manager->active_tool->state = ACTIVE;
gimp_tool_control (tool_manager->active_tool,
action, gdisp);
}
}
break;
case HALT:
active_tool->state = INACTIVE;
tool_manager->active_tool->state = INACTIVE;
gimp_tool_control (active_tool, action, gdisp);
gimp_tool_control (tool_manager->active_tool, action, gdisp);
break;
case DESTROY:
gtk_object_unref (GTK_OBJECT (active_tool));
active_tool = NULL;
gtk_object_unref (GTK_OBJECT (tool_manager->active_tool));
tool_manager->active_tool = NULL;
break;
default:
@ -317,7 +384,7 @@ tool_manager_control_active (ToolAction action,
}
else if (action == HALT)
{
active_tool->state = INACTIVE;
tool_manager->active_tool->state = INACTIVE;
}
}
}
@ -335,9 +402,12 @@ tool_manager_register_tool (Gimp *gimp,
const gchar *help_data,
const gchar **icon_data)
{
GimpToolInfo *tool_info;
GimpToolManager *tool_manager;
GimpToolInfo *tool_info;
tool_info = gimp_tool_info_new (global_tool_context,
tool_manager = tool_manager_get (gimp);
tool_info = gimp_tool_info_new (tool_manager->global_tool_context,
tool_type,
tool_context,
identifier,
@ -403,14 +473,17 @@ tool_manager_get_info_by_tool (Gimp *gimp,
const gchar *
tool_manager_active_get_PDB_string (Gimp *gimp)
{
GimpToolInfo *tool_info;
const gchar *tool_str = "gimp_paintbrush_default";
GimpToolManager *tool_manager;
GimpToolInfo *tool_info;
const gchar *tool_str = "gimp_paintbrush_default";
/* Return the correct PDB function for the active tool
* The default is paintbrush if the tool is not recognized
*/
if (! active_tool)
tool_manager = tool_manager_get (gimp);
if (! tool_manager->active_tool)
return tool_str;
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
@ -452,31 +525,42 @@ tool_manager_active_get_PDB_string (Gimp *gimp)
}
const gchar *
tool_manager_active_get_help_data (void)
tool_manager_active_get_help_data (Gimp *gimp)
{
g_return_val_if_fail (active_tool != NULL, NULL);
GimpToolManager *tool_manager;
return tool_manager_get_info_by_tool (the_gimp, active_tool)->help_data;
tool_manager = tool_manager_get (gimp);
if (! tool_manager->active_tool)
return NULL;
return tool_manager_get_info_by_tool (gimp,
tool_manager->active_tool)->help_data;
}
void
tool_manager_help_func (const gchar *help_data)
{
gimp_standard_help_func (tool_manager_active_get_help_data ());
gimp_standard_help_func (tool_manager_active_get_help_data (the_gimp));
}
/* private functions */
static void
active_tool_unref (void)
#define TOOL_MANAGER_DATA_KEY "gimp-tool-manager"
static GimpToolManager *
tool_manager_get (Gimp *gimp)
{
if (! active_tool)
return;
return gtk_object_get_data (GTK_OBJECT (gimp), TOOL_MANAGER_DATA_KEY);
}
gtk_object_unref (GTK_OBJECT (active_tool));
active_tool = NULL;
static void
tool_manager_set (Gimp *gimp,
GimpToolManager *tool_manager)
{
gtk_object_set_data (GTK_OBJECT (gimp), TOOL_MANAGER_DATA_KEY,
tool_manager);
}
static void
@ -484,12 +568,15 @@ tool_manager_tool_changed (GimpContext *user_context,
GimpToolInfo *tool_info,
gpointer data)
{
GimpTool *new_tool = NULL;
GimpContext *tool_context = NULL;
GimpToolManager *tool_manager;
GimpTool *new_tool = NULL;
GimpContext *tool_context = NULL;
if (! tool_info)
return;
tool_manager = (GimpToolManager *) data;
/* FIXME: gimp_busy HACK */
if (gimp_busy)
{
@ -498,20 +585,21 @@ tool_manager_tool_changed (GimpContext *user_context,
*/
gtk_signal_emit_stop_by_name (GTK_OBJECT (user_context), "tool_changed");
if (GTK_OBJECT (active_tool)->klass->type != tool_info->tool_type)
if (GTK_OBJECT (tool_manager->active_tool)->klass->type !=
tool_info->tool_type)
{
gtk_signal_handler_block_by_func (GTK_OBJECT (user_context),
tool_manager_tool_changed,
NULL);
data);
/* explicitly set the current tool */
gimp_context_set_tool (user_context,
tool_manager_get_info_by_tool (user_context->gimp,
active_tool));
tool_manager->active_tool));
gtk_signal_handler_unblock_by_func (GTK_OBJECT (user_context),
tool_manager_tool_changed,
NULL);
data);
}
return;
@ -530,9 +618,9 @@ tool_manager_tool_changed (GimpContext *user_context,
if (! gimprc.global_paint_options)
{
if (active_tool &&
if (tool_manager->active_tool &&
(tool_context = tool_manager_get_info_by_tool (user_context->gimp,
active_tool)->context))
tool_manager->active_tool)->context))
{
gimp_context_unset_parent (tool_context);
}
@ -545,5 +633,5 @@ tool_manager_tool_changed (GimpContext *user_context,
}
}
tool_manager_select_tool (new_tool);
tool_manager_select_tool (user_context->gimp, new_tool);
}

View File

@ -20,31 +20,32 @@
#define __TOOL_MANAGER_H__
/* Global Data Structures */
extern GimpTool *active_tool;
void tool_manager_init (Gimp *gimp);
void tool_manager_exit (Gimp *gimp);
void tool_manager_set_global_paint_options (Gimp *gimp,
gboolean global);
void tool_manager_set_global_paint_options (Gimp *gimp,
gboolean global);
void tool_manager_select_tool (GimpTool *tool);
GimpTool * tool_manager_get_active (Gimp *gimp);
void tool_manager_push_tool (GimpTool *tool);
void tool_manager_pop_tool (void);
void tool_manager_select_tool (Gimp *gimp,
GimpTool *tool);
void tool_manager_push_tool (Gimp *gimp,
GimpTool *tool);
void tool_manager_pop_tool (Gimp *gimp);
void tool_manager_initialize_tool (Gimp *gimp,
GimpTool *tool,
GDisplay *gdisp);
void tool_manager_control_active (ToolAction action,
void tool_manager_control_active (Gimp *gimp,
ToolAction action,
GDisplay *gdisp);
const gchar * tool_manager_active_get_PDB_string (Gimp *gimp);
const gchar * tool_manager_active_get_help_data (void);
const gchar * tool_manager_active_get_help_data (Gimp *gimp);
void tool_manager_register_tool (Gimp *gimp,
@ -68,7 +69,6 @@ GimpToolInfo * tool_manager_get_info_by_tool (Gimp *gimp,
GimpTool *tool);
void tool_manager_help_func (const gchar *help_data);

View File

@ -1272,12 +1272,15 @@ undo_pop_transform (GimpImage *gimage,
UndoType type,
gpointer tu_ptr)
{
GimpTool *active_tool;
GimpTransformTool *tt;
TransformUndo *tu;
TileManager *temp;
gdouble d;
gint i;
active_tool = tool_manager_get_active (gimage->gimp);
/* Can't have ANY tool selected - maybe a plugin running */
if (active_tool == NULL)
return TRUE;
@ -1363,10 +1366,13 @@ undo_pop_paint (GimpImage *gimage,
UndoType type,
gpointer pu_ptr)
{
GimpTool *active_tool;
GimpPaintTool *pt;
PaintUndo *pu;
gdouble tmp;
active_tool = tool_manager_get_active (gimage->gimp);
/* Can't have ANY tool selected - maybe a plugin running */
if (active_tool == NULL)
return TRUE;

View File

@ -283,10 +283,13 @@ tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data)
{
GimpToolInfo *tool_info;
GimpTool *active_tool;
GtkWidget *shell;
shell = (GtkWidget *) data;
active_tool = tool_manager_get_active (the_gimp);
if (! active_tool)
return;