From 11b5cb0d8e1b2f76caaad0df4c5f670b0a88b7fa Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 5 Mar 2010 19:20:49 +0100 Subject: [PATCH] When MiscAlwaysShowTabs is false, hide tabs after some inactivity --- terminal/terminal-window.c | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index 6294ef2..83220b3 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -105,7 +105,8 @@ static void terminal_window_notebook_page_reordered (GtkNoteboo GtkNotebookPage *page, guint page_num, TerminalWindow *window); -static void terminal_window_notebook_show_tabs (TerminalWindow *window); +static void terminal_window_notebook_show_tabs (TerminalWindow *window, + gboolean show_tabs); static void terminal_window_notebook_page_added (GtkNotebook *notebook, GtkWidget *child, guint page_num, @@ -184,6 +185,7 @@ static void terminal_window_action_report_bug (GtkAction TerminalWindow *window); static void terminal_window_action_about (GtkAction *action, TerminalWindow *window); +static gboolean terminal_window_callback_tabs (gpointer data); @@ -852,15 +854,22 @@ terminal_window_notebook_page_reordered (GtkNotebook *notebook, terminal_window_rebuild_gomenu (window); } - +static gboolean +terminal_window_callback_tabs (gpointer data) +{ + TerminalWindow *window = (TerminalWindow *) data; + terminal_window_notebook_show_tabs (window, FALSE); + return FALSE; +} static void -terminal_window_notebook_show_tabs (TerminalWindow *window) +terminal_window_notebook_show_tabs (TerminalWindow *window, + gboolean show_tabs) { GtkNotebook *notebook = GTK_NOTEBOOK (window->notebook); - gboolean show_tabs = TRUE; gint npages; gint width_chars, height_chars; + gboolean always_show_tabs; /* set the visibility of the tabs */ npages = gtk_notebook_get_n_pages (notebook); @@ -880,6 +889,10 @@ terminal_window_notebook_show_tabs (TerminalWindow *window) terminal_window_set_size_force_grid (window, window->active, width_chars, height_chars); } + + g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL); + if (show_tabs && !always_show_tabs) + g_timeout_add_seconds (2, terminal_window_callback_tabs, window); } @@ -915,7 +928,7 @@ terminal_window_notebook_page_added (GtkNotebook *notebook, terminal_screen_set_size (screen, w, h); /* show the tabs when needed */ - terminal_window_notebook_show_tabs (window); + terminal_window_notebook_show_tabs (window, TRUE); } else { @@ -964,7 +977,7 @@ terminal_window_notebook_page_removed (GtkNotebook *notebook, else { /* show the tabs when needed */ - terminal_window_notebook_show_tabs (window); + terminal_window_notebook_show_tabs (window, TRUE); /* regenerate the "Go" menu */ terminal_window_rebuild_gomenu (window); @@ -1481,6 +1494,8 @@ terminal_window_action_prev_tab (GtkAction *action, n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), (page_num - 1) % n_pages); + + terminal_window_notebook_show_tabs (window, TRUE); } @@ -1496,6 +1511,8 @@ terminal_window_action_next_tab (GtkAction *action, n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), (page_num + 1) % n_pages); + + terminal_window_notebook_show_tabs (window, TRUE); } -- 1.7.0