[gimp] app: add gimpdisplayshell-actions.[ch]



commit 388bf5d4cae99e57e54aa09a5209da46ec2ef9b3
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 14 22:51:21 2016 +0200

    app: add gimpdisplayshell-actions.[ch]
    
    which contains functions to update shell-related actions in the "view"
    group. Took the code out of gimpdisplayshell-appearance.c.

 app/display/Makefile.am                   |    2 +
 app/display/gimpdisplayshell-actions.c    |  111 +++++++++++++++++++++++++++++
 app/display/gimpdisplayshell-actions.h    |   30 ++++++++
 app/display/gimpdisplayshell-appearance.c |  108 ++++------------------------
 4 files changed, 158 insertions(+), 93 deletions(-)
---
diff --git a/app/display/Makefile.am b/app/display/Makefile.am
index 7dbd0c4..1aea72f 100644
--- a/app/display/Makefile.am
+++ b/app/display/Makefile.am
@@ -84,6 +84,8 @@ libappdisplay_a_sources = \
        gimpdisplay-handlers.h                  \
        gimpdisplayshell.c                      \
        gimpdisplayshell.h                      \
+       gimpdisplayshell-actions.c              \
+       gimpdisplayshell-actions.h              \
        gimpdisplayshell-appearance.c           \
        gimpdisplayshell-appearance.h           \
        gimpdisplayshell-autoscroll.c           \
diff --git a/app/display/gimpdisplayshell-actions.c b/app/display/gimpdisplayshell-actions.c
new file mode 100644
index 0000000..b6b2275
--- /dev/null
+++ b/app/display/gimpdisplayshell-actions.c
@@ -0,0 +1,111 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+#include <gtk/gtk.h>
+
+#include "display-types.h"
+
+#include "core/gimp.h"
+#include "core/gimpcontext.h"
+
+#include "widgets/gimpactiongroup.h"
+#include "widgets/gimpuimanager.h"
+
+#include "gimpdisplay.h"
+#include "gimpdisplayshell.h"
+#include "gimpdisplayshell-actions.h"
+#include "gimpimagewindow.h"
+
+
+void
+gimp_display_shell_set_action_active (GimpDisplayShell *shell,
+                                      const gchar      *action,
+                                      gboolean          active)
+{
+  GimpImageWindow *window;
+  GimpContext     *context;
+
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (action != NULL);
+
+  window = gimp_display_shell_get_window (shell);
+
+  if (window && gimp_image_window_get_active_shell (window) == shell)
+    {
+      GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
+      GimpActionGroup *action_group;
+
+      action_group = gimp_ui_manager_get_action_group (manager, "view");
+
+      if (action_group)
+        gimp_action_group_set_action_active (action_group, action, active);
+    }
+
+  context = gimp_get_user_context (shell->display->gimp);
+
+  if (shell->display == gimp_context_get_display (context))
+    {
+      GimpActionGroup *action_group;
+
+      action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
+                                                       "view");
+
+      if (action_group)
+        gimp_action_group_set_action_active (action_group, action, active);
+    }
+}
+
+void
+gimp_display_shell_set_action_color (GimpDisplayShell *shell,
+                                     const gchar      *action,
+                                     const GimpRGB    *color)
+{
+  GimpImageWindow *window;
+  GimpContext     *context;
+
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+  g_return_if_fail (action != NULL);
+
+  window = gimp_display_shell_get_window (shell);
+
+  if (window && gimp_image_window_get_active_shell (window) == shell)
+    {
+      GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
+      GimpActionGroup *action_group;
+
+      action_group = gimp_ui_manager_get_action_group (manager, "view");
+
+      if (action_group)
+        gimp_action_group_set_action_color (action_group, action, color, FALSE);
+    }
+
+  context = gimp_get_user_context (shell->display->gimp);
+
+  if (shell->display == gimp_context_get_display (context))
+    {
+      GimpActionGroup *action_group;
+
+      action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
+                                                       "view");
+
+      if (action_group)
+        gimp_action_group_set_action_color (action_group, action, color, FALSE);
+    }
+}
diff --git a/app/display/gimpdisplayshell-actions.h b/app/display/gimpdisplayshell-actions.h
new file mode 100644
index 0000000..f2a1963
--- /dev/null
+++ b/app/display/gimpdisplayshell-actions.h
@@ -0,0 +1,30 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_DISPLAY_SHELL_ACTIONS_H__
+#define __GIMP_DISPLAY_SHELL_ACTIONS_H__
+
+
+void   gimp_display_shell_set_action_active (GimpDisplayShell *shell,
+                                             const gchar      *action,
+                                             gboolean          active);
+void   gimp_display_shell_set_action_color  (GimpDisplayShell *shell,
+                                             const gchar      *action,
+                                             const GimpRGB    *color);
+
+
+#endif /* __GIMP_DISPLAY_SHELL_ACTIONS_H__ */
diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c
index a3bbcdf..74f6103 100644
--- a/app/display/gimpdisplayshell-appearance.c
+++ b/app/display/gimpdisplayshell-appearance.c
@@ -20,27 +20,21 @@
 #include <gegl.h>
 #include <gtk/gtk.h>
 
