Commit e8e469c5 authored by Martin Nordholts's avatar Martin Nordholts

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 :(
parent 5334cc13
......@@ -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);
}
......@@ -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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment