mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
b5f8fa24d8
commit
6a723efc4b
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
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)
|
||||
{
|
||||
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_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,10 +349,16 @@ 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
|
||||
|
@ -334,11 +367,12 @@ layers_actions_update (GimpActionGroup *group,
|
|||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer = NULL;
|
||||
GimpLayerMask *mask = FALSE; /* layer mask */
|
||||
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 preserve = FALSE;
|
||||
gboolean next_alpha = FALSE;
|
||||
gboolean text_layer = FALSE;
|
||||
GList *next = NULL;
|
||||
|
@ -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-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-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 && 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,6 +69,32 @@
|
|||
#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,
|
||||
|
@ -82,6 +108,7 @@ static void layers_resize_layer_query (GimpDisplay *gdisp,
|
|||
GimpLayer *layer,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent);
|
||||
static gint layers_paint_mode_index (GimpLayerModeEffects paint_mode);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -160,18 +187,6 @@ layers_raise_cmd_callback (GtkAction *action,
|
|||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
layers_lower_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_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
layers_raise_to_top_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
@ -184,6 +199,18 @@ layers_raise_to_top_cmd_callback (GtkAction *action,
|
|||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
layers_lower_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_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
layers_lower_to_bottom_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
@ -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"
|
||||
|
||||
|
@ -112,18 +114,6 @@ vectors_new_cmd_callback (GtkAction *action,
|
|||
NULL, TRUE, widget);
|
||||
}
|
||||
|
||||
void
|
||||
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_to_top (gimage, vectors);
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
vectors_raise_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
@ -136,6 +126,18 @@ vectors_raise_cmd_callback (GtkAction *action,
|
|||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
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_to_top (gimage, vectors);
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
|
||||
void
|
||||
vectors_lower_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
@ -169,7 +171,8 @@ vectors_duplicate_cmd_callback (GtkAction *action,
|
|||
GimpVectors *new_vectors;
|
||||
return_if_no_vectors (gimage, vectors, data);
|
||||
|
||||
new_vectors =GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
|
||||
new_vectors =
|
||||
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
|
||||
G_TYPE_FROM_INSTANCE (vectors),
|
||||
TRUE));
|
||||
gimp_image_add_vectors (gimage, new_vectors, -1);
|
||||
|
@ -340,6 +343,60 @@ vectors_export_cmd_callback (GtkAction *action,
|
|||
vectors_export_query (gimage, vectors, widget);
|
||||
}
|
||||
|
||||
void
|
||||
vectors_visible_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpVectors *vectors;
|
||||
gboolean visible;
|
||||
return_if_no_vectors (gimage, vectors, data);
|
||||
|
||||
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
||||
|
||||
if (visible != gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
{
|
||||
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 (vectors))
|
||||
push_undo = FALSE;
|
||||
|
||||
gimp_item_set_visible (GIMP_ITEM (vectors), visible, push_undo);
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vectors_linked_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpVectors *vectors;
|
||||
gboolean linked;
|
||||
return_if_no_vectors (gimage, vectors, data);
|
||||
|
||||
linked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
||||
|
||||
if (linked != gimp_item_get_linked (GIMP_ITEM (vectors)))
|
||||
{
|
||||
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 (vectors))
|
||||
push_undo = FALSE;
|
||||
|
||||
gimp_item_set_visible (GIMP_ITEM (vectors), linked, push_undo);
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vectors_vectors_tool (GimpVectors *vectors,
|
||||
GimpContext *context,
|
||||
|
|
|
@ -60,6 +60,11 @@ void vectors_import_cmd_callback (GtkAction *action,
|
|||
void vectors_export_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
void vectors_visible_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void vectors_linked_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
void vectors_vectors_tool (GimpVectors *vectors,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent);
|
||||
|
|
|
@ -984,9 +984,21 @@ gimp_layer_tree_view_preserve_button_toggled (GtkWidget *widget,
|
|||
|
||||
if (gimp_layer_get_preserve_trans (layer) != preserve_trans)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
gboolean push_undo = TRUE;
|
||||
|
||||
/* compress opacity undos */
|
||||
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;
|
||||
|
||||
BLOCK();
|
||||
gimp_layer_set_preserve_trans (layer, preserve_trans, TRUE);
|
||||
gimp_layer_set_preserve_trans (layer, preserve_trans, push_undo);
|
||||
UNBLOCK();
|
||||
|
||||
gimp_image_flush (gimage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,6 +347,12 @@
|
|||
<menuitem action="layers-mask-delete" />
|
||||
</placeholder>
|
||||
<separator />
|
||||
<placeholder name="Properties">
|
||||
<menuitem action="layers-mask-show" />
|
||||
<menuitem action="layers-mask-edit" />
|
||||
<menuitem action="layers-mask-disable" />
|
||||
</placeholder>
|
||||
<separator />
|
||||
<placeholder name="Selection">
|
||||
<menuitem action="layers-mask-selection-replace" />
|
||||
<menuitem action="layers-mask-selection-add" />
|
||||
|
@ -395,6 +401,14 @@
|
|||
<menuitem action="layers-crop" />
|
||||
</placeholder>
|
||||
<separator />
|
||||
<!--
|
||||
<placeholder name="Properties">
|
||||
<menuitem action="drawable-visible" />
|
||||
<menuitem action="drawable-linked" />
|
||||
<menuitem action="layers-preserve-transparency" />
|
||||
</placeholder>
|
||||
-->
|
||||
<separator />
|
||||
</menu>
|
||||
|
||||
<menu action="tools-menu" name="Tools">
|
||||
|
|
|
@ -24,11 +24,12 @@
|
|||
<menuitem action="layers-scale" />
|
||||
<separator />
|
||||
<menuitem action="layers-mask-add" />
|
||||
<menuitem action="layers-mask-apply" />
|
||||
<menuitem action="layers-mask-delete" />
|
||||
<separator />
|
||||
<menuitem action="layers-mask-show" />
|
||||
<menuitem action="layers-mask-edit" />
|
||||
<menuitem action="layers-mask-disable" />
|
||||
<menuitem action="layers-mask-apply" />
|
||||
<menuitem action="layers-mask-delete" />
|
||||
<menuitem action="layers-mask-selection-replace" />
|
||||
<separator />
|
||||
<menuitem action="layers-alpha-add" />
|
||||
|
|
Loading…
Reference in New Issue