summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-08-06 22:09:08 +0200
committerBenjamin Otte <otte@redhat.com>2010-08-10 21:02:31 +0200
commit6b19815f877ad9c7f6b6be4ff935d8549087236d (patch)
treedb579dc572bc1f499d7a1a87a8a00fa935adb2e3 /tests
parentad571a3a5e335c4c879ecfb52c6cf0c6331ddafd (diff)
downloadgtk+-6b19815f877ad9c7f6b6be4ff935d8549087236d.tar.gz
testgtk: Use pixbufs instead of pixmaps
This is for creating a GtkImage with an icon.
Diffstat (limited to 'tests')
-rw-r--r--tests/testgtk.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 33c40c021d..5ad59bfc40 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -1252,29 +1252,26 @@ create_button_box (GtkWidget *widget)
*/
static GtkWidget*
-new_pixmap (char *filename,
+new_pixbuf (char *filename,
GdkWindow *window,
GdkColor *background)
{
- GtkWidget *wpixmap;
- GdkPixmap *pixmap;
- GdkBitmap *mask;
+ GtkWidget *widget;
+ GdkPixbuf *pixbuf;
- if (strcmp (filename, "test.xpm") == 0 ||
- !file_exists (filename))
- {
- pixmap = gdk_pixmap_create_from_xpm_d (window, &mask,
- background,
- openfile);
- }
+ if (strcmp (filename, "test.xpm") == 0)
+ pixbuf = NULL;
else
- pixmap = gdk_pixmap_create_from_xpm (window, &mask,
- background,
- filename);
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+
+ if (pixbuf == NULL)
+ pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
- wpixmap = gtk_image_new_from_pixmap (pixmap, mask);
+ widget = gtk_image_new_from_pixbuf (pixbuf);
+
+ g_object_unref (pixbuf);
- return wpixmap;
+ return widget;
}
@@ -1433,7 +1430,7 @@ create_toolbar (GtkWidget *widget)
{
GtkWidget *icon;
- icon = new_pixmap ("test.xpm", window->window,
+ icon = new_pixbuf ("test.xpm", window->window,
&window->style->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, create_toolbar_items[i].label);
}
@@ -1504,7 +1501,7 @@ make_toolbar (GtkWidget *window)
toolitem = gtk_separator_tool_item_new ();
continue;
}
- icon = new_pixmap ("test.xpm", window->window,
+ icon = new_pixbuf ("test.xpm", window->window,
&window->style->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, make_toolbar_items[i].label);
gtk_tool_item_set_tooltip_text (toolitem, make_toolbar_items[i].tooltip);
@@ -2920,7 +2917,7 @@ create_pixmap (GtkWidget *widget)
button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
- pixmapwid = new_pixmap ("test.xpm", window->window, NULL);
+ pixmapwid = new_pixbuf ("test.xpm", window->window, NULL);
label = gtk_label_new ("Pixmap\ntest");
box3 = gtk_hbox_new (FALSE, 0);
@@ -2932,7 +2929,7 @@ create_pixmap (GtkWidget *widget)
button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
- pixmapwid = new_pixmap ("test.xpm", window->window, NULL);
+ pixmapwid = new_pixbuf ("test.xpm", window->window, NULL);
label = gtk_label_new ("Pixmap\ntest");
box3 = gtk_hbox_new (FALSE, 0);