Commit d7519e6c authored by Benjamin Otte's avatar Benjamin Otte

notebook: Split out tabs size computation into its own function

parent edd2f24b
......@@ -1949,17 +1949,24 @@ _gtk_notebook_get_tab_flags (GtkNotebook *notebook,
}
static void
gtk_notebook_size_request (GtkWidget *widget,
gtk_notebook_get_preferred_tabs_size (GtkNotebook *notebook,
GtkRequisition *requisition)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
GtkNotebookPage *page;
GtkNotebookPrivate *priv;
GtkWidget *widget;
gint tab_width = 0;
gint tab_height = 0;
gint tab_max = 0;
gint padding;
gint i;
gint action_width = 0;
gint action_height = 0;
guint vis_pages = 0;
GList *children;
GtkRequisition child_requisition;
GtkNotebookPage *page;
GtkRequisition action_widget_requisition[2] = { { 0 }, { 0 } };
gboolean switch_page = FALSE;
gint vis_pages;
GtkRequisition child_requisition;
GtkStyleContext *context;
gint focus_width;
gint focus_pad;
gint tab_overlap;
......@@ -1967,8 +1974,10 @@ gtk_notebook_size_request (GtkWidget *widget,
gint arrow_spacing;
gint scroll_arrow_hlength;
gint scroll_arrow_vlength;
guint border_width;
priv = notebook->priv;
widget = GTK_WIDGET (notebook);
context = gtk_widget_get_style_context (widget);
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
......@@ -1979,68 +1988,6 @@ gtk_notebook_size_request (GtkWidget *widget,
"scroll-arrow-vlength", &scroll_arrow_vlength,
NULL);
requisition->width = 0;
requisition->height = 0;
for (children = priv->children, vis_pages = 0; children;
children = children->next)
{
GtkWidget *parent;
page = children->data;
if (gtk_widget_get_visible (page->child))
{
vis_pages++;
gtk_widget_get_preferred_size (page->child,
&child_requisition, NULL);
requisition->width = MAX (requisition->width,
child_requisition.width);
requisition->height = MAX (requisition->height,
child_requisition.height);
if (priv->menu && page->menu_label)
{
parent = gtk_widget_get_parent (page->menu_label);
if (parent && !gtk_widget_get_visible (parent))
gtk_widget_show (parent);
}
}
else
{
if (page == priv->cur_page)
switch_page = TRUE;
if (priv->menu && page->menu_label)
{
parent = gtk_widget_get_parent (page->menu_label);
if (parent && gtk_widget_get_visible (parent))
gtk_widget_hide (parent);
}
}
}
if (priv->show_border || priv->show_tabs)
{
GtkStyleContext *context;
GtkBorder notebook_padding;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_padding (context, 0, &notebook_padding);
requisition->width += notebook_padding.left + notebook_padding.right;
requisition->height += notebook_padding.top + notebook_padding.bottom;
if (priv->show_tabs)
{
gint tab_width = 0;
gint tab_height = 0;
gint tab_max = 0;
gint padding;
gint i;
gint action_width = 0;
gint action_height = 0;
for (children = priv->children; children;
children = children->next)
{
......@@ -2050,6 +1997,8 @@ gtk_notebook_size_request (GtkWidget *widget,
{
GtkBorder tab_padding;
vis_pages++;
if (!gtk_widget_get_visible (page->tab_label))
gtk_widget_show (page->tab_label);
......@@ -2099,8 +2048,6 @@ gtk_notebook_size_request (GtkWidget *widget,
{
gtk_widget_get_preferred_size (priv->action_widget[i],
&action_widget_requisition[i], NULL);
action_widget_requisition[i].width += notebook_padding.left;
action_widget_requisition[i].height += notebook_padding.top;
}
}
......@@ -2143,14 +2090,11 @@ gtk_notebook_size_request (GtkWidget *widget,
action_width += action_widget_requisition[ACTION_WIDGET_START].width;
action_width += action_widget_requisition[ACTION_WIDGET_END].width;
if (priv->homogeneous && !priv->scrollable)
requisition->width = MAX (requisition->width,
vis_pages * tab_max +
tab_overlap + action_width);
requisition->width = vis_pages * tab_max + tab_overlap + action_width;
else
requisition->width = MAX (requisition->width,
tab_width + tab_overlap + action_width);
requisition->width = tab_width + tab_overlap + action_width;
requisition->height += tab_height;
requisition->height = tab_height;
break;
case GTK_POS_LEFT:
case GTK_POS_RIGHT:
......@@ -2191,23 +2135,102 @@ gtk_notebook_size_request (GtkWidget *widget,
action_height += action_widget_requisition[ACTION_WIDGET_END].height;
if (priv->homogeneous && !priv->scrollable)
requisition->height =
MAX (requisition->height,
vis_pages * tab_max + tab_overlap + action_height);
requisition->height = vis_pages * tab_max + tab_overlap + action_height;
else
requisition->height =
MAX (requisition->height,
tab_height + tab_overlap + action_height);
requisition->height = tab_height + tab_overlap + action_height;
if (!priv->homogeneous || priv->scrollable)
vis_pages = 1;
requisition->height = MAX (requisition->height,
vis_pages * tab_max + tab_overlap);
requisition->width += tab_width;
requisition->width = tab_width;
break;
default:
g_assert_not_reached ();
requisition->width = 0;
requisition->height = 0;
}
}
else
{
requisition->width = 0;
requisition->height = 0;
}
}
static void
gtk_notebook_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
GtkNotebookPage *page;
GList *children;
GtkRequisition child_requisition;
gboolean switch_page = FALSE;
gint vis_pages;
guint border_width;
requisition->width = 0;
requisition->height = 0;
for (children = priv->children, vis_pages = 0; children;
children = children->next)
{
GtkWidget *parent;
page = children->data;
if (gtk_widget_get_visible (page->child))
{
vis_pages++;
gtk_widget_get_preferred_size (page->child,
&child_requisition, NULL);
requisition->width = MAX (requisition->width,
child_requisition.width);
requisition->height = MAX (requisition->height,
child_requisition.height);
if (priv->menu && page->menu_label)
{
parent = gtk_widget_get_parent (page->menu_label);
if (parent && !gtk_widget_get_visible (parent))
gtk_widget_show (parent);
}
}
else
{
if (page == priv->cur_page)
switch_page = TRUE;
if (priv->menu && page->menu_label)
{
parent = gtk_widget_get_parent (page->menu_label);
if (parent && gtk_widget_get_visible (parent))
gtk_widget_hide (parent);
}
}
}
if (priv->show_border || priv->show_tabs)
{
GtkStyleContext *context;
GtkBorder notebook_padding;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_padding (context, 0, &notebook_padding);
requisition->width += notebook_padding.left + notebook_padding.right;
requisition->height += notebook_padding.top + notebook_padding.bottom;
if (priv->show_tabs)
{
GtkRequisition tabs_requisition;
gtk_notebook_get_preferred_tabs_size (notebook, &tabs_requisition);
requisition->width += tabs_requisition.width;
requisition->height += tabs_requisition.height;
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment