After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748989 - Using one command to open multiple tab, cannot set title
Using one command to open multiple tab, cannot set title
Status: RESOLVED DUPLICATE of bug 740188
Product: gnome-terminal
Classification: Core
Component: general
3.12.x
Other Linux
: Normal minor
: ---
Assigned To: GNOME Terminal Maintainers
GNOME Terminal Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-05-06 03:09 UTC by luozy
Modified: 2015-06-04 08:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description luozy 2015-05-06 03:09:43 UTC
Old version:
gnome-terminal --tab -t "project1" --tab -t "project2" --tab -t "project3" --tab -t "LAB1" --tab -t "LAB2" --tab -t "LAB3"

I can create six tab once, each tab has a proper tile. Using other option, such as "--working-directory".
I can open a developer environment with one command!!!!!!! it's very wonderful.

New version:
it ignores "--tabe".
Comment 1 luozy 2015-05-07 07:06:21 UTC
it ignores "--title" or "-t".

Actually, I don't want to change the title after running.
Comment 2 Christian Persch 2015-05-11 07:59:25 UTC

*** This bug has been marked as a duplicate of bug 740188 ***
Comment 3 luozy 2015-05-25 03:31:25 UTC
Today installed ubuntu 15.04, found that gnome-terminal versin 3.14.
Cannot set title by -t option or --title option.

So I added a user-defined title option in a private patch.
Feature:
(1) Using -T option to set a user-defined title, it never changes.
(2) it ignores the close button in the tab with user-defined title.
    you can close it with right click.

Usage:
Terminal options; if used before the first --window or --tab argument, sets the default for all terminals:
...
  --working-directory=DIRNAME     Set the working directory
  -T, --ud-title=UDTITLE          Set the user-defined title, never change! <<<<<<
...

Example:
gnome-terminal --tab -T "aaa" --tab -T "bbb" --tab -T "ccc"


the patch is generated with gnome-terminal 3.14.3.

(1) get source https://github.com/GNOME/gnome-terminal/archive/3.14.3.tar.gz
(2) cd src; patch < patch_file
(3)./autogen.sh --disable-search-provider;make;sudo make install

