[Xfce4-commits] r29774 - in thunar/branches/migration-to-gio: . thunar

Jannis Pohlmann jannis at xfce.org
Sun Apr 12 02:33:37 CEST 2009


Author: jannis
Date: 2009-04-12 00:33:36 +0000 (Sun, 12 Apr 2009)
New Revision: 29774

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
   thunar/branches/migration-to-gio/thunar/thunar-list-model.c
   thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c
Log:
	* thunar/thunar-file.{c,h}: Add GFileInfo filesystem info member to
	  ThunarFile. Initialize it in thunar_file_load(), otherwise make sure
	  it's set to NULL. Make thunar_file_get_default_handler(),
	  thunar_file_get_kind(), thunar_file_get_mode(),
	  thunar_file_get_free_space(), thunar_file_is_directory() real
	  functions and make them use GFile/GFileInfo.
	* thunar/thunar-list-model.c, thunar/thunar-properties-dialog.c: Use
	  guint64 instead of ThunarVfsFileSize. Use g_file_size_humanize()
	  instead of thunar_vfs_humanize_size().

Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog	2009-04-11 23:31:23 UTC (rev 29773)
+++ thunar/branches/migration-to-gio/ChangeLog	2009-04-12 00:33:36 UTC (rev 29774)
@@ -1,5 +1,17 @@
 2009-04-12	Jannis Pohlmann <jannis at xfce.org>
 
+	* thunar/thunar-file.{c,h}: Add GFileInfo filesystem info member to
+	  ThunarFile. Initialize it in thunar_file_load(), otherwise make sure
+	  it's set to NULL. Make thunar_file_get_default_handler(),
+	  thunar_file_get_kind(), thunar_file_get_mode(),
+	  thunar_file_get_free_space(), thunar_file_is_directory() real
+	  functions and make them use GFile/GFileInfo. 
+	* thunar/thunar-list-model.c, thunar/thunar-properties-dialog.c: Use
+	  guint64 instead of ThunarVfsFileSize. Use g_file_size_humanize()
+	  instead of thunar_vfs_humanize_size().
+
+2009-04-12	Jannis Pohlmann <jannis at xfce.org>
+
 	* thunar/thunar-clipboard-manager.c: Use a GFile list and
 	  thunar_file_list_to_g_file_list() instead of the ThunarVFS
 	  equivalents in thunar_clipboard_manager_get_callback().

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c	2009-04-11 23:31:23 UTC (rev 29773)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c	2009-04-12 00:33:36 UTC (rev 29774)
@@ -314,9 +314,15 @@
   if ((file->flags & THUNAR_FILE_OWNS_METAFILE_REFERENCE) != 0)
     g_object_unref (G_OBJECT (metafile));
 
-  /* release GIO data */
+  /* release file info */
   if (file->ginfo != NULL)
     g_object_unref (file->ginfo);
+
+  /* release filesystem info */
+  if (file->filesystem_info != NULL)
+    g_object_unref (file->filesystem_info);
+
+  /* release file */
   g_object_unref (file->gfile);
 
   /* release the file info */
@@ -612,6 +618,7 @@
       file = g_object_new (THUNAR_TYPE_FILE, NULL);
       file->gfile = g_object_ref (gfile);
       file->ginfo = NULL;
+      file->filesystem_info = NULL;
       file->info = info;
 
       thunar_file_load (file, NULL, error);
@@ -667,11 +674,16 @@
           file->info = thunar_vfs_info_ref (info);
 
           g_object_unref (file->gfile);
+
           if (file->ginfo != NULL)
             g_object_unref (file->ginfo);
 
+          if (file->filesystem_info != NULL)
+            g_object_unref (file->filesystem_info);
+
           file->gfile = g_object_ref (gfile);
           file->ginfo = NULL;
+          file->filesystem_info = NULL;
 
           thunar_file_load (file, NULL, NULL);
 
@@ -686,6 +698,7 @@
 
       file->gfile = g_object_ref (gfile);
       file->ginfo = NULL;
+      file->filesystem_info = NULL;
 
       thunar_file_load (file, NULL, NULL);
 
@@ -828,13 +841,23 @@
       file->ginfo = NULL;
     }
 
+  if (file->filesystem_info != NULL)
+    {
+      g_object_unref (file->filesystem_info);
+      file->filesystem_info = NULL;
+    }
+
   file->ginfo = g_file_query_info (file->gfile,
-                                   THUNAR_FILE_G_FILE_INFO_NAMESPACE ","
-                                   THUNAR_FILE_G_FILE_INFO_FILESYSTEM_NAMESPACE,
+                                   THUNAR_FILE_G_FILE_INFO_NAMESPACE,
                                    G_FILE_QUERY_INFO_NONE,
                                    cancellable,
                                    error);
 
