bookmark-agent: fix backward compatibility with glib < 2.66

This commit is contained in:
rbuj 2021-11-01 10:21:17 +01:00 committed by Luke from DC
parent f6bd25fdf6
commit 384ce5d358
2 changed files with 20 additions and 2 deletions

View File

@ -294,6 +294,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)
{
@ -333,8 +341,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;

View File

@ -21,10 +21,13 @@
#ifndef __BOOKMARK_AGENT_H__
#define __BOOKMARK_AGENT_H__
#include <time.h>
#include <glib.h>
#include <glib-object.h>
#if !GLIB_CHECK_VERSION(2,66,0)
#include <time.h>
#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;