here is the patch:
diff -urp gnome-terminal-3.14.3.orig/src/terminal-app.c gnome-terminal-3.14.3/src/terminal-app.c
--- gnome-terminal-3.14.3.orig/src/terminal-app.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-app.c	2015-05-22 13:13:24.682045517 +0800
@@ -551,7 +551,7 @@ terminal_app_new_terminal (TerminalApp
   g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
   g_return_val_if_fail (TERMINAL_IS_WINDOW (window), NULL);
 
-  screen = terminal_screen_new (profile, override_command,
+  screen = terminal_screen_new (profile, override_command, NULL,
                                 working_dir, child_env, zoom);
 
   terminal_window_add_screen (window, screen, -1);
diff -urp gnome-terminal-3.14.3.orig/src/terminal.c gnome-terminal-3.14.3/src/terminal.c
--- gnome-terminal-3.14.3.orig/src/terminal.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal.c	2015-05-22 18:50:10.642017697 +0800
@@ -102,7 +102,7 @@ handle_options (TerminalFactory *factory
                                                           iw->geometry,
                                                           iw->role,
                                                           it->profile ? it->profile : options->default_profile,
-                                                          NULL /* title */,
+                                                          it->ud_title,
                                                           iw->start_maximized,
                                                           iw->start_fullscreen);
 
diff -urp gnome-terminal-3.14.3.orig/src/terminal-client-utils.c gnome-terminal-3.14.3/src/terminal-client-utils.c
--- gnome-terminal-3.14.3.orig/src/terminal-client-utils.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-client-utils.c	2015-05-22 19:37:59.622082033 +0800
@@ -69,6 +69,7 @@ terminal_client_append_create_instance_o
   if (profile)
     g_variant_builder_add (builder, "{sv}", 
                            "profile", g_variant_new_string (profile));
+  /* ud_title, otherwise NULL */
   if (title)
     g_variant_builder_add (builder, "{sv}", 
                            "title", g_variant_new_string (title));
diff -urp gnome-terminal-3.14.3.orig/src/terminal-gdbus.c gnome-terminal-3.14.3/src/terminal-gdbus.c
--- gnome-terminal-3.14.3.orig/src/terminal-gdbus.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-gdbus.c	2015-05-22 13:09:02.300335713 +0800
@@ -368,7 +368,7 @@ terminal_factory_impl_create_instance (T
   TerminalObjectSkeleton *skeleton;
   char *object_path;
   GSettings *profile = NULL;
-  const char *profile_uuid;
+  const char *profile_uuid, *ud_title;
   gboolean zoom_set = FALSE;
   gdouble zoom = 1.0;
   guint window_id;
@@ -456,10 +456,12 @@ terminal_factory_impl_create_instance (T
 
   g_assert (window != NULL);
 
+  if (!g_variant_lookup (options, "title", "&s", &ud_title))
+    ud_title = NULL;
   if (g_variant_lookup (options, "zoom", "d", &zoom))
     zoom_set = TRUE;
 
-  screen = terminal_screen_new (profile, NULL, NULL, NULL,
+  screen = terminal_screen_new (profile, NULL, ud_title, NULL, NULL,
                                 zoom_set ? zoom : 1.0);
   terminal_window_add_screen (window, screen, -1);
   terminal_window_switch_screen (window, screen);
diff -urp gnome-terminal-3.14.3.orig/src/terminal-options.c gnome-terminal-3.14.3/src/terminal-options.c
--- gnome-terminal-3.14.3.orig/src/terminal-options.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-options.c	2015-05-22 17:29:38.214961669 +0800
@@ -96,6 +96,7 @@ initial_tab_new (char *profile /* adopts
 
   it->profile = profile;
   it->exec_argv = NULL;
+  it->ud_title = NULL;
   it->working_dir = NULL;
   it->zoom = 1.0;
   it->zoom_set = FALSE;
@@ -109,6 +110,7 @@ initial_tab_free (InitialTab *it)
 {
   g_free (it->profile);
   g_strfreev (it->exec_argv);
+  g_free (it->ud_title);
   g_free (it->working_dir);
   g_slice_free (InitialTab, it);
 }
@@ -594,6 +596,28 @@ option_load_config_cb (const gchar *opti
 }
 
 static gboolean
+option_ud_title_callback (const gchar *option_name,
+                       const gchar *value,
+                       gpointer     data,
+                       GError     **error)
+{
+  TerminalOptions *options = data;
+  InitialTab *it = ensure_top_tab (options);
+
+  g_free (it->ud_title);
+  if (options->initial_windows)
+    {
+      it->ud_title = g_strdup (value);
+    }
+  else
+    {
+      it->ud_title = NULL;
+    }
+
+  return TRUE;
+}
+
+static gboolean
 option_working_directory_callback (const gchar *option_name,
                                    const gchar *value,
                                    gpointer     data,
@@ -1142,6 +1166,15 @@ get_goption_context (TerminalOptions *op
       N_("DIRNAME")
     },
     {
+      "ud-title",
+      'T',
+      0,
+      G_OPTION_ARG_CALLBACK,
+      option_ud_title_callback,
+      N_("Set the user-defined title, never change!"),
+      N_("UDTITLE")
+    },
+    {
       "zoom",
       0,
       0,
diff -urp gnome-terminal-3.14.3.orig/src/terminal-options.h gnome-terminal-3.14.3/src/terminal-options.h
--- gnome-terminal-3.14.3.orig/src/terminal-options.h	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-options.h	2015-05-22 11:59:47.628161886 +0800
@@ -94,6 +94,7 @@ typedef struct
   char *profile;
   gboolean profile_is_id;
   char **exec_argv;
+  char *ud_title;
   char *working_dir;
   double zoom;
   guint zoom_set : 1;
diff -urp gnome-terminal-3.14.3.orig/src/terminal-screen.c gnome-terminal-3.14.3/src/terminal-screen.c
--- gnome-terminal-3.14.3.orig/src/terminal-screen.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-screen.c	2015-05-22 18:52:15.098017433 +0800
@@ -77,6 +77,11 @@ struct _TerminalScreenPrivate
   GSettings *profile; /* never NULL */
   guint profile_changed_id;
   guint profile_forgotten_id;
+  /*
+   * User-Defined title
+   * --ud-tile, -T, the title never changes. --luozy.
+   */
+  char *ud_title;
   char *initial_working_directory;
   char **initial_env;
   char **override_command;
@@ -592,6 +597,7 @@ terminal_screen_finalize (GObject *objec
 
   terminal_screen_set_profile (screen, NULL);
 
+  g_free (priv->ud_title);
   g_free (priv->initial_working_directory);
   g_strfreev (priv->override_command);
   g_strfreev (priv->initial_env);
@@ -607,6 +613,7 @@ terminal_screen_finalize (GObject *objec
 TerminalScreen *
 terminal_screen_new (GSettings       *profile,
                      char           **override_command,
+		     const char      *ud_title,
                      const char      *working_dir,
                      char           **child_env,
                      double           zoom)
@@ -624,6 +631,14 @@ terminal_screen_new (GSettings       *pr
                          g_settings_get_int (profile, TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS_KEY),
                          g_settings_get_int (profile, TERMINAL_PROFILE_DEFAULT_SIZE_ROWS_KEY));
 
+  if (ud_title) {
+    priv->ud_title = g_strdup (ud_title);
+    g_object_notify (G_OBJECT (screen), "title");
+    g_object_notify (G_OBJECT (screen), "icon-title");
+    g_object_notify (G_OBJECT (screen), "icon-title-set");
+  } else {
+    priv->ud_title = NULL;
+  }
   priv->initial_working_directory = g_strdup (working_dir);
 
   if (override_command)
@@ -677,15 +692,30 @@ terminal_screen_exec (TerminalScreen *sc
   return terminal_screen_do_exec (screen, data, error);
 }
 
+const char *
+terminal_screen_get_ud_title(TerminalScreen *screen)
+{
+  if (screen && screen->priv)
+    return screen->priv->ud_title;
+  else
+    return NULL;
+}
+
 const char*
 terminal_screen_get_title (TerminalScreen *screen)
 {
+  if (screen && screen->priv && screen->priv->ud_title)
+    return screen->priv->ud_title;
+
   return vte_terminal_get_window_title (VTE_TERMINAL (screen));
 }
 
 const char*
 terminal_screen_get_icon_title (TerminalScreen *screen)
 {
+  if (screen && screen->priv && screen->priv->ud_title)
+    return screen->priv->ud_title;
+
   return vte_terminal_get_icon_title (VTE_TERMINAL (screen));
 }
 
diff -urp gnome-terminal-3.14.3.orig/src/terminal-screen.h gnome-terminal-3.14.3/src/terminal-screen.h
--- gnome-terminal-3.14.3.orig/src/terminal-screen.h	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-screen.h	2015-05-22 14:47:41.909576807 +0800
@@ -76,6 +76,7 @@ const char *terminal_screen_get_uuid (Te
 
 TerminalScreen *terminal_screen_new (GSettings       *profile,
                                      char           **override_command,
+				     const char      *ud_title,
                                      const char      *working_dir,
                                      char           **child_env,
                                      double           zoom);
@@ -100,6 +101,7 @@ void         terminal_screen_set_initial
                                                       char           **argv);
 char **      terminal_screen_get_initial_environment (TerminalScreen  *screen);
 
+const char * terminal_screen_get_ud_title(TerminalScreen *screen);
 const char* terminal_screen_get_title          (TerminalScreen *screen);
 const char* terminal_screen_get_icon_title     (TerminalScreen *screen);
 gboolean    terminal_screen_get_icon_title_set (TerminalScreen *screen);
diff -urp gnome-terminal-3.14.3.orig/src/terminal-tab-label.c gnome-terminal-3.14.3/src/terminal-tab-label.c
--- gnome-terminal-3.14.3.orig/src/terminal-tab-label.c	2015-03-24 02:55:31.000000000 +0800
+++ gnome-terminal-3.14.3/src/terminal-tab-label.c	2015-05-22 14:54:05.281568257 +0800
@@ -61,6 +61,11 @@ static void
 close_button_clicked_cb (GtkWidget *widget,
                          TerminalTabLabel *tab_label)
 {
+  /* with user-defined title, ingore close button */
+  if (tab_label && tab_label->priv
+    	&& terminal_screen_get_ud_title(tab_label->priv->screen)) {
+    return;
+  }
   g_signal_emit (tab_label, signals[CLOSE_BUTTON_CLICKED], 0);
 }
Comment 4 luozy 2015-06-04 08:26:11 UTC
For 3.16.2, one file is different:

diff -ur gnome-terminal-3.16.2.orig/src/terminal.c gnome-terminal-3.16.2/src/terminal.c
--- gnome-terminal-3.16.2.orig/src/terminal.c   2015-05-11 02:16:36.000000000 +0800
+++ gnome-terminal-3.16.2/src/terminal.c        2015-05-25 10:56:31.708290532 +0800
@@ -102,7 +102,7 @@
                                                           iw->geometry,
                                                           iw->role,
                                                           it->profile ? it->profile : options->default_profile,
-                                                          NULL /* title */,
+                                                          it->ud_title,
                                                           it->active,
                                                           iw->start_maximized,
                                                           iw->start_fullscreen);