[totem] Bug 627573 — Port from GDK to Cairo
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] Bug 627573 — Port from GDK to Cairo
- Date: Sat, 4 Sep 2010 15:30:57 +0000 (UTC)
commit ed884ba7a2991b3d8f192154a117e386c0e6773f
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Aug 19 23:16:46 2010 +0100
Bug 627573 â?? Port from GDK to Cairo
browser-plugin/totem-glow-button.c | 47 +++++++--------------
src/backend/bacon-video-widget-gst-0.10.c | 16 ++++----
src/plugins/screenshot/gnome-screenshot-widget.c | 10 ++++-
3 files changed, 32 insertions(+), 41 deletions(-)
---
diff --git a/browser-plugin/totem-glow-button.c b/browser-plugin/totem-glow-button.c
index 4244ff9..ffb65a1 100644
--- a/browser-plugin/totem-glow-button.c
+++ b/browser-plugin/totem-glow-button.c
@@ -51,6 +51,8 @@ struct _TotemGlowButton {
/* Set when we don't want to play animation
* anymore in pointer entered mode */
guint anim_finished :1;
+
+ guint in_expose : 1;
};
static void totem_glow_button_set_timeout (TotemGlowButton *button,
@@ -234,6 +236,7 @@ take_screenshot (TotemGlowButton *button)
GtkStyle *style;
GdkPixmap *pixmap;
gint width, height;
+ cairo_t *cr;
buttonw = GTK_WIDGET (button);
gtk_widget_get_allocation (buttonw, &allocation);
@@ -243,40 +246,19 @@ take_screenshot (TotemGlowButton *button)
pixmap = gdk_pixmap_new (gtk_widget_get_window (buttonw),
width, height, -1);
+ cr = gdk_cairo_create (pixmap);
/* Draw a rectangle with bg[SELECTED] */
style = gtk_widget_get_style (buttonw);
- gdk_draw_rectangle (pixmap,
- style->bg_gc[GTK_STATE_SELECTED],
- TRUE, 0, 0, width + 1, height + 1);
+ gdk_cairo_set_source_color (cr, &(style->bg[GTK_STATE_SELECTED]));
+ cairo_rectangle (cr, 0.0, 0.0, width + 1.0, height + 1.0);
+ cairo_fill (cr);
/* then the image */
- fake_expose_widget (gtk_button_get_image (GTK_BUTTON(button)), pixmap,
+ fake_expose_widget (gtk_button_get_image (GTK_BUTTON (button)), pixmap,
-allocation.x, -allocation.y);
- return pixmap;
-}
-
-static GdkPixmap *
-copy_pixmap (GtkWidget *widget)
-{
- GdkPixmap *pixmap;
- GtkAllocation allocation;
- GtkStyle *style;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
- allocation.width,
- allocation.height, -1);
-
- style = gtk_widget_get_style (widget);
- gdk_draw_drawable (pixmap,
- style->bg_gc[GTK_STATE_NORMAL],
- gtk_widget_get_window (widget),
- allocation.x, allocation.y,
- 0, 0,
- allocation.width, allocation.height);
+ cairo_destroy (cr);
return pixmap;
}
@@ -291,14 +273,17 @@ totem_glow_button_expose (GtkWidget *buttonw,
(* GTK_WIDGET_CLASS (parent_class)->expose_event) (buttonw, event);
- if (button->glow != FALSE && button->screenshot == NULL &&
+ if (button->glow != FALSE && button->screenshot == NULL && button->in_expose == FALSE &&
/* Don't take screenshots if we finished playing animation after
- pointer entered */
+ pointer entered, or if we're already in an expose event. */
(button->pointer_entered != FALSE &&
button->anim_finished != FALSE) == FALSE) {
- button->screenshot = copy_pixmap (buttonw);
+ button->in_expose = TRUE;
+
+ button->screenshot = gtk_widget_get_snapshot (buttonw, NULL);;
button->screenshot_faded = take_screenshot (button);
- return FALSE;
+
+ button->in_expose = FALSE;
}
return FALSE;
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index b04f7f0..d3f5525 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -706,6 +706,7 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
XID window;
GdkWindow *win;
GtkAllocation allocation;
+ cairo_t *cr;
if (event && event->count > 0)
return TRUE;
@@ -729,8 +730,11 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
/* Start with a nice black canvas */
win = gtk_widget_get_window (widget);
gtk_widget_get_allocation (widget, &allocation);
- gdk_draw_rectangle (win, gtk_widget_get_style (widget)->black_gc, TRUE, 0, 0,
- allocation.width, allocation.height);
+
+ cr = gdk_cairo_create (win);
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_paint (cr);
/* If there's only audio and no visualisation, draw the logo as well.
* If we have a cover image to display, we display it regardless of whether we're
@@ -747,11 +751,6 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
GdkPixbuf *logo = NULL;
gint s_width, s_height, d_width, d_height;
gfloat ratio;
- cairo_t *cr;
-
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
s_width = gdk_pixbuf_get_width (pixbuf);
s_height = gdk_pixbuf_get_height (pixbuf);
@@ -787,7 +786,6 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
gdk_cairo_set_source_pixbuf (cr, logo, (allocation.width - s_width) / 2, (allocation.height - s_height) / 2);
cairo_paint (cr);
- cairo_destroy (cr);
g_object_unref (logo);
} else if (win) {
@@ -812,6 +810,8 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
if (xoverlay != NULL)
gst_object_unref (xoverlay);
+ cairo_destroy (cr);
+
return TRUE;
}
diff --git a/src/plugins/screenshot/gnome-screenshot-widget.c b/src/plugins/screenshot/gnome-screenshot-widget.c
index 2862775..6a89cf3 100644
--- a/src/plugins/screenshot/gnome-screenshot-widget.c
+++ b/src/plugins/screenshot/gnome-screenshot-widget.c
@@ -267,6 +267,7 @@ on_preview_expose_event (GtkWidget *drawing_area, GdkEventExpose *event, GnomeSc
GdkPixbuf *pixbuf = NULL;
gboolean free_pixbuf = FALSE;
GtkStyle *style;
+ cairo_t *cr;
style = gtk_widget_get_style (drawing_area);
@@ -289,10 +290,15 @@ on_preview_expose_event (GtkWidget *drawing_area, GdkEventExpose *event, GnomeSc
pixbuf = g_object_ref (self->priv->preview_image);
}
+ cr = gdk_cairo_create (gtk_widget_get_window (drawing_area));
+
/* FIXME: Draw it insensitive in that case */
- gdk_draw_pixbuf (gtk_widget_get_window (drawing_area), style->white_gc, pixbuf, event->area.x, event->area.y, event->area.x, event->area.y,
- event->area.width, event->area.height, GDK_RGB_DITHER_NORMAL, 0, 0);
+ gdk_cairo_rectangle (cr, &(event->area));
+ cairo_clip (cr);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0.0, 0.0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
g_object_unref (pixbuf);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]