Commit ea95a322 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Replaced Garry's fix for bug #98843 by a more general solution which stops

2003-01-02  Michael Natterer  <mitch@gimp.org>

	Replaced Garry's fix for bug #98843 by a more general solution
	which stops the active tool when an undo group start is pushed:

	* app/core/gimpimage.[ch]: removed the "layer_merge" signal
	and added "undo_start" instead.

	* app/undo.c: emit "undo_start" in undo_push_group_start()
	_before_ checking if gimage->undo_on is TRUE.

	* app/tools/tool_manager.c: connect to "undo_start" and HALT the
	active tool if neccessary.

	* app/core/core-types.h: added EDIT_COPY_UNDO_GROUP.

	* app/core/gimpedit.c: push an undo group around the copy
	operation. Will probably have to add more undo group types to wrap
	other critical image modifications with.

	* app/core/gimpimage-merge.c
	* app/gui/convert-dialog.c
	* app/gui/edit-commands.c
	* app/gui/test-commands.c
	* app/tools/gimpimagemaptool.c: removed all special code to
	stop the active tool.
parent 2ed23516
2003-01-02 Michael Natterer <mitch@gimp.org>
Replaced Garry's fix for bug #98843 by a more general solution
which stops the active tool when an undo group start is pushed:
* app/core/gimpimage.[ch]: removed the "layer_merge" signal
and added "undo_start" instead.
* app/undo.c: emit "undo_start" in undo_push_group_start()
_before_ checking if gimage->undo_on is TRUE.
* app/tools/tool_manager.c: connect to "undo_start" and HALT the
active tool if neccessary.
* app/core/core-types.h: added EDIT_COPY_UNDO_GROUP.
* app/core/gimpedit.c: push an undo group around the copy
operation. Will probably have to add more undo group types to wrap
other critical image modifications with.
* app/core/gimpimage-merge.c
* app/gui/convert-dialog.c
* app/gui/edit-commands.c
* app/gui/test-commands.c
* app/tools/gimpimagemaptool.c: removed all special code to
stop the active tool.
2003-01-02 Michael Natterer <mitch@gimp.org>
 
