[gimp] Move the fullscreen API from GimpDisplayShell to GimpImageWindow



commit be93e6564a20b510113007cb533f3995e8263d7d
Author: Michael Natterer <mitch gimp org>
Date:   Wed Sep 23 14:52:33 2009 +0200

    Move the fullscreen API from GimpDisplayShell to GimpImageWindow
    
    Also remove GimpDisplayShell's "window_state" member. Use
    gtk_widget_get_toplvel() to get to the GimpImageWindow when we need a
    display shell's fullscreen state.

 app/actions/view-actions.c                |    5 ++-
 app/actions/view-commands.c               |   21 ++++++++----
 app/display/gimpdisplayshell-appearance.c |   29 ++--------------
 app/display/gimpdisplayshell-appearance.h |    4 --
 app/display/gimpdisplayshell-handlers.c   |    6 +++-
 app/display/gimpdisplayshell.c            |   18 ++--------
 app/display/gimpdisplayshell.h            |    1 -
 app/display/gimpimagewindow.c             |   52 +++++++++++++++++++++++++++++
 app/display/gimpimagewindow.h             |    3 ++
 9 files changed, 86 insertions(+), 53 deletions(-)
---
diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c
index cac5415..b9b6b71 100644
--- a/app/actions/view-actions.c
+++ b/app/actions/view-actions.c
@@ -44,6 +44,7 @@
 #include "display/gimpdisplayshell-appearance.h"
 #include "display/gimpdisplayshell-scale.h"
 #include "display/gimpdisplayshell-selection.h"
+#include "display/gimpimagewindow.h"
 
 #include "actions.h"
 #include "view-actions.h"
