[vte] app: Add option to set initial title



commit 64b333b11b840d2fad6643516d5b0116ef82dba4
Author: Christian Persch <chpe src gnome org>
Date:   Fri Oct 8 19:24:57 2021 +0200

    app: Add option to set initial title
    
    Based on a patch by Zach DeCook.
    
    Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2517

 src/app/app.cc | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/src/app/app.cc b/src/app/app.cc
index 620410c4..1767f919 100644
--- a/src/app/app.cc
+++ b/src/app/app.cc
@@ -97,6 +97,7 @@ public:
         char* font_string{nullptr};
         char* geometry{nullptr};
         char* output_filename{nullptr};
+        char* title{nullptr};
         char* word_char_exceptions{nullptr};
         char* working_directory{nullptr};
         char** dingus{nullptr};
@@ -650,6 +651,7 @@ public:
                           "Specify the number of scrollback-lines (-1 for infinite)", nullptr },
                         { "sixel", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &no_sixel,
                           "Enable SIXEL images", nullptr },
+                        { "title", 0, 0, G_OPTION_ARG_STRING, &title, "Set the initial title of the window", 
"TITLE" },
                         { "transparent", 'T', 0, G_OPTION_ARG_INT, &transparency_percent,
                           "Enable the use of a transparent background", "0..100" },
                         { "track-clipboard-targets", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, 
&track_clipboard_targets,
@@ -2234,12 +2236,7 @@ window_window_title_changed_cb(VteTerminal* terminal,
                                VteappWindow* window)
 {
         auto const title = vte_terminal_get_window_title(window->terminal);
-#if VTE_GTK == 3
-        gtk_window_set_title(GTK_WINDOW(window), title);
-#elif VTE_GTK == 4
-        auto toplevel = GDK_TOPLEVEL(gtk_native_get_surface(GTK_NATIVE(window)));
-        gdk_toplevel_set_title(toplevel, title);
-#endif
+        gtk_window_set_title(GTK_WINDOW(window), title && title[0] ? title : "Terminal");
 }
 
 static void
@@ -2415,7 +2412,8 @@ vteapp_window_constructed(GObject *object)
 
         G_OBJECT_CLASS(vteapp_window_parent_class)->constructed(object);
 
-        gtk_window_set_title(GTK_WINDOW(window), "Terminal");
+        gtk_window_set_title(GTK_WINDOW(window),
+                             options.title && options.title[0] ? options.title : "Terminal");
 
         if (options.no_decorations)
                 gtk_window_set_decorated(GTK_WINDOW(window), false);


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