+static gboolean
+launch_previewer (void)
+{
+ GString *cmd_str;
+ gchar *cmd;
+ gint argc;
+ gchar **argv;
+ gboolean retval = FALSE;
+ GError *error = NULL;
+
+ /* Rebuild the command line, ignoring options
+ * not supported by the previewer and taking only
+ * the first path given
+ */
+ cmd_str = g_string_new ("evince-previewer");
+
+ if (print_settings) {
+ gchar *quoted;
+
+ quoted = g_shell_quote (print_settings);
+ g_string_append_printf (cmd_str, " --print-settings %s", quoted);
+ g_free (quoted);
+ }
+
+ if (unlink_temp_file)
+ g_string_append (cmd_str, " --unlink-tempfile");
+
+ if (file_arguments) {
+ gchar *quoted;
+
+ quoted = g_shell_quote (file_arguments[0]);
+ g_string_append_printf (cmd_str, " %s", quoted);
+ g_free (quoted);
+ }
+
+ cmd = g_string_free (cmd_str, FALSE);
+ g_shell_parse_argv (cmd, &argc, &argv, &error);
+ g_free (cmd);
+
+ if (!error) {
+ retval = gdk_spawn_on_screen (gdk_screen_get_default (),
+ NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL,
+ &error);
+ g_strfreev (argv);
+ }
+
+ if (error) {
+ g_warning ("Error launching previewer: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ return retval;
+}
+