diff --git a/src/planner-main.c b/src/planner-main.c
index 14c1f7c..8a7de03 100644
--- a/src/planner-main.c
+++ b/src/planner-main.c
@@ -92,26 +92,27 @@ main (int argc, char **argv)
 
        gtk_widget_show_all (main_window);
 
-       if (argc > 1) {
-               i = 1;
-               while (argv[i]) {
-                       if (g_str_has_prefix (argv[i], "file:")) {
+        if (args_remaining) {
+               i = 0;
+               char *arg;
+               while ((arg = args_remaining[i++])) {
+                       if (g_str_has_prefix (arg, "file:")) {
                                planner_window_open_in_existing_or_new (
-                                       PLANNER_WINDOW (main_window), argv[i], FALSE);
+                                       PLANNER_WINDOW (main_window), arg, FALSE);
                        } else {
                                gchar *uri;
 
-                               if (!g_path_is_absolute (argv[i])) {
+                               if (!g_path_is_absolute (arg)) {
                                        /* Relative path. */
                                        gchar *cwd, *tmp;
 
                                        cwd = g_get_current_dir ();
-                                       tmp = g_build_filename (cwd, argv[i], NULL);
+                                       tmp = g_build_filename (cwd, arg, NULL);
                                        uri = g_filename_to_uri (tmp, NULL, NULL);
                                        g_free (tmp);
                                        g_free (cwd);
                                } else {
-                                       uri = g_filename_to_uri (argv[i], NULL, NULL);
+                                       uri = g_filename_to_uri (arg, NULL, NULL);
                                }
 
                                if (uri) {
@@ -120,8 +121,6 @@ main (int argc, char **argv)
                                        g_free (uri);
                                }
                        }
-
-                       i++;
                }
        }
 

