[poppler] glib/demo
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Wed Jul 1 00:53:25 PDT 2009
glib/demo/main.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
New commits:
commit 28208d1c9b8afbb769a5f4d9b0655b99fd4af16e
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Wed Jul 1 09:52:12 2009 +0200
[glib-demo] Do not use gio if glib < 2.15
Fixes bug #22530.
diff --git a/glib/demo/main.c b/glib/demo/main.c
index 5973c8e..3026c6c 100644
--- a/glib/demo/main.c
+++ b/glib/demo/main.c
@@ -146,7 +146,6 @@ gint main (gint argc, gchar **argv)
GtkWidget *notebook;
GtkWidget *treeview;
GtkTreeSelection *selection;
- GFile *file;
gchar *uri;
GTimer *timer;
GError *error = NULL;
@@ -158,13 +157,43 @@ gint main (gint argc, gchar **argv)
if (!g_thread_supported ())
g_thread_init (NULL);
-
gtk_init (&argc, &argv);
+#if GLIB_CHECK_VERSION (2,15,0)
+ GFile *file;
+
file = g_file_new_for_commandline_arg (argv[1]);
uri = g_file_get_uri (file);
g_object_unref (file);
+#else
+ if (g_path_is_absolute (argv[1])) {
+ uri = g_filename_to_uri (argv[1], NULL, &error);
+ } else if (g_ascii_strncasecmp (argv[1], "file://", strlen ("file://")) == 0) {
+ uri = g_strdup (argv[1]);
+ } else if (!g_strrstr (argv[1], "://")) {
+ gchar *dir;
+ gchar *filename;
+
+ dir = g_get_current_dir ();
+ filename = g_build_filename (dir, argv[1], NULL);
+ g_free (dir);
+
+ uri = g_filename_to_uri (filename, NULL, &error);
+ g_free (filename);
+ } else {
+ g_print ("Error: unsupported uri\n");
+
+ return 1;
+ }
+
+ if (error) {
+ g_print ("Error: %s\n", error->message);
+ g_error_free (error);
+
+ return 1;
+ }
+#endif /* GLIB_CHECK_VERSION */
timer = g_timer_new ();
document = poppler_document_new_from_file (uri, NULL, &error);
More information about the poppler
mailing list