Commit 712e4bd4 authored by Sebastian Ramacher's avatar Sebastian Ramacher

use the correct sorting function

parent 09041f7d
......@@ -97,3 +97,18 @@ zathura_bookmarks_load(zathura_t* zathura, const gchar* file) {
return true;
}
int
zathura_bookmarks_compare(zathura_bookmark_t* lhs, zathura_bookmark_t* rhs)
{
if (lhs == NULL && rhs == NULL) {
return 0;
}
if (lhs == NULL) {
return -1;
}
if (rhs == NULL) {
return 1;
}
return g_strcmp0(lhs->id, rhs->id);
}
......@@ -53,4 +53,12 @@ void zathura_bookmark_free(zathura_bookmark_t* bookmark);
*/
bool zathura_bookmarks_load(zathura_t* zathura, const gchar* file);
/**
* Compare two bookmarks.
* @param lhs a bookmark
* @param rhs a bookmark
* @returns g_strcmp0(lhs->id, rhs->id)
*/
int zathura_bookmarks_compare(zathura_bookmark_t* lhs, zathura_bookmark_t* rhs);
#endif // BOOKMARKS_H
......@@ -194,7 +194,8 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
return NULL;
}
girara_list_t* result = girara_list_new();
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
if (result == NULL) {
return NULL;
}
......
......@@ -182,12 +182,12 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
return NULL;
}
girara_list_t* result = girara_list_new();
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
if (result == NULL) {
sqlite3_finalize(stmt);
return NULL;
}
girara_list_set_free_function(result, (girara_free_function_t) zathura_bookmark_free);
while (sqlite3_step(stmt) == SQLITE_ROW) {
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
......
......@@ -211,7 +211,7 @@ zathura_init(int argc, char* argv[])
}
/* bookmarks */
zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) g_strcmp0,
zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
/* open document if passed */
......
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