mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 11:55:59 +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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t)
|
girara_list_t* result = bookmarks_list_new();
|
||||||
zathura_bookmarks_compare, (girara_free_function_t)
|
|
||||||
zathura_bookmark_free);
|
|
||||||
|
|
||||||
gsize num_keys;
|
gsize num_keys;
|
||||||
char** keys = g_key_file_get_keys(priv->bookmarks, name, &num_keys, NULL);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
|
girara_list_t* result = bookmarks_list_new();
|
||||||
(girara_free_function_t) zathura_bookmark_free);
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return NULL;
|
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);
|
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);
|
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
|
#endif // DATABASE_H
|
||||||
|
|
Loading…
Reference in a new issue