[gtk+] GtkPopover: Survive attach_widget == NULL
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkPopover: Survive attach_widget == NULL
- Date: Fri, 14 Nov 2014 11:16:58 +0000 (UTC)
commit 49cf85509aa679439a42866318c7ce6a9b1a2588
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Nov 13 23:09:21 2014 -0500
GtkPopover: Survive attach_widget == NULL
We can't render a tail, but otherwise things should just work.
This will be useful in glade.
gtk/gtkpopover.c | 48 ++++++++++++++++++++++++++++++------------------
1 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 2a31982..550aa14 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -639,6 +639,9 @@ gtk_popover_apply_tail_path (GtkPopover *popover,
gint tip_x, tip_y;
gint final_x, final_y;
+ if (!popover->priv->widget)
+ return;
+
cairo_set_line_width (cr, 1);
gtk_popover_get_gap_coords (popover,
&initial_x, &initial_y,
@@ -843,29 +846,38 @@ gtk_popover_draw (GtkWidget *widget,
rect_x2 - rect_x1,
rect_y2 - rect_y1);
- gtk_popover_get_gap_coords (popover,
- &initial_x, &initial_y,
- NULL, NULL,
- &final_x, &final_y,
- &gap_side);
-
- if (POS_IS_VERTICAL (gap_side))
+ if (popover->priv->widget)
{
- gap_start = initial_x - rect_x1;
- gap_end = final_x - rect_x1;
+ gtk_popover_get_gap_coords (popover,
+ &initial_x, &initial_y,
+ NULL, NULL,
+ &final_x, &final_y,
+ &gap_side);
+
+ if (POS_IS_VERTICAL (gap_side))
+ {
+ gap_start = initial_x - rect_x1;
+ gap_end = final_x - rect_x1;
+ }
+ else
+ {
+ gap_start = initial_y - rect_y1;
+ gap_end = final_y - rect_y1;
+ }
+
+ /* Now render the frame, without the gap for the arrow tip */
+ gtk_render_frame_gap (context, cr,
+ rect_x1, rect_y1,
+ rect_x2 - rect_x1, rect_y2 - rect_y1,
+ gap_side,
+ gap_start, gap_end);
}
else
{
- gap_start = initial_y - rect_y1;
- gap_end = final_y - rect_y1;
- }
-
- /* Now render the frame, without the gap for the arrow tip */
- gtk_render_frame_gap (context, cr,
+ gtk_render_frame (context, cr,
rect_x1, rect_y1,
- rect_x2 - rect_x1, rect_y2 - rect_y1,
- gap_side,
- gap_start, gap_end);
+ rect_x2 - rect_x1, rect_y2 - rect_y1);
+ }
/* Clip to the arrow shape */
cairo_save (cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]