+  file->filesystem_info = g_file_query_filesystem_info (file->gfile,
+                                                        THUNAR_FILE_G_FILE_INFO_FILESYSTEM_NAMESPACE,
+                                                        cancellable,
+                                                        NULL);
+
   /* FIXME This is just temporary */
   g_assert (file->ginfo != NULL);
 
@@ -1545,6 +1568,111 @@
 
 
 /**
+ * thunar_file_get_default_handler:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the default #GAppInfo for @file or %NULL if there is none.
+ * 
+ * The caller is responsible to free the returned #GAppInfo using
+ * g_object_unref().
+ *
+ * Return value: Default #GAppInfo for @file or %NULL if there is none.
+ **/
+GAppInfo *
+thunar_file_get_default_handler (const ThunarFile *file) 
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
+  return g_file_query_default_handler (THUNAR_FILE ((file))->gfile, NULL, NULL);
+}
+
+
+
+/**
+ * thunar_file_get_kind:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the kind of @file.
+ *
+ * Return value: the kind of @file.
+ **/
+GFileType
+thunar_file_get_kind (const ThunarFile *file) 
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), G_FILE_TYPE_UNKNOWN);
+  _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), G_FILE_TYPE_UNKNOWN);
+  return g_file_info_get_file_type (file->ginfo);
+}
+
+
+
+/**
+ * thunar_file_get_mode:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the permission bits of @file.
+ *
+ * Return value: the permission bits of @file.
+ **/
+ThunarFileMode
+thunar_file_get_mode (const ThunarFile *file) 
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), 0);
+  _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), 0);
+  return g_file_info_get_attribute_uint32 (file->ginfo, G_FILE_ATTRIBUTE_UNIX_MODE);
+}
+
+
+
+/**
+ * thunar_file_get_free_space:
+ * @file              : a #ThunarFile instance.
+ * @free_space_return : return location for the amount of
+ *                      free space or %NULL.
+ *
+ * Determines the amount of free space of the volume on
+ * which @file resides. Returns %TRUE if the amount of
+ * free space was determined successfully and placed into
+ * @free_space_return, else %FALSE will be returned.
+ *
+ * Return value: %TRUE if successfull, else %FALSE.
+ **/
+gboolean
+thunar_file_get_free_space (const ThunarFile *file, 
+                            guint64          *free_space_return) 
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+
+  if (file->filesystem_info == NULL)
+    return FALSE;
+
+  *free_space_return = g_file_info_get_attribute_uint64 (file->filesystem_info,
+                                                         G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+  
+  return g_file_info_has_attribute (file->filesystem_info,
+                                    G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+}
+
+
+
+/**
+ * thunar_file_is_directory:
+ * @file : a #ThunarFile instance.
+ *
+ * Checks whether @file refers to a directory.
+ *
+ * Return value: %TRUE if @file is a directory.
+ **/
+gboolean
+thunar_file_is_directory (const ThunarFile *file) 
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+  _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+  return thunar_file_get_kind (file) == G_FILE_TYPE_DIRECTORY;
+}
+
+
+
+/**
  * thunar_file_get_deletion_date:
  * @file       : a #ThunarFile instance.
  * @date_style : the style used to format the date.
@@ -2099,6 +2227,12 @@
           file->ginfo = NULL;
         }
 
+      if (file->filesystem_info != NULL)
+        {
+          g_object_unref (file->filesystem_info);
+          file->filesystem_info = NULL;
+        }
+
       thunar_file_load (file, NULL, NULL);
 
       /* ... and tell others */

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h	2009-04-11 23:31:23 UTC (rev 29773)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h	2009-04-12 00:33:36 UTC (rev 29774)
@@ -137,6 +137,7 @@
   /*< private >*/
   ThunarVfsInfo *info;
   GFileInfo     *ginfo;
+  GFileInfo     *filesystem_info;
   GFile         *gfile;
   guint          flags;
 };
@@ -198,6 +199,12 @@
 const gchar      *thunar_file_get_basename         (const ThunarFile       *file);
 gboolean          thunar_file_is_symlink           (const ThunarFile       *file);
 guint64           thunar_file_get_size             (const ThunarFile       *file);
