[Xfce4-commits] [apps/xfce4-terminal] 01/01: Add command line option --active-tab

noreply at xfce.org noreply at xfce.org
Mon Apr 2 02:06:43 CEST 2018


This is an automated email from the git hooks/post-receive script.

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-terminal.

commit 2d791be68e9e6dd1a2b63b4543e55d4532ae7f46
Author: Igor <f2404 at yandex.ru>
Date:   Sun Apr 1 20:05:27 2018 -0400

    Add command line option --active-tab
    
    The option allows to specify active tab within a window.
    It also allows to keep the active tab when restoring an Xfce session.
---
 terminal/main.c             |  3 ++-
 terminal/terminal-app.c     | 19 +++++++++++++++----
 terminal/terminal-options.c |  4 ++++
 terminal/terminal-options.h |  1 +
 terminal/terminal-window.c  |  3 +++
 5 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/terminal/main.c b/terminal/main.c
index 9b8c3b2..d553a42 100644
--- a/terminal/main.c
+++ b/terminal/main.c
@@ -119,7 +119,8 @@ usage (void)
   g_print ("%s:\n"
            "  -x, --execute; -e, --command=%s; -T, --title=%s;\n"
            "  --dynamic-title-mode=%s ('replace', 'before', 'after', 'none');\n"
-           "  --initial-title=%s; --working-directory=%s; -H, --hold\n\n",
+           "  --initial-title=%s; --working-directory=%s; -H, --hold;\n"
+           "  --active-tab\n\n",
            _("Tab Options"),
            /* parameter of --command */
            _("command"),
diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c
index 00fa893..945deda 100644
--- a/terminal/terminal-app.c
+++ b/terminal/terminal-app.c
@@ -684,6 +684,7 @@ terminal_app_open_window (TerminalApp        *app,
   gboolean         reuse_window = FALSE;
   GdkDisplay      *attr_display;
   gint             attr_screen_num;
+  gint             active_tab = -1, i;
 #ifdef GDK_WINDOWING_X11
   GdkGravity       gravity = GDK_GRAVITY_NORTH_WEST;
   gint             mask = NoValue, x, y, new_x, new_y;
@@ -828,13 +829,23 @@ terminal_app_open_window (TerminalApp        *app,
     }
 
   /* add the tabs */
-  for (lp = attr->tabs; lp != NULL; lp = lp->next)
+  for (lp = attr->tabs, i = 0; lp != NULL; lp = lp->next, ++i)
     {
-      terminal = terminal_screen_new ((TerminalTabAttr *) lp->data,
-                                      width,
-                                      height);
+      TerminalTabAttr *tab_attr = (TerminalTabAttr *) lp->data;
+      terminal = terminal_screen_new (tab_attr, width, height);
       terminal_window_add (TERMINAL_WINDOW (window), terminal);
       terminal_screen_launch_child (terminal);
+
+      /* whether the tab was set as active */
+      if (G_UNLIKELY (tab_attr->active))
+        active_tab = i;
+    }
+
+  /* set active tab */
+  if (active_tab > -1)
+    {
+      GtkNotebook *notebook = GTK_NOTEBOOK (terminal_window_get_notebook (TERMINAL_WINDOW (window)));
+      gtk_notebook_set_current_page (notebook, active_tab);
     }
 
   if (!attr->drop_down)
diff --git a/terminal/terminal-options.c b/terminal/terminal-options.c
index 2dc63c5..9b9f3df 100644
--- a/terminal/terminal-options.c
+++ b/terminal/terminal-options.c
@@ -351,6 +351,10 @@ terminal_window_attr_parse (gint              argc,
         {
           tab_attr->hold = TRUE;
         }
+      else if (terminal_option_cmp ("active-tab", 0, argc, argv, &n, NULL))
+        {
+          tab_attr->active = TRUE;
+        }
       else if (terminal_option_cmp ("display", 0, argc, argv, &n, &s))
         {
           if (G_UNLIKELY (s == NULL))
diff --git a/terminal/terminal-options.h b/terminal/terminal-options.h
index 05c97b3..d4d676c 100644
--- a/terminal/terminal-options.h
+++ b/terminal/terminal-options.h
@@ -60,6 +60,7 @@ typedef struct
   gchar        *initial_title;
   TerminalTitle dynamic_title_mode;
   guint         hold : 1;
+  guint         active : 1;
 } TerminalTabAttr;
 
 typedef struct
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index d039a01..ba9497f 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -2722,6 +2722,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
     {
       if (lp != children)
         result = g_slist_prepend (result, g_strdup ("--tab"));
+      if (window->priv->active == lp->data)
+        result = g_slist_prepend (result, g_strdup ("--active-tab"));
       result = g_slist_concat (terminal_screen_get_restart_command (lp->data), result);
     }
   g_list_free (children);
@@ -2730,6 +2732,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 
+
 /**
  * terminal_window_set_grid_size:
  * @window  : A #TerminalWindow.

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list