1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #include "config.h"
19 
20 #include <gegl.h>
21 #include <gtk/gtk.h>
22 
23 #include "libgimpwidgets/gimpwidgets.h"
24 
25 #include "actions-types.h"
26 
27 #include "core/gimpcontext.h"
28 #include "core/gimpimage.h"
29 
30 #include "widgets/gimpactiongroup.h"
31 #include "widgets/gimphelp-ids.h"
32 
33 #include "actions.h"
34 #include "images-actions.h"
35 #include "images-commands.h"
36 
37 #include "gimp-intl.h"
38 
39 
40 static const GimpActionEntry images_actions[] =
41 {
42   { "images-popup", GIMP_ICON_DIALOG_IMAGES,
43     NC_("images-action", "Images Menu"), NULL, NULL, NULL,
44     GIMP_HELP_IMAGE_DIALOG },
45 
46   { "images-raise-views", GIMP_ICON_GO_TOP,
47     NC_("images-action", "_Raise Views"), NULL,
48     NC_("images-action", "Raise this image's displays"),
49     images_raise_views_cmd_callback,
50     NULL },
51 
52   { "images-new-view", GIMP_ICON_DOCUMENT_NEW,
53     NC_("images-action", "_New View"), NULL,
54     NC_("images-action", "Create a new display for this image"),
55     images_new_view_cmd_callback,
56     NULL },
57 
58   { "images-delete", GIMP_ICON_EDIT_DELETE,
59     NC_("images-action", "_Delete Image"), NULL,
60     NC_("images-action", "Delete this image"),
61     images_delete_image_cmd_callback,
62     NULL }
63 };
64 
65 
66 void
images_actions_setup(GimpActionGroup * group)67 images_actions_setup (GimpActionGroup *group)
68 {
69   gimp_action_group_add_actions (group, "images-action",
70                                  images_actions,
71                                  G_N_ELEMENTS (images_actions));
72 }
73 
74 void
images_actions_update(GimpActionGroup * group,gpointer data)75 images_actions_update (GimpActionGroup *group,
76                        gpointer         data)
77 {
78   GimpContext *context    = action_data_get_context (data);
79   GimpImage   *image      = NULL;
80   gint         disp_count = 0;
81 
82   if (context)
83     {
84       image = gimp_context_get_image (context);
85 
86       if (image)
87         disp_count = gimp_image_get_display_count (image);
88     }
89 
90 #define SET_SENSITIVE(action,condition) \
91         gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
92 
93   SET_SENSITIVE ("images-raise-views", image);
94   SET_SENSITIVE ("images-new-view",    image);
95   SET_SENSITIVE ("images-delete",      image && disp_count == 0);
96 
97 #undef SET_SENSITIVE
98 }
99