mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 19:46:00 +01:00
Factor out bookmark list creation
This commit is contained in:
parent
8c245cd254
commit
5d898adda6
4 changed files with 29 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue