gimp r27386 - in branches/gimp-2-6/app: display widgets



Author: neo
Date: Fri Oct 24 07:23:52 2008
New Revision: 27386
URL: http://svn.gnome.org/viewvc/gimp?rev=27386&view=rev

Log:
2008-10-24  Sven Neumann  <sven gimp org>

        Bug 556896 â Dialogs don't get minimized with single image 
window

	* app/display/gimpdisplayshell.c
	* app/display/gimpdisplay-foreach.[ch]
	* app/widgets/gimpdialogfactory.[ch]: merged changes from trunk.
	Hide the toolbox and docks if the last display is iconified.
	Unhide them if a display is uniconified.



Modified:
   branches/gimp-2-6/app/display/gimpdisplay-foreach.c
   branches/gimp-2-6/app/display/gimpdisplay-foreach.h
   branches/gimp-2-6/app/display/gimpdisplayshell.c
   branches/gimp-2-6/app/widgets/gimpdialogfactory.c
   branches/gimp-2-6/app/widgets/gimpdialogfactory.h

Modified: branches/gimp-2-6/app/display/gimpdisplay-foreach.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplay-foreach.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplay-foreach.c	Fri Oct 24 07:23:52 2008
@@ -227,6 +227,35 @@
   g_list_free (contexts);
 }
 
+gint
+gimp_displays_get_num_visible (Gimp *gimp)
+{
+  GList *list;
+  gint   visible = 0;
+
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0);
+
+  for (list = GIMP_LIST (gimp->displays)->list;
+       list;
+       list = g_list_next (list))
+    {
+      GimpDisplay *display = list->data;
+
+      if (GTK_WIDGET_DRAWABLE (display->shell))
+        {
+          GdkWindowState state = gdk_window_get_state (display->shell->window);
+
+          if ((state & (GDK_WINDOW_STATE_WITHDRAWN |
+                        GDK_WINDOW_STATE_ICONIFIED)) == 0)
+            {
+              visible++;
+            }
+        }
+    }
+
+  return visible;
+}
+
 void
 gimp_displays_set_busy (Gimp *gimp)
 {

Modified: branches/gimp-2-6/app/display/gimpdisplay-foreach.h
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplay-foreach.h	(original)
+++ branches/gimp-2-6/app/display/gimpdisplay-foreach.h	Fri Oct 24 07:23:52 2008
@@ -28,6 +28,8 @@
                                                 GimpImage *old,
                                                 GimpImage *new);
 
+gint            gimp_displays_get_num_visible  (Gimp      *gimp);
+
 void            gimp_displays_set_busy         (Gimp      *gimp);
 void            gimp_displays_unset_busy       (Gimp      *gimp);
 

Modified: branches/gimp-2-6/app/display/gimpdisplayshell.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell.c	Fri Oct 24 07:23:52 2008
@@ -59,6 +59,7 @@
 
 #include "gimpcanvas.h"
 #include "gimpdisplay.h"
+#include "gimpdisplay-foreach.h"
 #include "gimpdisplayoptions.h"
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-appearance.h"
@@ -615,12 +616,12 @@
                                        GdkEventWindowState *event)
 {
   GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
+  Gimp             *gimp  = shell->display->gimp;
 
   shell->window_state = event->new_window_state;
 
   if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
     {
-      Gimp            *gimp = shell->display->gimp;
       GimpActionGroup *group;
       gboolean         fullscreen;
 
@@ -644,6 +645,19 @@
 
   if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED)
     {
+      gboolean iconified = (event->new_window_state &
+                            GDK_WINDOW_STATE_ICONIFIED) != 0;
+
+      if (iconified)
+        {
+          if (gimp_displays_get_num_visible (gimp) == 0)
+            gimp_dialog_factories_hide_with_display ();
+        }
+      else
+        {
+          gimp_dialog_factories_show_with_display ();
+        }
+
       gimp_display_shell_progress_window_state_changed (shell);
     }
 

Modified: branches/gimp-2-6/app/widgets/gimpdialogfactory.c
==============================================================================
--- branches/gimp-2-6/app/widgets/gimpdialogfactory.c	(original)
+++ branches/gimp-2-6/app/widgets/gimpdialogfactory.c	Fri Oct 24 07:23:52 2008
@@ -45,6 +45,13 @@
 #include "gimp-log.h"
 
 
+typedef enum
+{
+  GIMP_DIALOGS_SHOWN,
+  GIMP_DIALOGS_HIDDEN_EXPLICITLY,  /* user used the Tab key to hide dialogs */
+  GIMP_DIALOGS_HIDDEN_WITH_DISPLAY /* dialogs are hidden with the display   */
+} GimpDialogsState;
+
 enum
 {
   DOCK_ADDED,
@@ -103,7 +110,7 @@
 
 static guint factory_signals[LAST_SIGNAL] = { 0 };
 
-static gboolean dialogs_shown = TRUE;  /* FIXME */
+static GimpDialogsState dialogs_state = GIMP_DIALOGS_SHOWN;
 
 
 static void
@@ -1079,7 +1086,7 @@
 
   gtk_widget_hide (dialog);
 
-  if (! dialogs_shown)
+  if (dialogs_state != GIMP_DIALOGS_SHOWN)
     g_object_set_data (G_OBJECT (dialog), GIMP_DIALOG_VISIBILITY_KEY,
                        GINT_TO_POINTER (GIMP_DIALOG_VISIBILITY_INVISIBLE));
 }
@@ -1122,30 +1129,61 @@
                         NULL);
 }
 
