added new signal "buffer_changed" and new function

2004-02-19  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp.[ch]: added new signal "buffer_changed" and new
	function gimp_set_global_buffer() which emits it when the global
	buffer changes.

	* app/core/gimp-edit.c (gimp_edit_extract): use it instead
	of fiddling with gimp->global_buffer manually.

	* app/gui/image-menu.c: connect to "buffer_changed" and set the
	"Paste" menu entries sensitive. Fixes bug #134752.

	(image_menu_update): changed accordingly. Also changed a lot of
	buggy SET_SENSITIVE() lines which made menu items which work fine
	on any drawable insensitive when there were no layers (instead
	of no drawable).

	* app/gui/edit-commands.c: added new macro return_if_new_drawable()
	and use it instead of return_if_no_image() so we don't run
	into assertions if there is no active drawable.

	(cut,copy_named_buffer_callback): unfortunately had to introduce
	two new translated messages about not being able to cut/copy when
	there is no active drawable.
This commit is contained in:
Michael Natterer 2004-02-19 12:49:15 +00:00 committed by Michael Natterer
parent fc38ede399
commit 513f5eac36
8 changed files with 297 additions and 136 deletions

View File

@ -1,3 +1,28 @@
2004-02-19 Michael Natterer <mitch@gimp.org>
* app/core/gimp.[ch]: added new signal "buffer_changed" and new
function gimp_set_global_buffer() which emits it when the global
buffer changes.
* app/core/gimp-edit.c (gimp_edit_extract): use it instead
of fiddling with gimp->global_buffer manually.
* app/gui/image-menu.c: connect to "buffer_changed" and set the
"Paste" menu entries sensitive. Fixes bug #134752.
(image_menu_update): changed accordingly. Also changed a lot of
buggy SET_SENSITIVE() lines which made menu items which work fine
on any drawable insensitive when there were no layers (instead
of no drawable).
* app/gui/edit-commands.c: added new macro return_if_new_drawable()
and use it instead of return_if_no_image() so we don't run
into assertions if there is no active drawable.
(cut,copy_named_buffer_callback): unfortunately had to introduce
two new translated messages about not being able to cut/copy when
there is no active drawable.
2004-02-19 Michael Natterer <mitch@gimp.org>
* app/config/gimpconfig-serialize.c

View File

