static gboolean draw_cb_extension (GtkWidget *widget, cairo_t *cr) { GtkStyleContext *context; context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); gtk_style_context_add_class (context, "notebook"); gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, 0); gtk_style_context_set_state (context, 0); gtk_render_extension (context, cr, 26, 12, 24, 12, GTK_POS_BOTTOM); gtk_render_extension (context, cr, 12, 26, 12, 24, GTK_POS_RIGHT); gtk_render_extension (context, cr, 26, 52, 24, 12, GTK_POS_TOP); gtk_render_extension (context, cr, 52, 26, 12, 24, GTK_POS_LEFT); gtk_style_context_restore (context); return TRUE; }
static void anjuta_tabber_draw_tab (AnjutaTabber* tabber, cairo_t* cr, GList* child) { GtkWidget* widget = GTK_WIDGET (tabber); GtkWidget* tab = GTK_WIDGET (child->data); gboolean current; gint focus_width; gint focus_pad; gint tab_curvature; gint tab_overlap; gint focus_space; gint tab_begin; gint tab_end; GtkStateFlags state; GtkRegionFlags region_flags; GtkBorder tab_padding; GtkAllocation alloc; GtkAllocation widget_alloc; GtkStyleContext* context = gtk_widget_get_style_context (widget); current = g_list_position (tabber->priv->children, child) == tabber->priv->active_page; gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, "tab-curvature", &tab_curvature, "tab-overlap", &tab_overlap, NULL); focus_space = focus_pad + focus_width; /* Get border/padding for tab */ gtk_style_context_save (context); anjuta_tabber_setup_style_context (tabber, context, child, &state, ®ion_flags); gtk_style_context_get_padding (context, state, &tab_padding); gtk_widget_get_allocation (widget, &widget_alloc); gtk_widget_get_allocation (tab, &alloc); tab_begin = tab_curvature - tab_overlap; tab_end = tab_curvature - tab_overlap; if (region_flags | GTK_REGION_FIRST) tab_begin += tab_overlap; if (region_flags | GTK_REGION_LAST) tab_end += tab_overlap; alloc.x -= widget_alloc.x; alloc.x -= tab_begin; alloc.x -= focus_space + tab_padding.left; alloc.y -= widget_alloc.y; alloc.y -= focus_space + tab_padding.top; alloc.width += 2 * focus_space + tab_padding.left + tab_padding.right + tab_begin + tab_end; alloc.height += 2 * focus_space + tab_padding.top + tab_padding.bottom; gtk_render_extension (context, cr, alloc.x, alloc.y, alloc.width, alloc.height, GTK_POS_BOTTOM); if (gtk_widget_has_focus (widget) && current) { GtkAllocation allocation; gtk_widget_get_allocation (tab, &allocation); gtk_render_focus (context, cr, allocation.x - focus_space, allocation.y - focus_space, allocation.width + 2 * focus_space, allocation.height + 2 * focus_space); } gtk_style_context_restore (context); }
static void anjuta_tabber_render_tab (GtkWidget* widget, GtkWidget* tab, cairo_t* cr, gboolean current, GtkRegionFlags region_flags) { AnjutaTabber* tabber = ANJUTA_TABBER (widget); GtkAllocation alloc; GtkAllocation widget_alloc; gint focus_width; gint tab_curvature; gint tab_overlap; gint tab_begin; gint tab_end; gint xpadding; gint ypadding; GtkStyleContext* context = gtk_widget_get_style_context (widget); if (current) gtk_widget_set_state_flags (tab, GTK_STATE_FLAG_ACTIVE, TRUE); else gtk_widget_unset_state_flags (tab, GTK_STATE_FLAG_ACTIVE); gtk_widget_style_get (widget, "focus-line-width", &focus_width, "tab-curvature", &tab_curvature, "tab-overlap", &tab_overlap, NULL); /* Get border/padding for tab */ gtk_style_context_save (context); gtk_style_context_add_class (context, GTK_STYLE_CLASS_NOTEBOOK); gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, region_flags); if (current) gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) gtk_style_context_set_junction_sides (context, GTK_JUNCTION_CORNER_TOPLEFT); else gtk_style_context_set_junction_sides (context, GTK_JUNCTION_CORNER_TOPRIGHT); gtk_widget_get_allocation (widget, &widget_alloc); gtk_widget_get_allocation (tab, &alloc); xpadding = focus_width + tabber->priv->tab_hborder; ypadding = focus_width + tabber->priv->tab_vborder; tab_begin = tab_curvature - tab_overlap; tab_end = tab_curvature - tab_overlap; if (region_flags | GTK_REGION_FIRST) tab_begin += tab_overlap; if (region_flags | GTK_REGION_LAST) tab_end += tab_overlap; alloc.x -= widget_alloc.x; alloc.x -= tab_begin; alloc.x -= xpadding; alloc.y -= widget_alloc.y; alloc.y -= ypadding; alloc.width += 2 * (xpadding) + tab_begin + tab_end; alloc.height += 2 * ypadding; gtk_render_extension (context, cr, alloc.x, alloc.y, alloc.width, alloc.height, GTK_POS_BOTTOM); if (gtk_widget_has_focus (widget) && current) { GtkAllocation allocation; gtk_widget_get_allocation (tab, &allocation); gtk_render_focus (context, cr, allocation.x - focus_width, allocation.y - focus_width, allocation.width + 2 * focus_width, allocation.height + 2 * focus_width); } gtk_style_context_restore (context); }