Author: jannis
Date: 2008-12-18 02:20:35 +0000 (Thu, 18 Dec 2008)
New Revision: 29034

Added:
   thunar/branches/port-to-gio/TODO-GIO
Modified:
   thunar/branches/port-to-gio/ChangeLog
   thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.c
   thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.h
   thunar/branches/port-to-gio/thunar/thunar-file.c
   thunar/branches/port-to-gio/thunar/thunar-file.h
   thunar/branches/port-to-gio/thunar/thunar-list-model.c
   thunar/branches/port-to-gio/thunar/thunar-properties-dialog.c
Log:
        * TODO-GIO: Add special TODO file for the port to GIO.
        * thunar/thunar-file.{c,h}: Add macros for the GFileInfo namespaces to
          be used. Implement thunar_file_get_mode(), thunar_file_get_kind(),
          thunar_file_get_size() and thunar_file_get_free_space() using GIO.
        * thunar/thunar-list-model.c, thunar/thunar-properties-dialog.c: Use
          guint64 for file sizes instead of ThunarVfsFileSize.
        * thunar-vfs/thunar-vfs-utils.{c,h} (thunar_vfs_humanize_size): Use
          guint64 for the size parameter.

Modified: thunar/branches/port-to-gio/ChangeLog
===================================================================
--- thunar/branches/port-to-gio/ChangeLog       2008-12-18 00:42:34 UTC (rev 
29033)
+++ thunar/branches/port-to-gio/ChangeLog       2008-12-18 02:20:35 UTC (rev 
29034)
@@ -1,5 +1,16 @@
 2008-12-18     Jannis Pohlmann <jan...@xfce.org>
 
+       * TODO-GIO: Add special TODO file for the port to GIO.
+       * thunar/thunar-file.{c,h}: Add macros for the GFileInfo namespaces to
+         be used. Implement thunar_file_get_mode(), thunar_file_get_kind(),
+         thunar_file_get_size() and thunar_file_get_free_space() using GIO.
+       * thunar/thunar-list-model.c, thunar/thunar-properties-dialog.c: Use
+         guint64 for file sizes instead of ThunarVfsFileSize.
+       * thunar-vfs/thunar-vfs-utils.{c,h} (thunar_vfs_humanize_size): Use
+         guint64 for the size parameter.
+
+2008-12-18     Jannis Pohlmann <jan...@xfce.org>
+
        * configure.in.in: Add dependency on GIO 2.16 and updated GLib
          dependency to 2.16 as well.
        * thunar/Makefile.am: Add compiler and linker flags for GLib and GIO.

Added: thunar/branches/port-to-gio/TODO-GIO
===================================================================
--- thunar/branches/port-to-gio/TODO-GIO                                (rev 0)
+++ thunar/branches/port-to-gio/TODO-GIO        2008-12-18 02:20:35 UTC (rev 
29034)
@@ -0,0 +1,6 @@
+TODO for porting Thunar to GIO/GVfs
+===================================
+
+* Remove Thunar's own trash:// implementation and just use GIO/GVfs 
+  for that. No special treatment needed. Right now browsing the trash
+  makes Thunar crash.

Modified: thunar/branches/port-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/port-to-gio/thunar/thunar-file.c    2008-12-18 00:42:34 UTC 
(rev 29033)
+++ thunar/branches/port-to-gio/thunar/thunar-file.c    2008-12-18 02:20:35 UTC 
(rev 29034)
@@ -54,6 +54,11 @@
 
 
 
+/* Namespaces to use for GFileInfo objects */
+#define THUNAR_FILE_G_FILE_INFO_NAMESPACE            "standard::*,unix::*"
+#define THUNAR_FILE_G_FILE_INFO_FILESYSTEM_NAMESPACE "filesystem::*"
+
+
 /* Additional flags associated with a ThunarFile */
 #define THUNAR_FILE_IN_DESTRUCTION          0x04
 #define THUNAR_FILE_OWNS_METAFILE_REFERENCE 0x08
