Commit 14535b8f authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

use a sorted list for bookmarks

parent 09d2ee09
......@@ -159,8 +159,6 @@ cc_bookmarks(girara_session_t* session, const char* input)
}
const size_t input_length = input ? strlen(input) : 0;
girara_list_sort(zathura->bookmarks.bookmarks, (girara_compare_function_t) g_strcmp0);
GIRARA_LIST_FOREACH(zathura->bookmarks.bookmarks, zathura_bookmark_t*, iter, bookmark)
if (input_length <= strlen(bookmark->id) && !strncmp(input, bookmark->id, input_length)) {
gchar* paged = g_strdup_printf("Page %d", bookmark->page);
......
......@@ -97,7 +97,7 @@ prepare_statement(sqlite3* session, const char* statement)
const char* pz_tail = NULL;
sqlite3_stmt* pp_stmt = NULL;
if (sqlite3_prepare(session, statement, -1, &pp_stmt, &pz_tail) != SQLITE_OK) {
if (sqlite3_prepare_v2(session, statement, -1, &pp_stmt, &pz_tail) != SQLITE_OK) {
girara_error("Failed to prepare query: %s", statement);
sqlite3_finalize(pp_stmt);
return NULL;
......@@ -134,7 +134,7 @@ zathura_db_add_bookmark(zathura_database_t* db, const char* file,
int res = sqlite3_step(stmt);
sqlite3_finalize(stmt);
return res == SQLITE_OK;
return res == SQLITE_DONE;
}
bool
......@@ -144,7 +144,7 @@ zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const char*
g_return_val_if_fail(db && file && id, false);
static const char SQL_BOOKMARK_ADD[] =
"DELETE FROM bookmarks WHERE file = ? && id = ?;";
"DELETE FROM bookmarks WHERE file = ? AND id = ?;";
sqlite3_stmt* stmt = prepare_statement(db->session, SQL_BOOKMARK_ADD);
if (stmt == NULL) {
......@@ -160,7 +160,7 @@ zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const char*
int res = sqlite3_step(stmt);
sqlite3_finalize(stmt);
return res == SQLITE_OK;
return res == SQLITE_DONE;
}
girara_list_t*
......@@ -229,7 +229,7 @@ zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int
int res = sqlite3_step(stmt);
sqlite3_finalize(stmt);
return res == SQLITE_OK;
return res == SQLITE_DONE;
}
bool
......
......@@ -211,8 +211,8 @@ zathura_init(int argc, char* argv[])
}
/* bookmarks */
zathura->bookmarks.bookmarks = girara_list_new();
girara_list_set_free_function(zathura->bookmarks.bookmarks, (girara_free_function_t) zathura_bookmark_free);
zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) g_strcmp0,
(girara_free_function_t) zathura_bookmark_free);
/* open document if passed */
if (argc > 1) {
......
Supports Markdown
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