notebook: Add a style property for whether to draw a tab gap
Add a has-tab-gap style property to GtkNotebook so that we can disable drawing the gap between tabs and the page in the Adwaita theme without breaking existing themes. https://bugzilla.gnome.org/show_bug.cgi?id=707920
This commit is contained in:
@ -934,6 +934,23 @@ gtk_notebook_class_init (GtkNotebookClass *class)
|
|||||||
0,
|
0,
|
||||||
GTK_PARAM_READABLE));
|
GTK_PARAM_READABLE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkNotebook:has-tab-gap:
|
||||||
|
*
|
||||||
|
* The "has-tab-gap" property defines whether the active tab is draw
|
||||||
|
* with a gap at the bottom. When %TRUE the theme engine uses
|
||||||
|
* gtk_render_extension to draw the active tab. When %FALSE
|
||||||
|
* gtk_render_background and gtk_render_frame are used.
|
||||||
|
*
|
||||||
|
* Since: 3.12
|
||||||
|
*/
|
||||||
|
gtk_widget_class_install_style_property (widget_class,
|
||||||
|
g_param_spec_boolean ("has-tab-gap",
|
||||||
|
P_("Tab gap"),
|
||||||
|
P_("Active tab is drawn with a gap at the bottom"),
|
||||||
|
TRUE,
|
||||||
|
GTK_PARAM_READABLE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkNotebook::switch-page:
|
* GtkNotebook::switch-page:
|
||||||
* @notebook: the object which received the signal.
|
* @notebook: the object which received the signal.
|
||||||
@ -3550,7 +3567,7 @@ on_drag_icon_draw (GtkWidget *widget,
|
|||||||
GtkWidget *notebook, *child;
|
GtkWidget *notebook, *child;
|
||||||
GtkRequisition requisition;
|
GtkRequisition requisition;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
gint gap_pos;
|
gboolean has_tab_gap;
|
||||||
|
|
||||||
notebook = GTK_WIDGET (data);
|
notebook = GTK_WIDGET (data);
|
||||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
@ -3561,11 +3578,29 @@ on_drag_icon_draw (GtkWidget *widget,
|
|||||||
|
|
||||||
gtk_widget_get_preferred_size (widget,
|
gtk_widget_get_preferred_size (widget,
|
||||||
&requisition, NULL);
|
&requisition, NULL);
|
||||||
gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook));
|
|
||||||
|
|
||||||
gtk_render_extension (context, cr, 0, 0,
|
gtk_widget_style_get (GTK_WIDGET (notebook),
|
||||||
requisition.width, requisition.height,
|
"has-tab-gap", &has_tab_gap,
|
||||||
gap_pos);
|
NULL);
|
||||||
|
|
||||||
|
if (has_tab_gap)
|
||||||
|
{
|
||||||
|
gint gap_pos;
|
||||||
|
gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook));
|
||||||
|
gtk_render_extension (context, cr, 0, 0,
|
||||||
|
requisition.width, requisition.height,
|
||||||
|
gap_pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_render_background (context, cr, 0, 0,
|
||||||
|
requisition.width,
|
||||||
|
requisition.height);
|
||||||
|
|
||||||
|
gtk_render_frame (context, cr, 0, 0,
|
||||||
|
requisition.width,
|
||||||
|
requisition.height);
|
||||||
|
}
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
|
gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
|
||||||
@ -5128,6 +5163,7 @@ gtk_notebook_paint (GtkWidget *widget,
|
|||||||
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
gint gap_x = 0, gap_width = 0, step = STEP_PREV;
|
gint gap_x = 0, gap_width = 0, step = STEP_PREV;
|
||||||
gboolean is_rtl;
|
gboolean is_rtl;
|
||||||
|
gboolean has_tab_gap;
|
||||||
gint tab_pos;
|
gint tab_pos;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
|
|
||||||
@ -5270,11 +5306,19 @@ gtk_notebook_paint (GtkWidget *widget,
|
|||||||
gtk_style_context_set_junction_sides (context, junction);
|
gtk_style_context_set_junction_sides (context, junction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_widget_style_get (GTK_WIDGET (notebook),
|
||||||
|
"has-tab-gap", &has_tab_gap,
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_render_background (context, cr,
|
gtk_render_background (context, cr,
|
||||||
x, y, width, height);
|
x, y, width, height);
|
||||||
gtk_render_frame_gap (context, cr,
|
if (has_tab_gap)
|
||||||
x, y, width, height,
|
gtk_render_frame_gap (context, cr,
|
||||||
tab_pos, gap_x, gap_x + gap_width);
|
x, y, width, height,
|
||||||
|
tab_pos, gap_x, gap_x + gap_width);
|
||||||
|
else
|
||||||
|
gtk_render_frame (context, cr,
|
||||||
|
x, y, width, height);
|
||||||
|
|
||||||
gtk_style_context_restore (context);
|
gtk_style_context_restore (context);
|
||||||
|
|
||||||
@ -5349,6 +5393,7 @@ gtk_notebook_draw_tab (GtkNotebook *notebook,
|
|||||||
GtkNotebookPrivate *priv;
|
GtkNotebookPrivate *priv;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
|
gboolean has_tab_gap;
|
||||||
|
|
||||||
if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) ||
|
if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) ||
|
||||||
!gtk_widget_get_mapped (page->tab_label) ||
|
!gtk_widget_get_mapped (page->tab_label) ||
|
||||||
@ -5362,12 +5407,33 @@ gtk_notebook_draw_tab (GtkNotebook *notebook,
|
|||||||
gtk_style_context_save (context);
|
gtk_style_context_save (context);
|
||||||
notebook_tab_prepare_style_context (notebook, page, context, use_flags);
|
notebook_tab_prepare_style_context (notebook, page, context, use_flags);
|
||||||
|
|
||||||
gtk_render_extension (context, cr,
|
gtk_widget_style_get (GTK_WIDGET (notebook),
|
||||||
page->allocation.x,
|
"has-tab-gap", &has_tab_gap,
|
||||||
page->allocation.y,
|
NULL);
|
||||||
page->allocation.width,
|
|
||||||
page->allocation.height,
|
if (has_tab_gap)
|
||||||
get_tab_gap_pos (notebook));
|
{
|
||||||
|
gtk_render_extension (context, cr,
|
||||||
|
page->allocation.x,
|
||||||
|
page->allocation.y,
|
||||||
|
page->allocation.width,
|
||||||
|
page->allocation.height,
|
||||||
|
get_tab_gap_pos (notebook));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_render_background (context, cr,
|
||||||
|
page->allocation.x,
|
||||||
|
page->allocation.y,
|
||||||
|
page->allocation.width,
|
||||||
|
page->allocation.height);
|
||||||
|
|
||||||
|
gtk_render_frame (context, cr,
|
||||||
|
page->allocation.x,
|
||||||
|
page->allocation.y,
|
||||||
|
page->allocation.width,
|
||||||
|
page->allocation.height);
|
||||||
|
}
|
||||||
|
|
||||||
if (gtk_widget_has_visible_focus (widget) &&
|
if (gtk_widget_has_visible_focus (widget) &&
|
||||||
priv->cur_page == page)
|
priv->cur_page == page)
|
||||||
|
Reference in New Issue
Block a user