@@ -600,7 +605,7 @@
   _thunar_return_val_if_fail (info != NULL, NULL);
 
   uri = thunar_vfs_path_dup_uri (info->path);
-          
+
   /* check if we already have a cached version of that file */
   file = thunar_file_cache_lookup (info->path);
   if (G_UNLIKELY (file != NULL))
@@ -618,7 +623,8 @@
 
           file->info = thunar_vfs_info_ref (info);
           file->gfile = g_file_new_for_uri (uri);
-          file->ginfo = g_file_query_info (file->gfile, "standard::*", 
G_FILE_QUERY_INFO_NONE, NULL, NULL);
+          file->ginfo = g_file_query_info (file->gfile, 
THUNAR_FILE_G_FILE_INFO_NAMESPACE, 
+                                           G_FILE_QUERY_INFO_NONE, NULL, NULL);
 
           thunar_file_changed (file);
         }
@@ -631,7 +637,8 @@
 
       /* create GFile and GFileInfo */
       file->gfile = g_file_new_for_uri (uri);
-      file->ginfo = g_file_query_info (file->gfile, "standard::*", 
G_FILE_QUERY_INFO_NONE, NULL, NULL);
+      file->ginfo = g_file_query_info (file->gfile, 
THUNAR_FILE_G_FILE_INFO_NAMESPACE, 
+                                       G_FILE_QUERY_INFO_NONE, NULL, NULL);
 
       /* insert the file into the cache */
       g_hash_table_insert (file_cache, thunar_vfs_path_ref (info->path), file);
@@ -1616,7 +1623,6 @@
 }
 
 
