Browse files

[glib-demo] Allow using relative paths in demo application

  • Loading branch information...
1 parent a568248 commit 5ee4ff2aaf98e2eaa1ec2dc9f7e659b3b01ba7bf Carlos Garcia Campos committed Jun 20, 2009
Showing with 5 additions and 12 deletions.
  1. +5 −12 glib/demo/main.c
View
17 glib/demo/main.c
@@ -146,6 +146,7 @@ gint main (gint argc, gchar **argv)
GtkWidget *notebook;
GtkWidget *treeview;
GtkTreeSelection *selection;
+ GFile *file;
gchar *uri;
GTimer *timer;
GError *error = NULL;
@@ -161,18 +162,10 @@ gint main (gint argc, gchar **argv)
gtk_init (&argc, &argv);
- if (g_ascii_strncasecmp (argv[1], "file://", strlen ("file://")) == 0) {
- uri = g_strdup (argv[1]);
- } else {
- uri = g_filename_to_uri (argv[1], NULL, &error);
- if (error) {
- g_print ("Error: %s\n", error->message);
- g_error_free (error);
-
- return 1;
- }
- }
-
+ file = g_file_new_for_commandline_arg (argv[1]);
+ uri = g_file_get_uri (file);
+ g_object_unref (file);
+
timer = g_timer_new ();
document = poppler_document_new_from_file (uri, NULL, &error);
g_timer_stop (timer);

0 comments on commit 5ee4ff2

Please sign in to comment.