Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pwmt
zathura
Commits
48183d67
Commit
48183d67
authored
Oct 27, 2014
by
Moritz Lipp
Browse files
Correct the given scale value
parent
42c1780a
Changes
6
Hide whitespace changes
Inline
Side-by-side
links.c
View file @
48183d67
...
...
@@ -135,7 +135,8 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
case
ZATHURA_LINK_GOTO_DEST
:
if
(
link
->
target
.
destination_type
!=
ZATHURA_LINK_DESTINATION_UNKNOWN
)
{
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
);
}
...
...
marks.c
View file @
48183d67
...
...
@@ -239,7 +239,8 @@ mark_evaluate(zathura_t* zathura, int key)
/* search for existing mark */
GIRARA_LIST_FOREACH
(
zathura
->
global
.
marks
,
zathura_mark_t
*
,
iter
,
mark
)
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
);
zathura_jumplist_add
(
zathura
);
...
...
shortcuts.c
View file @
48183d67
...
...
@@ -1390,20 +1390,8 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
}
/* 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
);
if
(
scale
<
zoom_min
)
{
zathura_document_set_scale
(
zathura
->
document
,
zoom_min
);
}
else
if
(
scale
>
zoom_max
)
{
zathura_document_set_scale
(
zathura
->
document
,
zoom_max
);
}
zathura_document_set_scale
(
zathura
->
document
,
zathura_correct_scale_value
(
session
,
scale
));
const
double
new_zoom
=
zathura_document_get_scale
(
zathura
->
document
);
if
(
fabs
(
new_zoom
-
old_zoom
)
<=
DBL_EPSILON
)
{
...
...
utils.c
View file @
48183d67
...
...
@@ -23,6 +23,35 @@
#include "plugin.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
file_valid_extension
(
zathura_t
*
zathura
,
const
char
*
path
)
{
...
...
utils.h
View file @
48183d67
...
...
@@ -95,4 +95,16 @@ char* zathura_get_version_string(zathura_t* zathura, bool markup);
*/
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
zathura.c
View file @
48183d67
...
...
@@ -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
);
/* check for valid scale value */
if
(
file_info
.
scale
<=
FLT_EPSILON
)
{
girara_warning
(
"document info: '%s' has non positive scale"
,
file_path
);
zathura_document_set_scale
(
document
,
1
);
}
else
{
zathura_document_set_scale
(
document
,
file_info
.
scale
);
}
zathura_document_set_scale
(
document
,
zathura_correct_scale_value
(
zathura
->
ui
.
session
,
file_info
.
scale
));
/* check current page number */
/* if it wasn't specified on the command-line, get it from file_info */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment