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

Save zoom level in the bookmarks file



This patch introduces new configuration option: save_zoom_level.
If this option is set (default) zathura will store zoom level
in the bookmarks file on quit and restore it on open.

Signed-off-by: default avatarPavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: default avatarSebastian Ramacher <s.ramacher@gmx.at>
parent a5e9c126
......@@ -29,7 +29,9 @@ static const char DATA_DIR[] = "~/.local/share/zathura";
/* bookmarks */
static const char BM_PAGE_ENTRY[] = "page";
static const char BM_PAGE_OFFSET[] = "offset";
static const char BM_PAGE_SCALE[] = "scale";
int save_position = 1;
int save_zoom_level = 1;
/* look */
char* font = "monospace normal 9";
......@@ -251,6 +253,7 @@ Setting settings[] = {
{"recolor_darkcolor", &(recolor_darkcolor), 's', FALSE, TRUE, "Recoloring (dark color)"},
{"recolor_lightcolor", &(recolor_lightcolor), 's', FALSE, TRUE, "Recoloring (light color)"},
{"save_position", &(save_position), 'b', FALSE, FALSE, "Save position in file on quit and restore it on open"},
{"save_zoom_level", &(save_zoom_level), 'b', FALSE, FALSE, "Save zoom level on quit and restore it on open"},
{"scroll_step", &(scroll_step), 'f', FALSE, FALSE, "Scroll step"},
{"scroll_wrap", &(scroll_wrap), 'b', FALSE, FALSE, "Wrap scolling at last page"},
{"scrollbars", &(show_scrollbars), 'b', FALSE, TRUE, "Show scrollbars"},
......
......@@ -1065,6 +1065,13 @@ close_file(gboolean keep_monitor)
BM_PAGE_OFFSET, Zathura.PDF.page_offset);
}
if (save_zoom_level)
{
/* set zoom level */
g_key_file_set_integer(Zathura.Bookmarks.data, Zathura.PDF.file,
BM_PAGE_SCALE, Zathura.PDF.scale);
}
/* save bookmarks */
int i;
for(i = 0; i < Zathura.Bookmarks.number_of_bookmarks; i++)
......@@ -1395,6 +1402,17 @@ open_file(char* path, char* password)
if((Zathura.PDF.page_offset != 0) && (Zathura.PDF.page_offset != GOTO_OFFSET))
Zathura.PDF.page_offset = GOTO_OFFSET;
/* get zoom level */
if (save_zoom_level && g_key_file_has_key(Zathura.Bookmarks.data, file, BM_PAGE_SCALE, NULL))
{
Zathura.PDF.scale = g_key_file_get_integer(Zathura.Bookmarks.data, file, BM_PAGE_SCALE, NULL);
Zathura.Global.adjust_mode = ADJUST_NONE;
}
if (Zathura.PDF.scale > zoom_max)
Zathura.PDF.scale = zoom_max;
if (Zathura.PDF.scale < zoom_min)
Zathura.PDF.scale = zoom_min;
/* open and read bookmark file */
gsize i = 0;
gsize number_of_keys = 0;
......
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