@@ -549,10 +550,12 @@ view_actions_update (GimpActionGroup *group,
 
   if (display)
     {
+      GtkWidget *window = gtk_widget_get_toplevel (display->shell);
+
       image = display->image;
       shell = GIMP_DISPLAY_SHELL (display->shell);
 
-      fullscreen = gimp_display_shell_get_fullscreen (shell);
+      fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
 
       options = (image ?
                  (fullscreen ? shell->fullscreen_options : shell->options) :
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index f664244..5c7c422 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -42,6 +42,7 @@
 #include "display/gimpdisplayshell-scale.h"
 #include "display/gimpdisplayshell-scale-dialog.h"
 #include "display/gimpdisplayshell-scroll.h"
+#include "display/gimpimagewindow.h"
 
 #include "widgets/gimpactiongroup.h"
 #include "widgets/gimpcolordialog.h"
@@ -573,14 +574,17 @@ view_padding_color_cmd_callback (GtkAction *action,
                                  gpointer   data)
 {
   GimpDisplay        *display;
+  GtkWidget          *window;
   GimpDisplayShell   *shell;
   GimpDisplayOptions *options;
   gboolean            fullscreen;
   return_if_no_display (display, data);
 
+  window = gtk_widget_get_toplevel (display->shell);
+
   shell = GIMP_DISPLAY_SHELL (display->shell);
 
-  fullscreen = gimp_display_shell_get_fullscreen (shell);
+  fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
 
   if (fullscreen)
     options = shell->fullscreen_options;
@@ -672,16 +676,16 @@ void
 view_fullscreen_cmd_callback (GtkAction *action,
                               gpointer   data)
 {
-  GimpDisplay      *display;
-  GimpDisplayShell *shell;
-  gboolean          active;
+  GimpDisplay *display;
+  GtkWidget   *window;
+  gboolean     active;
   return_if_no_display (display, data);
 
-  shell = GIMP_DISPLAY_SHELL (display->shell);
+  window = gtk_widget_get_toplevel (display->shell);
 
   active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_fullscreen (shell, active);
+  gimp_image_window_set_fullscreen (GIMP_IMAGE_WINDOW (window), active);
 }
 
 void
@@ -730,10 +734,13 @@ view_padding_color_dialog_update (GimpColorDialog      *dialog,
                                   GimpColorDialogState  state,
                                   GimpDisplayShell     *shell)
 {
+  GtkWidget          *window;
   GimpDisplayOptions *options;
   gboolean            fullscreen;
 
-  fullscreen = gimp_display_shell_get_fullscreen (shell);
+  window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
+
+  fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
 
   if (fullscreen)
     options = shell->fullscreen_options;
diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c
index 1f93cfc..049276a 100644
--- a/app/display/gimpdisplayshell-appearance.c
+++ b/app/display/gimpdisplayshell-appearance.c
@@ -43,12 +43,13 @@
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-appearance.h"
 #include "gimpdisplayshell-selection.h"
+#include "gimpimagewindow.h"
 #include "gimpstatusbar.h"
 
 
 #define GET_OPTIONS(shell) \
   (shell->display->image ? \
-   (gimp_display_shell_get_fullscreen (shell) ? \
+   (gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell)))) ? \
     shell->fullscreen_options : shell->options) : \
    shell->no_image_options)
 
@@ -78,7 +79,8 @@ gimp_display_shell_appearance_update (GimpDisplayShell *shell)
 
   options = GET_OPTIONS (shell);
 
-  fullscreen = gimp_display_shell_get_fullscreen (shell);
+  /* FIXME temp image window hack */
+  fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (shell));
 
   if (shell->menubar)
     gtk_widget_set_name (GTK_WIDGET (shell->menubar),
@@ -111,29 +113,6 @@ gimp_display_shell_appearance_update (GimpDisplayShell *shell)
 }
 
 void
-gimp_display_shell_set_fullscreen (GimpDisplayShell *shell,
-                                   gboolean          fullscreen)
-{
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  if (fullscreen != gimp_display_shell_get_fullscreen (shell))
-    {
-      if (fullscreen)
-        gtk_window_fullscreen (GTK_WINDOW (shell));
-      else
-        gtk_window_unfullscreen (GTK_WINDOW (shell));
-    }
-}
-
-gboolean
-gimp_display_shell_get_fullscreen (const GimpDisplayShell *shell)
-{
-  g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
-
-  return (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
-}
-
-void
 gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
                                      gboolean          show)
 {
diff --git a/app/display/gimpdisplayshell-appearance.h b/app/display/gimpdisplayshell-appearance.h
index 20fa1b7..c899c6e 100644
--- a/app/display/gimpdisplayshell-appearance.h
+++ b/app/display/gimpdisplayshell-appearance.h
@@ -21,10 +21,6 @@
 
 void       gimp_display_shell_appearance_update      (GimpDisplayShell       *shell);
 
-void       gimp_display_shell_set_fullscreen         (GimpDisplayShell       *shell,
-                                                      gboolean                fullscreen);
-gboolean   gimp_display_shell_get_fullscreen         (const GimpDisplayShell *shell);
-
 void       gimp_display_shell_set_show_menubar       (GimpDisplayShell       *shell,
                                                       gboolean                show);
 gboolean   gimp_display_shell_get_show_menubar       (const GimpDisplayShell *shell);
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 8e572f8..a242744 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -48,6 +48,7 @@
 #include "gimpdisplayshell-scroll.h"
 #include "gimpdisplayshell-selection.h"
 #include "gimpdisplayshell-title.h"
+#include "gimpimagewindow.h"
 
 
 /*  local function prototypes  */
@@ -671,13 +672,16 @@ gimp_display_shell_padding_notify_handler (GObject          *config,
                                            GimpDisplayShell *shell)
 {
   GimpDisplayConfig     *display_config;
+  GtkWidget             *window;
   gboolean               fullscreen;
   GimpCanvasPaddingMode  padding_mode;
   GimpRGB                padding_color;
 
   display_config = shell->display->config;
 
-  fullscreen = gimp_display_shell_get_fullscreen (shell);
+  window = gtk_widget_get_toplevel (GTK_WIDGET (shell));
+
+  fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
 
   /*  if the user did not set the padding mode for this display explicitely  */
   if (! shell->fullscreen_options->padding_mode_set)
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 5261ce2..28fdd07 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -338,7 +338,6 @@ gimp_display_shell_init (GimpDisplayShell *shell)
 
   shell->paused_count           = 0;
 
-  shell->window_state           = 0;
   shell->zoom_on_resize         = FALSE;
   shell->show_transform_preview = FALSE;
 
@@ -645,21 +644,17 @@ gimp_display_shell_window_state_event (GtkWidget           *widget,
 
   GTK_WIDGET_CLASS (parent_class)->window_state_event (widget, event);
 
-  shell->window_state = event->new_window_state;
-
   if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
     {
+      GtkWidget       *window;
       GimpActionGroup *group;
       gboolean         fullscreen;
 
-      gimp_display_shell_appearance_update (shell);
+      window = gtk_widget_get_toplevel (widget);
 
-      fullscreen = gimp_display_shell_get_fullscreen (shell);
+      gimp_display_shell_appearance_update (shell);
 
-      GIMP_LOG (WM, "Display shell '%s' [%p] set fullscreen %s",
-                gtk_window_get_title (GTK_WINDOW (widget)),
-                widget,
-                fullscreen ? "TURE" : "FALSE");
+      fullscreen = gimp_image_window_get_fullscreen (GIMP_IMAGE_WINDOW (window));
 
       group = gimp_ui_manager_get_action_group (shell->menubar_manager, "view");
       gimp_action_group_set_action_active (group,
@@ -680,11 +675,6 @@ gimp_display_shell_window_state_event (GtkWidget           *widget,
       gboolean iconified = (event->new_window_state &
                             GDK_WINDOW_STATE_ICONIFIED) != 0;
 
-      GIMP_LOG (WM, "Display shell '%s' [%p] set %s",
-                gtk_window_get_title (GTK_WINDOW (widget)),
-                widget,
-                iconified ? "iconified" : "uniconified");
-
       if (iconified)
         {
           if (gimp_displays_get_num_visible (gimp) == 0)
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index ea79076..9c5b036 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -184,7 +184,6 @@ struct _GimpDisplayShell
   GimpTreeHandler   *vectors_thaw_handler;
   GimpTreeHandler   *vectors_visible_handler;
 
-  GdkWindowState     window_state;     /* for fullscreen display              */
   gboolean           zoom_on_resize;
   gboolean           show_transform_preview;
 
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 62a99ea..1b40dfe 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -24,6 +24,7 @@
 
 #include "display-types.h"
 
+#include "widgets/gimpactiongroup.h"
 #include "widgets/gimpmenufactory.h"
 #include "widgets/gimpuimanager.h"
 
@@ -186,6 +187,34 @@ gimp_image_window_window_state (GtkWidget           *widget,
 
   window->window_state = event->new_window_state;
 
+  if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
+    {
+      GimpActionGroup *group;
+      gboolean         fullscreen;
+
+      fullscreen = gimp_image_window_get_fullscreen (window);
+
+      GIMP_LOG (WM, "Image window '%s' [%p] set fullscreen %s",
+                gtk_window_get_title (GTK_WINDOW (widget)),
+                widget,
+                fullscreen ? "TURE" : "FALSE");
+
+      group = gimp_ui_manager_get_action_group (window->menubar_manager, "view");
+      gimp_action_group_set_action_active (group,
+                                           "view-fullscreen", fullscreen);
+    }
+
+  if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED)
+    {
+      gboolean iconified = (event->new_window_state &
+                            GDK_WINDOW_STATE_ICONIFIED) != 0;
+
+      GIMP_LOG (WM, "Image window '%s' [%p] set %s",
+                gtk_window_get_title (GTK_WINDOW (widget)),
+                widget,
+                iconified ? "iconified" : "uniconified");
+    }
+
   return FALSE;
 }
 
@@ -199,3 +228,26 @@ gimp_image_window_get_active_display (GimpImageWindow *window)
 
   return GIMP_DISPLAY_SHELL (window)->display;
 }
+
+void
+gimp_image_window_set_fullscreen (GimpImageWindow *window,
+                                  gboolean         fullscreen)
+{
+  g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
+
+  if (fullscreen != gimp_image_window_get_fullscreen (window))
+    {
+      if (fullscreen)
+        gtk_window_fullscreen (GTK_WINDOW (window));
+      else
+        gtk_window_unfullscreen (GTK_WINDOW (window));
+    }
+}
+
+gboolean
+gimp_image_window_get_fullscreen (GimpImageWindow *window)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE_WINDOW (window), FALSE);
+
+  return (window->window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
+}
diff --git a/app/display/gimpimagewindow.h b/app/display/gimpimagewindow.h
index d28c657..a5e46e9 100644
--- a/app/display/gimpimagewindow.h
+++ b/app/display/gimpimagewindow.h
@@ -51,6 +51,9 @@ GType         gimp_image_window_get_type           (void) G_GNUC_CONST;
 
 GimpDisplay * gimp_image_window_get_active_display (GimpImageWindow *window);
 
+void          gimp_image_window_set_fullscreen     (GimpImageWindow *window,
+                                                    gboolean         fullscreen);
+gboolean      gimp_image_window_get_fullscreen     (GimpImageWindow *window);
 
 
 #endif /* __GIMP_IMAGE_WINDOW_H__ */



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