From: Carlos Garcia Campos Date: Thu, 30 Jul 2009 11:04:09 +0000 (+0200) Subject: [shell] Don't show crash recovery dialog when requested file is the only one to be... X-Git-Tag: EVINCE_2_27_90~16 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=c5e6f5a17b28e55076110e1f32a20021aa4be1a6;p=evince.git [shell] Don't show crash recovery dialog when requested file is the only one to be recovered See bgo#578894 --- diff --git a/shell/ev-application.c b/shell/ev-application.c index 006aad00..8ba99bc1 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -256,11 +256,48 @@ save_session_crashed_in_idle (EvApplication *application) } static gboolean -ev_application_run_crash_recovery_dialog (EvApplication *application) +ev_application_run_crash_recovery_dialog (EvApplication *application, + const gchar **files) { GtkWidget *dialog; gint response; + /* Do not show the recover dialog if the requested file is the + * only one to be recovered + */ + if (files && g_strv_length ((gchar **)files) == 1) { + GKeyFile *state_file; + gchar **uri_list; + + state_file = g_key_file_new (); + g_key_file_load_from_file (state_file, + application->crashed_file, + G_KEY_FILE_NONE, + NULL); + uri_list = g_key_file_get_string_list (state_file, + "Evince", + "documents", + NULL, NULL); + if (uri_list && g_strv_length (uri_list) == 1) { + GFile *file; + gchar *uri; + + file = g_file_new_for_commandline_arg (files[0]); + uri = g_file_get_uri (file); + g_object_unref (file); + if (g_ascii_strcasecmp (uri, uri_list[0]) == 0) { + g_strfreev (uri_list); + g_key_file_free (state_file); + g_free (uri); + + return FALSE; + } + g_free (uri); + g_strfreev (uri_list); + } + g_key_file_free (state_file); + } + dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, @@ -292,7 +329,8 @@ ev_application_run_crash_recovery_dialog (EvApplication *application) #endif /* ENABLE_DBUS */ gboolean -ev_application_load_session (EvApplication *application) +ev_application_load_session (EvApplication *application, + const gchar **files) { GKeyFile *state_file; gchar **uri_list; @@ -306,7 +344,7 @@ ev_application_load_session (EvApplication *application) #endif /* WITH_SMCLIENT */ #ifdef ENABLE_DBUS if (g_file_test (application->crashed_file, G_FILE_TEST_IS_REGULAR)) { - if (ev_application_run_crash_recovery_dialog (application)) { + if (ev_application_run_crash_recovery_dialog (application, files)) { state_file = g_key_file_new (); g_key_file_load_from_file (state_file, application->crashed_file, diff --git a/shell/ev-application.h b/shell/ev-application.h index 2ae2a8a0..821f9c52 100644 --- a/shell/ev-application.h +++ b/shell/ev-application.h @@ -53,7 +53,8 @@ EvApplication *ev_application_get_instance (void); gboolean ev_application_register_service (EvApplication *application); void ev_application_shutdown (EvApplication *application); -gboolean ev_application_load_session (EvApplication *application); +gboolean ev_application_load_session (EvApplication *application, + const gchar **files); gboolean ev_application_open_window (EvApplication *application, GHashTable *args, guint32 timestamp, diff --git a/shell/main.c b/shell/main.c index 214e9c0e..2ad17da5 100644 --- a/shell/main.c +++ b/shell/main.c @@ -485,7 +485,7 @@ main (int argc, char *argv[]) gtk_window_set_default_icon_name ("evince"); #endif /* WITH_SMCLIENT && GDK_WINDOWING_X11 */ - ev_application_load_session (EV_APP); + ev_application_load_session (EV_APP, file_arguments); load_files (file_arguments, args); g_hash_table_destroy (args);