[gtk+] Sync the window title initially



commit 5918a4dae845c6a766fdd220bf29dd6d1091b6a2
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 10 18:44:26 2013 -0500

    Sync the window title initially
    
    When setting a custom titlebar that happens to be a GtkHeaderBar,
    we connect to notify::title to pick up title changes on the headerbar,
    but we forgot to sync the title initially. Fix that.

 gtk/gtkwindow.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f1bc2f4..d949000 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3557,8 +3557,10 @@ on_titlebar_title_notify (GtkHeaderBar *titlebar,
                           GParamSpec   *pspec,
                           GtkWindow    *self)
 {
-  gtk_window_set_title_internal (self, gtk_header_bar_get_title (titlebar),
-                                 FALSE);
+  const gchar *title;
+
+  title = gtk_header_bar_get_title (titlebar);
+  gtk_window_set_title_internal (self, title, FALSE);
 }
 
 /**
@@ -3595,8 +3597,12 @@ gtk_window_set_titlebar (GtkWindow *window,
 
   priv->title_box = titlebar;
   gtk_widget_set_parent (priv->title_box, widget);
-  g_signal_connect (titlebar, "notify::title",
-                    G_CALLBACK (on_titlebar_title_notify), window);
+  if (GTK_IS_HEADER_BAR (titlebar))
+    {
+      g_signal_connect (titlebar, "notify::title",
+                        G_CALLBACK (on_titlebar_title_notify), window);
+      on_titlebar_title_notify (GTK_HEADER_BAR (titlebar), NULL, window);
+    }
 
   visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget));
   if (visual)


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