Commit 5d898add authored by Sebastian Ramacher's avatar Sebastian Ramacher

Factor out bookmark list creation

parent 8c245cd2
......@@ -397,9 +397,7 @@ plain_load_bookmarks(zathura_database_t* db, const char* file)
return NULL;
}
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t)
zathura_bookmarks_compare, (girara_free_function_t)
zathura_bookmark_free);
girara_list_t* result = bookmarks_list_new();
gsize num_keys;
char** keys = g_key_file_get_keys(priv->bookmarks, name, &num_keys, NULL);
......
......@@ -471,8 +471,7 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
return NULL;
}
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
girara_list_t* result = bookmarks_list_new();
if (result == NULL) {
sqlite3_finalize(stmt);
return NULL;
......
......@@ -76,3 +76,24 @@ zathura_db_get_recent_files(zathura_database_t* db, int max, const char* basepat
return ZATHURA_DATABASE_GET_INTERFACE(db)->get_recent_files(db, max, basepath);
}
static int
bookmarks_compare(const void* l, const void* r)
{
const zathura_bookmark_t* lhs = l;
const zathura_bookmark_t* rhs = r;
return zathura_bookmarks_compare(lhs, rhs);
}
static void
bookmarks_free(void* p)
{
zathura_bookmark_t* bookmark = p;
zathura_bookmark_free(bookmark);
}
girara_list_t* bookmarks_list_new(void)
{
return girara_sorted_list_new2(bookmarks_compare, bookmarks_free);
}
......@@ -140,5 +140,11 @@ bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file,
*/
girara_list_t* zathura_db_get_recent_files(zathura_database_t* db, int max, const char* basepath);
/**
* Create list of bookmarks.
* @return empty list of bookmarks
*/
girara_list_t* bookmarks_list_new(void);
#endif // DATABASE_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment