summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorCarlos Garnacho <carlos@lanedo.com>2013-01-15 17:32:42 +0100
committerMatthias Clasen <mclasen@redhat.com>2013-03-05 16:47:59 -0500
commita960230a20f86ebb31594a40132e341c1b7a7c21 (patch)
tree368f8cb98850140580306bf053137c9b05aeaab8 /gtk
parent320613c439c6c7eeb5bc64685522195e0a6adc4e (diff)
downloadgtk+-a960230a20f86ebb31594a40132e341c1b7a7c21.tar.gz
GtkBubbleWindow: Use style border color to stroke the bubble shape
This improves themeability a bit, corners are still square though...
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbubblewindow.c55
1 files changed, 44 insertions, 11 deletions
diff --git a/gtk/gtkbubblewindow.c b/gtk/gtkbubblewindow.c
index 4198a95814..08c735d9e6 100644
--- a/gtk/gtkbubblewindow.c
+++ b/gtk/gtkbubblewindow.c
@@ -248,22 +248,20 @@ _gtk_bubble_window_apply_tail_path (GtkBubbleWindow *window,
{
cairo_move_to (cr, CLAMP (x - priv->win_x - TAIL_GAP_WIDTH / 2,
0, allocation->width - TAIL_GAP_WIDTH), base);
+ cairo_line_to (cr, CLAMP (x - priv->win_x, 0, allocation->width), tip);
cairo_line_to (cr, CLAMP (x - priv->win_x + TAIL_GAP_WIDTH / 2,
TAIL_GAP_WIDTH, allocation->width), base);
- cairo_line_to (cr, CLAMP (x - priv->win_x, 0, allocation->width), tip);
}
else
{
cairo_move_to (cr, base,
CLAMP (y - priv->win_y - TAIL_GAP_WIDTH / 2,
0, allocation->height - TAIL_GAP_WIDTH));
+ cairo_line_to (cr, tip, CLAMP (y - priv->win_y, 0, allocation->height));
cairo_line_to (cr, base,
CLAMP (y - priv->win_y + TAIL_GAP_WIDTH / 2,
TAIL_GAP_WIDTH, allocation->height));
- cairo_line_to (cr, tip, CLAMP (y - priv->win_y, 0, allocation->height));
}
-
- cairo_close_path (cr);
}
static void
@@ -276,18 +274,38 @@ _gtk_bubble_window_apply_border_path (GtkBubbleWindow *window,
priv = window->_priv;
gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
+ _gtk_bubble_window_apply_tail_path (window, cr, &allocation);
+
if (priv->final_position == GTK_POS_TOP)
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height - TAIL_HEIGHT);
+ {
+ cairo_line_to (cr, allocation.width, allocation.height - TAIL_HEIGHT);
+ cairo_line_to (cr, allocation.width, 0);
+ cairo_line_to (cr, 0, 0);
+ cairo_line_to (cr, 0, allocation.height - TAIL_HEIGHT);
+ }
else if (priv->final_position == GTK_POS_BOTTOM)
- cairo_rectangle (cr, 0, TAIL_HEIGHT , allocation.width,
- allocation.height - TAIL_HEIGHT);
+ {
+ cairo_line_to (cr, allocation.width, TAIL_HEIGHT);
+ cairo_line_to (cr, allocation.width, allocation.height);
+ cairo_line_to (cr, 0, allocation.height);
+ cairo_line_to (cr, 0, TAIL_HEIGHT);
+ }
else if (priv->final_position == GTK_POS_LEFT)
- cairo_rectangle (cr, 0, 0, allocation.width - TAIL_HEIGHT, allocation.height);
+ {
+ cairo_line_to (cr, allocation.width - TAIL_HEIGHT, allocation.height);
+ cairo_line_to (cr, 0, allocation.height);
+ cairo_line_to (cr, 0, 0);
+ cairo_line_to (cr, allocation.width - TAIL_HEIGHT, 0);
+ }
else if (priv->final_position == GTK_POS_RIGHT)
- cairo_rectangle (cr, TAIL_HEIGHT, 0,
- allocation.width - TAIL_HEIGHT, allocation.height);
+ {
+ cairo_line_to (cr, TAIL_HEIGHT, 0);
+ cairo_line_to (cr, allocation.width, 0);
+ cairo_line_to (cr, allocation.width, allocation.height);
+ cairo_line_to (cr, TAIL_HEIGHT, allocation.height);
+ }
- _gtk_bubble_window_apply_tail_path (window, cr, &allocation);
+ cairo_close_path (cr);
}
static void
@@ -385,11 +403,15 @@ gtk_bubble_window_draw (GtkWidget *widget,
GtkStyleContext *context;
GtkAllocation allocation;
GtkWidget *child;
+ GdkRGBA *border;
cairo_save (cr);
context = gtk_widget_get_style_context (widget);
gtk_widget_get_allocation (widget, &allocation);
+ gtk_render_background (context, cr, 0, 0,
+ allocation.width, allocation.height);
+
if (gtk_widget_is_composited (widget))
{
cairo_save (cr);
@@ -404,6 +426,15 @@ gtk_bubble_window_draw (GtkWidget *widget,
gtk_render_background (context, cr, 0, 0,
allocation.width, allocation.height);
+
+ gtk_style_context_get (context, gtk_widget_get_state_flags (widget),
+ GTK_STYLE_PROPERTY_BORDER_COLOR, &border,
+ NULL);
+
+ _gtk_bubble_window_apply_border_path (GTK_BUBBLE_WINDOW (widget), cr);
+ gdk_cairo_set_source_rgba (cr, border);
+ cairo_stroke (cr);
+
child = gtk_bin_get_child (GTK_BIN (widget));
if (child)
@@ -411,6 +442,8 @@ gtk_bubble_window_draw (GtkWidget *widget,
cairo_restore (cr);
+ gdk_rgba_free (border);
+
return TRUE;
}