display: redo the code that does evil things to the statusbar's widgets

Actually use the hbox that is provided via gtk_statusbar_get_message_area()
since GTK+ 2.19.1 instead of always replacing it by our own.
This commit is contained in:
Michael Natterer
2010-02-11 19:24:08 +01:00
parent ba5e6d4ca2
commit f2f83109ec

View File

@ -160,10 +160,9 @@ static void
gimp_statusbar_init (GimpStatusbar *statusbar) gimp_statusbar_init (GimpStatusbar *statusbar)
{ {
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *label;
GtkWidget *image; GtkWidget *image;
GimpUnitStore *store; GimpUnitStore *store;
GtkWidget *original_child;
GtkWidget *original_child_parent;
statusbar->shell = NULL; statusbar->shell = NULL;
statusbar->messages = NULL; statusbar->messages = NULL;
@ -181,18 +180,27 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->progress_active = FALSE; statusbar->progress_active = FALSE;
statusbar->progress_shown = FALSE; statusbar->progress_shown = FALSE;
label = g_object_ref (GTK_STATUSBAR (statusbar)->label);
/* remove the message area or label and insert a hbox */ /* remove the message area or label and insert a hbox */
#if GTK_CHECK_VERSION (2, 19, 1) #if GTK_CHECK_VERSION (2, 19, 1)
original_child = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar)); {
hbox = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
gtk_box_set_spacing (GTK_BOX (hbox), 1);
gtk_container_remove (GTK_CONTAINER (hbox), label);
}
#else #else
original_child = GTK_STATUSBAR (statusbar)->label; {
#endif GtkWidget *label_parent;
original_child_parent = gtk_widget_get_parent (original_child);
gtk_container_remove (GTK_CONTAINER (original_child_parent), g_object_ref (original_child));
hbox = gtk_hbox_new (FALSE, 1); label_parent = gtk_widget_get_parent (label);
gtk_container_add (GTK_CONTAINER (original_child_parent), hbox); gtk_container_remove (GTK_CONTAINER (label_parent), label);
gtk_widget_show (hbox);
hbox = gtk_hbox_new (FALSE, 1);
gtk_container_add (GTK_CONTAINER (label_parent), hbox);
gtk_widget_show (hbox);
}
#endif
statusbar->cursor_label = gtk_label_new ("8888, 8888"); statusbar->cursor_label = gtk_label_new ("8888, 8888");
gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5); gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5);
@ -226,9 +234,10 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
G_CALLBACK (gimp_statusbar_scale_activated), G_CALLBACK (gimp_statusbar_scale_activated),
statusbar); statusbar);
/* put the message area or label back into our hbox */ /* put the message area or label back into the hbox */
gtk_box_pack_start (GTK_BOX (hbox), original_child, TRUE, TRUE, 1); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 1);
g_object_unref (original_child);
g_object_unref (label);
g_signal_connect_after (GTK_STATUSBAR (statusbar)->label, "expose-event", g_signal_connect_after (GTK_STATUSBAR (statusbar)->label, "expose-event",
G_CALLBACK (gimp_statusbar_label_expose), G_CALLBACK (gimp_statusbar_label_expose),