-#include "libgimpcolor/gimpcolor.h"
-#include "libgimpwidgets/gimpwidgets.h"
-
 #include "display-types.h"
 
 #include "config/gimpdisplayoptions.h"
 
-#include "core/gimp.h"
-#include "core/gimpcontext.h"
 #include "core/gimpimage.h"
 
-#include "widgets/gimpactiongroup.h"
 #include "widgets/gimpdockcolumns.h"
 #include "widgets/gimprender.h"
-#include "widgets/gimpuimanager.h"
 #include "widgets/gimpwidgets-utils.h"
 
 #include "gimpcanvas.h"
 #include "gimpcanvasitem.h"
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
+#include "gimpdisplayshell-actions.h"
 #include "gimpdisplayshell-appearance.h"
 #include "gimpdisplayshell-selection.h"
 #include "gimpimagewindow.h"
@@ -49,14 +43,7 @@
 
 /*  local function prototypes  */
 
-static GimpDisplayOptions *
-              appearance_get_options       (GimpDisplayShell       *shell);
-static void   appearance_set_action_active (GimpDisplayShell       *shell,
-                                            const gchar            *action,
-                                            gboolean                active);
-static void   appearance_set_action_color  (GimpDisplayShell       *shell,
-                                            const gchar            *action,
-                                            const GimpRGB          *color);
+static GimpDisplayOptions * appearance_get_options (GimpDisplayShell *shell);
 
 
 /*  public functions  */
@@ -81,7 +68,8 @@ gimp_display_shell_appearance_update (GimpDisplayShell *shell)
 
       fullscreen = gimp_image_window_get_fullscreen (window);
 
-      appearance_set_action_active (shell, "view-fullscreen", fullscreen);
+      gimp_display_shell_set_action_active (shell, "view-fullscreen",
+                                            fullscreen);
 
       left_docks  = gimp_image_window_get_left_docks (window);
       right_docks = gimp_image_window_get_right_docks (window);
@@ -138,7 +126,7 @@ gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
       gimp_image_window_set_show_menubar (window, show);
     }
 
-  appearance_set_action_active (shell, "view-show-menubar", show);
+  gimp_display_shell_set_action_active (shell, "view-show-menubar", show);
 }
 
 gboolean
@@ -164,7 +152,7 @@ gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
   gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
   gimp_statusbar_set_visible (GIMP_STATUSBAR (shell->statusbar), show);
 
-  appearance_set_action_active (shell, "view-show-statusbar", show);
+  gimp_display_shell_set_action_active (shell, "view-show-statusbar", show);
 }
 
 gboolean
@@ -192,7 +180,7 @@ gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
   gtk_widget_set_visible (shell->hrule, show);
   gtk_widget_set_visible (shell->vrule, show);
 
-  appearance_set_action_active (shell, "view-show-rulers", show);
+  gimp_display_shell_set_action_active (shell, "view-show-rulers", show);
 }
 
 gboolean
@@ -222,7 +210,7 @@ gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
   gtk_widget_set_visible (shell->quick_mask_button, show);
   gtk_widget_set_visible (shell->zoom_button, show);
 
-  appearance_set_action_active (shell, "view-show-scrollbars", show);
+  gimp_display_shell_set_action_active (shell, "view-show-scrollbars", show);
 }
 
 gboolean
