From 62385ba63409e647381c04dbd7a647d3018d777f Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 1 Nov 2021 10:21:17 +0100 Subject: bookmark-agent: fix backward compatibility with glib < 2.66 --- libslab/bookmark-agent.c | 13 ++++++++++++- libslab/bookmark-agent.h | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c index b37616ff..6258c40f 100644 --- a/libslab/bookmark-agent.c +++ b/libslab/bookmark-agent.c @@ -296,6 +296,14 @@ bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris) save_store (this); } +#if !GLIB_CHECK_VERSION(2,66,0) +static gint +recent_item_mru_comp_func (gconstpointer a, gconstpointer b) +{ + return ((BookmarkItem *) b)->mtime - ((BookmarkItem *) a)->mtime; +} +#endif + static GList * make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store) { @@ -335,8 +343,11 @@ make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store) } } +#if GLIB_CHECK_VERSION(2,66,0) items_ordered = g_list_sort (items_ordered, g_date_time_compare); - +#else + items_ordered = g_list_sort (items_ordered, recent_item_mru_comp_func); +#endif g_strfreev (uris); return items_ordered; diff --git a/libslab/bookmark-agent.h b/libslab/bookmark-agent.h index 409509e1..f54415bf 100644 --- a/libslab/bookmark-agent.h +++ b/libslab/bookmark-agent.h @@ -21,10 +21,13 @@ #ifndef __BOOKMARK_AGENT_H__ #define __BOOKMARK_AGENT_H__ -#include #include #include +#if !GLIB_CHECK_VERSION(2,66,0) +#include +#endif + G_BEGIN_DECLS #define BOOKMARK_AGENT_TYPE (bookmark_agent_get_type ()) @@ -41,7 +44,11 @@ typedef struct { gchar *uri; gchar *title; gchar *mime_type; +#if GLIB_CHECK_VERSION(2,66,0) GDateTime *mtime; +#else + time_t mtime; +#endif gchar *icon; gchar *app_name; gchar *app_exec; -- cgit v1.2.1