diff options
author | Alexander Larsson <alexl@redhat.com> | 2017-10-23 12:49:42 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2017-10-23 13:45:25 +0200 |
commit | 6f8644ad25f25ca0a874e49d82370df9de4d8de9 (patch) | |
tree | 6711b4814b40589b313a7ddd4c5bca0807f3ebab /tests/testentryicons.c | |
parent | 7a0ce9804f075ddf188d5dce703861c486f40e8a (diff) | |
download | gtk+-6f8644ad25f25ca0a874e49d82370df9de4d8de9.tar.gz |
GtkEntry: Use surfaces, not pixbufs for bitmapped icons
Diffstat (limited to 'tests/testentryicons.c')
-rw-r--r-- | tests/testentryicons.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/testentryicons.c b/tests/testentryicons.c index f4e30797d4..4a8fdb8dab 100644 --- a/tests/testentryicons.c +++ b/tests/testentryicons.c @@ -80,16 +80,20 @@ set_gicon (GtkWidget *button, } static void -set_pixbuf (GtkWidget *button, - GtkEntry *entry) +set_surface (GtkWidget *button, + GtkEntry *entry) { GdkPixbuf *pixbuf; + cairo_surface_t *surface; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) { pixbuf = gdk_pixbuf_new_from_resource ("/org/gtk/libgtk/inspector/logo.png", NULL); - gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_SECONDARY, pixbuf); + surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, gtk_widget_get_window (button)); g_object_unref (pixbuf); + + gtk_entry_set_icon_from_surface (entry, GTK_ENTRY_ICON_SECONDARY, surface); + cairo_surface_destroy (surface); } } @@ -269,10 +273,10 @@ main (int argc, char **argv) gtk_radio_button_join_group (GTK_RADIO_BUTTON (button3), GTK_RADIO_BUTTON (button1)); g_signal_connect (button3, "toggled", G_CALLBACK (set_gicon), entry); gtk_container_add (GTK_CONTAINER (box), button3); - button4 = gtk_radio_button_new_with_label (NULL, "Pixbuf"); + button4 = gtk_radio_button_new_with_label (NULL, "Surface"); gtk_widget_set_valign (button4, GTK_ALIGN_START); gtk_radio_button_join_group (GTK_RADIO_BUTTON (button4), GTK_RADIO_BUTTON (button1)); - g_signal_connect (button4, "toggled", G_CALLBACK (set_pixbuf), entry); + g_signal_connect (button4, "toggled", G_CALLBACK (set_surface), entry); gtk_container_add (GTK_CONTAINER (box), button4); label = gtk_label_new ("Emoji:"); |