[gimp] app: Check for API availability in gimp_statusbar_init()



commit ae3c3291b0c6cf5de56efd0726b68ec2d96e9d2c
Author: Martin Nordholts <martinn src gnome org>
Date:   Mon Nov 30 23:14:54 2009 +0100

    app: Check for API availability in gimp_statusbar_init()

 app/display/gimpstatusbar.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index 4e192b3..aeb637c 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -162,8 +162,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   GtkWidget     *hbox;
   GtkWidget     *image;
   GimpUnitStore *store;
-  GtkWidget     *message_area;
-  GtkWidget     *message_area_parent;
+  GtkWidget     *original_child;
+  GtkWidget     *original_child_parent;
 
   statusbar->shell          = NULL;
   statusbar->messages       = NULL;
@@ -181,13 +181,17 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   statusbar->progress_active      = FALSE;
   statusbar->progress_shown       = FALSE;
 
-  /* remove the message area and insert a hbox */
-  message_area = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
-  message_area_parent = gtk_widget_get_parent (message_area);
-  gtk_container_remove (GTK_CONTAINER (message_area_parent), g_object_ref (message_area));
+  /* remove the message area or label and insert a hbox */
+#if GTK_CHECK_VERSION (2, 19, 1)
+  original_child = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
+#else
+  original_child = GTK_STATUSBAR (statusbar)->label;
+#endif
+  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);
-  gtk_container_add (GTK_CONTAINER (message_area_parent), hbox);
+  gtk_container_add (GTK_CONTAINER (original_child_parent), hbox);
   gtk_widget_show (hbox);
 
   statusbar->cursor_label = gtk_label_new ("8888, 8888");
@@ -222,9 +226,9 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
                     G_CALLBACK (gimp_statusbar_scale_activated),
                     statusbar);
 
-  /*  put the message area back into our hbox  */
-  gtk_box_pack_start (GTK_BOX (hbox), message_area, TRUE, TRUE, 1);
-  g_object_unref (message_area);
+  /*  put the message area or label back into our hbox  */
+  gtk_box_pack_start (GTK_BOX (hbox), original_child, TRUE, TRUE, 1);
+  g_object_unref (original_child);
 
   g_signal_connect_after (GTK_STATUSBAR (statusbar)->label, "expose-event",
                           G_CALLBACK (gimp_statusbar_label_expose),



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