summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-07-28 04:14:47 +0200
committerlukefromdc <[email protected]>2018-08-01 15:19:29 -0400
commit03238f85321f178e56b62a1f029169f3c21dc964 (patch)
tree2b84e413392157bf914afefbb8c23a84314a69f2
parent323d3a3e68244e825b0955efdf7042d3c35d49c2 (diff)
downloadpluma-03238f85321f178e56b62a1f029169f3c21dc964.tar.bz2
pluma-03238f85321f178e56b62a1f029169f3c21dc964.tar.xz
add the option to hide the frist tab if there is only one tab
-rw-r--r--data/org.mate.pluma.gschema.xml.in5
-rw-r--r--pluma/pluma-notebook.c18
-rw-r--r--pluma/pluma-window.c15
3 files changed, 26 insertions, 12 deletions
diff --git a/data/org.mate.pluma.gschema.xml.in b/data/org.mate.pluma.gschema.xml.in
index 3305283f..7cbaba7f 100644
--- a/data/org.mate.pluma.gschema.xml.in
+++ b/data/org.mate.pluma.gschema.xml.in
@@ -16,6 +16,11 @@
<summary>Switch tabs with [ctrl] + [tab]</summary>
<description>If true, it enables the ability to switch tabs using [ctrl + tab] and [ctrl + shift + tab].</description>
</key>
+ <key name="show-single-tab" type="b">
+ <default>true</default>
+ <summary>Show the first tab if there is only one tab</summary>
+ <description>If false, it hides the first tab if there is only one tab.</description>
+ </key>
<key name="color-scheme" type="s">
<default>'tango'</default>
<summary>Style Scheme</summary>
diff --git a/pluma/pluma-notebook.c b/pluma/pluma-notebook.c
index f8d174f1..6278fbcb 100644
--- a/pluma/pluma-notebook.c
+++ b/pluma/pluma-notebook.c
@@ -62,7 +62,6 @@ struct _PlumaNotebookPrivate
gint x_start;
gint y_start;
gint drag_in_progress : 1;
- gint always_show_tabs : 1;
gint close_buttons_sensitive : 1;
gint tab_drag_and_drop_enabled : 1;
guint destroy_has_run : 1;
@@ -783,8 +782,7 @@ pluma_notebook_switch_page_cb (GtkNotebook *notebook,
* and the pref is not set.
*/
static void
-update_tabs_visibility (PlumaNotebook *nb,
- gboolean before_inserting)
+update_tabs_visibility (PlumaNotebook *nb)
{
gboolean show_tabs;
guint num;
@@ -792,12 +790,10 @@ update_tabs_visibility (PlumaNotebook *nb,
num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
- if (before_inserting) num++;
-
- show_tabs = (nb->priv->always_show_tabs || num > 1);
-
settings = g_settings_new ("org.mate.pluma");
+ show_tabs = (g_settings_get_boolean (settings, "show-single-tab") || num > 1);
+
if (g_settings_get_boolean (settings, "show-tabs-with-side-pane"))
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
else
@@ -807,6 +803,8 @@ update_tabs_visibility (PlumaNotebook *nb,
else
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
}
+
+ g_object_unref (settings);
}
static void
@@ -821,8 +819,6 @@ pluma_notebook_init (PlumaNotebook *notebook)
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
- notebook->priv->always_show_tabs = TRUE;
-
g_signal_connect (notebook,
"button-press-event",
(GCallback)button_press_cb,
@@ -988,7 +984,7 @@ pluma_notebook_add_tab (PlumaNotebook *nb,
GTK_WIDGET (tab),
tab_label,
position);
- update_tabs_visibility (nb, TRUE);
+ update_tabs_visibility (nb);
g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
@@ -1054,7 +1050,7 @@ remove_tab (PlumaTab *tab,
remove_tab_label (nb, tab);
gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
- update_tabs_visibility (nb, FALSE);
+ update_tabs_visibility (nb);
g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
diff --git a/pluma/pluma-window.c b/pluma/pluma-window.c
index b3ac4f47..771f3a4e 100644
--- a/pluma/pluma-window.c
+++ b/pluma/pluma-window.c
@@ -3623,7 +3623,18 @@ side_panel_visibility_changed (GtkWidget *side_panel,
settings = g_settings_new ("org.mate.pluma");
if (!g_settings_get_boolean (settings, "show-tabs-with-side-pane"))
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), !visible);
+ {
+ if (visible)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
+ else
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
+ g_settings_get_boolean (settings, "show-single-tab") ||
+ (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
+ }
+ else
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
+ g_settings_get_boolean (settings, "show-single-tab") ||
+ (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
if (pluma_prefs_manager_side_pane_visible_can_set ())
pluma_prefs_manager_set_side_pane_visible (visible);
@@ -3638,6 +3649,8 @@ side_panel_visibility_changed (GtkWidget *side_panel,
if (!visible && window->priv->active_tab != NULL)
gtk_widget_grab_focus (GTK_WIDGET (
pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab))));
+
+ g_object_unref (settings);
}
static void