@ -75,6 +75,12 @@
if (! gimage) \
return
#define return_if_no_drawable(gimage,drawable,data) \
return_if_no_image (gimage, data); \
drawable = gimp_image_active_drawable (gimage); \
if (! drawable) \
return;
/* local function prototypes */
@ -114,27 +120,24 @@ void
edit_cut_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
if (gimp_edit_cut (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage)))
{
gimp_image_flush (gdisp->gimage);
}
if (gimp_edit_cut (gimage, drawable))
gimp_image_flush (gimage);
}
void
edit_copy_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
if (gimp_edit_copy (gimage, gimp_image_active_drawable (gimage)))
{
gimp_image_flush (gimage);
}
if (gimp_edit_copy (gimage, drawable))
gimp_image_flush (gimage);
}
void
@ -233,10 +236,11 @@ void
edit_clear_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
gimp_edit_clear (gimage, gimp_image_active_drawable (gimage));
gimp_edit_clear (gimage, drawable);
gimp_image_flush (gimage);
}
@ -246,12 +250,13 @@ edit_fill_cmd_callback (GtkWidget *widget,
guint action)
{
GimpImage *gimage;
GimpDrawable *drawable;
GimpFillType fill_type;
return_if_no_image (gimage, data);
return_if_no_drawable (gimage, drawable, data);
fill_type = (GimpFillType) action;
gimp_edit_fill (gimage, gimp_image_active_drawable (gimage), fill_type);
gimp_edit_fill (gimage, drawable, fill_type);
gimp_image_flush (gimage);
}
@ -259,8 +264,9 @@ void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
edit_stroke_selection (GIMP_ITEM (gimp_image_get_mask (gimage)), widget);
}
@ -301,8 +307,17 @@ cut_named_buffer_callback (GtkWidget *widget,
{
GimpImage *gimage = GIMP_IMAGE (data);
const GimpBuffer *cut_buffer;
GimpDrawable *active_drawable;
cut_buffer = gimp_edit_cut (gimage, gimp_image_active_drawable (gimage));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to cut from."));
return;
}
cut_buffer = gimp_edit_cut (gimage, active_drawable);
if (cut_buffer)
{
@ -316,9 +331,9 @@ cut_named_buffer_callback (GtkWidget *widget,
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
g_object_unref (new_buffer);
}
gimp_image_flush (gimage);
gimp_image_flush (gimage);
}
}
static void
@ -328,8 +343,17 @@ copy_named_buffer_callback (GtkWidget *widget,
{
GimpImage *gimage = GIMP_IMAGE (data);
const GimpBuffer *copy_buffer;
GimpDrawable *active_drawable;
copy_buffer = gimp_edit_copy (gimage, gimp_image_active_drawable (gimage));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to copy from."));
return;
}
copy_buffer = gimp_edit_copy (gimage, active_drawable);
if (copy_buffer)
{
@ -343,5 +367,7 @@ copy_named_buffer_callback (GtkWidget *widget,
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
g_object_unref (new_buffer);
gimp_image_flush (gimage);
}
}

View File

@ -329,12 +329,12 @@ gimp_edit_extract (GimpImage *gimage,
if (tiles)
{
GimpBuffer *buffer;
/* Only crop if the gimage mask wasn't empty */
if (! empty)
{
TileManager *crop;
crop = tile_manager_crop (tiles, 0);
TileManager *crop = tile_manager_crop (tiles, 0);
if (crop != tiles)
{
@ -343,14 +343,9 @@ gimp_edit_extract (GimpImage *gimage,
}
}
/* Set the global edit buffer */
if (gimage->gimp->global_buffer)
g_object_unref (gimage->gimp->global_buffer);
gimage->gimp->global_buffer = gimp_buffer_new (tiles, "Global Buffer",
FALSE);
gimage->gimp->have_current_cut_buffer = TRUE;
buffer = gimp_buffer_new (tiles, "Global Buffer", FALSE);
gimp_set_global_buffer (gimage->gimp, buffer);
g_object_unref (buffer);
return gimage->gimp->global_buffer;
}

View File

@ -76,6 +76,7 @@ enum
INITIALIZE,
RESTORE,
EXIT,
BUFFER_CHANGED,
LAST_SIGNAL
};
@ -194,6 +195,15 @@ gimp_class_init (GimpClass *klass)
G_TYPE_BOOLEAN, 1,
G_TYPE_BOOLEAN);
gimp_signals[BUFFER_CHANGED] =
g_signal_new ("buffer-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpClass, buffer_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->dispose = gimp_dispose;
object_class->finalize = gimp_finalize;
@ -202,6 +212,7 @@ gimp_class_init (GimpClass *klass)
klass->initialize = gimp_real_initialize;
klass->restore = gimp_real_restore;
klass->exit = gimp_real_exit;
klass->buffer_changed = NULL;
}
static void
@ -489,11 +500,9 @@ static gint64
gimp_get_memsize (GimpObject *object,
gint64 *gui_size)
{
Gimp *gimp;
Gimp *gimp = GIMP (object);
gint64 memsize = 0;
gimp = GIMP (object);
memsize += gimp_g_list_get_memsize (gimp->user_units, 0 /* FIXME */);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->parasites),
@ -939,6 +948,29 @@ gimp_exit (Gimp *gimp,
&handled);
}
void
gimp_set_global_buffer (Gimp *gimp,
GimpBuffer *buffer)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (buffer == NULL || GIMP_IS_BUFFER (buffer));
if (buffer == gimp->global_buffer)
return;
if (gimp->global_buffer)
g_object_unref (gimp->global_buffer);
gimp->global_buffer = buffer;
if (gimp->global_buffer)
g_object_ref (gimp->global_buffer);
gimp->have_current_cut_buffer = (buffer != NULL);
g_signal_emit (gimp, gimp_signals[BUFFER_CHANGED], 0);
}
void
gimp_threads_enter (Gimp *gimp)
{

View File

@ -199,12 +199,14 @@ struct _GimpClass
{
GimpObjectClass parent_class;
void (* initialize) (Gimp *gimp,
GimpInitStatusFunc status_callback);
void (* restore) (Gimp *gimp,
GimpInitStatusFunc status_callback);
gboolean (* exit) (Gimp *gimp,
gboolean force);
void (* initialize) (Gimp *gimp,
GimpInitStatusFunc status_callback);
void (* restore) (Gimp *gimp,
GimpInitStatusFunc status_callback);
gboolean (* exit) (Gimp *gimp,
gboolean force);
void (* buffer_changed) (Gimp *gimp);
};
@ -232,6 +234,9 @@ void gimp_restore (Gimp *gimp,
void gimp_exit (Gimp *gimp,
gboolean force);
void gimp_set_global_buffer (Gimp *gimp,
GimpBuffer *buffer);
void gimp_threads_enter (Gimp *gimp);
void gimp_threads_leave (Gimp *gimp);

View File

@ -75,6 +75,12 @@
if (! gimage) \
return
#define return_if_no_drawable(gimage,drawable,data) \
return_if_no_image (gimage, data); \
drawable = gimp_image_active_drawable (gimage); \
if (! drawable) \
return;
/* local function prototypes */
@ -114,27 +120,24 @@ void
edit_cut_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
if (gimp_edit_cut (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage)))
{
gimp_image_flush (gdisp->gimage);
}
if (gimp_edit_cut (gimage, drawable))
gimp_image_flush (gimage);
}
void
edit_copy_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
if (gimp_edit_copy (gimage, gimp_image_active_drawable (gimage)))
{
gimp_image_flush (gimage);
}
if (gimp_edit_copy (gimage, drawable))
gimp_image_flush (gimage);
}
void
@ -233,10 +236,11 @@ void
edit_clear_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
gimp_edit_clear (gimage, gimp_image_active_drawable (gimage));
gimp_edit_clear (gimage, drawable);
gimp_image_flush (gimage);
}
@ -246,12 +250,13 @@ edit_fill_cmd_callback (GtkWidget *widget,
guint action)
{
GimpImage *gimage;
GimpDrawable *drawable;
GimpFillType fill_type;
return_if_no_image (gimage, data);
return_if_no_drawable (gimage, drawable, data);
fill_type = (GimpFillType) action;
gimp_edit_fill (gimage, gimp_image_active_drawable (gimage), fill_type);
gimp_edit_fill (gimage, drawable, fill_type);
gimp_image_flush (gimage);
}
@ -259,8 +264,9 @@ void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_drawable (gimage, drawable, data);
edit_stroke_selection (GIMP_ITEM (gimp_image_get_mask (gimage)), widget);
}
@ -301,8 +307,17 @@ cut_named_buffer_callback (GtkWidget *widget,
{
GimpImage *gimage = GIMP_IMAGE (data);
const GimpBuffer *cut_buffer;
GimpDrawable *active_drawable;
cut_buffer = gimp_edit_cut (gimage, gimp_image_active_drawable (gimage));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to cut from."));
return;
}
cut_buffer = gimp_edit_cut (gimage, active_drawable);
if (cut_buffer)
{
@ -316,9 +331,9 @@ cut_named_buffer_callback (GtkWidget *widget,
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
g_object_unref (new_buffer);
}
gimp_image_flush (gimage);
gimp_image_flush (gimage);
}
}
static void
@ -328,8 +343,17 @@ copy_named_buffer_callback (GtkWidget *widget,
{
GimpImage *gimage = GIMP_IMAGE (data);
const GimpBuffer *copy_buffer;
GimpDrawable *active_drawable;
copy_buffer = gimp_edit_copy (gimage, gimp_image_active_drawable (gimage));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to copy from."));
return;
}
copy_buffer = gimp_edit_copy (gimage, active_drawable);
if (copy_buffer)
{
@ -343,5 +367,7 @@ copy_named_buffer_callback (GtkWidget *widget,
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
g_object_unref (new_buffer);
gimp_image_flush (gimage);
}
}

View File

@ -79,6 +79,8 @@
/* local function prototypes */
static void image_menu_buffer_changed (Gimp *gimp,
GimpItemFactory *item_factory);
static void image_menu_foreground_changed (GimpContext *context,
const GimpRGB *color,
GimpItemFactory *item_factory);
@ -1175,6 +1177,12 @@ image_menu_setup (GimpItemFactory *factory)
}
}
g_signal_connect_object (factory->gimp, "buffer_changed",
G_CALLBACK (image_menu_buffer_changed),
factory, 0);
image_menu_buffer_changed (factory->gimp, factory);
{
GimpContext *user_context;
GimpRGB fg;
@ -1335,6 +1343,7 @@ image_menu_update (GtkItemFactory *item_factory,
GimpLayer *layer = NULL;
GimpVectors *vectors = NULL;
GimpImageType drawable_type = -1;
gboolean ad = FALSE;
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
@ -1386,7 +1395,10 @@ image_menu_update (GtkItemFactory *item_factory,
drawable = gimp_image_active_drawable (gimage);
if (drawable)
drawable_type = gimp_drawable_type (drawable);
{
drawable_type = gimp_drawable_type (drawable);
ad = TRUE;
}
if (lp)
{
@ -1426,9 +1438,9 @@ image_menu_update (GtkItemFactory *item_factory,
/* File */
SET_SENSITIVE ("/File/Save", gdisp && drawable);
SET_SENSITIVE ("/File/Save as...", gdisp && drawable);
SET_SENSITIVE ("/File/Save a Copy...", gdisp && drawable);
SET_SENSITIVE ("/File/Save", gdisp && ad);
SET_SENSITIVE ("/File/Save as...", gdisp && ad);
SET_SENSITIVE ("/File/Save a Copy...", gdisp && ad);
SET_SENSITIVE ("/File/Save as Template...", gdisp);
SET_SENSITIVE ("/File/Revert", gdisp && GIMP_OBJECT (gimage)->name);
SET_SENSITIVE ("/File/Close", gdisp);
@ -1468,22 +1480,20 @@ image_menu_update (GtkItemFactory *item_factory,
g_free (redo_name);
}
SET_SENSITIVE ("/Edit/Cut", lp);
SET_SENSITIVE ("/Edit/Copy", lp);
SET_SENSITIVE ("/Edit/Cut", ad);
SET_SENSITIVE ("/Edit/Copy", ad);
SET_SENSITIVE ("/Edit/Paste", gdisp && gimp->global_buffer);
SET_SENSITIVE ("/Edit/Paste Into", gdisp && gimp->global_buffer);
SET_SENSITIVE ("/Edit/Paste as New", gimp->global_buffer);
SET_SENSITIVE ("/Edit/Buffer/Cut Named...", lp);
SET_SENSITIVE ("/Edit/Buffer/Copy Named...", lp);
SET_SENSITIVE ("/Edit/Buffer/Paste Named...", lp);
SET_SENSITIVE ("/Edit/Buffer/Cut Named...", ad);
SET_SENSITIVE ("/Edit/Buffer/Copy Named...", ad);
SET_SENSITIVE ("/Edit/Clear", lp);
SET_SENSITIVE ("/Edit/Fill with FG Color", lp);
SET_SENSITIVE ("/Edit/Fill with BG Color", lp);
SET_SENSITIVE ("/Edit/Fill with Pattern", lp);
SET_SENSITIVE ("/Edit/Stroke Selection...", lp && sel);
SET_SENSITIVE ("/Edit/Stroke Path...", lp && vectors);
SET_SENSITIVE ("/Edit/Clear", ad);
SET_SENSITIVE ("/Edit/Fill with FG Color", ad);
SET_SENSITIVE ("/Edit/Fill with BG Color", ad);
SET_SENSITIVE ("/Edit/Fill with Pattern", ad);
SET_SENSITIVE ("/Edit/Stroke Selection...", ad && sel);
SET_SENSITIVE ("/Edit/Stroke Path...", ad && vectors);
/* Select */
@ -1617,18 +1627,18 @@ image_menu_update (GtkItemFactory *item_factory,
lp && !fs && !aux && alpha && lind < (lnum - 1));
}
SET_SENSITIVE ("/Layer/Colors/Color Balance...", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Hue-Saturation...", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Colorize...", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Brightness-Contrast...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Threshold...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Levels...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Curves...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Posterize...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Desaturate", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Invert", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Auto/Equalize", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Histogram", lp);
SET_SENSITIVE ("/Layer/Colors/Color Balance...", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Hue-Saturation...", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Colorize...", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Brightness-Contrast...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Threshold...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Levels...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Curves...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Posterize...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Desaturate", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Invert", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Auto/Equalize", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Histogram", ad);
SET_SENSITIVE ("/Layer/Mask/Add Layer Mask...", lp && !fs && !aux && !lm && alpha);
SET_SENSITIVE ("/Layer/Mask/Apply Layer Mask", lm && !fs && !aux);
@ -1644,12 +1654,12 @@ image_menu_update (GtkItemFactory *item_factory,
SET_SENSITIVE ("/Layer/Transparency/Subtract from Selection", lp && !aux);
SET_SENSITIVE ("/Layer/Transparency/Intersect with Selection", lp && !aux);
SET_SENSITIVE ("/Layer/Transform/Flip Horizontally", lp);
SET_SENSITIVE ("/Layer/Transform/Flip Vertically", lp);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CW", lp);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CCW", lp);
SET_SENSITIVE ("/Image/Transform/Rotate 180 degrees", lp);
SET_SENSITIVE ("/Layer/Transform/Offset...", lp);
SET_SENSITIVE ("/Layer/Transform/Flip Horizontally", ad);
SET_SENSITIVE ("/Layer/Transform/Flip Vertically", ad);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CW", ad);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CCW", ad);
SET_SENSITIVE ("/Image/Transform/Rotate 180 degrees", ad);
SET_SENSITIVE ("/Layer/Transform/Offset...", ad);
#undef SET_ACTIVE
#undef SET_VISIBLE
@ -1662,6 +1672,22 @@ image_menu_update (GtkItemFactory *item_factory,
/* private functions */
static void
image_menu_buffer_changed (Gimp *gimp,
GimpItemFactory *item_factory)
{
GtkItemFactory *gtk_factory = GTK_ITEM_FACTORY (item_factory);
gboolean buf = (gimp->global_buffer != NULL);
if (GTK_IS_MENU_BAR (gtk_factory->widget))
{
gimp_item_factory_set_sensitive (gtk_factory, "/Edit/Paste", buf);
gimp_item_factory_set_sensitive (gtk_factory, "/Edit/Paste Into", buf);
}
gimp_item_factory_set_sensitive (gtk_factory, "/Edit/Paste as New", buf);
}
static void
image_menu_foreground_changed (GimpContext *context,
const GimpRGB *color,

View File

@ -79,6 +79,8 @@
/* local function prototypes */
static void image_menu_buffer_changed (Gimp *gimp,
GimpItemFactory *item_factory);
static void image_menu_foreground_changed (GimpContext *context,
const GimpRGB *color,
GimpItemFactory *item_factory);
@ -1175,6 +1177,12 @@ image_menu_setup (GimpItemFactory *factory)
}
}
g_signal_connect_object (factory->gimp, "buffer_changed",
G_CALLBACK (image_menu_buffer_changed),
factory, 0);
image_menu_buffer_changed (factory->gimp, factory);
{
GimpContext *user_context;
GimpRGB fg;
@ -1335,6 +1343,7 @@ image_menu_update (GtkItemFactory *item_factory,
GimpLayer *layer = NULL;
GimpVectors *vectors = NULL;
GimpImageType drawable_type = -1;
gboolean ad = FALSE;
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
@ -1386,7 +1395,10 @@ image_menu_update (GtkItemFactory *item_factory,
drawable = gimp_image_active_drawable (gimage);
if (drawable)
drawable_type = gimp_drawable_type (drawable);
{
drawable_type = gimp_drawable_type (drawable);
ad = TRUE;
}
if (lp)
{
@ -1426,9 +1438,9 @@ image_menu_update (GtkItemFactory *item_factory,
/* File */
SET_SENSITIVE ("/File/Save", gdisp && drawable);
SET_SENSITIVE ("/File/Save as...", gdisp && drawable);
SET_SENSITIVE ("/File/Save a Copy...", gdisp && drawable);
SET_SENSITIVE ("/File/Save", gdisp && ad);
SET_SENSITIVE ("/File/Save as...", gdisp && ad);
SET_SENSITIVE ("/File/Save a Copy...", gdisp && ad);
SET_SENSITIVE ("/File/Save as Template...", gdisp);
SET_SENSITIVE ("/File/Revert", gdisp && GIMP_OBJECT (gimage)->name);
SET_SENSITIVE ("/File/Close", gdisp);
@ -1468,22 +1480,20 @@ image_menu_update (GtkItemFactory *item_factory,
g_free (redo_name);
}
SET_SENSITIVE ("/Edit/Cut", lp);
SET_SENSITIVE ("/Edit/Copy", lp);
SET_SENSITIVE ("/Edit/Cut", ad);
SET_SENSITIVE ("/Edit/Copy", ad);
SET_SENSITIVE ("/Edit/Paste", gdisp && gimp->global_buffer);
SET_SENSITIVE ("/Edit/Paste Into", gdisp && gimp->global_buffer);
SET_SENSITIVE ("/Edit/Paste as New", gimp->global_buffer);
SET_SENSITIVE ("/Edit/Buffer/Cut Named...", lp);
SET_SENSITIVE ("/Edit/Buffer/Copy Named...", lp);
SET_SENSITIVE ("/Edit/Buffer/Paste Named...", lp);
SET_SENSITIVE ("/Edit/Buffer/Cut Named...", ad);
SET_SENSITIVE ("/Edit/Buffer/Copy Named...", ad);
SET_SENSITIVE ("/Edit/Clear", lp);
SET_SENSITIVE ("/Edit/Fill with FG Color", lp);
SET_SENSITIVE ("/Edit/Fill with BG Color", lp);
SET_SENSITIVE ("/Edit/Fill with Pattern", lp);
SET_SENSITIVE ("/Edit/Stroke Selection...", lp && sel);
SET_SENSITIVE ("/Edit/Stroke Path...", lp && vectors);
SET_SENSITIVE ("/Edit/Clear", ad);
SET_SENSITIVE ("/Edit/Fill with FG Color", ad);
SET_SENSITIVE ("/Edit/Fill with BG Color", ad);
SET_SENSITIVE ("/Edit/Fill with Pattern", ad);
SET_SENSITIVE ("/Edit/Stroke Selection...", ad && sel);
SET_SENSITIVE ("/Edit/Stroke Path...", ad && vectors);
/* Select */
@ -1617,18 +1627,18 @@ image_menu_update (GtkItemFactory *item_factory,
lp && !fs && !aux && alpha && lind < (lnum - 1));
}
SET_SENSITIVE ("/Layer/Colors/Color Balance...", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Hue-Saturation...", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Colorize...", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Brightness-Contrast...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Threshold...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Levels...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Curves...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Posterize...", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Desaturate", lp && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Invert", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Auto/Equalize", lp && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Histogram", lp);
SET_SENSITIVE ("/Layer/Colors/Color Balance...", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Hue-Saturation...", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Colorize...", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Brightness-Contrast...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Threshold...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Levels...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Curves...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Posterize...", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Desaturate", ad && is_rgb);
SET_SENSITIVE ("/Layer/Colors/Invert", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Auto/Equalize", ad && ! is_indexed);
SET_SENSITIVE ("/Layer/Colors/Histogram", ad);
SET_SENSITIVE ("/Layer/Mask/Add Layer Mask...", lp && !fs && !aux && !lm && alpha);
SET_SENSITIVE ("/Layer/Mask/Apply Layer Mask", lm && !fs && !aux);
@ -1644,12 +1654,12 @@ image_menu_update (GtkItemFactory *item_factory,
SET_SENSITIVE ("/Layer/Transparency/Subtract from Selection", lp && !aux);
SET_SENSITIVE ("/Layer/Transparency/Intersect with Selection", lp && !aux);
SET_SENSITIVE ("/Layer/Transform/Flip Horizontally", lp);
SET_SENSITIVE ("/Layer/Transform/Flip Vertically", lp);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CW", lp);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CCW", lp);
SET_SENSITIVE ("/Image/Transform/Rotate 180 degrees", lp);
SET_SENSITIVE ("/Layer/Transform/Offset...", lp);
SET_SENSITIVE ("/Layer/Transform/Flip Horizontally", ad);
SET_SENSITIVE ("/Layer/Transform/Flip Vertically", ad);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CW", ad);
SET_SENSITIVE ("/Layer/Transform/Rotate 90 degrees CCW", ad);
SET_SENSITIVE ("/Image/Transform/Rotate 180 degrees", ad);
SET_SENSITIVE ("/Layer/Transform/Offset...", ad);
#undef SET_ACTIVE
#undef SET_VISIBLE
@ -1662,6 +1672,22 @@ image_menu_update (GtkItemFactory *item_factory,
/* private functions */
static void
image_menu_buffer_changed (Gimp *gimp,
GimpItemFactory *item_factory)
{
GtkItemFactory *gtk_factory = GTK_ITEM_FACTORY (item_factory);
gboolean buf = (gimp->global_buffer != NULL);
if (GTK_IS_MENU_BAR (gtk_factory->widget))
{
gimp_item_factory_set_sensitive (gtk_factory, "/Edit/Paste", buf);
gimp_item_factory_set_sensitive (gtk_factory, "/Edit/Paste Into", buf);
}
gimp_item_factory_set_sensitive (gtk_factory, "/Edit/Paste as New", buf);
}
static void
image_menu_foreground_changed (GimpContext *context,
const GimpRGB *color,