-void
-gimp_dialog_factories_toggle (void)
+static void
+gimp_dialog_factories_set_state (GimpDialogsState state)
 {
   GimpDialogFactoryClass *factory_class;
 
   factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
 
-  if (dialogs_shown)
+  dialogs_state = state;
+
+  if (state == GIMP_DIALOGS_SHOWN)
     {
-      dialogs_shown = FALSE;
       g_hash_table_foreach (factory_class->factories,
-                            (GHFunc) gimp_dialog_factories_hide_foreach,
+                            (GHFunc) gimp_dialog_factories_show_foreach,
                             NULL);
     }
   else
     {
-      dialogs_shown = TRUE;
       g_hash_table_foreach (factory_class->factories,
-                            (GHFunc) gimp_dialog_factories_show_foreach,
+                            (GHFunc) gimp_dialog_factories_hide_foreach,
                             NULL);
     }
 }
 
 void
+gimp_dialog_factories_show_with_display (void)
+{
+  if (dialogs_state == GIMP_DIALOGS_HIDDEN_WITH_DISPLAY)
+    {
+      gimp_dialog_factories_set_state (GIMP_DIALOGS_SHOWN);
+    }
+}
+
+void
+gimp_dialog_factories_hide_with_display (void)
+{
+  if (dialogs_state == GIMP_DIALOGS_SHOWN)
+    {
+      gimp_dialog_factories_set_state (GIMP_DIALOGS_HIDDEN_WITH_DISPLAY);
+    }
+}
+
+void
+gimp_dialog_factories_toggle (void)
+{
+  if (dialogs_state == GIMP_DIALOGS_SHOWN)
+    {
+      gimp_dialog_factories_set_state (GIMP_DIALOGS_HIDDEN_EXPLICITLY);
+    }
+  else
+    {
+      gimp_dialog_factories_set_state (GIMP_DIALOGS_SHOWN);
+    }
+}
+
+void
 gimp_dialog_factories_set_busy (void)
 {
   GimpDialogFactoryClass *factory_class;

Modified: branches/gimp-2-6/app/widgets/gimpdialogfactory.h
==============================================================================
--- branches/gimp-2-6/app/widgets/gimpdialogfactory.h	(original)
+++ branches/gimp-2-6/app/widgets/gimpdialogfactory.h	Fri Oct 24 07:23:52 2008
@@ -103,74 +103,77 @@
 };
 
 
-GType               gimp_dialog_factory_get_type  (void) G_GNUC_CONST;
+GType               gimp_dialog_factory_get_type    (void) G_GNUC_CONST;
 
-GimpDialogFactory * gimp_dialog_factory_new       (const gchar       *name,
-                                                   GimpContext       *context,
-                                                   GimpMenuFactory   *menu_factory,
-                                                   GimpDialogNewFunc  new_dock_func,
-                                                   gboolean           toggle_visibility);
-
-GimpDialogFactory * gimp_dialog_factory_from_name (const gchar       *name);
-
-void        gimp_dialog_factory_set_constructor   (GimpDialogFactory *factory,
-                                                   GimpDialogConstructor constructor);
-
-void        gimp_dialog_factory_register_entry    (GimpDialogFactory *factory,
-                                                   const gchar       *identifier,
-                                                   const gchar       *name,
-                                                   const gchar       *blurb,
-                                                   const gchar       *stock_id,
-                                                   const gchar       *help_id,
-                                                   GimpDialogNewFunc  new_func,
-                                                   gint               view_size,
-                                                   gboolean           singleton,
-                                                   gboolean           session_managed,
-                                                   gboolean           remember_size,
-                                                   gboolean           remember_if_open);
+GimpDialogFactory * gimp_dialog_factory_new         (const gchar       *name,
+                                                     GimpContext       *context,
+                                                     GimpMenuFactory   *menu_factory,
+                                                     GimpDialogNewFunc  new_dock_func,
+                                                     gboolean           toggle_visibility);
+
+GimpDialogFactory * gimp_dialog_factory_from_name   (const gchar       *name);
+
+void        gimp_dialog_factory_set_constructor     (GimpDialogFactory *factory,
+                                                     GimpDialogConstructor constructor);
+
+void        gimp_dialog_factory_register_entry      (GimpDialogFactory *factory,
+                                                     const gchar       *identifier,
+                                                     const gchar       *name,
+                                                     const gchar       *blurb,
+                                                     const gchar       *stock_id,
+                                                     const gchar       *help_id,
+                                                     GimpDialogNewFunc  new_func,
+                                                     gint               view_size,
+                                                     gboolean           singleton,
+                                                     gboolean           session_managed,
+                                                     gboolean           remember_size,
+                                                     gboolean           remember_if_open);
 GimpDialogFactoryEntry * gimp_dialog_factory_find_entry