+GAppInfo         *thunar_file_get_default_handler  (const ThunarFile       *file);
+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_directory         (const ThunarFile       *file);
 
 gchar            *thunar_file_get_deletion_date    (const ThunarFile       *file,
                                                     ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
@@ -314,19 +321,6 @@
 #define thunar_file_get_file(file) (THUNAR_FILE ((file))->gfile)
 
 /**
- * thunar_file_get_default_handler:
- * @file : a #ThunarFile instance.
- *
- * Returns the default #GAppInfo for @file or %NULL if there is none.
- * 
- * The caller is responsible to free the returned #GAppInfo using
- * g_object_unref().
- *
- * Return value: Default #GAppInfo for @file or %NULL if there is none.
- **/
-#define thunar_file_get_default_handler(file) (g_file_query_default_handler (THUNAR_FILE ((file))->gfile, NULL, NULL))
-
-/**
  * thunar_file_get_mime_info:
  * @file : a #ThunarFile instance.
  *
@@ -343,41 +337,6 @@
 #define thunar_file_get_mime_info(file) (THUNAR_FILE ((file))->info->mime_info)
 
 /**
- * thunar_file_get_kind:
- * @file : a #ThunarFile instance.
- *
- * Returns the kind of @file.
- *
- * Return value: the kind of @file.
- **/
-#define thunar_file_get_kind(file) (THUNAR_FILE ((file))->info->type)
-
-/**
- * thunar_file_get_mode:
- * @file : a #ThunarFile instance.
- *
- * Returns the permission bits of @file.
- *
- * Return value: the permission bits of @file.
- **/
-#define thunar_file_get_mode(file) (THUNAR_FILE ((file))->info->mode)
-
-/**
- * thunar_file_get_free_space:
- * @file              : a #ThunarFile instance.
- * @free_space_return : return location for the amount of
- *                      free space or %NULL.
- *
- * Determines the amount of free space of the volume on
- * which @file resides. Returns %TRUE if the amount of
- * free space was determined successfully and placed into
- * @free_space_return, else %FALSE will be returned.
- *
- * Return value: %TRUE if successfull, else %FALSE.
- **/
-#define thunar_file_get_free_space(file, free_space_return) (thunar_vfs_info_get_free_space (THUNAR_FILE ((file))->info, (free_space_return)))
-
-/**
  * thunar_file_dup_uri:
  * @file : a #ThunarFile instance.
  *
@@ -457,16 +416,6 @@
 #define thunar_file_is_ancestor(file, ancestor) (thunar_vfs_path_is_ancestor (thunar_file_get_path ((file)), thunar_file_get_path ((ancestor))))
 
 /**
- * thunar_file_is_directory:
- * @file : a #ThunarFile instance.
- *
- * Checks whether @file refers to a directory.
- *
- * Return value: %TRUE if @file is a directory.
- **/
-#define thunar_file_is_directory(file) (THUNAR_FILE ((file))->info->type == THUNAR_VFS_FILE_TYPE_DIRECTORY)
-
-/**
  * thunar_file_is_executable:
  * @file : a #ThunarFile instance.
  *

Modified: thunar/branches/migration-to-gio/thunar/thunar-list-model.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-list-model.c	2009-04-11 23:31:23 UTC (rev 29773)
+++ thunar/branches/migration-to-gio/thunar/thunar-list-model.c	2009-04-12 00:33:36 UTC (rev 29774)
@@ -2201,9 +2201,9 @@
                                       GList           *selected_items)
 {
   ThunarVfsFileSize  size_summary;
-  ThunarVfsFileSize  size;
   GtkTreeIter        iter;
   ThunarFile        *file;
+  guint64            size;
   GSList            *row;
   GList             *lp;
   gchar             *absolute_path;

Modified: thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c	2009-04-11 23:31:23 UTC (rev 29773)
+++ thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c	2009-04-12 00:33:36 UTC (rev 29774)
@@ -783,7 +783,6 @@
 thunar_properties_dialog_update (ThunarPropertiesDialog *dialog)
 {
   ThunarIconFactory *icon_factory;
-  ThunarVfsFileSize  size;
   ThunarVfsMimeInfo *info;
   ThunarDateStyle    date_style;
   ThunarVfsVolume   *volume;
@@ -791,6 +790,7 @@
   const gchar       *icon_name;
   const gchar       *name;
   GdkPixbuf         *icon;
+  guint64            size;
   glong              offset;
   gchar             *display_name;
   gchar             *size_string;
@@ -942,9 +942,10 @@
     }
 
   /* update the free space (only for folders) */
-  if (thunar_file_is_directory (dialog->file) && thunar_file_get_free_space (dialog->file, &size))
+  if (thunar_file_is_directory (dialog->file) 
+      && thunar_file_get_free_space (dialog->file, &size))
     {
-      size_string = thunar_vfs_humanize_size (size, NULL, 0);
+      size_string = g_file_size_humanize (size);
       gtk_label_set_text (GTK_LABEL (dialog->freespace_label), size_string);
       gtk_widget_show (dialog->freespace_label);
       g_free (size_string);




More information about the Xfce4-commits mailing list