diff --git a/database-plain.c b/database-plain.c index 0bb5513..783e3b2 100644 --- a/database-plain.c +++ b/database-plain.c @@ -223,7 +223,7 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file) bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int - page, int offset, float scale) + page, int offset, double scale) { if (db == NULL || db->history == NULL || file == NULL) { return false; @@ -247,7 +247,7 @@ zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned int* - page, int* offset, float* scale) + page, int* offset, double* scale) { if (db == NULL || db->history == NULL || file == NULL || page == NULL || offset == NULL || scale == NULL) { @@ -260,7 +260,7 @@ zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned int* *page = g_key_file_get_integer(db->history, file, KEY_PAGE, NULL); *offset = g_key_file_get_integer(db->history, file, KEY_OFFSET, NULL); - *scale = strtof(g_key_file_get_string(db->history, file, KEY_SCALE, NULL), NULL); + *scale = strtod(g_key_file_get_string(db->history, file, KEY_SCALE, NULL), NULL); return true; } diff --git a/database-sqlite.c b/database-sqlite.c index 779cc32..a6bfa2e 100644 --- a/database-sqlite.c +++ b/database-sqlite.c @@ -197,7 +197,7 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file) bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int - page, int offset, float scale) + page, int offset, double scale) { g_return_val_if_fail(db && file, false); @@ -225,7 +225,7 @@ zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned int* - page, int* offset, float* scale) + page, int* offset, double* scale) { g_return_val_if_fail(db && file && page && offset && scale, false); diff --git a/database.h b/database.h index 44ee74d..6958b39 100644 --- a/database.h +++ b/database.h @@ -61,7 +61,7 @@ girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char* * @return true on success, false otherwise. */ bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned - int page, int offset, float scale); + int page, int offset, double scale); /* Get file info (last site, ...) from the database. * @param db The database instance @@ -72,6 +72,6 @@ bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned * @return true on success, false otherwise. */ bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned - int* page, int* offset, float* scale); + int* page, int* offset, double* scale); #endif // DATABASE_H diff --git a/document.c b/document.c index cb1c441..075bc16 100644 --- a/document.c +++ b/document.c @@ -20,7 +20,7 @@ #include "utils.h" #include "zathura.h" #include "render.h" -#include "utils.h" +#include "database.h" void zathura_document_plugins_load(zathura_t* zathura) @@ -218,6 +218,10 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password document->scale = 1.0; document->zathura = zathura; + int offset = 0; + zathura_db_get_fileinfo(zathura->database, document->file_path, + &document->current_page_number, &offset, &document->scale); + if (plugin->open_function != NULL) { if (plugin->open_function(document) == true) { /* update statusbar */ diff --git a/zathura.c b/zathura.c index b0fe85d..31d116f 100644 --- a/zathura.c +++ b/zathura.c @@ -335,13 +335,7 @@ document_open(zathura_t* zathura, const char* path, const char* password) girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path); } - unsigned int page = 0u; - int offset = 0; - float scale = 1.0f; - if (zathura_db_get_fileinfo(zathura->database, zathura->document->file_path, &page, &offset, &scale)) { - page_set_delayed(zathura, page - 1); - zathura->document->scale = scale; - } + page_set_delayed(zathura, document->current_page_number - 1); return true; @@ -533,7 +527,7 @@ int main(int argc, char* argv[]) zathura_t* zathura = zathura_init(argc, argv); if (zathura == NULL) { - printf("error: coult not initialize zathura\n"); + printf("error: could not initialize zathura\n"); return -1; }