@@ -247,7 +235,7 @@ gimp_display_shell_set_show_selection (GimpDisplayShell *shell,
 
   gimp_display_shell_selection_set_show (shell, show);
 
-  appearance_set_action_active (shell, "view-show-selection", show);
+  gimp_display_shell_set_action_active (shell, "view-show-selection", show);
 }
 
 gboolean
@@ -272,7 +260,7 @@ gimp_display_shell_set_show_layer (GimpDisplayShell *shell,
 
   gimp_canvas_item_set_visible (shell->layer_boundary, show);
 
-  appearance_set_action_active (shell, "view-show-layer-boundary", show);
+  gimp_display_shell_set_action_active (shell, "view-show-layer-boundary", show);
 }
 
 gboolean
@@ -297,7 +285,7 @@ gimp_display_shell_set_show_guides (GimpDisplayShell *shell,
 
   gimp_canvas_item_set_visible (shell->guides, show);
 
-  appearance_set_action_active (shell, "view-show-guides", show);
+  gimp_display_shell_set_action_active (shell, "view-show-guides", show);
 }
 
 gboolean
@@ -322,7 +310,7 @@ gimp_display_shell_set_show_grid (GimpDisplayShell *shell,
 
   gimp_canvas_item_set_visible (shell->grid, show);
 
-  appearance_set_action_active (shell, "view-show-grid", show);
+  gimp_display_shell_set_action_active (shell, "view-show-grid", show);
 }
 
 gboolean
@@ -347,7 +335,7 @@ gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell,
 
   gimp_canvas_item_set_visible (shell->sample_points, show);
 
-  appearance_set_action_active (shell, "view-show-sample-points", show);
+  gimp_display_shell_set_action_active (shell, "view-show-sample-points", show);
 }
 
 gboolean
@@ -491,8 +479,8 @@ gimp_display_shell_set_padding (GimpDisplayShell      *shell,
 
   gimp_canvas_set_bg_color (GIMP_CANVAS (shell->canvas), &color);
 
-  appearance_set_action_color (shell, "view-padding-color-menu",
-                               &options->padding_color);
+  gimp_display_shell_set_action_color (shell, "view-padding-color-menu",
+                                       &options->padding_color);
 }
 
 void
@@ -531,69 +519,3 @@ appearance_get_options (GimpDisplayShell *shell)
 
   return shell->no_image_options;
 }
-
-static void
-appearance_set_action_active (GimpDisplayShell *shell,
-                              const gchar      *action,
-                              gboolean          active)
-{
-  GimpImageWindow *window = gimp_display_shell_get_window (shell);
-  GimpContext     *context;
-
-  if (window && gimp_image_window_get_active_shell (window) == shell)
-    {
-      GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
-      GimpActionGroup *action_group;
-
-      action_group = gimp_ui_manager_get_action_group (manager, "view");
-
-      if (action_group)
-        gimp_action_group_set_action_active (action_group, action, active);
-    }
-
-  context = gimp_get_user_context (shell->display->gimp);
-
-  if (shell->display == gimp_context_get_display (context))
-    {
-      GimpActionGroup *action_group;
-
-      action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
-                                                       "view");
-
-      if (action_group)
-        gimp_action_group_set_action_active (action_group, action, active);
-    }
-}
-
-static void
-appearance_set_action_color (GimpDisplayShell *shell,
-                             const gchar      *action,
-                             const GimpRGB    *color)
-{
-  GimpImageWindow *window = gimp_display_shell_get_window (shell);
-  GimpContext     *context;
-
-  if (window && gimp_image_window_get_active_shell (window) == shell)
-    {
-      GimpUIManager   *manager = gimp_image_window_get_ui_manager (window);
-      GimpActionGroup *action_group;
-
-      action_group = gimp_ui_manager_get_action_group (manager, "view");
-
-      if (action_group)
-        gimp_action_group_set_action_color (action_group, action, color, FALSE);
-    }
-
-  context = gimp_get_user_context (shell->display->gimp);
-
-  if (shell->display == gimp_context_get_display (context))
-    {
-      GimpActionGroup *action_group;
-
-      action_group = gimp_ui_manager_get_action_group (shell->popup_manager,
-                                                       "view");
-
-      if (action_group)
-        gimp_action_group_set_action_color (action_group, action, color, FALSE);
-    }
-}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]