Commit 86088236 authored by Pavel Borzenkov's avatar Pavel Borzenkov Committed by Sebastian Ramacher
Browse files

Get file info earlier



We need to know the document's 'scale' value earlier (before cairo
surfaces are created). Otherwise, cairo surfaces will be re-created and
wrong page will be rendered (since zoom doesn't preserve page number).
Signed-off-by: default avatarPavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: default avatarSebastian Ramacher <s.ramacher@gmx.at>
parent 88be0727
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......@@ -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 */
......
......@@ -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;
}
......
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