Hi

In current GIMP the docking bars are always visible even though they are
only useful when rearranging the GIMP UI. I have attached a fairly
simple patch (you need latest trunk) that hides these by default and
only shows them when a dockable-drag is started. They are hidden again
when the dockable-drag is completed.

For better understanding, look at this before- and after-patch-applied
screenshot that shows a dock when GIMP has started:
http://www.chromecode.com/temp/gimp-on-demand-docking-2009-01-03.png

This is not a trivial UI change so I want to probe for comments on this
list before possibly applying. Any objections to me applying it? Any
suggestions for improvement?

- Martin

Index: app/widgets/gimpdock.c
===================================================================
--- app/widgets/gimpdock.c      (revision 27881)
+++ app/widgets/gimpdock.c      (working copy)
@@ -76,6 +76,9 @@ struct _GimpDockPriv
   GList             *dockbooks;
 
   gint               ID; /* for themeing */
+
+  GtkWidget         *north_separator;
+  GtkWidget         *south_separator;
 };
 
 
@@ -102,6 +105,8 @@ static void      gimp_dock_real_book_add
                                               GimpDockbook          *dockbook);
 static void      gimp_dock_real_book_removed (GimpDock              *dock,
                                               GimpDockbook          *dockbook);
+static void      gimp_dock_show_dockers      (GimpDock              *dock,
+                                              gboolean               show);
 
 
 G_DEFINE_TYPE (GimpDock, gimp_dock, GIMP_TYPE_WINDOW)
