diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-02-19 14:45:55 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-02-19 14:45:55 +0100 |
commit | bf19319ce0927ec6c5c2c797b0e63cea7f152580 (patch) | |
tree | 3019c7d4a893a1fe1662783511660b7dd01d037c | |
parent | 0d686bf856b1ca67ab5a606c4287f3250b01a432 (diff) | |
download | gnome-bluetooth-bf19319ce0927ec6c5c2c797b0e63cea7f152580.tar.gz |
settings-widget: Sort by time created rather than alphabetically
Sort devices by the time a row was created for them. This means that
newly discovered devices should appear at the bottom of the list, rather
than the top, making it less likely that the widget under the mouse or
finger would change before it's clicked.
This should also make the list of setup devices more static even if
the device names are changed.
Closes: #55
-rw-r--r-- | lib/bluetooth-settings-widget.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c index ae649d7b..8832f31f 100644 --- a/lib/bluetooth-settings-widget.c +++ b/lib/bluetooth-settings-widget.c @@ -1412,20 +1412,19 @@ device_sort_func (gconstpointer a, gconstpointer b, gpointer data) gboolean paired_a, paired_b; gboolean trusted_a, trusted_b; gboolean connected_a, connected_b; - g_autofree char *alias_a = NULL; - g_autofree char *alias_b = NULL; + gint64 time_a, time_b; g_object_get (row_a, "paired", &paired_a, "trusted", &trusted_a, "connected", &connected_a, - "alias", &alias_a, + "time-created", &time_a, NULL); g_object_get (row_b, "paired", &paired_b, "trusted", &trusted_b, "connected", &connected_b, - "alias", &alias_b, + "time-created", &time_b, NULL); /* First, paired or trusted devices (setup devices) */ @@ -1446,13 +1445,8 @@ device_sort_func (gconstpointer a, gconstpointer b, gpointer data) return 1; } - if (alias_a == NULL) - return 1; - if (alias_b == NULL) - return -1; - - /* And all being equal, alphabetically */ - return g_utf8_collate (alias_a, alias_b); + /* And all being equal, oldest ones first */ + return (time_a > time_b) ? 1 : -1; } static void |