[evince] [shell] Don't show crash recovery dialog when requested file is the only one to be recovered



commit c5e6f5a17b28e55076110e1f32a20021aa4be1a6
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Thu Jul 30 13:04:09 2009 +0200

    [shell] Don't show crash recovery dialog when requested file is the only one to be recovered
    
    See bgo#578894

 shell/ev-application.c |   44 +++++++++++++++++++++++++++++++++++++++++---
 shell/ev-application.h |    3 ++-
 shell/main.c           |    2 +-
 3 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 006aad0..8ba99bc 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 2ae2a8a..821f9c5 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 214e9c0..2ad17da 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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]