diff options
author | Nick Schermer <nick@xfce.org> | 2012-10-20 19:34:41 +0200 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2012-10-20 19:34:41 +0200 |
commit | dada966eae39a370bae5f9bf13dee8786a2ae28c (patch) | |
tree | 79dc5b9db91d1029451bc4f1c8fb51ff1c6141d2 /thunar | |
parent | 8aa057167e3a078b3d35d2fbb171df9a54c71ccb (diff) | |
download | thunar-dada966eae39a370bae5f9bf13dee8786a2ae28c.tar.gz |
Drop usage of glib 2.32 functions.
Diffstat (limited to 'thunar')
-rw-r--r-- | thunar/thunar-device.c | 25 | ||||
-rw-r--r-- | thunar/thunar-device.h | 3 | ||||
-rw-r--r-- | 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 5ff1154e..7f20a626 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 614fd517..35ce1a48 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 0e26ad9d..d795e570 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); } |