Commit 6a723efc authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/actions/layers-actions.c added actions and callbacks

2004-09-15  Michael Natterer  <mitch@gimp.org>

	* app/actions/layers-actions.c
	* app/actions/layers-commands.[ch]: added actions and callbacks
	"layers-preserve-transparency" and
	"layers-paint-mode-first,last,previous,next". Update the "active"
	state of the recently added layer mask property actions in
	layers_actions_update().

	* app/actions/drawable-actions.c
	* app/actions/drawable-commands.[ch]: added actions and callbacks
	for "drawable-visible" and "drawable-linked". Fixes bug #152597.

	* app/actions/vectors-actions.c
	* app/actions/vectors-commands.[ch]: same here ("vectors-visible"
	and "vectors-linked").

	* app/widgets/gimplayertreeview.c
	(gimp_layer_tree_view_preserve_button_toggled): flush the image
	so the new actions are updated. Compress preserve_trans undos.

	* menus/image-menu.xml.in: added the layer mask property actions
	to the Layers/Mask submenu.

	* menus/layers-menu.xml: reordered the mask property actions
	to have the same order as in the image menu.
parent b5f8fa24
2004-09-15 Michael Natterer <mitch@gimp.org>
* app/actions/layers-actions.c
* app/actions/layers-commands.[ch]: added actions and callbacks
"layers-preserve-transparency" and
"layers-paint-mode-first,last,previous,next". Update the "active"
state of the recently added layer mask property actions in
layers_actions_update().
* app/actions/drawable-actions.c
* app/actions/drawable-commands.[ch]: added actions and callbacks
for "drawable-visible" and "drawable-linked". Fixes bug #152597.
* app/actions/vectors-actions.c
* app/actions/vectors-commands.[ch]: same here ("vectors-visible"
and "vectors-linked").
* app/widgets/gimplayertreeview.c
(gimp_layer_tree_view_preserve_button_toggled): flush the image
so the new actions are updated. Compress preserve_trans undos.
* menus/image-menu.xml.in: added the layer mask property actions
to the Layers/Mask submenu.
* menus/layers-menu.xml: reordered the mask property actions
to have the same order as in the image menu.
2004-09-15 Sven Neumann <sven@gimp.org>
* app/widgets/gimpcontainertreeview.c
......
......@@ -63,6 +63,21 @@ static GimpActionEntry drawable_actions[] =
GIMP_HELP_LAYER_OFFSET }
};
static GimpToggleActionEntry drawable_toggle_actions[] =
{
{ "drawable-visible", GIMP_STOCK_VISIBLE,
N_("_Visible"), NULL, NULL,
G_CALLBACK (drawable_visible_cmd_callback),
FALSE,
NULL },
{ "drawable-linked", GIMP_STOCK_LINKED,
N_("_Linked"), NULL, NULL,
G_CALLBACK (drawable_linked_cmd_callback),
FALSE,
NULL }
};
static GimpEnumActionEntry drawable_flip_actions[] =
{
{ "drawable-flip-horizontal", GIMP_STOCK_FLIP_HORIZONTAL,
......@@ -102,6 +117,10 @@ drawable_actions_setup (GimpActionGroup *group)
drawable_actions,
G_N_ELEMENTS (drawable_actions));
gimp_action_group_add_toggle_actions (group,
drawable_toggle_actions,
G_N_ELEMENTS (drawable_toggle_actions));
gimp_action_group_add_enum_actions (group,
drawable_flip_actions,
G_N_ELEMENTS (drawable_flip_actions),
......@@ -122,6 +141,8 @@ drawable_actions_update (GimpActionGroup *group,
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
gboolean visible = FALSE;
gboolean linked = FALSE;
gimage = action_data_get_image (data);
......@@ -131,22 +152,34 @@ drawable_actions_update (GimpActionGroup *group,
if (drawable)
{
GimpImageType drawable_type = gimp_drawable_type (drawable);
GimpItem *item = GIMP_ITEM (drawable);
GimpImageType drawable_type = gimp_drawable_type (drawable);
is_rgb = GIMP_IMAGE_TYPE_IS_RGB (drawable_type);
is_gray = GIMP_IMAGE_TYPE_IS_GRAY (drawable_type);
is_rgb = GIMP_IMAGE_TYPE_IS_RGB (drawable_type);
is_gray = GIMP_IMAGE_TYPE_IS_GRAY (drawable_type);
is_indexed = GIMP_IMAGE_TYPE_IS_INDEXED (drawable_type);
visible = gimp_item_get_visible (item);
linked = gimp_item_get_linked (item);
}
}
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_SENSITIVE ("drawable-desaturate", drawable && is_rgb);
SET_SENSITIVE ("drawable-invert", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-equalize", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-offset", drawable);
SET_SENSITIVE ("drawable-visible", drawable);
SET_SENSITIVE ("drawable-linked", drawable);
SET_ACTIVE ("drawable-visible", visible);
SET_ACTIVE ("drawable-linked", linked);
SET_SENSITIVE ("drawable-flip-horizontal", drawable);
SET_SENSITIVE ("drawable-flip-vertical", drawable);
......@@ -155,4 +188,5 @@ drawable_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("drawable-rotate-270", drawable);
#undef SET_SENSITIVE
#undef SET_ACTIVE
}
......@@ -32,6 +32,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimpitem-linked.h"
#include "core/gimpitemundo.h"
#include "dialogs/offset-dialog.h"
......@@ -97,6 +98,60 @@ drawable_equalize_cmd_callback (GtkAction *action,
gimp_image_flush (gimage);
}
void
drawable_visible_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable;
gboolean visible;
return_if_no_drawable (gimage, drawable, data);
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (visible != gimp_item_get_visible (GIMP_ITEM (drawable)))
{
GimpUndo *undo;
gboolean push_undo = TRUE;
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
GIMP_UNDO_ITEM_VISIBILITY);
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawable))
push_undo = FALSE;
gimp_item_set_visible (GIMP_ITEM (drawable), visible, push_undo);
gimp_image_flush (gimage);
}
}
void
drawable_linked_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable;
gboolean linked;
return_if_no_drawable (gimage, drawable, data);
linked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (linked != gimp_item_get_linked (GIMP_ITEM (drawable)))
{
GimpUndo *undo;
gboolean push_undo = TRUE;
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
GIMP_UNDO_ITEM_LINKED);
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawable))
push_undo = FALSE;
gimp_item_set_linked (GIMP_ITEM (drawable), linked, push_undo);
gimp_image_flush (gimage);
}
}
void
drawable_flip_cmd_callback (GtkAction *action,
gint value,
......
......@@ -26,6 +26,10 @@ void drawable_invert_cmd_callback (GtkAction *action,
gpointer data);
void drawable_equalize_cmd_callback (GtkAction *action,
gpointer data);
void drawable_visible_cmd_callback (GtkAction *action,
gpointer data);
void drawable_linked_cmd_callback (GtkAction *action,
gpointer data);
void drawable_flip_cmd_callback (GtkAction *action,
gint value,
gpointer data);
......
......@@ -26,6 +26,7 @@
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimplist.h"
#include "text/gimptextlayer.h"
......@@ -156,15 +157,21 @@ static GimpActionEntry layers_actions[] =
GIMP_HELP_LAYER_ALPHA_ADD }
};
static GimpToggleActionEntry layers_mask_toggle_actions[] =
static GimpToggleActionEntry layers_toggle_actions[] =
{
{ "layers-mask-edit", NULL,
{ "layers-preserve-transparency", GIMP_STOCK_TRANSPARENCY,
N_("Preserve Transparency"), NULL, NULL,
G_CALLBACK (layers_preserve_trans_cmd_callback),
FALSE,
NULL },
{ "layers-mask-edit", GIMP_STOCK_EDIT,
N_("Edit Layer Mask"), NULL, NULL,
G_CALLBACK (layers_mask_edit_cmd_callback),
FALSE,
NULL },
{ "layers-mask-show", NULL,
{ "layers-mask-show", GIMP_STOCK_VISIBLE,
N_("Show Layer Mask"), NULL, NULL,
G_CALLBACK (layers_mask_show_cmd_callback),
FALSE,
......@@ -291,6 +298,26 @@ static GimpEnumActionEntry layers_opacity_actions[] =
NULL }
};
static GimpEnumActionEntry layers_paint_mode_actions[] =
{
{ "layers-paint-mode-first", GIMP_STOCK_TOOL_PENCIL,
"First Paint Mode", NULL, NULL,
GIMP_ACTION_SELECT_FIRST,
NULL },
{ "layers-paint-mode-last", GIMP_STOCK_TOOL_PENCIL,
"Last Paint Mode", NULL, NULL,
GIMP_ACTION_SELECT_LAST,
NULL },
{ "layers-paint-mode-previous", GIMP_STOCK_TOOL_PENCIL,
"Previous Paint Mode", NULL, NULL,
GIMP_ACTION_SELECT_PREVIOUS,
NULL },
{ "layers-paint-mode-next", GIMP_STOCK_TOOL_PENCIL,
"Next Paint Mode", NULL, NULL,
GIMP_ACTION_SELECT_NEXT,
NULL }
};
void
layers_actions_setup (GimpActionGroup *group)
......@@ -299,15 +326,15 @@ layers_actions_setup (GimpActionGroup *group)
layers_actions,
G_N_ELEMENTS (layers_actions));
gimp_action_group_add_toggle_actions (group,
layers_toggle_actions,
G_N_ELEMENTS (layers_toggle_actions));
gimp_action_group_add_enum_actions (group,
layers_mask_apply_actions,
G_N_ELEMENTS (layers_mask_apply_actions),
G_CALLBACK (layers_mask_apply_cmd_callback));
gimp_action_group_add_toggle_actions (group,
layers_mask_toggle_actions,
G_N_ELEMENTS (layers_mask_toggle_actions));
gimp_action_group_add_enum_actions (group,
layers_mask_to_selection_actions,
G_N_ELEMENTS (layers_mask_to_selection_actions),
......@@ -322,27 +349,34 @@ layers_actions_setup (GimpActionGroup *group)
layers_select_actions,
G_N_ELEMENTS (layers_select_actions),
G_CALLBACK (layers_select_cmd_callback));
gimp_action_group_add_enum_actions (group,
layers_opacity_actions,
G_N_ELEMENTS (layers_opacity_actions),
G_CALLBACK (layers_opacity_cmd_callback));
gimp_action_group_add_enum_actions (group,
layers_paint_mode_actions,
G_N_ELEMENTS (layers_paint_mode_actions),
G_CALLBACK (layers_paint_mode_cmd_callback));
}
void
layers_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer = NULL;
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
gboolean lm = FALSE; /* layer mask */
gboolean alpha = FALSE; /* alpha channel present */
gboolean indexed = FALSE; /* is indexed */
gboolean next_alpha = FALSE;
gboolean text_layer = FALSE;
GList *next = NULL;
GList *prev = NULL;
GimpImage *gimage;
GimpLayer *layer = NULL;
GimpLayerMask *mask = FALSE; /* layer mask */
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
gboolean alpha = FALSE; /* alpha channel present */
gboolean indexed = FALSE; /* is indexed */
gboolean preserve = FALSE;
gboolean next_alpha = FALSE;
gboolean text_layer = FALSE;
GList *next = NULL;
GList *prev = NULL;
gimage = action_data_get_image (data);
......@@ -353,7 +387,11 @@ layers_actions_update (GimpActionGroup *group,
layer = gimp_image_get_active_layer (gimage);
if (layer)
lm = (gimp_layer_get_mask (layer)) ? TRUE : FALSE;
{
mask = gimp_layer_get_mask (layer);
preserve = gimp_layer_get_preserve_trans (layer);
}
fs = (gimp_image_floating_sel (gimage) != NULL);
ac = (gimp_image_get_active_channel (gimage) != NULL);
......@@ -387,6 +425,8 @@ layers_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_visible (group, action, (condition) != 0)
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_VISIBLE ("layers-text-tool", text_layer && !ac);
SET_SENSITIVE ("layers-edit-attributes", layer && !fs && !ac);
......@@ -415,18 +455,27 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-resize-to-image", layer && !ac);
SET_SENSITIVE ("layers-scale", layer && !ac);
SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !lm && alpha);
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-disable", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-apply", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-alpha-add", layer && !fs && !alpha);
SET_SENSITIVE ("layers-alpha-add", layer && !fs && !alpha);
SET_SENSITIVE ("layers-preserve-transparency", layer);
SET_ACTIVE ("layers-preserve-transparency", preserve);
SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask && alpha);
SET_SENSITIVE ("layers-mask-apply", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-disable", layer && !fs && !ac && mask);
SET_ACTIVE ("layers-mask-edit", mask && gimp_layer_mask_get_edit (mask));
SET_ACTIVE ("layers-mask-show", mask && gimp_layer_mask_get_show (mask));
SET_ACTIVE ("layers-mask-disable", mask && !gimp_layer_mask_get_apply (mask));
SET_SENSITIVE ("layers-mask-selection-replace", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-selection-add", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-selection-subtract", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-selection-intersect", layer && !fs && !ac && lm);
SET_SENSITIVE ("layers-mask-selection-replace", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-selection-add", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-selection-subtract", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-selection-intersect", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-alpha-selection-replace", layer && !fs && !ac);
SET_SENSITIVE ("layers-alpha-selection-add", layer && !fs && !ac);
......@@ -435,4 +484,5 @@ layers_actions_update (GimpActionGroup *group,
#undef SET_VISIBLE
#undef SET_SENSITIVE
#undef SET_ACTIVE
}
......@@ -69,19 +69,46 @@
#include "gimp-intl.h"
static const GimpLayerModeEffects paint_modes[] =
{
GIMP_NORMAL_MODE,
GIMP_DISSOLVE_MODE,
GIMP_MULTIPLY_MODE,
GIMP_DIVIDE_MODE,
GIMP_SCREEN_MODE,
GIMP_OVERLAY_MODE,
GIMP_DODGE_MODE,
GIMP_BURN_MODE,
GIMP_HARDLIGHT_MODE,
GIMP_SOFTLIGHT_MODE,
GIMP_GRAIN_EXTRACT_MODE,
GIMP_GRAIN_MERGE_MODE,
GIMP_DIFFERENCE_MODE,
GIMP_ADDITION_MODE,
GIMP_SUBTRACT_MODE,
GIMP_DARKEN_ONLY_MODE,
GIMP_LIGHTEN_ONLY_MODE,
GIMP_HUE_MODE,
GIMP_SATURATION_MODE,
GIMP_COLOR_MODE,
GIMP_VALUE_MODE
};
/* local function prototypes */
static void layers_add_mask_query (GimpLayer *layer,
GtkWidget *parent);
static void layers_scale_layer_query (GimpDisplay *gdisp,
GimpImage *gimage,
GimpLayer *layer,
GtkWidget *parent);
static void layers_resize_layer_query (GimpDisplay *gdisp,
GimpImage *gimage,
GimpLayer *layer,
GimpContext *context,
GtkWidget *parent);
static void layers_add_mask_query (GimpLayer *layer,
GtkWidget *parent);
static void layers_scale_layer_query (GimpDisplay *gdisp,
GimpImage *gimage,
GimpLayer *layer,
GtkWidget *parent);
static void layers_resize_layer_query (GimpDisplay *gdisp,
GimpImage *gimage,
GimpLayer *layer,
GimpContext *context,
GtkWidget *parent);
static gint layers_paint_mode_index (GimpLayerModeEffects paint_mode);
/* public functions */
......@@ -161,26 +188,26 @@ layers_raise_cmd_callback (GtkAction *action,
}
void
layers_lower_cmd_callback (GtkAction *action,
gpointer data)
layers_raise_to_top_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
return_if_no_layer (gimage, layer, data);
gimp_image_lower_layer (gimage, layer);
gimp_image_raise_layer_to_top (gimage, layer);
gimp_image_flush (gimage);
}
void
layers_raise_to_top_cmd_callback (GtkAction *action,
gpointer data)
layers_lower_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
return_if_no_layer (gimage, layer, data);
gimp_image_raise_layer_to_top (gimage, layer);
gimp_image_lower_layer (gimage, layer);
gimp_image_flush (gimage);
}
......@@ -386,6 +413,7 @@ layers_mask_edit_cmd_callback (GtkAction *action,
return_if_no_layer (gimage, layer, data);
mask = gimp_layer_get_mask (layer);
if (mask)
{
gboolean active;
......@@ -522,15 +550,70 @@ layers_opacity_cmd_callback (GtkAction *action,
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
push_undo = FALSE;
opacity = gimp_layer_get_opacity (layer);
opacity = action_select_value ((GimpActionSelectType) value,
opacity,
gimp_layer_get_opacity (layer),
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_layer_set_opacity (layer, opacity, push_undo);
gimp_image_flush (gimage);
}
void
layers_paint_mode_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
GimpLayerModeEffects paint_mode;
gint index;
GimpUndo *undo;
gboolean push_undo = TRUE;
return_if_no_layer (gimage, layer, data);
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
GIMP_UNDO_LAYER_OPACITY);
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
push_undo = FALSE;
paint_mode = gimp_layer_get_mode (layer);
index = action_select_value ((GimpActionSelectType) value,
layers_paint_mode_index (paint_mode),
0, G_N_ELEMENTS (paint_modes) - 1,
1.0, 1.0, FALSE);
gimp_layer_set_mode (layer, paint_modes[index], push_undo);
gimp_image_flush (gimage);
}
void
layers_preserve_trans_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gboolean preserve;
return_if_no_layer (gimage, layer, data);
preserve = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (preserve != gimp_layer_get_preserve_trans (layer))
{
GimpUndo *undo;
gboolean push_undo = TRUE;
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
GIMP_UNDO_LAYER_PRESERVE_TRANS);
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
push_undo = FALSE;
gimp_layer_set_preserve_trans (layer, preserve, push_undo);
gimp_image_flush (gimage);
}
}
void
layers_text_tool (GimpLayer *layer,
GimpContext *context,
......@@ -1286,3 +1369,14 @@ layers_resize_layer_query (GimpDisplay *gdisp,
gtk_widget_show (options->dialog->shell);
}
static gint
layers_paint_mode_index (GimpLayerModeEffects paint_mode)
{
gint i = 0;
while (i < (G_N_ELEMENTS (paint_modes) - 1) && paint_modes[i] != paint_mode)
i++;
return i;
}
......@@ -33,10 +33,10 @@ void layers_select_cmd_callback (GtkAction *action,
void layers_raise_cmd_callback (GtkAction *action,
gpointer data);
void layers_lower_cmd_callback (GtkAction *action,
gpointer data);
void layers_raise_to_top_cmd_callback (GtkAction *action,
gpointer data);
void layers_lower_cmd_callback (GtkAction *action,
gpointer data);
void layers_lower_to_bottom_cmd_callback (GtkAction *action,
gpointer data);
......@@ -84,6 +84,12 @@ void layers_alpha_to_selection_cmd_callback (GtkAction *action,
void layers_opacity_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void layers_paint_mode_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void layers_preserve_trans_cmd_callback (GtkAction *action,
gpointer data);
void layers_text_tool (GimpLayer *layer,
GimpContext *context,
......
......@@ -120,6 +120,21 @@ static GimpActionEntry vectors_actions[] =
GIMP_HELP_PATH_EXPORT }
};
static GimpToggleActionEntry vectors_toggle_actions[] =
{
{ "vectors-visible", GIMP_STOCK_VISIBLE,
N_("_Visible"), NULL, NULL,
G_CALLBACK (vectors_visible_cmd_callback),
FALSE,
NULL },
{ "vectors-linked", GIMP_STOCK_LINKED,
N_("_Linked"), NULL, NULL,
G_CALLBACK (vectors_linked_cmd_callback),
FALSE,
NULL }
};
static GimpEnumActionEntry vectors_to_selection_actions[] =
{
{ "vectors-selection-replace", GIMP_STOCK_SELECTION_REPLACE,
......@@ -174,6 +189,10 @@ vectors_actions_setup (GimpActionGroup *group)
vectors_actions,
G_N_ELEMENTS (vectors_actions));
gimp_action_group_add_toggle_actions (group,
vectors_toggle_actions,
G_N_ELEMENTS (vectors_toggle_actions));
gimp_action_group_add_enum_actions (group,
vectors_to_selection_actions,
G_N_ELEMENTS (vectors_to_selection_actions),
......@@ -194,6 +213,8 @@ vectors_actions_update (GimpActionGroup *group,
gint n_vectors = 0;
gboolean mask_empty = TRUE;
gboolean global_buf = FALSE;
gboolean visible = FALSE;
gboolean linked = FALSE;
GList *next = NULL;
GList *prev = NULL;
......@@ -211,6 +232,14 @@ vectors_actions_update (GimpActionGroup *group,
global_buf = FALSE;
if (vectors)
{
GimpItem *item = GIMP_ITEM (vectors);
visible = gimp_item_get_visible (item);
linked = gimp_item_get_linked (item);
}
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
......@@ -226,6 +255,8 @@ vectors_actions_update (GimpActionGroup *group,
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_SENSITIVE ("vectors-path-tool", vectors);
SET_SENSITIVE ("vectors-edit-attributes", vectors);
......@@ -240,16 +271,22 @@ vectors_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("vectors-lower", vectors && next);
SET_SENSITIVE ("vectors-lower-to-bottom", vectors && next);
SET_SENSITIVE ("vectors-selection-to-vectors", ! mask_empty);
SET_SENSITIVE ("vectors-selection-to-vectors-short", ! mask_empty);
SET_SENSITIVE ("vectors-selection-to-vectors-advanced", ! mask_empty);
SET_SENSITIVE ("vectors-stroke", vectors);
SET_SENSITIVE ("vectors-copy", vectors);
SET_SENSITIVE ("vectors-paste", global_buf);
SET_SENSITIVE ("vectors-import", gimage);
SET_SENSITIVE ("vectors-export", vectors);
SET_SENSITIVE ("vectors-visible", vectors);
SET_SENSITIVE ("vectors-linked", vectors);
SET_ACTIVE ("vectors-visible", visible);
SET_ACTIVE ("vectors-linked", linked);
SET_SENSITIVE ("vectors-selection-to-vectors", ! mask_empty);
SET_SENSITIVE ("vectors-selection-to-vectors-short", ! mask_empty);
SET_SENSITIVE ("vectors-selection-to-vectors-advanced", ! mask_empty);
SET_SENSITIVE ("vectors-stroke", vectors);
SET_SENSITIVE ("vectors-selection-replace", vectors);
SET_SENSITIVE ("vectors-selection-from-vectors", vectors);
SET_SENSITIVE ("vectors-selection-add", vectors);
......@@ -257,4 +294,5 @@ vectors_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("vectors-selection-intersect", vectors);
#undef SET_SENSITIVE
#undef SET_ACTIVE
}
......@@ -33,6 +33,8 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-undo.h"
#include "core/gimpitemundo.h"
#include "core/gimpprogress.h"
#include "core/gimptoolinfo.h"
......@@ -113,26 +115,26 @@ vectors_new_cmd_callback (GtkAction *action,
}
void
vectors_raise_to_top_cmd_callback (GtkAction *action,
gpointer data)
vectors_raise_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpVectors *vectors;
return_if_no_vectors (gimage, vectors, data);
gimp_image_raise_vectors_to_top (gimage, vectors);
gimp_image_raise_vectors (gimage, vectors);
gimp_image_flush (gimage);
}
void
vectors_raise_cmd_callback (GtkAction *action,
gpointer data)
vectors_raise_to_top_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpVectors *vectors;
return_if_no_vectors (gimage, vectors, data);
gimp_image_raise_vectors (gimage, vectors);
gimp_image_raise_vectors_to_top (gimage, vectors);
gimp_image_flush (gimage);
}
......@@ -169,9 +171,10 @@ vectors_duplicate_cmd_callback (GtkAction *action,
GimpVectors *new_vectors;
return_if_no_vectors (gimage, vectors, data);