@@ -110,6 +115,8 @@ G_DEFINE_TYPE (GimpDock, gimp_dock, GIMP
 
 static guint dock_signals[LAST_SIGNAL] = { 0 };
 
+static GList *dock_instances = NULL;
+
 
 static void
 gimp_dock_class_init (GimpDockClass *klass)
@@ -185,7 +192,6 @@ static void
 gimp_dock_init (GimpDock *dock)
 {
   static gint  dock_ID = 1;
-  GtkWidget   *separator;
   gchar       *name;
 
   dock->priv = G_TYPE_INSTANCE_GET_PRIVATE (dock,
@@ -212,9 +218,8 @@ gimp_dock_init (GimpDock *dock)
   gtk_container_add (GTK_CONTAINER (dock->priv->main_vbox), dock->priv->vbox);
   gtk_widget_show (dock->priv->vbox);
 
-  separator = gimp_dock_separator_new (dock, GTK_ANCHOR_NORTH);
-  gtk_box_pack_start (GTK_BOX (dock->priv->vbox), separator, FALSE, FALSE, 0);
-  gtk_widget_show (separator);
+  dock->priv->north_separator = gimp_dock_separator_new (dock, 
GTK_ANCHOR_NORTH);
+  gtk_box_pack_start (GTK_BOX (dock->priv->vbox), dock->priv->north_separator, 
FALSE, FALSE, 0);
 }
 
 static GObject *
@@ -236,6 +241,8 @@ gimp_dock_constructor (GType            
   config = GIMP_GUI_CONFIG (dock->priv->context->gimp->config);
 
   gimp_window_set_hint (GTK_WINDOW (dock), config->dock_window_hint);
+  
+  dock_instances = g_list_prepend (dock_instances, dock);
 
   return object;
 }
@@ -293,6 +300,8 @@ gimp_dock_destroy (GtkObject *object)
 {
   GimpDock *dock = GIMP_DOCK (object);
 
+  dock_instances = g_list_remove (dock_instances, dock);
+
   while (dock->priv->dockbooks)
     gimp_dock_remove_book (dock, GIMP_DOCKBOOK (dock->priv->dockbooks->data));
 
@@ -401,6 +410,21 @@ gimp_dock_real_book_removed (GimpDock   
     gtk_widget_destroy (GTK_WIDGET (dock));
 }
 
+static void
+gimp_dock_show_dockers (GimpDock *dock,
+                        gboolean  show)
+{
+  if (dock->priv->north_separator)
+    g_object_set (dock->priv->north_separator,
+                  "visible", show,
+                  NULL);
+
+  if (dock->priv->south_separator)
+    g_object_set (dock->priv->south_separator,
+                  "visible", show,
+                  NULL);
+}
+
 
 /*  public functions  */
 
@@ -534,14 +558,11 @@ gimp_dock_add_book (GimpDock     *dock,
 
   if (old_length == 0)
     {
-      GtkWidget *separator;
-
       gtk_box_pack_start (GTK_BOX (dock->priv->vbox), GTK_WIDGET (dockbook),
                           TRUE, TRUE, 0);
 
-      separator = gimp_dock_separator_new (dock, GTK_ANCHOR_SOUTH);
-      gtk_box_pack_end (GTK_BOX (dock->priv->vbox), separator, FALSE, FALSE, 
0);
-      gtk_widget_show (separator);
+      dock->priv->south_separator = gimp_dock_separator_new (dock, 
GTK_ANCHOR_SOUTH);
+      gtk_box_pack_end (GTK_BOX (dock->priv->vbox), 
dock->priv->south_separator, FALSE,FALSE, 0);
     }
   else
     {
@@ -669,3 +690,19 @@ gimp_dock_remove_book (GimpDock     *doc
 
   g_object_unref (dockbook);
 }
+
+void
+gimp_dock_class_show_separators (GimpDockClass *klass,
+                                 gboolean       show)
+{
+  GList *list;
+
+  g_return_if_fail (GIMP_IS_DOCK_CLASS (klass));
+
+  for (list = dock_instances; list != NULL; list = list->next)
+    {
+      GimpDock *dock = GIMP_DOCK (list->data);
+
+      gimp_dock_show_dockers (dock, show);
+    }
+}
Index: app/widgets/gimpdock.h
===================================================================
--- app/widgets/gimpdock.h      (revision 27882)
+++ app/widgets/gimpdock.h      (working copy)
@@ -63,32 +63,36 @@ struct _GimpDockClass
 };
 
 
-GType               gimp_dock_get_type           (void) G_GNUC_CONST;
+GType               gimp_dock_get_type              (void) G_GNUC_CONST;
 
-void                gimp_dock_setup              (GimpDock       *dock,
-                                                  const GimpDock *template);
-void                gimp_dock_set_aux_info       (GimpDock       *dock,
-                                                  GList          *aux_info);
-GList             * gimp_dock_get_aux_info       (GimpDock       *dock);
-GimpContext       * gimp_dock_get_context        (GimpDock       *dock);
-GimpDialogFactory * gimp_dock_get_dialog_factory (GimpDock       *dock);
-GList             * gimp_dock_get_dockbooks      (GimpDock       *dock);
-GtkWidget         * gimp_dock_get_main_vbox      (GimpDock       *dock);
-GtkWidget         * gimp_dock_get_vbox           (GimpDock       *dock);
-gint                gimp_dock_get_id             (GimpDock       *dock);
-
-void                gimp_dock_add                (GimpDock       *dock,
-                                                  GimpDockable   *dockable,
-                                                  gint            book,
-                                                  gint            index);
-void                gimp_dock_remove             (GimpDock       *dock,
-                                                  GimpDockable   *dockable);
-
-void                gimp_dock_add_book           (GimpDock       *dock,
-                                                  GimpDockbook   *dockbook,
-                                                  gint            index);
-void                gimp_dock_remove_book        (GimpDock       *dock,
-                                                  GimpDockbook   *dockbook);
+void                gimp_dock_setup                 (GimpDock       *dock,
+                                                     const GimpDock *template);
+void                gimp_dock_set_aux_info          (GimpDock       *dock,
+                                                     GList          *aux_info);
+GList             * gimp_dock_get_aux_info          (GimpDock       *dock);
+GimpContext       * gimp_dock_get_context           (GimpDock       *dock);
+GimpDialogFactory * gimp_dock_get_dialog_factory    (GimpDock       *dock);
+GList             * gimp_dock_get_dockbooks         (GimpDock       *dock);
+GtkWidget         * gimp_dock_get_main_vbox         (GimpDock       *dock);
+GtkWidget         * gimp_dock_get_vbox              (GimpDock       *dock);
+gint                gimp_dock_get_id                (GimpDock       *dock);
+
+void                gimp_dock_add                   (GimpDock       *dock,
+                                                     GimpDockable   *dockable,
+                                                     gint            book,
+                                                     gint            index);
+void                gimp_dock_remove                (GimpDock       *dock,
+                                                     GimpDockable   *dockable);
+
+void                gimp_dock_add_book              (GimpDock       *dock,
+                                                     GimpDockbook   *dockbook,
+                                                     gint            index);
+void                gimp_dock_remove_book           (GimpDock       *dock,
+                                                     GimpDockbook   *dockbook);
+
+
+void                gimp_dock_class_show_separators (GimpDockClass  *klass,
+                                                     gboolean        show);
 
 
 #endif /* __GIMP_DOCK_H__ */
Index: app/widgets/gimpdockbook.c
===================================================================
--- app/widgets/gimpdockbook.c  (revision 27881)
+++ app/widgets/gimpdockbook.c  (working copy)
@@ -610,6 +610,7 @@ gimp_dockbook_tab_drag_begin (GtkWidget 
 {
   GtkWidget      *window;
   GtkWidget      *view;
+  GimpDockClass  *dock_class = GIMP_DOCK_GET_CLASS (dockable->dockbook->dock);
   GtkRequisition  requisition;
 
   window = gtk_window_new (GTK_WINDOW_POPUP);
@@ -639,6 +640,8 @@ gimp_dockbook_tab_drag_begin (GtkWidget 
    * it's the dockable that's being dragged around
    */
   gtk_widget_set_sensitive (GTK_WIDGET (dockable), FALSE);
+
+  gimp_dock_class_show_separators (dock_class, TRUE);
 }
 
 static void
@@ -646,7 +649,8 @@ gimp_dockbook_tab_drag_end (GtkWidget   
                             GdkDragContext *context,
                             GimpDockable   *dockable)
 {
-  GtkWidget *drag_widget = g_object_get_data (G_OBJECT (dockable),
+  GimpDockClass *dock_class  = GIMP_DOCK_GET_CLASS (dockable->dockbook->dock);
+  GtkWidget     *drag_widget = g_object_get_data (G_OBJECT (dockable),
                                               "gimp-dock-drag-widget");
 
   /*  finding the drag_widget means the drop was not successful, so
@@ -661,6 +665,8 @@ gimp_dockbook_tab_drag_end (GtkWidget   
   dockable->drag_x = GIMP_DOCKABLE_DRAG_OFFSET;
   dockable->drag_y = GIMP_DOCKABLE_DRAG_OFFSET;
   gtk_widget_set_sensitive (GTK_WIDGET (dockable), TRUE);
+
+  gimp_dock_class_show_separators (dock_class, FALSE);
 }
 
 
_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

Reply via email to