[gtk+] tests: add a test for pixbufs implementing the GIcon interface
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tests: add a test for pixbufs implementing the GIcon interface
- Date: Fri, 5 Nov 2010 15:26:52 +0000 (UTC)
commit fcfd494b78e7173054f8f9f77506eb30a8e02741
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Nov 5 10:33:50 2010 +0100
tests: add a test for pixbufs implementing the GIcon interface
https://bugzilla.gnome.org/show_bug.cgi?id=634060
tests/Makefile.am | 6 ++++
tests/testgiconpixbuf.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9daf69a..83b70a5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -48,6 +48,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testfilechooserbutton \
testframe \
testgeometry \
+ testgiconpixbuf \
testgrid \
testgtk \
testheightforwidth \
@@ -139,6 +140,7 @@ testfilechooser_DEPENDENCIES = $(TEST_DEPS)
testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
testframe_DEPENDENCIES = $(TEST_DEPS)
testgeometry_DEPENDENCIES = $(TEST_DEPS)
+testgiconpixbuf = $(TEST_DEPS)
testgrid_DEPENDENCIES = $(TEST_DEPS)
testgtk_DEPENDENCIES = $(TEST_DEPS)
testinput_DEPENDENCIES = $(TEST_DEPS)
@@ -206,6 +208,7 @@ testfilechooser_LDADD = $(LDADDS)
testfilechooserbutton_LDADD = $(LDADDS)
testframe_LDADD = $(LDADDS)
testgeometry_LDADD = $(LDADDS)
+testgiconpixbuf_LDADD = $(LDADDS)
testgrid_LDADD = $(LDADDS)
testgtk_LDADD = $(LDADDS)
testheightforwidth_LDADD = $(LDADDS)
@@ -335,6 +338,9 @@ testframe_SOURCES = \
testgeometry_SOURCES = \
testgeometry.c
+testgiconpixbuf_SOURCES = \
+ testgiconpixbuf.c
+
testiconview_SOURCES = \
testiconview.c \
prop-editor.c
diff --git a/tests/testgiconpixbuf.c b/tests/testgiconpixbuf.c
new file mode 100644
index 0000000..2972b26
--- /dev/null
+++ b/tests/testgiconpixbuf.c
@@ -0,0 +1,74 @@
+/* testgiconpixbuf.c
+ * Copyright (C) 2010 Red Hat, Inc.
+ * Authors: Cosimo Cecchi
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+int
+main (int argc,
+ char **argv)
+{
+ GdkPixbuf *pixbuf, *otherpix;
+ GtkWidget *image, *image2, *hbox, *vbox, *label, *toplevel;
+ GIcon *emblemed;
+ GEmblem *emblem;
+ gchar *str;
+
+ gtk_init (&argc, &argv);
+
+ pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
+ toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12, FALSE);
+ gtk_container_add (GTK_CONTAINER (toplevel), hbox);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12, FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_DIALOG);
+ gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ str = g_strdup_printf ("Normal icon, hash %u", g_icon_hash (G_ICON (pixbuf)));
+ gtk_label_set_label (GTK_LABEL (label), str);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ otherpix = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
+ emblem = g_emblem_new (G_ICON (otherpix));
+ emblemed = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12, FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ image2 = gtk_image_new_from_gicon (emblemed, GTK_ICON_SIZE_DIALOG);
+ gtk_box_pack_start (GTK_BOX (vbox), image2, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ str = g_strdup_printf ("Emblemed icon, hash %u", g_icon_hash (emblemed));
+ gtk_label_set_label (GTK_LABEL (label), str);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (toplevel);
+
+ g_signal_connect (toplevel, "delete-event",
+ G_CALLBACK (gtk_main_quit), NULL);
+
+ gtk_main ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]