X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fmain.c;h=7d4fb0d317b723f8e713a2deaa8a23b3a6b93e0d;hb=5f03f96e78d00dd631bbf21225721a0f1dc2d353;hp=3252f1a5566f6cced574960945bbf43794756cba;hpb=19a00ed1cd086dcca4b6bfeb84e0b1488b2e3089;p=evince.git diff --git a/shell/main.c b/shell/main.c index 3252f1a5..7d4fb0d3 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) @@ -146,6 +143,28 @@ launch_previewer (void) 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) { @@ -171,13 +190,24 @@ load_files (const char **files) mode = EV_WINDOW_MODE_PRESENTATION; for (i = 0; files[i]; i++) { + const gchar *filename; gchar *uri; gchar *label; GFile *file; EvLinkDest *dest = NULL; const gchar *app_uri; - file = g_file_new_for_commandline_arg (files[i]); + filename = files[i]; + label = get_label_from_filename (filename); + if (label) { + *label = 0; + label++; + dest = ev_link_dest_new_page_label (label); + } else if (global_dest) { + dest = g_object_ref (global_dest); + } + + file = g_file_new_for_commandline_arg (filename); uri = g_file_get_uri (file); g_object_unref (file); @@ -187,14 +217,7 @@ load_files (const char **files) continue; } - label = strchr (uri, '#'); - if (label) { - *label = 0; - label++; - dest = ev_link_dest_new_page_label (label); - } else if (global_dest) { - dest = g_object_ref (global_dest); - } + ev_application_open_uri_at_dest (EV_APP, uri, screen, dest, mode, ev_find_string, @@ -243,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 @@ -290,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 ();