[accounts-dialog] Port strength bar to GTK+ 3.x drawing API
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accounts-dialog] Port strength bar to GTK+ 3.x drawing API
- Date: Wed, 6 Oct 2010 13:32:16 +0000 (UTC)
commit fc495c8831dbaf2b1544e97040014ee7a8d61ac0
Author: Bastien Nocera <hadess hadess net>
Date: Wed Oct 6 14:30:44 2010 +0100
Port strength bar to GTK+ 3.x drawing API
src/um-strength-bar.c | 64 ++++++++++++++++++++++--------------------------
1 files changed, 29 insertions(+), 35 deletions(-)
---
diff --git a/src/um-strength-bar.c b/src/um-strength-bar.c
index d2cb294..64af45f 100644
--- a/src/um-strength-bar.c
+++ b/src/um-strength-bar.c
@@ -163,45 +163,39 @@ get_color (gdouble value, gdouble *r, gdouble *g, gdouble *b)
}
static gboolean
-um_strength_bar_expose (GtkWidget *widget,
- GdkEventExpose *event)
+um_strength_bar_draw (GtkWidget *widget,
+ cairo_t *cr)
{
UmStrengthBar *bar = UM_STRENGTH_BAR (widget);
gdouble r, g, b;
GdkWindow *window;
GtkAllocation allocation;
- if (gtk_widget_is_drawable (widget)) {
- cairo_t *cr;
-
- window = gtk_widget_get_window (widget);
- gtk_widget_get_allocation (widget, &allocation);
- cr = gdk_cairo_create (window);
- cairo_set_line_width (cr, 1);
-
- cairo_rectangle (cr,
- allocation.x,
- allocation.y,
- bar->priv->strength * allocation.width,
- allocation.height);
- cairo_clip (cr);
-
- curved_rectangle (cr,
- allocation.x + 0.5,
- allocation.y + 0.5,
- allocation.width - 1,
- allocation.height - 1,
- 4);
- get_color (bar->priv->strength, &r, &g ,&b);
- cairo_set_source_rgb (cr, r, g, b);
- cairo_fill_preserve (cr);
-
- cairo_reset_clip (cr);
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_stroke (cr);
-
- cairo_destroy (cr);
- }
+ window = gtk_widget_get_window (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+ cr = gdk_cairo_create (window);
+ cairo_set_line_width (cr, 1);
+
+ cairo_rectangle (cr,
+ allocation.x,
+ allocation.y,
+ bar->priv->strength * allocation.width,
+ allocation.height);
+ cairo_clip (cr);
+
+ curved_rectangle (cr,
+ allocation.x + 0.5,
+ allocation.y + 0.5,
+ allocation.width - 1,
+ allocation.height - 1,
+ 4);
+ get_color (bar->priv->strength, &r, &g ,&b);
+ cairo_set_source_rgb (cr, r, g, b);
+ cairo_fill_preserve (cr);
+
+ cairo_reset_clip (cr);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_stroke (cr);
return FALSE;
}
@@ -218,7 +212,7 @@ um_strength_bar_class_init (UmStrengthBarClass *class)
gobject_class->set_property = um_strength_bar_set_property;
gobject_class->get_property = um_strength_bar_get_property;
- widget_class->expose_event = um_strength_bar_expose;
+ widget_class->draw = um_strength_bar_draw;
g_object_class_install_property (gobject_class,
PROP_STRENGTH,
@@ -255,7 +249,7 @@ um_strength_bar_set_strength (UmStrengthBar *bar,
g_object_notify (G_OBJECT (bar), "strength");
- if (GTK_WIDGET_DRAWABLE (bar)) {
+ if (gtk_widget_is_drawable (GTK_WIDGET (bar))) {
gtk_widget_queue_draw (GTK_WIDGET (bar));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]