[gimp] app: Add gimp_dock_temp_add/remove()



commit e8e469c53c52371276e59271d43e79085f350cd8
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun May 30 15:39:36 2010 +0200

    app: Add gimp_dock_temp_add/remove()
    
    In order to get accurate measurements of widgets that will be put in a
    GimpDock, add gimp_dock_temp_add() and gimp_dock_temp_remove(). That
    way we can add a widget temporarliy, measure it with the
    GimpDock::font-scale property applied, then remove it when we're
    done. We can't apply style properties on widget detached from a
    GdkScreen hierarchy :(

 app/widgets/gimpdock.c |   41 +++++++++++++++++++++++++++++++++++++++++
 app/widgets/gimpdock.h |    4 ++++
 2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index 26f940c..1226f90 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -60,6 +60,7 @@ enum
 
 struct _GimpDockPrivate
 {
+  GtkWidget         *temp_vbox;
   GtkWidget         *main_vbox;
   GtkWidget         *paned_vbox;
 
@@ -173,6 +174,10 @@ gimp_dock_init (GimpDock *dock)
   gtk_widget_set_name (GTK_WIDGET (dock), name);
   g_free (name);
 
+  dock->p->temp_vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (dock), dock->p->temp_vbox);
+  /* Never show it */
+  
   dock->p->main_vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (dock), dock->p->main_vbox);
   gtk_widget_show (dock->p->main_vbox);
@@ -700,3 +705,39 @@ gimp_dock_remove_book (GimpDock     *dock,
 
   g_object_unref (dockbook);
 }
+
+/**
+ * gimp_dock_temp_add:
+ * @dock:
+ * @widget:
+ *
+ * Method to temporarily add a widget to the dock, for example to make
+ * font-scale style property to be applied temporarily to the
+ * child.
+ **/
+void
+gimp_dock_temp_add (GimpDock  *dock,
+                    GtkWidget *child)
+{
+  g_return_if_fail (GIMP_IS_DOCK (dock));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+
+  gtk_container_add (GTK_CONTAINER (dock->p->temp_vbox), child);
+}
+
+/**
+ * gimp_dock_temp_remove:
+ * @dock:
+ * @child:
+ *
+ * Removes a temporarly child added with gimp_dock_temp_add().
+ **/
+void
+gimp_dock_temp_remove (GimpDock  *dock,
+                       GtkWidget *child)
+{
+  g_return_if_fail (GIMP_IS_DOCK (dock));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+
+  gtk_container_remove (GTK_CONTAINER (dock->p->temp_vbox), child);
+}
diff --git a/app/widgets/gimpdock.h b/app/widgets/gimpdock.h
index 00e1ddc..315e2e8 100644
--- a/app/widgets/gimpdock.h
+++ b/app/widgets/gimpdock.h
@@ -109,6 +109,10 @@ void                gimp_dock_add_book                (GimpDock       *dock,
                                                        gint            index);
 void                gimp_dock_remove_book             (GimpDock       *dock,
                                                        GimpDockbook   *dockbook);
+void                gimp_dock_temp_add                (GimpDock       *dock,
+                                                       GtkWidget      *widget);
+void                gimp_dock_temp_remove             (GimpDock       *dock,
+                                                       GtkWidget      *widget);
 
 
 #endif /* __GIMP_DOCK_H__ */



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