libgnomeui r5585 - trunk/test-gnome
- From: kmaraas svn gnome org
- To: svn-commits-list gnome org
- Subject: libgnomeui r5585 - trunk/test-gnome
- Date: Sun, 16 Mar 2008 12:38:59 +0000 (GMT)
Author: kmaraas
Date: Sun Mar 16 12:38:59 2008
New Revision: 5585
URL: http://svn.gnome.org/viewvc/libgnomeui?rev=5585&view=rev
Log:
Forgot this file
Added:
trunk/test-gnome/testgnomegdkpixbuf.c
Added: trunk/test-gnome/testgnomegdkpixbuf.c
==============================================================================
--- (empty file)
+++ trunk/test-gnome/testgnomegdkpixbuf.c Sun Mar 16 12:38:59 2008
@@ -0,0 +1,101 @@
+
+#include <config.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <gio/gio.h>
+#include <libgnomeui.h>
+#include <libgnomeui/gnome-thumbnail.h>
+
+static gboolean async_ok;
+
+static void
+pixbuf_done (GnomeGdkPixbufAsyncHandle *handle, gpointer user_data)
+{
+ gtk_main_quit ();
+}
+
+static void
+pixbuf_loaded (GnomeGdkPixbufAsyncHandle *handle,
+ GnomeVFSResult error,
+ GdkPixbuf *pixbuf,
+ gpointer user_data)
+{
+ if (pixbuf != NULL) {
+ GError *error = NULL;
+
+ if (!gdk_pixbuf_save (pixbuf, "pixbuf-async.png", "png", &error, NULL)) {
+ g_warning ("Error saving file pixbuf-async.png: %s", error->message);
+ } else {
+ async_ok = TRUE;
+ }
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ int ret;
+ char *uri;
+ GdkPixbuf *pixbuf;
+ GFile *file;
+ GError *error;
+ GnomeGdkPixbufAsyncHandle *handle;
+
+ uri = NULL;
+ error = NULL;
+ async_ok = FALSE;
+ ret = 1;
+
+ gtk_init (&argc, &argv);
+
+ if (argc != 2) {
+ g_warning ("usage: %s <uri_to_imagefile>", argv[0]);
+ goto out;
+ }
+
+ /* this is a cheap trick to get file:/// properly appended */
+ file = g_file_new_for_commandline_arg (argv[1]);
+ uri = g_file_get_uri (file);
+ g_object_unref (file);
+
+ /* first, test the sync version */
+ g_message ("Using gnome_gdk_pixbuf_new_from_uri() to load file with uri '%s'", uri);
+
+ pixbuf = gnome_gdk_pixbuf_new_from_uri (uri);
+ if (pixbuf == NULL) {
+ g_warning ("gnome_gdk_pixbuf_new_from_uri() failed");
+ goto out;
+ }
+ if (!gdk_pixbuf_save (pixbuf, "pixbuf-sync.png", "png", &error, NULL)) {
+ g_warning ("Error saving file pixbuf-sync.png: %s", error->message);
+ goto out;
+ }
+ g_object_unref (pixbuf);
+
+ g_message ("Saved pixbuf to pixbuf-sync.png");
+
+ /* now, the async version */
+ g_message ("Using gnome_gdk_pixbuf_new_from_uri_async() to load file with uri '%s'", uri);
+
+ handle = gnome_gdk_pixbuf_new_from_uri_async (uri,
+ pixbuf_loaded,
+ pixbuf_done,
+ NULL);
+
+ gtk_main ();
+
+ if (!async_ok) {
+ g_warning ("Error saving file pixbuf-async.png");
+ goto out;
+ }
+
+ g_message ("Saved pixbuf to pixbuf-async.png");
+
+ ret = 0;
+
+out:
+ g_free (uri);
+ return ret;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]