app/actions/layers-actions.[ch] app/actions/layers-commands.[ch] added

2004-08-21  Sven Neumann  <sven@gimp.org>

	* app/actions/layers-actions.[ch]
	* app/actions/layers-commands.[ch]
	* app/widgets/gimplayertreeview.c: added actions to handle layer
	masks as suggested in bug #150446.

	* menus/layers-menu.xml: added menu entries for new actions,
	commented out raise/lower menu entries.
This commit is contained in:
Sven Neumann 2004-08-20 22:32:14 +00:00 committed by Sven Neumann
parent f5045bdcdb
commit c04ddea85e
7 changed files with 175 additions and 34 deletions

View File

@ -1,3 +1,13 @@
2004-08-21 Sven Neumann <sven@gimp.org>
* app/actions/layers-actions.[ch]
* app/actions/layers-commands.[ch]
* app/widgets/gimplayertreeview.c: added actions to handle layer
masks as suggested in bug #150446.
* menus/layers-menu.xml: added menu entries for new actions,
commented out raise/lower menu entries.
2004-08-20 Sven Neumann <sven@gimp.org>
* modules/controller_linux_input.c: declare local function as static.

View File

@ -156,6 +156,27 @@ static GimpActionEntry layers_actions[] =
GIMP_HELP_LAYER_ALPHA_ADD }
};
static GimpToggleActionEntry layers_mask_toggle_actions[] =
{
{ "layers-mask-edit", NULL,
N_("Edit Layer Mask"), NULL, NULL,
G_CALLBACK (layers_mask_edit_cmd_callback),
FALSE,
NULL },
{ "layers-mask-show", NULL,
N_("Show Layer Mask"), NULL, NULL,
G_CALLBACK (layers_mask_show_cmd_callback),
FALSE,
NULL },
{ "layers-mask-disable", NULL,
N_("Disable Layer Mask"), NULL, NULL,
G_CALLBACK (layers_mask_disable_cmd_callback),
FALSE,
NULL }
};
static GimpEnumActionEntry layers_mask_apply_actions[] =
{
{ "layers-mask-apply", NULL,
@ -283,6 +304,10 @@ layers_actions_setup (GimpActionGroup *group)
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),
@ -390,10 +415,13 @@ 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-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-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);

View File

@ -20,7 +20,7 @@
#define __LAYERS_ACTIONS_H__
void layers_actions_setup (GimpActionGroup *group);
void layers_actions_setup (GimpActionGroup *group);
void layers_actions_update (GimpActionGroup *group,
gpointer data);

View File