* app/gui/user-install-dialog.c: replaced the 0755 by properly
......
......@@ -37,8 +37,6 @@
#include "display/gimpdisplay.h"
#include "tools/tool_manager.h"
#include "widgets/gimpdialogfactory.h"
#include "dialogs.h"
......@@ -111,9 +109,6 @@ edit_cut_cmd_callback (GtkWidget *widget,
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_cut (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage)))
{
......@@ -143,9 +138,6 @@ edit_paste_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
gdisp->gimage->gimp->global_buffer,
......@@ -165,9 +157,6 @@ edit_paste_into_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
gdisp->gimage->gimp->global_buffer,
......@@ -187,9 +176,6 @@ edit_paste_as_new_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
gimp_edit_paste_as_new (gdisp->gimage->gimp,
gdisp->gimage,
gdisp->gimage->gimp->global_buffer);
......@@ -204,9 +190,6 @@ edit_named_cut_cmd_callback (GtkWidget *widget,
GtkWidget *qbox;
return_if_no_display (gdisp, data);
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
qbox = gimp_query_string_box (_("Cut Named"),
gimp_standard_help_func,
"dialogs/cut_named.html",
......
......@@ -88,6 +88,7 @@ typedef enum /*< pdb-skip >*/ /*< skip >*/
FS_ANCHOR_UNDO_GROUP,
EDIT_PASTE_UNDO_GROUP,
EDIT_CUT_UNDO_GROUP,
EDIT_COPY_UNDO_GROUP,
TEXT_UNDO_GROUP,
TRANSFORM_UNDO_GROUP,
PAINT_UNDO_GROUP,
......
......@@ -114,6 +114,9 @@ gimp_edit_copy (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
undo_push_group_start (gimage, EDIT_COPY_UNDO_GROUP);
/* See if the gimage mask is empty */
empty = gimp_image_mask_is_empty (gimage);
......@@ -139,6 +142,9 @@ gimp_edit_copy (GimpImage *gimage,
else
cropped_copy = NULL;
/* end the group undo */
undo_push_group_end (gimage);
if (cropped_copy)
{
/* Free the old global edit buffer */
......
......@@ -114,6 +114,9 @@ gimp_edit_copy (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
undo_push_group_start (gimage, EDIT_COPY_UNDO_GROUP);
/* See if the gimage mask is empty */
empty = gimp_image_mask_is_empty (gimage);
......@@ -139,6 +142,9 @@ gimp_edit_copy (GimpImage *gimage,
else
cropped_copy = NULL;
/* end the group undo */
undo_push_group_end (gimage);
if (cropped_copy)
{
/* Free the old global edit buffer */
......
......@@ -296,10 +296,6 @@ gimp_image_merge_layers (GimpImage *gimage,
if ((x2 - x1) == 0 || (y2 - y1) == 0)
return NULL;
/* Tell any listeners about impending layer merges */
gimp_image_layer_merge (gimage);
/* Start a merge undo group. */
undo_push_group_start (gimage, IMAGE_LAYERS_MERGE_UNDO_GROUP);
......
......@@ -640,6 +640,9 @@ undo_push_group_start (GimpImage *gimage,
g_return_val_if_fail (type > FIRST_UNDO_GROUP &&
type <= LAST_UNDO_GROUP, FALSE);
/* Notify listeners that the image will be modified */
gimp_image_undo_start (gimage);
if (! gimage->undo_on)
return FALSE;
......@@ -3617,6 +3620,7 @@ undo_name[] =
{ FS_ANCHOR_UNDO_GROUP, N_("Anchor Floating Selection") },
{ EDIT_PASTE_UNDO_GROUP, N_("Paste") },
{ EDIT_CUT_UNDO_GROUP, N_("Cut") },
{ EDIT_COPY_UNDO_GROUP, N_("Copy") },
{ TEXT_UNDO_GROUP, N_("Text") },
{ TRANSFORM_UNDO_GROUP, N_("Transform") },
{ PAINT_UNDO_GROUP, N_("Paint") },
......
......@@ -89,9 +89,9 @@ enum
UPDATE,
UPDATE_GUIDE,
COLORMAP_CHANGED,
UNDO_START,
UNDO_EVENT,
FLUSH,
LAYER_MERGE,
LAST_SIGNAL
};
......@@ -356,6 +356,15 @@ gimp_image_class_init (GimpImageClass *klass)
G_TYPE_NONE, 1,
G_TYPE_INT);
gimp_image_signals[UNDO_START] =
g_signal_new ("undo_start",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, undo_start),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[UNDO_EVENT] =
g_signal_new ("undo_event",
G_TYPE_FROM_CLASS (klass),
......@@ -375,15 +384,6 @@ gimp_image_class_init (GimpImageClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_image_signals[LAYER_MERGE] =
g_signal_new ("layer_merge",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, layer_merge),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->dispose = gimp_image_dispose;
object_class->finalize = gimp_image_finalize;
......@@ -410,11 +410,12 @@ gimp_image_class_init (GimpImageClass *klass)
klass->update = NULL;
klass->update_guide = NULL;
klass->colormap_changed = gimp_image_real_colormap_changed;
klass->undo_start = NULL;
klass->undo_event = NULL;
klass->flush = NULL;
klass->undo = gimp_image_undo;
klass->redo = gimp_image_redo;
klass->flush = NULL;
klass->layer_merge = NULL;
gimp_image_color_hash_init ();
}
......@@ -1569,6 +1570,14 @@ gimp_image_undo_thaw (GimpImage *gimage)
return TRUE;
}
void
gimp_image_undo_start (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[UNDO_START], 0);
}
void
gimp_image_undo_event (GimpImage *gimage,
gint event)
......@@ -1657,16 +1666,6 @@ gimp_image_flush (GimpImage *gimage)
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[FLUSH], 0);
}
/* Post notification of a layer merge */
void
gimp_image_layer_merge (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_signal_emit (G_OBJECT (gimage), gimp_image_signals[LAYER_MERGE], 0);
}
/* color transforms / utilities */
......
......@@ -172,6 +172,7 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
/* signals */
void (* mode_changed) (GimpImage *gimage);
void (* alpha_changed) (GimpImage *gimage);
void (* floating_selection_changed) (GimpImage *gimage);
......@@ -200,14 +201,15 @@ struct _GimpImageClass
GimpGuide *guide);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_start) (GimpImage *gimage);
void (* undo_event) (GimpImage *gimage,
gint event);
void (* flush) (GimpImage *gimage);
/* virtual functions */
void (* undo) (GimpImage *gimage);
void (* redo) (GimpImage *gimage);
void (* flush) (GimpImage *gimage);
void (* layer_merge) (GimpImage *gimage);
};
......@@ -304,6 +306,7 @@ gboolean gimp_image_undo_enable (GimpImage *gimage);
gboolean gimp_image_undo_disable (GimpImage *gimage);
gboolean gimp_image_undo_freeze (GimpImage *gimage);
gboolean gimp_image_undo_thaw (GimpImage *gimage);
void gimp_image_undo_start (GimpImage *gimage);
void gimp_image_undo_event (GimpImage *gimage,
gint event);
gint gimp_image_dirty (GimpImage *gimage);
......@@ -315,10 +318,6 @@ void gimp_image_clean_all (GimpImage *gimage);
void gimp_image_flush (GimpImage *gimage);
/* Post notification of layer mergers */
void gimp_image_layer_merge (GimpImage *gimage);
/* color transforms / utilities */
......
......@@ -31,9 +31,6 @@
#include "core/gimplist.h"
#include "core/gimppalette.h"
#include "libgimptool/gimptool.h"
#include "tools/tool_manager.h"
#include "widgets/gimpenummenu.h"
#include "widgets/gimpviewabledialog.h"
......@@ -441,18 +438,9 @@ indexed_ok_callback (GtkWidget *widget,
gpointer data)
{
IndexedDialog *dialog;
GimpTool *active_tool;
dialog = (IndexedDialog *) data;
/* 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 (dialog->gimage->gimp, HALT, active_tool->gdisp);
/* Convert the image to indexed color */
gimp_image_convert (dialog->gimage,
GIMP_INDEXED,
......
......@@ -31,9 +31,6 @@
#include "core/gimplist.h"
#include "core/gimppalette.h"
#include "libgimptool/gimptool.h"
#include "tools/tool_manager.h"
#include "widgets/gimpenummenu.h"
#include "widgets/gimpviewabledialog.h"
......@@ -441,18 +438,9 @@ indexed_ok_callback (GtkWidget *widget,
gpointer data)
{
IndexedDialog *dialog;
GimpTool *active_tool;
dialog = (IndexedDialog *) data;
/* 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 (dialog->gimage->gimp, HALT, active_tool->gdisp);
/* Convert the image to indexed color */
gimp_image_convert (dialog->gimage,
GIMP_INDEXED,
......
......@@ -37,8 +37,6 @@
#include "display/gimpdisplay.h"
#include "tools/tool_manager.h"
#include "widgets/gimpdialogfactory.h"
#include "dialogs.h"
......@@ -111,9 +109,6 @@ edit_cut_cmd_callback (GtkWidget *widget,
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_cut (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage)))
{
......@@ -143,9 +138,6 @@ edit_paste_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
gdisp->gimage->gimp->global_buffer,
......@@ -165,9 +157,6 @@ edit_paste_into_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
gdisp->gimage->gimp->global_buffer,
......@@ -187,9 +176,6 @@ edit_paste_as_new_cmd_callback (GtkWidget *widget,
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
gimp_edit_paste_as_new (gdisp->gimage->gimp,
gdisp->gimage,
gdisp->gimage->gimp->global_buffer);
......@@ -204,9 +190,6 @@ edit_named_cut_cmd_callback (GtkWidget *widget,
GtkWidget *qbox;
return_if_no_display (gdisp, data);
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
qbox = gimp_query_string_box (_("Cut Named"),
gimp_standard_help_func,
"dialogs/cut_named.html",
......
......@@ -49,8 +49,6 @@
#include "widgets/gimpdrawablelistview.h"
#include "widgets/gimppreview.h"
#include "tools/tool_manager.h"
#include "dialogs.h"
#include "libgimp/gimpintl.h"
......
......@@ -172,11 +172,6 @@ gimp_image_map_tool_finalize (GObject *object)
gtk_widget_destroy (image_map_tool->shell);
image_map_tool->shell = NULL;
image_map_tool->main_vbox = NULL;
g_signal_handlers_disconnect_by_func (
gimp_item_get_image (GIMP_ITEM (image_map_tool->drawable)),
gimp_image_map_tool_cancel_clicked,
image_map_tool
);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
......@@ -261,10 +256,6 @@ gimp_image_map_tool_initialize (GimpTool *tool,
G_CALLBACK (gimp_image_map_tool_flush),
image_map_tool);
g_signal_connect (G_OBJECT (gdisp->gimage), "layer_merge",
G_CALLBACK (gimp_image_map_tool_cancel_clicked),
image_map_tool);
gimp_display_shell_set_menu_sensitivity (GIMP_DISPLAY_SHELL (gdisp->shell),
gdisp->gimage->gimp, FALSE);
}
......
......@@ -70,6 +70,7 @@ struct _GimpToolManager
GimpContext *global_tool_context;
GQuark image_dirty_handler_id;
GQuark image_undo_start_handler_id;
};
......@@ -82,7 +83,9 @@ static void tool_manager_tool_changed (GimpContext *user_context,
GimpToolInfo *tool_info,
gpointer data);
static void tool_manager_image_dirty (GimpImage *gimage,
gpointer data);
GimpToolManager *tool_manager);
static void tool_manager_image_undo_start (GimpImage *gimage,
GimpToolManager *tool_manager);
/* public functions */
......@@ -102,6 +105,7 @@ tool_manager_init (Gimp *gimp)
tool_manager->tool_stack = NULL;
tool_manager->global_tool_context = NULL;
tool_manager->image_dirty_handler_id = 0;
tool_manager->image_undo_start_handler_id = 0;
tool_manager_set (gimp, tool_manager);
......@@ -110,6 +114,11 @@ tool_manager_init (Gimp *gimp)
G_CALLBACK (tool_manager_image_dirty),
tool_manager);
tool_manager->image_undo_start_handler_id =
gimp_container_add_handler (gimp->images, "undo_start",
G_CALLBACK (tool_manager_image_undo_start),
tool_manager);
user_context = gimp_get_user_context (gimp);
g_signal_connect (G_OBJECT (user_context), "tool_changed",
......@@ -187,6 +196,8 @@ tool_manager_exit (Gimp *gimp)
gimp_container_remove_handler (gimp->images,
tool_manager->image_dirty_handler_id);
gimp_container_remove_handler (gimp->images,
tool_manager->image_undo_start_handler_id);
if (tool_manager->active_tool)
g_object_unref (G_OBJECT (tool_manager->active_tool));
......@@ -710,12 +721,8 @@ tool_manager_tool_changed (GimpContext *user_context,
static void
tool_manager_image_dirty (GimpImage *gimage,
gpointer data)
GimpToolManager *tool_manager)
{
GimpToolManager *tool_manager;
tool_manager = (GimpToolManager *) data;
if (tool_manager->active_tool &&
! gimp_tool_control_preserve (tool_manager->active_tool->control))
{
......@@ -746,3 +753,16 @@ tool_manager_image_dirty (GimpImage *gimage,
}
}
}
static void
tool_manager_image_undo_start (GimpImage *gimage,
GimpToolManager *tool_manager)
{
if (tool_manager->active_tool &&
tool_manager->active_tool->gdisp &&
tool_manager->active_tool->gdisp->gimage == gimage)
{
tool_manager_control_active (gimage->gimp, HALT,
tool_manager->active_tool->gdisp);
}
}
......@@ -640,6 +640,9 @@ undo_push_group_start (GimpImage *gimage,
g_return_val_if_fail (type > FIRST_UNDO_GROUP &&
type <= LAST_UNDO_GROUP, FALSE);
/* Notify listeners that the image will be modified */
gimp_image_undo_start (gimage);
if (! gimage->undo_on)
return FALSE;
......@@ -3617,6 +3620,7 @@ undo_name[] =
{ FS_ANCHOR_UNDO_GROUP, N_("Anchor Floating Selection") },
{ EDIT_PASTE_UNDO_GROUP, N_("Paste") },
{ EDIT_CUT_UNDO_GROUP, N_("Cut") },
{ EDIT_COPY_UNDO_GROUP, N_("Copy") },
{ TEXT_UNDO_GROUP, N_("Text") },
{ TRANSFORM_UNDO_GROUP, N_("Transform") },
{ PAINT_UNDO_GROUP, N_("Paint") },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment