[gtk+/rendering-cleanup-next: 33/154] accellabel: Port to draw vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup-next: 33/154] accellabel: Port to draw vfunc
- Date: Tue, 14 Sep 2010 15:49:26 +0000 (UTC)
commit 92175a18018bf0043df35a74f4136cb4764bbe4c
Author: Benjamin Otte <otte redhat com>
Date: Sun Sep 5 20:42:56 2010 +0200
accellabel: Port to draw vfunc
gtk/gtkaccellabel.c | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index 486bce0..b8619eb 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -120,8 +120,8 @@ static void gtk_accel_label_get_property (GObject *object,
GParamSpec *pspec);
static void gtk_accel_label_destroy (GtkObject *object);
static void gtk_accel_label_finalize (GObject *object);
-static gboolean gtk_accel_label_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gtk_accel_label_draw (GtkWidget *widget,
+ cairo_t *cr);
static const gchar *gtk_accel_label_get_string (GtkAccelLabel *accel_label);
@@ -152,7 +152,7 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
object_class->destroy = gtk_accel_label_destroy;
- widget_class->expose_event = gtk_accel_label_expose_event;
+ widget_class->draw = gtk_accel_label_draw;
class->signal_quote1 = g_strdup ("<:");
class->signal_quote2 = g_strdup (":>");
@@ -388,8 +388,8 @@ get_first_baseline (PangoLayout *layout)
}
static gboolean
-gtk_accel_label_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_accel_label_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (widget);
GtkMisc *misc = GTK_MISC (accel_label);
@@ -419,42 +419,48 @@ gtk_accel_label_expose_event (GtkWidget *widget,
label_layout = gtk_label_get_layout (GTK_LABEL (accel_label));
+ cairo_save (cr);
+
+ /* XXX: Mad hack: We modify the label's width so it renders
+ * properly in its draw function that we chain to. */
if (direction == GTK_TEXT_DIR_RTL)
- allocation.x += ac_width;
- allocation.width -= ac_width;
+ cairo_translate (cr, ac_width, 0);
if (gtk_label_get_ellipsize (label))
pango_layout_set_width (label_layout,
pango_layout_get_width (label_layout)
- ac_width * PANGO_SCALE);
- if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event)
- GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event (widget, event);
- if (direction == GTK_TEXT_DIR_RTL)
- allocation.x -= ac_width;
- allocation.width += ac_width;
+ allocation.width -= ac_width;
+ gtk_widget_set_allocation (widget, &allocation);
+ if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->draw)
+ GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->draw (widget,
+ cr);
+ allocation.width += ac_width;
+ gtk_widget_set_allocation (widget, &allocation);
if (gtk_label_get_ellipsize (label))
pango_layout_set_width (label_layout,
pango_layout_get_width (label_layout)
+ ac_width * PANGO_SCALE);
+ cairo_restore (cr);
+
gtk_misc_get_padding (misc, &xpad, NULL);
if (direction == GTK_TEXT_DIR_RTL)
- x = allocation.x + xpad;
+ x = xpad;
else
- x = allocation.x + allocation.width - xpad - ac_width;
+ x = gtk_widget_get_allocated_width (widget) - xpad - ac_width;
gtk_label_get_layout_offsets (GTK_LABEL (accel_label), NULL, &y);
accel_layout = gtk_widget_create_pango_layout (widget, gtk_accel_label_get_string (accel_label));
- y += get_first_baseline (label_layout) - get_first_baseline (accel_layout);
+ y += get_first_baseline (label_layout) - get_first_baseline (accel_layout) - allocation.y;
- gtk_paint_layout (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ gtk_cairo_paint_layout (gtk_widget_get_style (widget),
+ cr,
gtk_widget_get_state (widget),
FALSE,
- &event->area,
widget,
"accellabel",
x, y,
@@ -464,8 +470,8 @@ gtk_accel_label_expose_event (GtkWidget *widget,
}
else
{
- if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event)
- GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event (widget, event);
+ if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->draw)
+ GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->draw (widget, cr);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]