[gnome-screenshot] dialog: use gtk_render_icon()
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screenshot] dialog: use gtk_render_icon()
- Date: Tue, 25 Oct 2011 14:02:16 +0000 (UTC)
commit 9712e4b75093a69745e014d9aee96e50ebc0407d
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Oct 25 09:44:29 2011 -0400
dialog: use gtk_render_icon()
Instead of deprecated GtkStyle functions.
src/screenshot-dialog.c | 34 ++++++----------------------------
1 files changed, 6 insertions(+), 28 deletions(-)
---
diff --git a/src/screenshot-dialog.c b/src/screenshot-dialog.c
index d6d954d..f51c2cc 100644
--- a/src/screenshot-dialog.c
+++ b/src/screenshot-dialog.c
@@ -53,37 +53,15 @@ on_preview_draw (GtkWidget *drawing_area,
gpointer data)
{
ScreenshotDialog *dialog = data;
- GdkPixbuf *pixbuf = NULL;
+ GtkStyleContext *context;
- /* Stolen from GtkImage. I really should just make the drawing area an
- * image some day */
- if (gtk_widget_get_state (drawing_area) != GTK_STATE_NORMAL)
- {
- GtkIconSource *source;
-
- source = gtk_icon_source_new ();
- gtk_icon_source_set_pixbuf (source, dialog->preview_image);
- gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
- gtk_icon_source_set_size_wildcarded (source, FALSE);
-
- pixbuf = gtk_style_render_icon (gtk_widget_get_style (drawing_area),
- source,
- gtk_widget_get_direction (drawing_area),
- gtk_widget_get_state (drawing_area),
- (GtkIconSize) -1,
- drawing_area,
- "gtk-image");
- gtk_icon_source_free (source);
- }
- else
- {
- pixbuf = g_object_ref (dialog->preview_image);
- }
+ context = gtk_widget_get_style_context (drawing_area);
+ gtk_style_context_save (context);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
+ gtk_style_context_set_state (context, gtk_widget_get_state_flags (drawing_area));
+ gtk_render_icon (context, cr, dialog->preview_image, 0, 0);
- g_object_unref (pixbuf);
+ gtk_style_context_restore (context);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]