mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 13:16:00 +01:00
Correct the given scale value
This commit is contained in:
parent
42c1780aef
commit
48183d6717
6 changed files with 48 additions and 21 deletions
3
links.c
3
links.c
|
@ -135,7 +135,8 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
|
||||||
case ZATHURA_LINK_GOTO_DEST:
|
case ZATHURA_LINK_GOTO_DEST:
|
||||||
if (link->target.destination_type != ZATHURA_LINK_DESTINATION_UNKNOWN) {
|
if (link->target.destination_type != ZATHURA_LINK_DESTINATION_UNKNOWN) {
|
||||||
if (link->target.scale != 0 && link_zoom) {
|
if (link->target.scale != 0 && link_zoom) {
|
||||||
zathura_document_set_scale(zathura->document, link->target.scale);
|
zathura_document_set_scale(zathura->document,
|
||||||
|
zathura_correct_scale_value(zathura->ui.session, link->target.scale));
|
||||||
render_all(zathura);
|
render_all(zathura);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
marks.c
3
marks.c
|
@ -239,7 +239,8 @@ mark_evaluate(zathura_t* zathura, int key)
|
||||||
/* search for existing mark */
|
/* search for existing mark */
|
||||||
GIRARA_LIST_FOREACH(zathura->global.marks, zathura_mark_t*, iter, mark)
|
GIRARA_LIST_FOREACH(zathura->global.marks, zathura_mark_t*, iter, mark)
|
||||||
if (mark != NULL && mark->key == key) {
|
if (mark != NULL && mark->key == key) {
|
||||||
zathura_document_set_scale(zathura->document, mark->scale);
|
zathura_document_set_scale(zathura->document,
|
||||||
|
zathura_correct_scale_value(zathura->ui.session, mark->scale));
|
||||||
render_all(zathura);
|
render_all(zathura);
|
||||||
|
|
||||||
zathura_jumplist_add(zathura);
|
zathura_jumplist_add(zathura);
|
||||||
|
|
14
shortcuts.c
14
shortcuts.c
|
@ -1390,20 +1390,8 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
|
||||||
}
|
}
|
||||||
|
|
||||||
/* zoom limitations */
|
/* zoom limitations */
|
||||||
int zoom_min_int = 10;
|
|
||||||
int zoom_max_int = 1000;
|
|
||||||
girara_setting_get(session, "zoom-min", &zoom_min_int);
|
|
||||||
girara_setting_get(session, "zoom-max", &zoom_max_int);
|
|
||||||
|
|
||||||
const double zoom_min = zoom_min_int * 0.01;
|
|
||||||
const double zoom_max = zoom_max_int * 0.01;
|
|
||||||
|
|
||||||
const double scale = zathura_document_get_scale(zathura->document);
|
const double scale = zathura_document_get_scale(zathura->document);
|
||||||
if (scale < zoom_min) {
|
zathura_document_set_scale(zathura->document, zathura_correct_scale_value(session, scale));
|
||||||
zathura_document_set_scale(zathura->document, zoom_min);
|
|
||||||
} else if (scale > zoom_max) {
|
|
||||||
zathura_document_set_scale(zathura->document, zoom_max);
|
|
||||||
}
|
|
||||||
|
|
||||||
const double new_zoom = zathura_document_get_scale(zathura->document);
|
const double new_zoom = zathura_document_get_scale(zathura->document);
|
||||||
if (fabs(new_zoom - old_zoom) <= DBL_EPSILON) {
|
if (fabs(new_zoom - old_zoom) <= DBL_EPSILON) {
|
||||||
|
|
29
utils.c
29
utils.c
|
@ -23,6 +23,35 @@
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "content-type.h"
|
#include "content-type.h"
|
||||||
|
|
||||||
|
double
|
||||||
|
zathura_correct_scale_value(girara_session_t* session, const double scale)
|
||||||
|
{
|
||||||
|
if (scale <= FLT_EPSILON) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session == NULL) {
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* zoom limitations */
|
||||||
|
int zoom_min_int = 10;
|
||||||
|
int zoom_max_int = 1000;
|
||||||
|
girara_setting_get(session, "zoom-min", &zoom_min_int);
|
||||||
|
girara_setting_get(session, "zoom-max", &zoom_max_int);
|
||||||
|
|
||||||
|
const double zoom_min = zoom_min_int * 0.01;
|
||||||
|
const double zoom_max = zoom_max_int * 0.01;
|
||||||
|
|
||||||
|
if (scale < zoom_min) {
|
||||||
|
return zoom_min;
|
||||||
|
} else if (scale > zoom_max) {
|
||||||
|
return zoom_max;
|
||||||
|
} else {
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
file_valid_extension(zathura_t* zathura, const char* path)
|
file_valid_extension(zathura_t* zathura, const char* path)
|
||||||
{
|
{
|
||||||
|
|
12
utils.h
12
utils.h
|
@ -95,4 +95,16 @@ char* zathura_get_version_string(zathura_t* zathura, bool markup);
|
||||||
*/
|
*/
|
||||||
GdkAtom* get_selection(zathura_t* zathura);
|
GdkAtom* get_selection(zathura_t* zathura);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the valid scale value which needs to lie in the interval of zoom_min
|
||||||
|
* and zoom_max specified in the girara session
|
||||||
|
*
|
||||||
|
* @param[in] session The session
|
||||||
|
* @param[in] scale The proposed scale value
|
||||||
|
*
|
||||||
|
* @return The corrected scale value
|
||||||
|
*/
|
||||||
|
double zathura_correct_scale_value(girara_session_t* session, const double
|
||||||
|
scale);
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
|
|
@ -607,12 +607,8 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
zathura_document_set_page_offset(document, file_info.page_offset);
|
zathura_document_set_page_offset(document, file_info.page_offset);
|
||||||
|
|
||||||
/* check for valid scale value */
|
/* check for valid scale value */
|
||||||
if (file_info.scale <= FLT_EPSILON) {
|
zathura_document_set_scale(document,
|
||||||
girara_warning("document info: '%s' has non positive scale", file_path);
|
zathura_correct_scale_value(zathura->ui.session, file_info.scale));
|
||||||
zathura_document_set_scale(document, 1);
|
|
||||||
} else {
|
|
||||||
zathura_document_set_scale(document, file_info.scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check current page number */
|
/* check current page number */
|
||||||
/* if it wasn't specified on the command-line, get it from file_info */
|
/* if it wasn't specified on the command-line, get it from file_info */
|
||||||
|
|
Loading…
Reference in a new issue