-
 /**
  * thunar_file_has_parent:
  * @file : a #ThunarFile instance.
@@ -1646,6 +1652,90 @@
 
 
 /**
+ * thunar_file_get_mode:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the permission bits of @file.
+ *
+ * Return value: the permission bits of @file.
+ **/
+guint32
+thunar_file_get_mode (const ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), 0);
+  return g_file_info_get_attribute_uint32 (file->ginfo, 
G_FILE_ATTRIBUTE_UNIX_MODE);
+}
+
+
+/**
+ * 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);
+  return g_file_info_get_file_type (file->ginfo);
+}
+
+
+/**
+ * thunar_file_get_size:
+ * @file : a #ThunarFile instance.
+ *
+ * Tries to determine the size of @file in bytes and
+ * returns the size.
+ *
+ * Return value: the size of @file in bytes.
+ **/
+guint64
+thunar_file_get_size (const ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), 0);
+  return g_file_info_get_attribute_uint64 (file->ginfo, 
G_FILE_ATTRIBUTE_STANDARD_SIZE);
+}
+
+
+/**
+ * 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)
+{
+  GFileInfo *fs_info;
+
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+  _thunar_return_val_if_fail (free_space_return != NULL, FALSE);
+
+  fs_info = g_file_query_filesystem_info (file->gfile, 
THUNAR_FILE_G_FILE_INFO_FILESYSTEM_NAMESPACE, NULL, NULL);
+
+  if (G_LIKELY (fs_info != NULL))
+    {
+      *free_space_return = g_file_info_get_attribute_uint64 (fs_info, 
G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+      g_object_unref (fs_info);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
+
+/**
  * thunar_file_get_icon_name:
  * @file       : a #ThunarFile instance.
  * @icon_state : the state of the @file<!---->s icon we are interested in.

Modified: thunar/branches/port-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/port-to-gio/thunar/thunar-file.h    2008-12-18 00:42:34 UTC 
(rev 29033)
+++ thunar/branches/port-to-gio/thunar/thunar-file.h    2008-12-18 02:20:35 UTC 
(rev 29034)
@@ -211,6 +211,11 @@
 gboolean         thunar_file_is_desktop              (const ThunarFile *file);
 
 gboolean         thunar_file_has_parent              (const ThunarFile *file);
+guint32          thunar_file_get_mode                (const ThunarFile *file);
+GFileType        thunar_file_get_kind                (const ThunarFile *file);
+guint64          thunar_file_get_size                (const ThunarFile *file);
+gboolean         thunar_file_get_free_space          (const ThunarFile *file, 
+                                                      guint64          
*free_space_return);
 
 
 /**
@@ -260,52 +265,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_size:
- * @file : a #ThunarFile instance.
- *
- * Tries to determine the size of @file in bytes and
- * returns the size.
- *
- * Return value: the size of @file in bytes.
- **/
-#define thunar_file_get_size(file) (THUNAR_FILE ((file))->info->size)
-
-/**
- * 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.
  *

Modified: thunar/branches/port-to-gio/thunar/thunar-list-model.c
===================================================================
--- thunar/branches/port-to-gio/thunar/thunar-list-model.c      2008-12-18 
00:42:34 UTC (rev 29033)
+++ thunar/branches/port-to-gio/thunar/thunar-list-model.c      2008-12-18 
02:20:35 UTC (rev 29034)
@@ -2201,12 +2201,12 @@
                                       GList           *selected_items)
 {
   ThunarVfsMimeInfo *mime_info;
-  ThunarVfsFileSize  size_summary;
-  ThunarVfsFileSize  size;
   GtkTreeIter        iter;
   ThunarFile        *file;
   GSList            *row;
   GList             *lp;
+  guint64            size_summary;
+  guint64            size;
   gchar             *absolute_path;
   gchar             *fspace_string;
   gchar             *display_name;

Modified: thunar/branches/port-to-gio/thunar/thunar-properties-dialog.c
===================================================================
--- thunar/branches/port-to-gio/thunar/thunar-properties-dialog.c       
2008-12-18 00:42:34 UTC (rev 29033)
+++ thunar/branches/port-to-gio/thunar/thunar-properties-dialog.c       
2008-12-18 02:20:35 UTC (rev 29034)
@@ -781,7 +781,6 @@
 thunar_properties_dialog_update (ThunarPropertiesDialog *dialog)
 {
   ThunarIconFactory *icon_factory;
-  ThunarVfsFileSize  size;
   ThunarVfsMimeInfo *info;
   ThunarDateStyle    date_style;
   ThunarVfsVolume   *volume;
@@ -789,6 +788,7 @@
   const gchar       *icon_name;
   const gchar       *name;
   GdkPixbuf         *icon;
+  guint64            size;
   glong              offset;
   gchar             *display_name;
   gchar             *size_string;

Modified: thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.c
===================================================================
--- thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.c    2008-12-18 
00:42:34 UTC (rev 29033)
+++ thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.c    2008-12-18 
02:20:35 UTC (rev 29034)
@@ -312,9 +312,9 @@
  * Return value: a string containing a human readable description of @size.
  **/
 gchar*
-thunar_vfs_humanize_size (ThunarVfsFileSize size,
-                          gchar            *buffer,
-                          gsize             buflen)
+thunar_vfs_humanize_size (guint64 size,
+                          gchar  *buffer,
+                          gsize  buflen)
 {
   /* allocate buffer if necessary */
   if (buffer == NULL)

Modified: thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.h
===================================================================
--- thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.h    2008-12-18 
00:42:34 UTC (rev 29033)
+++ thunar/branches/port-to-gio/thunar-vfs/thunar-vfs-util.h    2008-12-18 
02:20:35 UTC (rev 29034)
@@ -31,7 +31,7 @@
 gchar *thunar_vfs_expand_filename       (const gchar      *filename,
                                          GError          **error) 
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
-gchar *thunar_vfs_humanize_size         (ThunarVfsFileSize size,
+gchar *thunar_vfs_humanize_size         (guint64           size,
                                          gchar            *buffer,
                                          gsize             buflen);
 

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to