-                                                  (GimpDialogFactory *factory,
-                                                   const gchar       *identifier);
+                                                    (GimpDialogFactory *factory,
+                                                     const gchar       *identifier);
 
 GimpSessionInfo * gimp_dialog_factory_find_session_info
-                                                  (GimpDialogFactory *factory,
-                                                   const gchar       *identifier);
+                                                    (GimpDialogFactory *factory,
+                                                     const gchar       *identifier);
 
-GtkWidget * gimp_dialog_factory_dialog_new        (GimpDialogFactory *factory,
-                                                   GdkScreen         *screen,
-                                                   const gchar       *identifier,
-                                                   gint               view_size,
-                                                   gboolean           present);
-GtkWidget * gimp_dialog_factory_dialog_raise      (GimpDialogFactory *factory,
-                                                   GdkScreen         *screen,
-                                                   const gchar       *identifiers,
-                                                   gint               view_size);
-GtkWidget * gimp_dialog_factory_dockable_new      (GimpDialogFactory *factory,
-                                                   GimpDock          *dock,
-                                                   const gchar       *identifier,
-                                                   gint               view_size);
-GtkWidget * gimp_dialog_factory_dock_new          (GimpDialogFactory *factory,
-                                                   GdkScreen         *screen);
-
-void        gimp_dialog_factory_add_dialog        (GimpDialogFactory *factory,
-                                                   GtkWidget         *dialog);
-void        gimp_dialog_factory_add_foreign       (GimpDialogFactory *factory,
-                                                   const gchar       *identifier,
-                                                   GtkWidget         *dialog);
-void        gimp_dialog_factory_remove_dialog     (GimpDialogFactory *factory,
-                                                   GtkWidget         *dialog);
-
-void        gimp_dialog_factory_show_toolbox      (GimpDialogFactory *toolbox_factory);
-
-void        gimp_dialog_factory_hide_dialog       (GtkWidget         *dialog);
-
-void        gimp_dialog_factories_session_save    (GimpConfigWriter  *writer);
-void        gimp_dialog_factories_session_restore (void);
-void        gimp_dialog_factories_session_clear   (void);
-
-void        gimp_dialog_factories_toggle          (void);
-void        gimp_dialog_factories_set_busy        (void);
-void        gimp_dialog_factories_unset_busy      (void);
+GtkWidget * gimp_dialog_factory_dialog_new          (GimpDialogFactory *factory,
+                                                     GdkScreen         *screen,
+                                                     const gchar       *identifier,
+                                                     gint               view_size,
+                                                     gboolean           present);
+GtkWidget * gimp_dialog_factory_dialog_raise        (GimpDialogFactory *factory,
+                                                     GdkScreen         *screen,
+                                                     const gchar       *identifiers,
+                                                     gint               view_size);
+GtkWidget * gimp_dialog_factory_dockable_new        (GimpDialogFactory *factory,
+                                                     GimpDock          *dock,
+                                                     const gchar       *identifier,
+                                                     gint               view_size);
+GtkWidget * gimp_dialog_factory_dock_new            (GimpDialogFactory *factory,
+                                                     GdkScreen         *screen);
+
+void        gimp_dialog_factory_add_dialog          (GimpDialogFactory *factory,
+                                                     GtkWidget         *dialog);
+void        gimp_dialog_factory_add_foreign         (GimpDialogFactory *factory,
+                                                     const gchar       *identifier,
+                                                     GtkWidget         *dialog);
+void        gimp_dialog_factory_remove_dialog       (GimpDialogFactory *factory,
+                                                     GtkWidget         *dialog);
+
+void        gimp_dialog_factory_show_toolbox        (GimpDialogFactory *toolbox_factory);
+
+void        gimp_dialog_factory_hide_dialog         (GtkWidget         *dialog);
+
+void        gimp_dialog_factories_session_save      (GimpConfigWriter  *writer);
+void        gimp_dialog_factories_session_restore   (void);
+void        gimp_dialog_factories_session_clear     (void);
+
+void        gimp_dialog_factories_show_with_display (void);
+void        gimp_dialog_factories_hide_with_display (void);
+void        gimp_dialog_factories_toggle            (void);
+
+void        gimp_dialog_factories_set_busy          (void);
+void        gimp_dialog_factories_unset_busy        (void);
 
 GimpDialogFactory *
             gimp_dialog_factory_from_widget (GtkWidget               *dialog,



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