[Xfce4-commits] r30041 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Wed Jun 17 19:57:31 CEST 2009
Author: jannis
Date: 2009-06-17 17:57:30 +0000 (Wed, 17 Jun 2009)
New Revision: 30041
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-file.c
thunar/branches/migration-to-gio/thunar/thunar-file.h
Log:
* 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.
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-06-17 00:27:48 UTC (rev 30040)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-06-17 17:57:30 UTC (rev 30041)
@@ -1,5 +1,21 @@
2009-06-17 Jannis Pohlmann <jannis at 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 at xfce.org>
+
* thunar/thunar-thumbnailer.c: Make all D-Bus related code only
available when D-Bus is installed at compile time.
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-06-17 00:27:48 UTC (rev 30040)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-06-17 17:57:30 UTC (rev 30041)
@@ -591,7 +591,7 @@
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 @@
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,13 +784,25 @@
/* 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,
THUNAR_FILE_G_FILE_INFO_FILESYSTEM_NAMESPACE,
@@ -871,7 +884,17 @@
}
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 @@
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 @@
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 @@
ThunarFileIconState icon_state,
GtkIconTheme *icon_theme)
{
+ GFile *icon_file;
GIcon *icon;
gchar **themed_icon_names;
gchar *icon_name = NULL;
@@ -2597,17 +2638,26 @@
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)
+ 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]);
+ }
+
+ 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_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;
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-06-17 00:27:48 UTC (rev 30040)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-06-17 17:57:30 UTC (rev 30041)
@@ -125,6 +125,7 @@
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 @@
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);
More information about the Xfce4-commits
mailing list