+value_free (GValue *value)
+{
+ g_value_unset (value);
+ g_free (value);
+}
+
+/**
+ * arguments_parse:
+ *
+ * Parses the arguments and creates a #GHashTable with this data.
+ *
+ * key -> value
+ *
+ * dislay -> display at the default screen.
+ * screen -> screen number.
+ * page-label -> only if the page label argument has been passed,
+ * the page of the document to display.
+ * mode -> only if the view mode is one of the availables,
+ * the view mode.
+ * unlink-temp-file -> only if the view mode is preview mode and
+ * unlink-temp-file has been passed, unlink-temp-file.
+ *
+ * Returns: a pointer into #GHashTable with data from the arguments.
+ */
+static GHashTable *
+arguments_parse (void)
+{
+ GHashTable *args;
+ GValue *value;
+ EvWindowRunMode mode;
+ GdkScreen *screen;
+ GdkDisplay *display;
+ const gchar *display_name;
+ gint screen_number;
+
+ args = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)value_free);
+
+ screen = gdk_screen_get_default ();
+ display = gdk_screen_get_display (screen);
+
+ display_name = gdk_display_get_name (display);
+ screen_number = gdk_screen_get_number (screen);
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, display_name);
+ g_hash_table_insert (args, g_strdup ("display"), value);
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, screen_number);
+ g_hash_table_insert (args, g_strdup ("screen"), value);
+
+ if (ev_page_label) {
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, ev_page_label);
+
+ g_hash_table_insert (args, g_strdup ("page-label"), value);
+
+ g_free (ev_page_label);
+ ev_page_label = NULL;
+ }
+
+ if (ev_find_string) {
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, ev_find_string);
+
+ g_hash_table_insert (args, g_strdup ("find-string"), value);
+
+ g_free (ev_find_string);
+ ev_page_label = NULL;
+ }
+
+ if (fullscren_mode)
+ mode = EV_WINDOW_MODE_FULLSCREEN;
+ else if (presentation_mode)
+ mode = EV_WINDOW_MODE_PRESENTATION;
+ else if (preview_mode)
+ mode = EV_WINDOW_MODE_PREVIEW;
+ else
+ return args;
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_UINT);
+ g_value_set_uint (value, mode);
+
+ g_hash_table_insert (args, g_strdup ("mode"), value);
+
+ if (mode == EV_WINDOW_MODE_PREVIEW && unlink_temp_file) {
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value, unlink_temp_file);
+
+ g_hash_table_insert (args,
+ g_strdup ("unlink-temp-file"),
+ value);
+ }
+
+ if (mode == EV_WINDOW_MODE_PREVIEW && print_settings) {
+ value = g_new0 (GValue, 1);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, print_settings);
+
+ g_hash_table_insert (args,
+ g_strdup ("print-settings"),
+ value);
+ g_free (print_settings);
+ print_settings = NULL;
+ }
+
+ return args;
+}
+
+static void
+load_files (const char **files,
+ GHashTable *args)