]> www.fi.muni.cz Git - evince.git/commitdiff
[shell] Don't show crash recovery dialog when requested file is the only one to be...
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 30 Jul 2009 11:04:09 +0000 (13:04 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 30 Jul 2009 11:04:09 +0000 (13:04 +0200)
See bgo#578894

shell/ev-application.c
shell/ev-application.h
shell/main.c

index 006aad00afccc4e454c6a70e76b25dfe6fb92237..8ba99bc1e908f6aad13571a7b0d488d999028ce0 100644 (file)
@@ -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,
index 2ae2a8a05f245037e4d68d444d45498c7962c344..821f9c52a2cb809518ab0c9866eabd40ae4d2be0 100644 (file)
@@ -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,
index 214e9c0e2ea77625e246411488cc946adac31d5e..2ad17da562db4c9e6abc1b9ba07750da65dfa4a4 100644 (file)
@@ -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);