[Xfce4-commits] <thunar:master> Drop usage of glib 2.32 functions.

Nick Schermer noreply at xfce.org
Sat Oct 20 19:36:01 CEST 2012


Updating branch refs/heads/master
         to dada966eae39a370bae5f9bf13dee8786a2ae28c (commit)
       from 8aa057167e3a078b3d35d2fbb171df9a54c71ccb (commit)

commit dada966eae39a370bae5f9bf13dee8786a2ae28c
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Oct 20 19:34:41 2012 +0200

    Drop usage of glib 2.32 functions.

 thunar/thunar-device.c          |   25 +++++++++++++++----------
 thunar/thunar-device.h          |    3 ++-
 thunar/thunar-shortcuts-model.c |    3 +--
 3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/thunar/thunar-device.c b/thunar/thunar-device.c
index 5ff1154..7f20a62 100644
--- a/thunar/thunar-device.c
+++ b/thunar/thunar-device.c
@@ -65,7 +65,11 @@ struct _ThunarDevice
 
   ThunarDeviceKind  kind;
 
+  /* if the device is the list of hidden names */
   guint             hidden : 1;
+
+  /* added time for sorting */
+  gint64            stamp;
 };
 
 typedef struct
@@ -128,6 +132,7 @@ static void
 thunar_device_init (ThunarDevice *device)
 {
   device->kind = THUNAR_DEVICE_KIND_VOLUME;
+  device->stamp = g_get_real_time ();
 }
 
 
@@ -645,19 +650,19 @@ thunar_device_get_root (const ThunarDevice *device)
 
 
 
-const gchar *
-thunar_device_get_sort_key (const ThunarDevice *device)
+gint
+thunar_device_sort (const ThunarDevice *device1,
+                    const ThunarDevice *device2)
 {
-  _thunar_return_val_if_fail (THUNAR_IS_DEVICE (device), NULL);
+  _thunar_return_val_if_fail (THUNAR_IS_DEVICE (device1), 0);
+  _thunar_return_val_if_fail (THUNAR_IS_DEVICE (device2), 0);
 
-  if (G_IS_VOLUME (device->device))
-    return g_volume_get_sort_key (device->device);
-  else if (G_IS_MOUNT (device->device))
-    return g_mount_get_sort_key (device->device);
-  else
-    _thunar_assert_not_reached ();
+  /* sort volumes above mounts */
+  if (G_OBJECT_TYPE (device1->device) != G_OBJECT_TYPE (device2->device))
+    return G_IS_VOLUME (device1->device) ? 1 : -1;
 
-  return NULL;
+  /* sort by detect stamp */
+  return device1->stamp > device2->stamp ? 1 : -1;
 }
 
 
diff --git a/thunar/thunar-device.h b/thunar/thunar-device.h
index 614fd51..35ce1a4 100644
--- a/thunar/thunar-device.h
+++ b/thunar/thunar-device.h
@@ -67,7 +67,8 @@ gboolean             thunar_device_is_mounted       (const ThunarDevice   *devic
 
 GFile               *thunar_device_get_root         (const ThunarDevice   *device);
 
-const gchar         *thunar_device_get_sort_key     (const ThunarDevice   *device);
+gint                 thunar_device_sort             (const ThunarDevice   *device1,
+                                                     const ThunarDevice   *device2);
 
 void                 thunar_device_mount            (ThunarDevice         *device,
                                                      GMountOperation      *mount_operation,
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 0e26ad9..d795e57 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -994,8 +994,7 @@ thunar_shortcuts_model_sort_func (gconstpointer shortcut_a,
 
   /* properly sort devices by timestamp */
   if (a->device != NULL && b->device != NULL)
-    return -g_strcmp0 (thunar_device_get_sort_key (a->device),
-                       thunar_device_get_sort_key (b->device));
+    return thunar_device_sort (a->device, b->device);
 
   return g_strcmp0 (a->name, b->name);
 }


More information about the Xfce4-commits mailing list