gimp r27374 - in trunk: . app/display app/widgets



Author: neo
Date: Thu Oct 23 08:39:46 2008
New Revision: 27374
URL: http://svn.gnome.org/viewvc/gimp?rev=27374&view=rev

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

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

	* app/display/gimpdisplay-foreach.[ch]: added utility function 
to
	get the number of visible (not withdrawn or iconified) displays.

	* app/widgets/gimpdialogfactory.[ch]: added functions to hide 
and
	show the dock windows. Changed gimp_dialog_factories_toggle() to
	use the new functions.

	* app/display/gimpdisplayshell.c
	(gimp_display_shell_window_state_event): hide the docks if the
	last display is iconified. Unhide them if a display is
	uniconified. Probably needs more work ...



Modified:
   trunk/ChangeLog
   trunk/app/display/gimpdisplay-foreach.c
   trunk/app/display/gimpdisplay-foreach.h
   trunk/app/display/gimpdisplayshell.c
   trunk/app/widgets/gimpdialogfactory.c
   trunk/app/widgets/gimpdialogfactory.h

Modified: trunk/app/display/gimpdisplay-foreach.c
==============================================================================
--- trunk/app/display/gimpdisplay-foreach.c	(original)
+++ trunk/app/display/gimpdisplay-foreach.c	Thu Oct 23 08:39:46 2008
@@ -228,6 +228,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: trunk/app/display/gimpdisplay-foreach.h
==============================================================================
--- trunk/app/display/gimpdisplay-foreach.h	(original)
+++ trunk/app/display/gimpdisplay-foreach.h	Thu Oct 23 08:39:46 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: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c	(original)
+++ trunk/app/display/gimpdisplayshell.c	Thu Oct 23 08:39:46 2008
@@ -60,6 +60,7 @@
 
 #include "gimpcanvas.h"
 #include "gimpdisplay.h"
+#include "gimpdisplay-foreach.h"
 #include "gimpdisplayoptions.h"
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-appearance.h"
@@ -616,12 +617,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;
 
@@ -645,6 +646,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 ();
+        }
+      else
+        {
+          gimp_dialog_factories_show ();
+        }
+
       gimp_display_shell_progress_window_state_changed (shell);
     }
 

Modified: trunk/app/widgets/gimpdialogfactory.c
==============================================================================
--- trunk/app/widgets/gimpdialogfactory.c	(original)
+++ trunk/app/widgets/gimpdialogfactory.c	Thu Oct 23 08:39:46 2008
@@ -1123,25 +1123,47 @@
 }
 
 void
-gimp_dialog_factories_toggle (void)
+gimp_dialog_factories_show (void)
 {
-  GimpDialogFactoryClass *factory_class;
+  if (! dialogs_shown)
+    {
+      GimpDialogFactoryClass *factory_class;
 
-  factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
+      factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
+
+      dialogs_shown = TRUE;
+      g_hash_table_foreach (factory_class->factories,
+                            (GHFunc) gimp_dialog_factories_show_foreach,
+                            NULL);
+    }
+}
 
+void
+gimp_dialog_factories_hide (void)
+{
   if (dialogs_shown)
     {
+      GimpDialogFactoryClass *factory_class;
+
+      factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
+
       dialogs_shown = FALSE;
       g_hash_table_foreach (factory_class->factories,
                             (GHFunc) gimp_dialog_factories_hide_foreach,
                             NULL);
     }
+}
+
+void
+gimp_dialog_factories_toggle (void)
+{
+  if (dialogs_shown)
+    {
+      gimp_dialog_factories_hide ();
+    }
   else
     {
-      dialogs_shown = TRUE;
-      g_hash_table_foreach (factory_class->factories,
-                            (GHFunc) gimp_dialog_factories_show_foreach,
-                            NULL);
+      gimp_dialog_factories_show ();
     }
 }
 

Modified: trunk/app/widgets/gimpdialogfactory.h
==============================================================================
--- trunk/app/widgets/gimpdialogfactory.h	(original)
+++ trunk/app/widgets/gimpdialogfactory.h	Thu Oct 23 08:39:46 2008
@@ -168,7 +168,10 @@
 void        gimp_dialog_factories_session_restore (void);
 void        gimp_dialog_factories_session_clear   (void);
 
+void        gimp_dialog_factories_show            (void);
+void        gimp_dialog_factories_hide            (void);
 void        gimp_dialog_factories_toggle          (void);
+
 void        gimp_dialog_factories_set_busy        (void);
 void        gimp_dialog_factories_unset_busy      (void);
 



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