[Xfce4-commits] [apps/xfce4-terminal] 01/01: When closing an active tab, switch to the previously active one

noreply at xfce.org noreply at xfce.org
Sun Jun 3 19:32:12 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 22f7b4ad3de82da25bbbaca45234c804929d17e5
Author: Igor <f2404 at yandex.ru>
Date:   Sun Jun 3 13:32:05 2018 -0400

    When closing an active tab, switch to the previously active one
---
 terminal/terminal-window.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 584e8f3..868191a 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -281,6 +281,7 @@ struct _TerminalWindowPrivate
   GtkAction           *encoding_action;
 
   TerminalScreen      *active;
+  TerminalScreen      *last_active;
 
   /* cached actions to avoid lookups */
   GtkAction           *action_undo_close_tab;
@@ -1061,7 +1062,8 @@ terminal_window_notebook_page_switched (GtkNotebook     *notebook,
   /* only update when really changed */
   if (G_LIKELY (window->priv->active != active))
     {
-      /* set new active tab */
+      /* store last and set new active tab */
+      window->priv->last_active = window->priv->active;
       window->priv->active = active;
 
       /* set the new window title */
@@ -1100,11 +1102,13 @@ terminal_window_close_tab_request (TerminalScreen *screen,
 {
   if (terminal_window_confirm_close (screen, window))
     {
+      GtkNotebook *notebook = GTK_NOTEBOOK (window->priv->notebook);
+
       /* store attrs of the tab being closed */
       TerminalTabAttr *tab_attr = g_slice_new0 (TerminalTabAttr);
       tab_attr->active = (screen == window->priv->active);
       tab_attr->dynamic_title_mode = TERMINAL_TITLE_DEFAULT;
-      tab_attr->position = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (screen));
+      tab_attr->position = gtk_notebook_page_num (notebook, GTK_WIDGET (screen));
       tab_attr->directory = g_strdup (terminal_screen_get_working_directory (screen));
       tab_attr->title = IS_STRING (terminal_screen_get_custom_title (screen)) ?
                         g_strdup (terminal_screen_get_custom_title (screen)) : NULL;
@@ -1116,6 +1120,13 @@ terminal_window_close_tab_request (TerminalScreen *screen,
                               g_strdup (terminal_screen_get_custom_title_color (screen)) : NULL;
       g_queue_push_tail (window->priv->closed_tabs_list, tab_attr);
 
+      /* switch to the previously active tab */
+      if (screen == window->priv->active && window->priv->last_active != NULL)
+        {
+          gint page_num = gtk_notebook_page_num (notebook, GTK_WIDGET (window->priv->last_active));
+          gtk_notebook_set_current_page (notebook, page_num);
+        }
+
       gtk_widget_destroy (GTK_WIDGET (screen));
     }
 }

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


More information about the Xfce4-commits mailing list