From 33cda59c0562ae58927fd21b9189458c6ffb0399 Mon Sep 17 00:00:00 2001 From: Pavel Borzenkov Date: Tue, 5 Jul 2011 14:50:26 +0400 Subject: [PATCH] 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: Pavel Borzenkov Signed-off-by: Sebastian Ramacher --- config.def.h | 3 +++ zathura.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/config.def.h b/config.def.h index b06a2ec..9937373 100644 --- a/config.def.h +++ b/config.def.h @@ -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"}, diff --git a/zathura.c b/zathura.c index 69108f6..1cb651c 100644 --- a/zathura.c +++ b/zathura.c @@ -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;