[Xfce4-commits] <ristretto:ristretto-0.0> If a file in the recent-menu does not exist, show an error-dialog

Stephan Arts noreply at xfce.org
Sun Oct 23 19:16:44 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to 73304079584fdced4a7f58b86daacdb58cb68e7d (commit)
       from 47d300a0eac8bdfb734781b4534a078eebc20d5d (commit)

commit 73304079584fdced4a7f58b86daacdb58cb68e7d
Author: Stephan Arts <stephan at xfce.org>
Date:   Thu May 21 09:52:49 2009 +0200

    If a file in the recent-menu does not exist, show an error-dialog

 ChangeLog         |    6 +++++
 src/main_window.c |   60 ++++++++++++++++++++++++++++++++--------------------
 2 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d77a5f..4ba0c47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,13 @@
 2009-05-21  Stephan Arts <stephan at xfce.org>
 
+	* src/main_window.c: if a file in the recent_menu does not exist, because
+	  it has been deleted, show an error-dialog
+
+2009-05-21  Stephan Arts <stephan at xfce.org>
+
 	* src/main_window.c
 	  src/main_window_ui.xml: Add 'delete' button to remove an image from disk
+	  (Bug #4135)
 	* src/main_window.c: Add accelerators for leaving fullscreen-mode,
 	navigating to the next image and to the previous image using Escape,
 	Page_Up and Page_Down respectively
diff --git a/src/main_window.c b/src/main_window.c
index 2f940b4..251cc6c 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -1117,42 +1117,56 @@ cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *win
     GtkWidget *dialog, *err_dialog;
     gchar *uri = gtk_recent_chooser_get_current_uri (chooser);
     const gchar *filename;
+    GError *error = NULL;
     GFile *file = g_file_new_for_uri (uri);
     GFile *child_file;
     GFileEnumerator *file_enumarator = NULL;
     GFileInfo *child_file_info = NULL;
-    GFileInfo *file_info = g_file_query_info (file, "standard::type", 0, NULL, NULL);
+    GFileInfo *file_info = g_file_query_info (file, "standard::type", 0, NULL, &error);
 
-    if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
+    if (error == NULL)
     {
-        window->priv->busy = TRUE;
-        file_enumarator = g_file_enumerate_children (file, "standard::name", 0, NULL, NULL);
-        while (child_file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
+        if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
         {
-            filename = g_file_info_get_name (child_file_info);
-            child_file = g_file_get_child (file, filename);
+            window->priv->busy = TRUE;
+            file_enumarator = g_file_enumerate_children (file, "standard::name", 0, NULL, NULL);
+            while (child_file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
+            {
+                filename = g_file_info_get_name (child_file_info);
+                child_file = g_file_get_child (file, filename);
 
-            rstto_navigator_add_file (window->priv->props.navigator, child_file, NULL);
+                rstto_navigator_add_file (window->priv->props.navigator, child_file, NULL);
 
-            g_object_unref (child_file);
-            g_object_unref (child_file_info);
-        }
+                g_object_unref (child_file);
+                g_object_unref (child_file_info);
+            }
 
-        window->priv->busy = FALSE;
-        rstto_main_window_navigator_iter_changed (window);
+            window->priv->busy = FALSE;
+            rstto_main_window_navigator_iter_changed (window);
+        }
+        else
+        {
+            if (rstto_navigator_add_file (window->priv->props.navigator, file, NULL) == FALSE)
+            {
+                err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+                                                GTK_DIALOG_MODAL,
+                                                GTK_MESSAGE_ERROR,
+                                                GTK_BUTTONS_OK,
+                                                _("Could not open file"));
+                gtk_dialog_run( GTK_DIALOG(err_dialog));
+                gtk_widget_destroy(err_dialog);
+            }
+        }
     }
     else
     {
-        if (rstto_navigator_add_file (window->priv->props.navigator, file, NULL) == FALSE)
-        {
-            err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
-                                            GTK_DIALOG_MODAL,
-                                            GTK_MESSAGE_ERROR,
-                                            GTK_BUTTONS_OK,
-                                            _("Could not open file"));
-            gtk_dialog_run(GTK_DIALOG(dialog));
-            gtk_widget_destroy(dialog);
-        }
+        err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+                                        GTK_DIALOG_MODAL,
+                                        GTK_MESSAGE_ERROR,
+                                        GTK_BUTTONS_OK,
+                                        _("Could not open file"));
+        gtk_dialog_run (GTK_DIALOG (err_dialog));
+        gtk_widget_destroy (err_dialog);
     }
 
     rstto_main_window_navigator_iter_changed (window);


More information about the Xfce4-commits mailing list