Skip to content

Commit 03238f8

Browse files
sc0wlukefromdc
authored andcommitted
add the option to hide the frist tab if there is only one tab
1 parent 323d3a3 commit 03238f8

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

‎data/org.mate.pluma.gschema.xml.in‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<summary>Switch tabs with [ctrl] + [tab]</summary>
1717
<description>If true, it enables the ability to switch tabs using [ctrl + tab] and [ctrl + shift + tab].</description>
1818
</key>
19+
<key name="show-single-tab" type="b">
20+
<default>true</default>
21+
<summary>Show the first tab if there is only one tab</summary>
22+
<description>If false, it hides the first tab if there is only one tab.</description>
23+
</key>
1924
<key name="color-scheme" type="s">
2025
<default>'tango'</default>
2126
<summary>Style Scheme</summary>

‎pluma/pluma-notebook.c‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct _PlumaNotebookPrivate
6262
gint x_start;
6363
gint y_start;
6464
gint drag_in_progress : 1;
65-
gint always_show_tabs : 1;
6665
gint close_buttons_sensitive : 1;
6766
gint tab_drag_and_drop_enabled : 1;
6867
guint destroy_has_run : 1;
@@ -783,21 +782,18 @@ pluma_notebook_switch_page_cb (GtkNotebook *notebook,
783782
* and the pref is not set.
784783
*/
785784
static void
786-
update_tabs_visibility (PlumaNotebook *nb,
787-
gboolean before_inserting)
785+
update_tabs_visibility (PlumaNotebook *nb)
788786
{
789787
gboolean show_tabs;
790788
guint num;
791789
GSettings *settings;
792790

793791
num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
794792

795-
if (before_inserting) num++;
796-
797-
show_tabs = (nb->priv->always_show_tabs || num > 1);
798-
799793
settings = g_settings_new ("org.mate.pluma");
800794

795+
show_tabs = (g_settings_get_boolean (settings, "show-single-tab") || num > 1);
796+
801797
if (g_settings_get_boolean (settings, "show-tabs-with-side-pane"))
802798
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
803799
else
@@ -807,6 +803,8 @@ update_tabs_visibility (PlumaNotebook *nb,
807803
else
808804
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
809805
}
806+
807+
g_object_unref (settings);
810808
}
811809

812810
static void
@@ -821,8 +819,6 @@ pluma_notebook_init (PlumaNotebook *notebook)
821819
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
822820
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
823821

824-
notebook->priv->always_show_tabs = TRUE;
825-
826822
g_signal_connect (notebook,
827823
"button-press-event",
828824
(GCallback)button_press_cb,
@@ -988,7 +984,7 @@ pluma_notebook_add_tab (PlumaNotebook *nb,
988984
GTK_WIDGET (tab),
989985
tab_label,
990986
position);
991-
update_tabs_visibility (nb, TRUE);
987+
update_tabs_visibility (nb);
992988

993989
g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
994990

@@ -1054,7 +1050,7 @@ remove_tab (PlumaTab *tab,
10541050

10551051
remove_tab_label (nb, tab);
10561052
gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
1057-
update_tabs_visibility (nb, FALSE);
1053+
update_tabs_visibility (nb);
10581054

10591055
g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
10601056

‎pluma/pluma-window.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3623,7 +3623,18 @@ side_panel_visibility_changed (GtkWidget *side_panel,
36233623
settings = g_settings_new ("org.mate.pluma");
36243624

36253625
if (!g_settings_get_boolean (settings, "show-tabs-with-side-pane"))
3626-
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), !visible);
3626+
{
3627+
if (visible)
3628+
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
3629+
else
3630+
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
3631+
g_settings_get_boolean (settings, "show-single-tab") ||
3632+
(gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
3633+
}
3634+
else
3635+
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
3636+
g_settings_get_boolean (settings, "show-single-tab") ||
3637+
(gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
36273638

36283639
if (pluma_prefs_manager_side_pane_visible_can_set ())
36293640
pluma_prefs_manager_set_side_pane_visible (visible);
@@ -3638,6 +3649,8 @@ side_panel_visibility_changed (GtkWidget *side_panel,
36383649
if (!visible && window->priv->active_tab != NULL)
36393650
gtk_widget_grab_focus (GTK_WIDGET (
36403651
pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab))));
3652+
3653+
g_object_unref (settings);
36413654
}
36423655

36433656
static void

0 commit comments

Comments
 (0)