[gnome-text-editor] window: update window title with visible page



commit 37a602f661b25a41fac6f4482bdc42387d922559
Author: Christian Hergert <chergert redhat com>
Date:   Fri Nov 19 17:31:12 2021 -0800

    window: update window title with visible page
    
    Fixes #226

 src/editor-window.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/src/editor-window.c b/src/editor-window.c
index ebd088a..c92fe45 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -555,6 +555,24 @@ notify_focus_widget_cb (EditorWindow *self)
     }
 }
 
+static gboolean
+transform_window_title (GBinding     *binding,
+                        const GValue *from,
+                        GValue       *to,
+                        gpointer      user_data)
+{
+  g_autoptr(EditorPage) page = EDITOR_PAGE (g_binding_dup_source (binding));
+  g_autofree char *title = editor_page_dup_title (page);
+  g_autofree char *subtitle = editor_page_dup_subtitle (page);
+
+  g_value_take_string (to,
+                       /* translators: the first %s is replaced with the title, the second %s is replaced 
with the subtitle */
+                       g_strdup_printf (_("%s (%s) - Text Editor"),
+                                        title, subtitle));
+
+  return TRUE;
+}
+
 static void
 editor_window_dispose (GObject *object)
 {
@@ -784,6 +802,10 @@ editor_window_init (EditorWindow *self)
 
   self->page_bindings = editor_binding_group_new ();
 
+  editor_binding_group_bind_full (self->page_bindings, "title",
+                                  self, "title",
+                                  G_BINDING_SYNC_CREATE,
+                                  transform_window_title, NULL, NULL, NULL);
   editor_binding_group_bind (self->page_bindings, "title",
                              self->title, "label",
                              G_BINDING_SYNC_CREATE);


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