notebooks: Don't show tabs when the notebook only has one page
This commit is contained in:
parent
6e7586c654
commit
d79bc79dbc
|
@ -61,7 +61,6 @@ struct _XedNotebookPrivate
|
||||||
gint x_start;
|
gint x_start;
|
||||||
gint y_start;
|
gint y_start;
|
||||||
gint drag_in_progress : 1;
|
gint drag_in_progress : 1;
|
||||||
gint always_show_tabs : 1;
|
|
||||||
gint close_buttons_sensitive : 1;
|
gint close_buttons_sensitive : 1;
|
||||||
gint tab_drag_and_drop_enabled : 1;
|
gint tab_drag_and_drop_enabled : 1;
|
||||||
gint tab_scrolling_enabled : 1;
|
gint tab_scrolling_enabled : 1;
|
||||||
|
@ -691,22 +690,14 @@ xed_notebook_switch_page_cb (GtkNotebook *notebook,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update_tabs_visibility: Hide tabs if there is only one tab
|
* update_tabs_visibility: Hide tabs if there is only one tab
|
||||||
* and the pref is not set.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
update_tabs_visibility (XedNotebook *nb,
|
update_tabs_visibility (XedNotebook *notebook)
|
||||||
gboolean before_inserting)
|
|
||||||
{
|
{
|
||||||
gboolean show_tabs;
|
gboolean show_tabs;
|
||||||
guint num;
|
|
||||||
|
|
||||||
num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
|
show_tabs = (gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 1);
|
||||||
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), show_tabs);
|
||||||
if (before_inserting) num++;
|
|
||||||
|
|
||||||
show_tabs = (nb->priv->always_show_tabs || num > 1);
|
|
||||||
|
|
||||||
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -719,11 +710,9 @@ xed_notebook_init (XedNotebook *notebook)
|
||||||
notebook->priv->tab_scrolling_enabled = TRUE;
|
notebook->priv->tab_scrolling_enabled = TRUE;
|
||||||
|
|
||||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
||||||
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
// gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
||||||
gtk_notebook_set_show_tabs (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",
|
g_signal_connect (notebook, "button-press-event",
|
||||||
(GCallback)button_press_cb, NULL);
|
(GCallback)button_press_cb, NULL);
|
||||||
g_signal_connect (notebook, "button-release-event",
|
g_signal_connect (notebook, "button-release-event",
|
||||||
|
@ -840,24 +829,6 @@ remove_tab_label (XedNotebook *nb,
|
||||||
g_object_set_data (G_OBJECT (tab), "tab-label", NULL);
|
g_object_set_data (G_OBJECT (tab), "tab-label", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xed_notebook_set_always_show_tabs:
|
|
||||||
* @nb: a #XedNotebook
|
|
||||||
* @show_tabs: %TRUE to always show the tabs
|
|
||||||
*
|
|
||||||
* Sets the visibility of the tabs in the @nb.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xed_notebook_set_always_show_tabs (XedNotebook *nb,
|
|
||||||
gboolean show_tabs)
|
|
||||||
{
|
|
||||||
g_return_if_fail (XED_IS_NOTEBOOK (nb));
|
|
||||||
|
|
||||||
nb->priv->always_show_tabs = (show_tabs != FALSE);
|
|
||||||
|
|
||||||
update_tabs_visibility (nb, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xed_notebook_add_tab:
|
* xed_notebook_add_tab:
|
||||||
* @nb: a #XedNotebook
|
* @nb: a #XedNotebook
|
||||||
|
@ -880,7 +851,7 @@ xed_notebook_add_tab (XedNotebook *nb,
|
||||||
|
|
||||||
tab_label = create_tab_label (nb, tab);
|
tab_label = create_tab_label (nb, tab);
|
||||||
gtk_notebook_insert_page (GTK_NOTEBOOK (nb), GTK_WIDGET (tab), tab_label, position);
|
gtk_notebook_insert_page (GTK_NOTEBOOK (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);
|
g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
|
||||||
|
|
||||||
|
@ -940,7 +911,7 @@ remove_tab (XedTab *tab,
|
||||||
|
|
||||||
remove_tab_label (nb, tab);
|
remove_tab_label (nb, tab);
|
||||||
gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
|
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);
|
g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
|
||||||
|
|
||||||
|
|
|
@ -119,11 +119,6 @@ void xed_notebook_move_tab (XedNotebook *src,
|
||||||
XedTab *tab,
|
XedTab *tab,
|
||||||
gint dest_position);
|
gint dest_position);
|
||||||
|
|
||||||
/* FIXME: do we really need this function ? */
|
|
||||||
void xed_notebook_set_always_show_tabs
|
|
||||||
(XedNotebook *nb,
|
|
||||||
gboolean show_tabs);
|
|
||||||
|
|
||||||
void xed_notebook_set_close_buttons_sensitive
|
void xed_notebook_set_close_buttons_sensitive
|
||||||
(XedNotebook *nb,
|
(XedNotebook *nb,
|
||||||
gboolean sensitive);
|
gboolean sensitive);
|
||||||
|
|
|
@ -403,6 +403,8 @@ build_notebook_for_panel (XedPanel *panel)
|
||||||
|
|
||||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (panel->priv->notebook), TRUE);
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (panel->priv->notebook), TRUE);
|
||||||
gtk_notebook_popup_enable (GTK_NOTEBOOK (panel->priv->notebook));
|
gtk_notebook_popup_enable (GTK_NOTEBOOK (panel->priv->notebook));
|
||||||
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->priv->notebook), FALSE);
|
||||||
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (panel->priv->notebook), FALSE);
|
||||||
|
|
||||||
gtk_widget_show (GTK_WIDGET (panel->priv->notebook));
|
gtk_widget_show (GTK_WIDGET (panel->priv->notebook));
|
||||||
}
|
}
|
||||||
|
@ -505,6 +507,15 @@ build_tab_label (XedPanel *panel,
|
||||||
return hbox;
|
return hbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_tabs_visibility (XedPanel *panel)
|
||||||
|
{
|
||||||
|
gboolean show_tabs;
|
||||||
|
|
||||||
|
show_tabs = (gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->priv->notebook)) > 1);
|
||||||
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->priv->notebook), show_tabs);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xed_panel_add_item:
|
* xed_panel_add_item:
|
||||||
* @panel: a #XedPanel
|
* @panel: a #XedPanel
|
||||||
|
@ -561,6 +572,7 @@ xed_panel_add_item (XedPanel *panel,
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_notebook_append_page_menu (GTK_NOTEBOOK (panel->priv->notebook), item, tab_label, menu_label);
|
gtk_notebook_append_page_menu (GTK_NOTEBOOK (panel->priv->notebook), item, tab_label, menu_label);
|
||||||
|
update_tabs_visibility (panel);
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (panel), signals[ITEM_ADDED], 0, item);
|
g_signal_emit (G_OBJECT (panel), signals[ITEM_ADDED], 0, item);
|
||||||
}
|
}
|
||||||
|
@ -629,6 +641,7 @@ xed_panel_remove_item (XedPanel *panel,
|
||||||
g_object_ref (G_OBJECT (item));
|
g_object_ref (G_OBJECT (item));
|
||||||
|
|
||||||
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->priv->notebook), page_num);
|
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->priv->notebook), page_num);
|
||||||
|
update_tabs_visibility (panel);
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (panel), signals[ITEM_REMOVED], 0, item);
|
g_signal_emit (G_OBJECT (panel), signals[ITEM_REMOVED], 0, item);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue