diff options
author | Benjamin Otte <otte@redhat.com> | 2018-04-12 01:40:38 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-04-12 14:03:58 +0200 |
commit | 9cecf123f3fbb80c81659436f9c64fc88b353e30 (patch) | |
tree | aa966e9909e2a500b597188d4a6fc4916c50a7e5 /demos | |
parent | af6b2cdb378c0af700a7f0ebe0310d6f4e0d6176 (diff) | |
download | gtk+-9cecf123f3fbb80c81659436f9c64fc88b353e30.tar.gz |
widget-factory: Use a pixbuf instead of a surface
This gets rid of the last user of
gdk_cairo_surface_create_from_pixbuf().
Diffstat (limited to 'demos')
-rw-r--r-- | demos/widget-factory/widget-factory.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 60dbd07ceb..8627c1d5a5 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -1082,7 +1082,7 @@ set_accel (GtkApplication *app, GtkWidget *widget) typedef struct { GtkTextView tv; - cairo_surface_t *surface; + GdkPixbuf *pixbuf; } MyTextView; typedef GtkTextViewClass MyTextViewClass; @@ -1101,10 +1101,10 @@ my_tv_draw_layer (GtkTextView *widget, { MyTextView *tv = (MyTextView *)widget; - if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->surface) + if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->pixbuf) { cairo_save (cr); - cairo_set_source_surface (cr, tv->surface, 0.0, 0.0); + gdk_cairo_set_source_pixbuf (cr, tv->pixbuf, 0.0, 0.0); cairo_paint_with_alpha (cr, 0.333); cairo_restore (cr); } @@ -1115,8 +1115,7 @@ my_tv_finalize (GObject *object) { MyTextView *tv = (MyTextView *)object; - if (tv->surface) - cairo_surface_destroy (tv->surface); + g_clear_object (&tv->pixbuf); G_OBJECT_CLASS (my_text_view_parent_class)->finalize (object); } @@ -1134,18 +1133,14 @@ my_text_view_class_init (MyTextViewClass *class) static void my_text_view_set_background (MyTextView *tv, const gchar *filename) { - GdkPixbuf *pixbuf; GError *error = NULL; - if (tv->surface) - cairo_surface_destroy (tv->surface); - - tv->surface = NULL; + g_clear_object (&tv->pixbuf); if (filename == NULL) return; - pixbuf = gdk_pixbuf_new_from_file (filename, &error); + tv->pixbuf = gdk_pixbuf_new_from_file (filename, &error); if (error) { g_warning ("%s", error->message); @@ -1153,10 +1148,6 @@ my_text_view_set_background (MyTextView *tv, const gchar *filename) return; } - tv->surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL); - - g_object_unref (pixbuf); - gtk_widget_queue_draw (GTK_WIDGET (tv)); } |