@ -376,6 +376,73 @@ layers_mask_apply_cmd_callback (GtkAction *action,
}
}
void
layers_mask_edit_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
GimpLayerMask *mask;
return_if_no_layer (gimage, layer, data);
mask = gimp_layer_get_mask (layer);
if (mask)
{
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_layer_mask_set_edit (mask, active);
gimp_image_flush (gimage);
}
}
void
layers_mask_show_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
GimpLayerMask *mask;
return_if_no_layer (gimage, layer, data);
mask = gimp_layer_get_mask (layer);
if (mask)
{
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_layer_mask_set_show (mask, active);
gimp_image_flush (gimage);
}
}
void
layers_mask_disable_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
GimpLayerMask *mask;
return_if_no_layer (gimage, layer, data);
mask = gimp_layer_get_mask (layer);
if (mask)
{
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_layer_mask_set_apply (mask, ! active);
gimp_image_flush (gimage);
}
}
void
layers_mask_to_selection_cmd_callback (GtkAction *action,
gint value,

View File

@ -65,6 +65,12 @@ void layers_mask_add_cmd_callback (GtkAction *action,
void layers_mask_apply_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void layers_mask_edit_cmd_callback (GtkAction *action,
gpointer data);
void layers_mask_show_cmd_callback (GtkAction *action,
gpointer data);
void layers_mask_disable_cmd_callback (GtkAction *action,
gpointer data);
void layers_mask_to_selection_cmd_callback (GtkAction *action,
gint value,
gpointer data);

View File

@ -45,6 +45,7 @@
#include "file/file-open.h"
#include "file/file-utils.h"
#include "gimpactiongroup.h"
#include "gimpcellrendererviewable.h"
#include "gimpcontainerview.h"
#include "gimpdnd.h"
@ -125,6 +126,8 @@ static void gimp_layer_tree_view_layer_signal_handler
GimpLayerTreeView *view);
static void gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
GimpLayer *layer);
static void gimp_layer_tree_view_update_menu (GimpLayerTreeView *view,
GimpLayer *layer);
static void gimp_layer_tree_view_mask_update (GimpLayerTreeView *view,
GtkTreeIter *iter,
@ -592,6 +595,7 @@ gimp_layer_tree_view_select_item (GimpContainerView *view,
gimp_layer_tree_view_update_borders (layer_view,
(GtkTreeIter *) insert_data);
gimp_layer_tree_view_update_options (layer_view, GIMP_LAYER (item));
gimp_layer_tree_view_update_menu (layer_view, GIMP_LAYER (item));
}
options_sensitive = TRUE;
@ -1089,6 +1093,30 @@ gimp_layer_tree_view_update_options (GimpLayerTreeView *view,
#undef UNBLOCK
static void
gimp_layer_tree_view_update_menu (GimpLayerTreeView *layer_view,
GimpLayer *layer)
{
GimpUIManager *ui_manager = GIMP_EDITOR (layer_view)->ui_manager;
GimpActionGroup *group;
GimpLayerMask *mask;
group = gimp_ui_manager_get_action_group (ui_manager, "layers");
mask = gimp_layer_get_mask (layer);
gimp_action_group_set_action_active (group, "layers-mask-show",
mask &&
gimp_layer_mask_get_show (mask));
gimp_action_group_set_action_active (group, "layers-mask-disable",
mask &&
! gimp_layer_mask_get_apply (mask));
gimp_action_group_set_action_active (group, "layers-mask-edit",
mask &&
gimp_layer_mask_get_edit (mask));
}
/* Layer Mask callbacks */
static void
@ -1261,6 +1289,11 @@ gimp_layer_tree_view_layer_clicked (GimpCellRendererViewable *cell,
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
{
GimpPreviewRenderer *renderer;
GimpUIManager *ui_manager;
GimpActionGroup *group;
ui_manager = GIMP_EDITOR (tree_view)->ui_manager;
group = gimp_ui_manager_get_action_group (ui_manager, "layers");
gtk_tree_model_get (tree_view->model, &iter,
layer_view->model_column_mask, &renderer,
@ -1268,16 +1301,11 @@ gimp_layer_tree_view_layer_clicked (GimpCellRendererViewable *cell,
if (renderer)
{
GimpLayerMask *mask;
mask = GIMP_LAYER_MASK (renderer->viewable);
GimpLayerMask *mask = GIMP_LAYER_MASK (renderer->viewable);
if (gimp_layer_mask_get_edit (mask))
{
gimp_layer_mask_set_edit (mask, FALSE);
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (mask)));
}
gimp_action_group_set_action_active (group,
"layers-mask-edit", FALSE);
g_object_unref (renderer);
}
}
@ -1300,35 +1328,32 @@ gimp_layer_tree_view_mask_clicked (GimpCellRendererViewable *cell,
if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
{
GimpPreviewRenderer *renderer;
GimpLayerMask *mask;
gboolean flush = FALSE;
GimpUIManager *ui_manager;
GimpActionGroup *group;
ui_manager = GIMP_EDITOR (tree_view)->ui_manager;
group = gimp_ui_manager_get_action_group (ui_manager, "layers");
gtk_tree_model_get (tree_view->model, &iter,
layer_view->model_column_mask, &renderer,
-1);
mask = GIMP_LAYER_MASK (renderer->viewable);
if (state & GDK_MOD1_MASK)
if (renderer)
{
gimp_layer_mask_set_show (mask, ! gimp_layer_mask_get_show (mask));
flush = TRUE;
}
else if (state & GDK_CONTROL_MASK)
{
gimp_layer_mask_set_apply (mask, ! gimp_layer_mask_get_apply (mask));
flush = TRUE;
}
else if (! gimp_layer_mask_get_edit (mask))
{
gimp_layer_mask_set_edit (mask, TRUE);
flush = TRUE;
}
GimpLayerMask *mask = GIMP_LAYER_MASK (renderer->viewable);
if (flush)
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (mask)));
if (state & GDK_MOD1_MASK)
gimp_action_group_set_action_active (group, "layers-mask-show",
! gimp_layer_mask_get_show (mask));
else if (state & GDK_CONTROL_MASK)
gimp_action_group_set_action_active (group, "layers-mask-disable",
gimp_layer_mask_get_apply (mask));
else if (! gimp_layer_mask_get_edit (mask))
gimp_action_group_set_action_active (group,
"layers-mask-edit", TRUE);
g_object_unref (renderer);
g_object_unref (renderer);
}
}
gtk_tree_path_free (path);

View File

@ -7,10 +7,12 @@
<menuitem action="layers-edit-attributes" />
<separator />
<menuitem action="layers-new" />
<!--
<menuitem action="layers-raise" />
<menuitem action="layers-raise-to-top" />
<menuitem action="layers-lower" />
<menuitem action="layers-lower-to-bottom" />
-->
<menuitem action="layers-duplicate" />
<menuitem action="layers-anchor" />
<menuitem action="layers-merge-down" />
@ -22,6 +24,9 @@
<menuitem action="layers-scale" />
<separator />
<menuitem action="layers-mask-add" />
<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" />