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 "display-types.h"
24 
25 #include "core/gimp.h"
26 #include "core/gimpcontext.h"
27 
28 #include "widgets/gimpactiongroup.h"
29 #include "widgets/gimpuimanager.h"
30 
31 #include "gimpdisplay.h"
32 #include "gimpdisplayshell.h"
33 #include "gimpdisplayshell-actions.h"
34 #include "gimpimagewindow.h"
35 
36 
37 void
gimp_display_shell_set_action_sensitive(GimpDisplayShell * shell,const gchar * action,gboolean sensitive)38 gimp_display_shell_set_action_sensitive (GimpDisplayShell *shell,
39                                          const gchar      *action,
40                                          gboolean          sensitive)
41 {
42   GimpImageWindow *window;
43   GimpContext     *context;
44 
45   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
46   g_return_if_fail (action != NULL);
47 
48   window = gimp_display_shell_get_window (shell);
49 
50   if (window && gimp_image_window_get_active_shell (window) == shell)
51     {
52       GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
53       GimpActionGroup *action_group;
54 
55       action_group = gimp_ui_manager_get_action_group (manager, "view");
56 
57       if (action_group)
58         gimp_action_group_set_action_sensitive (action_group, action, sensitive);
59     }
60 
61   context = gimp_get_user_context (shell->display->gimp);
62 
63   if (shell->display == gimp_context_get_display (context))
64     {
65       GimpActionGroup *action_group;
66 
67       action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
68                                                        "view");
69 
70       if (action_group)
71         gimp_action_group_set_action_sensitive (action_group, action, sensitive);
72     }
73 }
74 
75 void
gimp_display_shell_set_action_active(GimpDisplayShell * shell,const gchar * action,gboolean active)76 gimp_display_shell_set_action_active (GimpDisplayShell *shell,
77                                       const gchar      *action,
78                                       gboolean          active)
79 {
80   GimpImageWindow *window;
81   GimpContext     *context;
82 
83   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
84   g_return_if_fail (action != NULL);
85 
86   window = gimp_display_shell_get_window (shell);
87 
88   if (window && gimp_image_window_get_active_shell (window) == shell)
89     {
90       GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
91       GimpActionGroup *action_group;
92 
93       action_group = gimp_ui_manager_get_action_group (manager, "view");
94 
95       if (action_group)
96         gimp_action_group_set_action_active (action_group, action, active);
97     }
98 
99   context = gimp_get_user_context (shell->display->gimp);
100 
101   if (shell->display == gimp_context_get_display (context))
102     {
103       GimpActionGroup *action_group;
104 
105       action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
106                                                        "view");
107 
108       if (action_group)
109         gimp_action_group_set_action_active (action_group, action, active);
110     }
111 }
112 
113 void
gimp_display_shell_set_action_color(GimpDisplayShell * shell,const gchar * action,const GimpRGB * color)114 gimp_display_shell_set_action_color (GimpDisplayShell *shell,
115                                      const gchar      *action,
116                                      const GimpRGB    *color)
117 {
118   GimpImageWindow *window;
119   GimpContext     *context;
120 
121   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
122   g_return_if_fail (action != NULL);
123 
124   window = gimp_display_shell_get_window (shell);
125 
126   if (window && gimp_image_window_get_active_shell (window) == shell)
127     {
128       GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
129       GimpActionGroup *action_group;
130 
131       action_group = gimp_ui_manager_get_action_group (manager, "view");
132 
133       if (action_group)
134         gimp_action_group_set_action_color (action_group, action, color, FALSE);
135     }
136 
137   context = gimp_get_user_context (shell->display->gimp);
138 
139   if (shell->display == gimp_context_get_display (context))
140     {
141       GimpActionGroup *action_group;
142 
143       action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
144                                                        "view");
145 
146       if (action_group)
147         gimp_action_group_set_action_color (action_group, action, color, FALSE);
148     }
149 }
150