X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fmain.c;h=ab4b8dfb9ab06fbda8701680168cd052a576eb66;hb=c935a25cdd0c9791158b1252835142472152d6cc;hp=d7d6e158447564f831a23121d97cd94a1cd62af0;hpb=b329a61d561198cd405721372580d05476c2240a;p=evince.git diff --git a/shell/main.c b/shell/main.c index d7d6e158..ab4b8dfb 100644 --- a/shell/main.c +++ b/shell/main.c @@ -41,9 +41,6 @@ #endif /* WITH_SMCLIENT */ #ifdef G_OS_WIN32 -#ifdef DATADIR -#undef DATADIR -#endif #include #include #if !(_WIN32_WINNT >= 0x0500) @@ -95,8 +92,6 @@ launch_previewer (void) { GString *cmd_str; gchar *cmd; - gint argc; - gchar **argv; gboolean retval = FALSE; GError *error = NULL; @@ -126,16 +121,16 @@ launch_previewer (void) } 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); + GAppInfo *app; + + app = g_app_info_create_from_commandline (cmd, NULL, 0, &error); + + if (app != NULL) { + retval = g_app_info_launch (app, NULL, NULL, &error); + g_object_unref (app); + } } if (error) { @@ -143,9 +138,33 @@ launch_previewer (void) g_error_free (error); } + g_free (cmd); + return retval; } +static gchar * +get_label_from_filename (const gchar *filename) +{ + GFile *file; + gchar *label; + gboolean exists; + + label = g_strrstr (filename, "#"); + if (!label) + return NULL; + + /* Filename contains a #, check + * whether it's part of the path + * or a label + */ + file = g_file_new_for_commandline_arg (filename); + exists = g_file_query_exists (file, NULL); + g_object_unref (file); + + return exists ? NULL : label; +} + static void load_files (const char **files) { @@ -179,7 +198,7 @@ load_files (const char **files) const gchar *app_uri; filename = files[i]; - label = strchr (filename, '#'); + label = get_label_from_filename (filename); if (label) { *label = 0; label++; @@ -216,11 +235,6 @@ main (int argc, char *argv[]) GOptionContext *context; GError *error = NULL; -#ifdef WITH_GCONF - /* Remove when porting is done */ - g_setenv ("GSETTINGS_BACKEND", "gconf", FALSE); -#endif - #ifdef G_OS_WIN32 if (fileno (stdout) != -1 && @@ -252,7 +266,7 @@ main (int argc, char *argv[]) #ifdef ENABLE_NLS /* Initialize the i18n stuff */ - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir()); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif @@ -299,14 +313,13 @@ main (int argc, char *argv[]) ev_application_load_session (EV_APP); load_files (file_arguments); - if (ev_application_has_window (EV_APP)) { - /* Change directory so we don't prevent unmounting in case the initial cwd - * is on an external device (see bug #575436) - */ - g_chdir (g_get_home_dir ()); - gtk_main (); - } + /* Change directory so we don't prevent unmounting in case the initial cwd + * is on an external device (see bug #575436) + */ + g_chdir (g_get_home_dir ()); + + gtk_main (); ev_shutdown (); ev_stock_icons_shutdown ();