[gnome-desktop] lib: Add thumbnail test application



commit cb04925f212b18235de6d9cfa4649c44297113eb
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 24 17:20:20 2012 +0200

    lib: Add thumbnail test application

 libgnome-desktop/Makefile.am              |    4 ++-
 libgnome-desktop/test-desktop-thumbnail.c |   37 +++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/libgnome-desktop/Makefile.am b/libgnome-desktop/Makefile.am
index f4c68cf..df060b3 100644
--- a/libgnome-desktop/Makefile.am
+++ b/libgnome-desktop/Makefile.am
@@ -133,7 +133,7 @@ gnome_rr_debug_LDADD =		\
 	$(lib_LTLIBRARIES)	\
 	$(XLIB_LIBS)
 
-noinst_PROGRAMS = test-xkb-info test-pnp-ids test-wall-clock
+noinst_PROGRAMS = test-xkb-info test-pnp-ids test-wall-clock test-desktop-thumbnail
 test_xkb_info_LDADD =		\
 	$(GNOME_DESKTOP_LIBS)	\
 	$(lib_LTLIBRARIES)	\
@@ -143,4 +143,6 @@ test_pnp_ids_LDADD = $(test_xkb_info_LDADD)
 
 test_wall_clock_LDADD = $(test_xkb_info_LDADD)
 
+test_desktop_thumbnail_LDADD = $(test_xkb_info_LDADD)
+
 -include $(top_srcdir)/git.mk
diff --git a/libgnome-desktop/test-desktop-thumbnail.c b/libgnome-desktop/test-desktop-thumbnail.c
new file mode 100644
index 0000000..7410d76
--- /dev/null
+++ b/libgnome-desktop/test-desktop-thumbnail.c
@@ -0,0 +1,37 @@
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-desktop-thumbnail.h>
+#include <gtk/gtk.h>
+
+int main (int argc, char **argv)
+{
+	GdkPixbuf *pixbuf;
+	GnomeDesktopThumbnailFactory *factory;
+	GtkWidget *window, *image;
+	char *content_type;
+
+	gtk_init (&argc, &argv);
+
+	if (argc < 2) {
+		g_print ("Usage: %s FILE...\n", argv[0]);
+		return 1;
+	}
+
+	content_type = g_content_type_guess (argv[1], NULL, 0, NULL);
+	factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
+	pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, argv[1], content_type);
+	g_free (content_type);
+
+	if (pixbuf == NULL) {
+		g_warning ("gnome_desktop_thumbnail_factory_generate_thumbnail() failed to generate a thumbnail for %s", argv[1]);
+		return 1;
+	}
+
+	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+	image = gtk_image_new_from_pixbuf (pixbuf);
+	gtk_container_add (GTK_CONTAINER (window), image);
+	gtk_widget_show_all (window);
+
+	gtk_main ();
+
+	return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]