Skip to content
Permalink
Browse files

add the option to hide the frist tab if there is only one tab

  • Loading branch information...
sc0w authored and lukefromdc committed Jul 28, 2018
1 parent 323d3a3 commit 03238f85321f178e56b62a1f029169f3c21dc964
Showing with 26 additions and 12 deletions.
  1. +5 −0 data/org.mate.pluma.gschema.xml.in
  2. +7 −11 pluma/pluma-notebook.c
  3. +14 −1 pluma/pluma-window.c
@@ -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>
@@ -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,21 +782,18 @@ 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;
GSettings *settings;

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);

@@ -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

0 comments on commit 03238f8

Please sign in to comment.
You can’t perform that action at this time.