Updating branch refs/heads/nick/new-shortcuts-pane-model
         to 84e148d3d35a3dd07d29d244328b84957ec9a876 (commit)
       from 52ce3f8bad65a729c7f927d7f87798c4f48ff94d (commit)

commit 84e148d3d35a3dd07d29d244328b84957ec9a876
Author: Nick Schermer <n...@xfce.org>
Date:   Sun Oct 7 21:25:35 2012 +0200

    Better handling of files without info.
    
    Add function to check if a file has info, with remotes and
    devices this sometimes is not working. Also handle null infos
    better.

 thunar/thunar-file.c           |   27 ++++++++++++++++++++++++++-
 thunar/thunar-file.h           |    2 ++
 thunar/thunar-folder.c         |    8 +++-----
 thunar/thunar-shortcuts-view.c |    2 +-
 4 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index cb93e57..d0c7286 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -1137,6 +1137,28 @@ thunar_file_get_parent (const ThunarFile *file,
 
 
 /**
+ * thunar_file_check_loaded:
+ * @file              : a #ThunarFile instance.
+ *
+ * Check if @file has its information loaded, if not, try this once else
+ * return %FALSE.
+ *
+ * Return value: %TRUE on success, else %FALSE.
+ **/
+gboolean
+thunar_file_check_loaded (ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+
+  if (G_UNLIKELY (file->info == NULL))
+    thunar_file_load (file, NULL, NULL);
+
+  return (file->info != NULL);
+}
+
+
+
+/**
  * thunar_file_execute:
  * @file              : a #ThunarFile instance.
  * @working_directory : the working directory used to resolve relative 
filenames 
@@ -2823,7 +2845,10 @@ thunar_file_get_emblem_names (ThunarFile *file)
   GList    *emblems = NULL;
 
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
-  _thunar_return_val_if_fail (G_IS_FILE_INFO (file->info), NULL);
+
+  /* leave if there is no info */
+  if (file->info == NULL)
+    return NULL;
 
   /* determine the custom emblems */
   emblem_names = g_file_info_get_attribute_stringv (file->info, 
"metadata::emblems");
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index a17325e..ae17d56 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -130,6 +130,8 @@ GFileInfo        *thunar_file_get_info             (const 
ThunarFile       *file
 ThunarFile       *thunar_file_get_parent           (const ThunarFile       
*file,
                                                     GError                
**error);
 
+gboolean          thunar_file_check_loaded         (ThunarFile             
*file);
+
 gboolean          thunar_file_execute              (ThunarFile             
*file,
                                                     GFile                  
*working_directory,
                                                     gpointer                
parent,
diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c
index d50076d..7faaa23 100644
--- a/thunar/thunar-folder.c
+++ b/thunar/thunar-folder.c
@@ -707,11 +707,9 @@ thunar_folder_get_for_file (ThunarFile *file)
 
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
 
-  /* make sure the folder is mounted, this happens when a
-   * mount is entered for the first time */
-  if (thunar_file_get_info (file) == NULL
-      && !thunar_file_is_mounted (file))
-    thunar_file_reload (file);
+  /* make sure the file is loaded */
+  if (!thunar_file_check_loaded (file))
+    return NULL;
 
   _thunar_return_val_if_fail (thunar_file_is_directory (file), NULL);
 
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 03badea..b8d19a3 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -1365,7 +1365,7 @@ thunar_shortcuts_view_poke_file_finish (ThunarBrowser 
*browser,
                                           gtk_widget_get_screen (GTK_WIDGET 
(browser)), NULL);
           g_object_unref (application);
         }
-      else
+      else if (thunar_file_check_loaded (target_file))
         {
           /* invoke the signal to change to that folder */
           g_signal_emit (browser, view_signals[SHORTCUT_ACTIVATED], 0, 
target_file);
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to