[gtranslator] Change title depending on the opened file



commit abb07642ffb449facef3b67b392b96d7acdb93ac
Author: Daniel GarcĂ­a Moreno <danigm wadobo com>
Date:   Mon Sep 10 19:45:23 2018 +0200

    Change title depending on the opened file

 src/gtr-window.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 633277e2..130a176b 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -247,10 +247,14 @@ set_window_title (GtrWindow * window, gboolean with_path)
   GtrTab *active_tab;
   GFile *file;
   gchar *title;
+  gchar *subtitle;
+  GtrWindowPrivate *priv = gtr_window_get_instance_private(window);
+  GtkHeaderBar *header;
 
   if (with_path)
     {
       gchar *path;
+      gchar *basename;
 
       active_tab = gtr_window_get_active_tab (window);
       po = gtr_tab_get_po (active_tab);
@@ -258,22 +262,38 @@ set_window_title (GtrWindow * window, gboolean with_path)
       po = gtr_tab_get_po (active_tab);
       file = gtr_po_get_location (po);
       path = g_file_get_path (file);
+      basename = g_file_get_basename (file);
+      subtitle = path;
 
       if (state == GTR_PO_STATE_MODIFIED)
-        /* Translators: this is the title of the window with a modified document */
-        title = g_strdup_printf (_("*%s - gtranslator"), path);
+        {
+          /* Translators: this is the title of the window with a modified document */
+          title = g_strdup_printf (_("*%s - gtranslator"), basename);
+        }
       else
-        /* Translators: this is the title of the window with a document opened */
-        title = g_strdup_printf (_("%s - gtranslator"), path);
+        {
+          /* Translators: this is the title of the window with a document opened */
+          title = g_strdup_printf (_("%s - gtranslator"), basename);
+        }
 
-      g_free (path);
+      g_free (basename);
       g_object_unref (file);
     }
   else
-    title = g_strdup (_("gtranslator"));
+    {
+      title = g_strdup (_("gtranslator"));
+      subtitle = g_strdup (_(""));
+    }
 
   gtk_window_set_title (GTK_WINDOW (window), title);
+
+  // notebook headerbar
+  header = GTK_HEADER_BAR (gtr_notebook_get_header (GTR_NOTEBOOK (priv->notebook)));
+  gtk_header_bar_set_title (header, title);
+  gtk_header_bar_set_subtitle (header, subtitle);
+
   g_free (title);
+  g_free (subtitle);
 }
 
 static void


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