diff options
author | Jannis Pohlmann <jannis@xfce.org> | 2009-06-17 17:57:30 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis@xfce.org> | 2009-06-17 17:57:30 +0000 |
commit | 92ae8573323125744390723483818b9867261186 (patch) | |
tree | e984f7fb93faaa13712efc951ae99604d2e5507e | |
parent | 1f08f689e31e59b9ddb793ab013863ba669d20a9 (diff) | |
download | thunar-92ae8573323125744390723483818b9867261186.tar.gz |
* thunar/thunar-file.{c,h}: Add new boolean is_mounted member to
ThunarFile. It is FALSE iff the GFileInfo of the file couldn't be
loaded due to G_IO_ERROR_NO_MOUNTED. Return TRUE from
thunar_file_load() only when the file info could be loaded or the
file is not mounted yet. Use the path instead of the file:// URI for
the display name of local files. Add new method
thunar_file_is_mounted(). Add support for GFileIcons in
thunar_file_get_icon_name() by returning the path to the icon
filename if the file has a GFileIcon. Call thunar_file_reload()
instead of thunar_file_destroy() on G_FILE_MONITOR_EVENT_DELETED and
G_FILE_MONITOR_EVEN_PRE_UNMOUNT. The reload function will then
destroy the file if it doesn't exist anymore. Not mounted files will
not be destroyed though.
(Old svn revision: 30041)
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | thunar/thunar-file.c | 82 | ||||
-rw-r--r-- | thunar/thunar-file.h | 2 |
3 files changed, 83 insertions, 17 deletions
@@ -1,5 +1,21 @@ 2009-06-17 Jannis Pohlmann <jannis@xfce.org> + * thunar/thunar-file.{c,h}: Add new boolean is_mounted member to + ThunarFile. It is FALSE iff the GFileInfo of the file couldn't be + loaded due to G_IO_ERROR_NO_MOUNTED. Return TRUE from + thunar_file_load() only when the file info could be loaded or the + file is not mounted yet. Use the path instead of the file:// URI for + the display name of local files. Add new method + thunar_file_is_mounted(). Add support for GFileIcons in + thunar_file_get_icon_name() by returning the path to the icon + filename if the file has a GFileIcon. Call thunar_file_reload() + instead of thunar_file_destroy() on G_FILE_MONITOR_EVENT_DELETED and + G_FILE_MONITOR_EVEN_PRE_UNMOUNT. The reload function will then + destroy the file if it doesn't exist anymore. Not mounted files will + not be destroyed though. + +2009-06-17 Jannis Pohlmann <jannis@xfce.org> + * thunar/thunar-thumbnailer.c: Make all D-Bus related code only available when D-Bus is installed at compile time. diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 648aa29e..4f8dece4 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -591,7 +591,7 @@ thunar_file_monitor_update (GFile *path, case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: case G_FILE_MONITOR_EVENT_DELETED: - thunar_file_destroy (file); + thunar_file_reload (file); break; default: @@ -742,11 +742,12 @@ thunar_file_load (ThunarFile *file, GError **error) { GKeyFile *key_file; + GError *err = NULL; GFile *thumbnail_dir; gchar *basename; gchar *md5_hash; gchar *thumbnail_dir_path; - gchar *uri; + gchar *uri = NULL; _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -783,12 +784,24 @@ thunar_file_load (ThunarFile *file, /* free thumbnail path */ g_free (file->thumbnail_path); + /* assume the file is mounted by default */ + file->is_mounted = TRUE; + /* query a new file info */ file->info = g_file_query_info (file->gfile, THUNAR_FILE_G_FILE_INFO_NAMESPACE, G_FILE_QUERY_INFO_NONE, cancellable, - NULL); + &err); + + if (err != NULL) + { + if (err->domain == G_IO_ERROR && err->code == G_IO_ERROR_NOT_MOUNTED) + { + file->is_mounted = FALSE; + g_clear_error (&err); + } + } /* query a new filesystem info */ file->filesystem_info = g_file_query_filesystem_info (file->gfile, @@ -871,7 +884,17 @@ thunar_file_load (ThunarFile *file, } else { - uri = g_file_get_uri (file->gfile); + if (g_file_is_native (file->gfile)) + { + uri = g_file_get_path (file->gfile); + if (uri == NULL) + uri = g_file_get_uri (file->gfile); + } + else + { + uri = g_file_get_uri (file->gfile); + } + file->display_name = g_filename_display_name (uri); g_free (uri); } @@ -891,7 +914,15 @@ thunar_file_load (ThunarFile *file, g_free (md5_hash); g_free (uri); - return TRUE; + if (err != NULL) + { + g_propagate_error (error, err); + return FALSE; + } + else + { + return TRUE; + } } /** @@ -1876,10 +1907,19 @@ thunar_file_get_free_space (const ThunarFile *file, gboolean +thunar_file_is_mounted (const ThunarFile *file) +{ + _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); + return file->is_mounted; +} + + + +gboolean thunar_file_exists (const ThunarFile *file) { _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); - return (file->info != NULL); + return g_file_query_exists (file->gfile, NULL); } @@ -2584,6 +2624,7 @@ thunar_file_get_icon_name (const ThunarFile *file, ThunarFileIconState icon_state, GtkIconTheme *icon_theme) { + GFile *icon_file; GIcon *icon; gchar **themed_icon_names; gchar *icon_name = NULL; @@ -2597,17 +2638,26 @@ thunar_file_get_icon_name (const ThunarFile *file, icon = g_file_info_get_icon (file->info); - if (icon != NULL && G_IS_THEMED_ICON (icon)) + if (icon != NULL) { - g_object_get (icon, "names", &themed_icon_names, NULL); + if (G_IS_THEMED_ICON (icon)) + { + g_object_get (icon, "names", &themed_icon_names, NULL); + + for (i = 0; icon_name == NULL && themed_icon_names[i] != NULL; ++i) + { + if (gtk_icon_theme_has_icon (icon_theme, themed_icon_names[i])) + icon_name = g_strdup (themed_icon_names[i]); + } - for (i = 0; icon_name == NULL && themed_icon_names[i] != NULL; ++i) + g_strfreev (themed_icon_names); + } + else if (G_IS_FILE_ICON (icon)) { - if (gtk_icon_theme_has_icon (icon_theme, themed_icon_names[i])) - icon_name = g_strdup (themed_icon_names[i]); + icon_file = g_file_icon_get_file (G_FILE_ICON (icon)); + icon_name = g_file_get_path (icon_file); + g_object_unref (icon_file); } - - g_strfreev (themed_icon_names); } if (icon_name == NULL) @@ -2806,11 +2856,9 @@ thunar_file_reload (ThunarFile *file) { _thunar_return_if_fail (THUNAR_IS_FILE (file)); - thunar_file_load (file, NULL, NULL); - - /* destroy the file if we cannot query any file information */ - if (file->info == NULL) + if (!thunar_file_load (file, NULL, NULL)) { + /* destroy the file if we cannot query any file information */ thunar_file_destroy (file); return; } diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index ae7ebb90..670a61c1 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -125,6 +125,7 @@ struct _ThunarFile gchar *thumbnail_path; guint flags; guint is_thumbnail : 1; + guint is_mounted : 1; }; GType thunar_file_get_type (void) G_GNUC_CONST; @@ -187,6 +188,7 @@ GFileType thunar_file_get_kind (const ThunarFile *file ThunarFileMode thunar_file_get_mode (const ThunarFile *file); gboolean thunar_file_get_free_space (const ThunarFile *file, guint64 *free_space_return); +gboolean thunar_file_is_mounted (const ThunarFile *file); gboolean thunar_file_exists (const ThunarFile *file); gboolean thunar_file_is_directory (const ThunarFile *file); gboolean thunar_file_is_local (const ThunarFile *file); |