mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-14 09:14:05 +01:00
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 <pavel.borzenkov@gmail.com> Signed-off-by: Sebastian Ramacher <s.ramacher@gmx.at>
This commit is contained in:
parent
a5e9c12651
commit
a206e5bb1f
@ -29,7 +29,9 @@ static const char DATA_DIR[] = "~/.local/share/zathura";
|
|||||||
/* bookmarks */
|
/* bookmarks */
|
||||||
static const char BM_PAGE_ENTRY[] = "page";
|
static const char BM_PAGE_ENTRY[] = "page";
|
||||||
static const char BM_PAGE_OFFSET[] = "offset";
|
static const char BM_PAGE_OFFSET[] = "offset";
|
||||||
|
static const char BM_PAGE_SCALE[] = "scale";
|
||||||
int save_position = 1;
|
int save_position = 1;
|
||||||
|
int save_zoom_level = 1;
|
||||||
|
|
||||||
/* look */
|
/* look */
|
||||||
char* font = "monospace normal 9";
|
char* font = "monospace normal 9";
|
||||||
@ -251,6 +253,7 @@ Setting settings[] = {
|
|||||||
{"recolor_darkcolor", &(recolor_darkcolor), 's', FALSE, TRUE, "Recoloring (dark color)"},
|
{"recolor_darkcolor", &(recolor_darkcolor), 's', FALSE, TRUE, "Recoloring (dark color)"},
|
||||||
{"recolor_lightcolor", &(recolor_lightcolor), 's', FALSE, TRUE, "Recoloring (light 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_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_step", &(scroll_step), 'f', FALSE, FALSE, "Scroll step"},
|
||||||
{"scroll_wrap", &(scroll_wrap), 'b', FALSE, FALSE, "Wrap scolling at last page"},
|
{"scroll_wrap", &(scroll_wrap), 'b', FALSE, FALSE, "Wrap scolling at last page"},
|
||||||
{"scrollbars", &(show_scrollbars), 'b', FALSE, TRUE, "Show scrollbars"},
|
{"scrollbars", &(show_scrollbars), 'b', FALSE, TRUE, "Show scrollbars"},
|
||||||
|
18
zathura.c
18
zathura.c
@ -1065,6 +1065,13 @@ close_file(gboolean keep_monitor)
|
|||||||
BM_PAGE_OFFSET, Zathura.PDF.page_offset);
|
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 */
|
/* save bookmarks */
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < Zathura.Bookmarks.number_of_bookmarks; 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))
|
if((Zathura.PDF.page_offset != 0) && (Zathura.PDF.page_offset != GOTO_OFFSET))
|
||||||
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 */
|
/* open and read bookmark file */
|
||||||
gsize i = 0;
|
gsize i = 0;
|
||||||
gsize number_of_keys = 0;
|
gsize number_of_keys = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user