app: Only show dock separators when rearranging the UI

For now, only show dock separators when they are needed, not all the
time. We need a better solution eventually, but at least docks in the
image window doesn't look terrible any longer.
This commit is contained in:
Martin Nordholts 2009-10-04 12:58:30 +02:00
parent 8fd011e75e
commit 3b721864d7
3 changed files with 104 additions and 53 deletions

View File

@ -68,6 +68,9 @@ struct _GimpDockPrivate
GtkWidget *vbox;
GList *dockbooks;
GtkWidget *north_separator;
GtkWidget *south_separator;
};
@ -79,6 +82,7 @@ static void gimp_dock_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_dock_finalize (GObject *object);
static void gimp_dock_destroy (GtkObject *object);
@ -86,6 +90,8 @@ static void gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_show_separators (GimpDock *dock,
gboolean show);
G_DEFINE_TYPE (GimpDock, gimp_dock, GTK_TYPE_VBOX)
@ -94,6 +100,9 @@ G_DEFINE_TYPE (GimpDock, gimp_dock, GTK_TYPE_VBOX)
static guint dock_signals[LAST_SIGNAL] = { 0 };
/* Keep the list of instance for gimp_dock_class_show_separators() */
static GList *dock_instances = NULL;
static void
gimp_dock_class_init (GimpDockClass *klass)
@ -141,6 +150,7 @@ gimp_dock_class_init (GimpDockClass *klass)
object_class->set_property = gimp_dock_set_property;
object_class->get_property = gimp_dock_get_property;
object_class->finalize = gimp_dock_finalize;
gtk_object_class->destroy = gimp_dock_destroy;
@ -177,8 +187,6 @@ gimp_dock_class_init (GimpDockClass *klass)
static void
gimp_dock_init (GimpDock *dock)
{
GtkWidget *separator;
dock->p = G_TYPE_INSTANCE_GET_PRIVATE (dock,
GIMP_TYPE_DOCK,
GimpDockPrivate);
@ -194,9 +202,10 @@ gimp_dock_init (GimpDock *dock)
gtk_container_add (GTK_CONTAINER (dock->p->main_vbox), dock->p->vbox);
gtk_widget_show (dock->p->vbox);
separator = gimp_dock_separator_new (dock, GTK_ANCHOR_NORTH);
gtk_box_pack_start (GTK_BOX (dock->p->vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
dock->p->north_separator = gimp_dock_separator_new (dock, GTK_ANCHOR_NORTH);
gtk_box_pack_start (GTK_BOX (dock->p->vbox), dock->p->north_separator, FALSE, FALSE, 0);
dock_instances = g_list_prepend (dock_instances, dock);
}
static void
@ -255,6 +264,12 @@ gimp_dock_get_property (GObject *object,
}
}
static void
gimp_dock_finalize (GObject *object)
{
dock_instances = g_list_remove (dock_instances, object);
}
static void
gimp_dock_destroy (GtkObject *object)
{
@ -290,6 +305,20 @@ gimp_dock_real_book_removed (GimpDock *dock,
{
}
static void
gimp_dock_show_separators (GimpDock *dock,
gboolean show)
{
if (dock->p->north_separator)
g_object_set (dock->p->north_separator,
"visible", show,
NULL);
if (dock->p->south_separator)
g_object_set (dock->p->south_separator,
"visible", show,
NULL);
}
/* public functions */
@ -491,14 +520,11 @@ gimp_dock_add_book (GimpDock *dock,
if (old_length == 0)
{
GtkWidget *separator;
gtk_box_pack_start (GTK_BOX (dock->p->vbox), GTK_WIDGET (dockbook),
TRUE, TRUE, 0);
separator = gimp_dock_separator_new (dock, GTK_ANCHOR_SOUTH);
gtk_box_pack_end (GTK_BOX (dock->p->vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
dock->p->south_separator = gimp_dock_separator_new (dock, GTK_ANCHOR_SOUTH);
gtk_box_pack_end (GTK_BOX (dock->p->vbox), dock->p->south_separator, FALSE, FALSE, 0);
}
else
{
@ -581,17 +607,9 @@ gimp_dock_remove_book (GimpDock *dock,
if (old_length == 1)
{
GtkWidget *separator;
GList *children;
children = gtk_container_get_children (GTK_CONTAINER (dock->p->vbox));
separator = g_list_nth_data (children, 2);
gtk_container_remove (GTK_CONTAINER (dock->p->vbox), separator);
gtk_container_remove (GTK_CONTAINER (dock->p->vbox), dock->p->south_separator);
gtk_container_remove (GTK_CONTAINER (dock->p->vbox), GTK_WIDGET (dockbook));
g_list_free (children);
dock->p->south_separator = NULL;
}
else
{
@ -626,3 +644,27 @@ gimp_dock_remove_book (GimpDock *dock,
g_object_unref (dockbook);
}
/**
* gimp_dock_class_show_separators:
* @klass:
* @show:
*
* Show/hide the separators in all docks.
**/
void
gimp_dock_class_show_separators (GimpDockClass *klass,
gboolean show)
{
GList *list;
/* Conceptually this is a class varaible */
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_separators (dock, show);
}
}

View File

@ -67,40 +67,43 @@ 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);
gchar * gimp_dock_get_title (GimpDock *dock);
void gimp_dock_invalidate_title (GimpDock *dock);
void gimp_dock_set_host_geometry_hints
(GimpDock *dock,
GtkWindow *window);
void gimp_dock_invalidate_geometry(GimpDock *dock);
GimpContext * gimp_dock_get_context (GimpDock *dock);
GimpDialogFactory * gimp_dock_get_dialog_factory (GimpDock *dock);
GimpUIManager * gimp_dock_get_ui_manager (GimpDock *dock);
GList * gimp_dock_get_dockbooks (GimpDock *dock);
gint gimp_dock_get_n_dockables (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_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);
gchar * gimp_dock_get_title (GimpDock *dock);
void gimp_dock_invalidate_title (GimpDock *dock);
void gimp_dock_set_host_geometry_hints (GimpDock *dock,
GtkWindow *window);
void gimp_dock_invalidate_geometry (GimpDock *dock);
GimpContext * gimp_dock_get_context (GimpDock *dock);
GimpDialogFactory * gimp_dock_get_dialog_factory (GimpDock *dock);
GimpUIManager * gimp_dock_get_ui_manager (GimpDock *dock);
GList * gimp_dock_get_dockbooks (GimpDock *dock);
gint gimp_dock_get_n_dockables (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 (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_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__ */

View File

@ -649,6 +649,7 @@ gimp_dockbook_tab_drag_begin (GtkWidget *widget,
GdkDragContext *context,
GimpDockable *dockable)
{
GimpDockClass *dock_class = GIMP_DOCK_GET_CLASS (dockable->dockbook->p->dock);
GtkWidget *window;
GtkWidget *view;
GtkRequisition requisition;
@ -680,6 +681,8 @@ gimp_dockbook_tab_drag_begin (GtkWidget *widget,
* 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
@ -687,8 +690,9 @@ gimp_dockbook_tab_drag_end (GtkWidget *widget,
GdkDragContext *context,
GimpDockable *dockable)
{
GtkWidget *drag_widget = g_object_get_data (G_OBJECT (dockable),
"gimp-dock-drag-widget");
GimpDockClass *dock_class = GIMP_DOCK_GET_CLASS (dockable->dockbook->p->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
* pop up a new dock and move the dockable there
@ -702,6 +706,8 @@ gimp_dockbook_tab_drag_end (GtkWidget *widget,
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);
}