mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 19:06:01 +01:00
use the correct sorting function
This commit is contained in:
parent
09041f7d78
commit
712e4bd408
5 changed files with 28 additions and 4 deletions
15
bookmarks.c
15
bookmarks.c
|
@ -97,3 +97,18 @@ zathura_bookmarks_load(zathura_t* zathura, const gchar* file) {
|
||||||
return true;
|
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);
|
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
|
#endif // BOOKMARKS_H
|
||||||
|
|
|
@ -194,7 +194,8 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
return NULL;
|
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) {
|
if (result == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,12 +182,12 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
return NULL;
|
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) {
|
if (result == NULL) {
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
girara_list_set_free_function(result, (girara_free_function_t) zathura_bookmark_free);
|
|
||||||
|
|
||||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||||
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
|
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
|
||||||
|
|
|
@ -211,7 +211,7 @@ zathura_init(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bookmarks */
|
/* 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);
|
(girara_free_function_t) zathura_bookmark_free);
|
||||||
|
|
||||||
/* open document if passed */
|
/* open document if passed */
|
||||||
|
|
Loading…
Reference in a new issue