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
1241afbe
Commit
1241afbe
authored
Oct 31, 2013
by
Sebastian Ramacher
Browse files
Merge branch 'feature/redo-page-refresh' into develop
Conflicts: links.c
parents
5c49792c
9f201f4a
Changes
18
Hide whitespace changes
Inline
Side-by-side
adjustment.c
View file @
1241afbe
...
...
@@ -2,6 +2,144 @@
#include "adjustment.h"
#include "utils.h"
#include <math.h>
double
page_calc_height_width
(
zathura_document_t
*
document
,
double
height
,
double
width
,
unsigned
int
*
page_height
,
unsigned
int
*
page_width
,
bool
rotate
)
{
g_return_val_if_fail
(
document
!=
NULL
&&
page_height
!=
NULL
&&
page_width
!=
NULL
,
0
.
0
);
double
scale
=
zathura_document_get_scale
(
document
);
double
real_scale
;
if
(
rotate
&&
zathura_document_get_rotation
(
document
)
%
180
)
{
*
page_width
=
round
(
height
*
scale
);
*
page_height
=
round
(
width
*
scale
);
real_scale
=
MAX
(
*
page_width
/
height
,
*
page_height
/
width
);
}
else
{
*
page_width
=
round
(
width
*
scale
);
*
page_height
=
round
(
height
*
scale
);
real_scale
=
MAX
(
*
page_width
/
width
,
*
page_height
/
height
);
}
return
real_scale
;
}
void
page_calc_position
(
zathura_document_t
*
document
,
double
x
,
double
y
,
double
*
xn
,
double
*
yn
)
{
g_return_if_fail
(
document
!=
NULL
&&
xn
!=
NULL
&&
yn
!=
NULL
);
unsigned
int
rot
=
zathura_document_get_rotation
(
document
);
if
(
rot
==
90
)
{
*
xn
=
1
-
y
;
*
yn
=
x
;
}
else
if
(
rot
==
180
)
{
*
xn
=
1
-
x
;
*
yn
=
1
-
y
;
}
else
if
(
rot
==
270
)
{
*
xn
=
y
;
*
yn
=
1
-
x
;
}
else
{
*
xn
=
x
;
*
yn
=
y
;
}
}
unsigned
int
position_to_page_number
(
zathura_document_t
*
document
,
double
pos_x
,
double
pos_y
){
g_return_val_if_fail
(
document
!=
NULL
,
0
);
unsigned
int
doc_width
,
doc_height
;
zathura_document_get_document_size
(
document
,
&
doc_height
,
&
doc_width
);
unsigned
int
cell_width
,
cell_height
;
zathura_document_get_cell_size
(
document
,
&
cell_height
,
&
cell_width
);
unsigned
int
c0
=
zathura_document_get_first_page_column
(
document
);
unsigned
int
npag
=
zathura_document_get_number_of_pages
(
document
);
unsigned
int
ncol
=
zathura_document_get_pages_per_row
(
document
);
unsigned
int
nrow
=
(
npag
+
c0
-
1
+
ncol
-
1
)
/
ncol
;
/* number of rows */
unsigned
int
pad
=
zathura_document_get_page_padding
(
document
);
unsigned
int
col
=
floor
(
pos_x
*
(
double
)
doc_width
/
(
double
)(
cell_width
+
pad
));
unsigned
int
row
=
floor
(
pos_y
*
(
double
)
doc_height
/
(
double
)(
cell_height
+
pad
));
return
ncol
*
(
row
%
nrow
)
+
(
col
%
ncol
)
-
(
c0
-
1
);
}
void
page_number_to_position
(
zathura_document_t
*
document
,
unsigned
int
page_number
,
double
xalign
,
double
yalign
,
double
*
pos_x
,
double
*
pos_y
)
{
g_return_if_fail
(
document
!=
NULL
);
unsigned
int
c0
=
zathura_document_get_first_page_column
(
document
);
unsigned
int
npag
=
zathura_document_get_number_of_pages
(
document
);
unsigned
int
ncol
=
zathura_document_get_pages_per_row
(
document
);
unsigned
int
nrow
=
(
npag
+
c0
-
1
+
ncol
-
1
)
/
ncol
;
/* number of rows */
/* row and column for page_number indexed from 0 */
unsigned
int
row
=
(
page_number
+
c0
-
1
)
/
ncol
;
unsigned
int
col
=
(
page_number
+
c0
-
1
)
%
ncol
;
/* sizes of page cell, viewport and document */
unsigned
int
cell_height
=
0
,
cell_width
=
0
;
zathura_document_get_cell_size
(
document
,
&
cell_height
,
&
cell_width
);
unsigned
int
view_height
=
0
,
view_width
=
0
;
zathura_document_get_viewport_size
(
document
,
&
view_height
,
&
view_width
);
unsigned
int
doc_height
=
0
,
doc_width
=
0
;
zathura_document_get_document_size
(
document
,
&
doc_height
,
&
doc_width
);
/* compute the shift to align to the viewport. If the page fits to viewport, just center it. */
double
shift_x
=
0
.
5
,
shift_y
=
0
.
5
;
if
(
cell_width
>
view_width
)
{
shift_x
=
0
.
5
+
(
xalign
-
0
.
5
)
*
((
double
)
cell_width
-
(
double
)
view_width
)
/
(
double
)
cell_width
;
}
if
(
cell_height
>
view_height
)
{
shift_y
=
0
.
5
+
(
yalign
-
0
.
5
)
*
((
double
)
cell_height
-
(
double
)
view_height
)
/
(
double
)
cell_height
;
}
/* compute the position */
*
pos_x
=
((
double
)
col
+
shift_x
)
/
(
double
)
ncol
;
*
pos_y
=
((
double
)
row
+
shift_y
)
/
(
double
)
nrow
;
}
bool
page_is_visible
(
zathura_document_t
*
document
,
unsigned
int
page_number
)
{
g_return_val_if_fail
(
document
!=
NULL
,
false
);
/* position at the center of the viewport */
double
pos_x
=
zathura_document_get_position_x
(
document
);
double
pos_y
=
zathura_document_get_position_y
(
document
);
/* get the center of page page_number */
double
page_x
,
page_y
;
page_number_to_position
(
document
,
page_number
,
0
.
5
,
0
.
5
,
&
page_x
,
&
page_y
);
unsigned
int
cell_width
,
cell_height
;
zathura_document_get_cell_size
(
document
,
&
cell_height
,
&
cell_width
);
unsigned
int
doc_width
,
doc_height
;
zathura_document_get_document_size
(
document
,
&
doc_height
,
&
doc_width
);
unsigned
int
view_width
,
view_height
;
zathura_document_get_viewport_size
(
document
,
&
view_height
,
&
view_width
);
return
(
fabs
(
pos_x
-
page_x
)
<
0
.
5
*
(
double
)(
view_width
+
cell_width
)
/
(
double
)
doc_width
&&
fabs
(
pos_y
-
page_y
)
<
0
.
5
*
(
double
)(
view_height
+
cell_height
)
/
(
double
)
doc_height
);
}
GtkAdjustment
*
zathura_adjustment_clone
(
GtkAdjustment
*
adjustment
)
...
...
adjustment.h
View file @
1241afbe
...
...
@@ -4,8 +4,73 @@
#define ZATHURA_ADJUSTMENT_H
#include <gtk/gtk.h>
#include <stdbool.h>
#include "document.h"
/* Clone a GtkAdjustment
/**
* Calculate the page size according to the corrent scaling and rotation if
* desired.
*
* @param document the document
* @param height width the original height and width
* @return page_height page_width the scaled and rotated height and width
* @param rotate honor page's rotation
* @return real scale after rounding
*/
double
page_calc_height_width
(
zathura_document_t
*
document
,
double
height
,
double
width
,
unsigned
int
*
page_height
,
unsigned
int
*
page_width
,
bool
rotate
);
/**
* Calculate a page relative position after a rotation. The positions x y are
* relative to a page, i.e. 0=top of page, 1=bottom of page. They are NOT
* relative to the entire document.
*
* @param document the document
* @param x y the x y coordinates on the unrotated page
* @param xn yn the x y coordinates after rotation
*/
void
page_calc_position
(
zathura_document_t
*
document
,
double
x
,
double
y
,
double
*
xn
,
double
*
yn
);
/**
* Converts a relative position within the document to a page number.
*
* @param document The document
* @param pos_x pos_y the position relative to the document
* @return page sitting in that position
*/
unsigned
int
position_to_page_number
(
zathura_document_t
*
document
,
double
pos_x
,
double
pos_y
);
/**
* Converts a page number to a position in units relative to the document
*
* We can specify where to aliwn the viewport and the page. For instance, xalign
* = 0 means align them on the left margin, xalign = 0.5 means centered, and
* xalign = 1.0 align them on the right margin.
*
* The return value is the position in in units relative to the document (0=top
* 1=bottom) of the point thet will lie at the center of the viewport.
*
* @param document The document
* @param page_number the given page number
* @param xalign yalign where to align the viewport and the page
* @return pos_x pos_y position that will lie at the center of the viewport.
*/
void
page_number_to_position
(
zathura_document_t
*
document
,
unsigned
int
page_number
,
double
xalign
,
double
yalign
,
double
*
pos_x
,
double
*
pos_y
);
/**
* Checks whether a given page falls within the viewport
*
* @param document The document
* @param page_number the page number
* @return true if the page intersects the viewport
*/
bool
page_is_visible
(
zathura_document_t
*
document
,
unsigned
int
page_number
);
/**
* Clone a GtkAdjustment
*
* Creates a new adjustment with the same value, lower and upper bounds, step
* and page increments and page_size as the original adjustment.
...
...
bookmarks.c
View file @
1241afbe
...
...
@@ -25,14 +25,14 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
g_return_val_if_fail
(
zathura
&&
zathura
->
document
&&
zathura
->
bookmarks
.
bookmarks
,
NULL
);
g_return_val_if_fail
(
id
,
NULL
);
double
x
=
zathura_
adjust
ment_get_
ratio
(
gtk_scrolled_window_get_hadjustment
(
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
))
);
double
y
=
zathura_
adjust
ment_get_
ratio
(
gtk_scrolled_window_get_vadjustment
(
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
))
);
double
position_
x
=
zathura_
docu
ment_get_
position_x
(
zathura
->
document
);
double
position_
y
=
zathura_
docu
ment_get_
position_y
(
zathura
->
document
);
zathura_bookmark_t
*
old
=
zathura_bookmark_get
(
zathura
,
id
);
if
(
old
!=
NULL
)
{
old
->
page
=
page
;
old
->
x
=
x
;
old
->
y
=
y
;
old
->
x
=
position_
x
;
old
->
y
=
position_
y
;
if
(
zathura
->
database
!=
NULL
)
{
const
char
*
path
=
zathura_document_get_path
(
zathura
->
document
);
...
...
@@ -52,8 +52,8 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
bookmark
->
id
=
g_strdup
(
id
);
bookmark
->
page
=
page
;
bookmark
->
x
=
x
;
bookmark
->
y
=
y
;
bookmark
->
x
=
position_
x
;
bookmark
->
y
=
position_
y
;
girara_list_append
(
zathura
->
bookmarks
.
bookmarks
,
bookmark
);
if
(
zathura
->
database
!=
NULL
)
{
...
...
callbacks.c
View file @
1241afbe
...
...
@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
#include <string.h>
#include <glib/gi18n.h>
#include <math.h>
#include "callbacks.h"
#include "links.h"
...
...
@@ -48,118 +49,95 @@ cb_buffer_changed(girara_session_t* session)
}
}
void
cb_view_vadjustment_value_changed
(
GtkAdjustment
*
GIRARA_UNUSED
(
adjustment
),
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
if
(
zathura
==
NULL
||
zathura
->
document
==
NULL
||
zathura
->
ui
.
page_widget
==
NULL
)
{
return
;
}
GtkAdjustment
*
view_vadjustment
=
gtk_scrolled_window_get_vadjustment
(
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
));
GtkAdjustment
*
view_hadjustment
=
gtk_scrolled_window_get_hadjustment
(
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
));
/* current adjustment values */
const
GdkRectangle
view_rect
=
{
.
x
=
0
,
.
y
=
0
,
.
width
=
gtk_adjustment_get_page_size
(
view_hadjustment
),
.
height
=
gtk_adjustment_get_page_size
(
view_vadjustment
)
};
int
page_padding
=
1
;
girara_setting_get
(
zathura
->
ui
.
session
,
"page-padding"
,
&
page_padding
);
const
GdkRectangle
center
=
{
.
x
=
(
view_rect
.
width
+
1
)
/
2
,
.
y
=
(
view_rect
.
height
+
1
)
/
2
,
.
width
=
(
2
*
page_padding
)
+
1
,
.
height
=
(
2
*
page_padding
)
+
1
};
static
void
update_visible_pages
(
zathura_t
*
zathura
)
{
const
unsigned
int
number_of_pages
=
zathura_document_get_number_of_pages
(
zathura
->
document
);
const
double
scale
=
zathura_document_get_scale
(
zathura
->
document
);
bool
updated
=
false
;
/* find page that fits */
for
(
unsigned
int
page_id
=
0
;
page_id
<
number_of_pages
;
page_id
++
)
{
zathura_page_t
*
page
=
zathura_document_get_page
(
zathura
->
document
,
page_id
);
GdkRectangle
page_rect
=
{
.
width
=
zathura_page_get_width
(
page
)
*
scale
,
.
height
=
zathura_page_get_height
(
page
)
*
scale
};
GtkWidget
*
page_widget
=
zathura_page_get_widget
(
zathura
,
page
);
ZathuraPage
*
zathura_page_widget
=
ZATHURA_PAGE
(
page_widget
);
gtk_widget_translate_coordinates
(
page_widget
,
zathura
->
ui
.
session
->
gtk
.
view
,
0
,
0
,
&
page_rect
.
x
,
&
page_rect
.
y
);
if
(
gdk_rectangle_intersect
(
&
view_rect
,
&
page_rect
,
NULL
)
==
TRUE
)
{
if
(
page_is_visible
(
zathura
->
document
,
page_id
)
==
true
)
{
/* make page visible */
if
(
zathura_page_get_visibility
(
page
)
==
false
)
{
zathura_page_set_visibility
(
page
,
true
);
zathura_page_widget_update_view_time
(
zathura_page_widget
);
zathura_renderer_page_cache_add
(
zathura
->
sync
.
render_thread
,
zathura_page_get_index
(
page
));
}
if
(
zathura
->
global
.
update_page_number
==
true
&&
updated
==
false
&&
gdk_rectangle_intersect
(
&
center
,
&
page_rect
,
NULL
)
==
TRUE
)
{
zathura_document_set_current_page_number
(
zathura
->
document
,
page_id
);
updated
=
true
;
}
}
else
{
/* make page invisible */
if
(
zathura_page_get_visibility
(
page
)
==
true
)
{
zathura_page_set_visibility
(
page
,
false
);
/* If a page becomes invisible, abort the render request. */
zathura_page_widget_abort_render_request
(
zathura_page_widget
);
}
/* reset current search result */
girara_list_t
*
results
=
NULL
;
g_object_get
(
page_widget
,
"search-results"
,
&
results
,
NULL
);
if
(
results
!=
NULL
)
{
g_object_set
(
page_widget
,
"search-current"
,
0
,
NULL
);
}
}
}
}
void
cb_view_hadjustment_value_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
if
(
zathura
==
NULL
||
zathura
->
document
==
NULL
)
{
return
;
}
/* Do nothing in index mode */
if
(
girara_mode_get
(
zathura
->
ui
.
session
)
==
zathura
->
modes
.
index
)
{
return
;
}
update_visible_pages
(
zathura
);
double
position_x
=
zathura_adjustment_get_ratio
(
adjustment
);
double
position_y
=
zathura_document_get_position_y
(
zathura
->
document
);
unsigned
int
page_id
=
position_to_page_number
(
zathura
->
document
,
position_x
,
position_y
);
zathura_document_set_position_x
(
zathura
->
document
,
position_x
);
zathura_document_set_position_y
(
zathura
->
document
,
position_y
);
zathura_document_set_current_page_number
(
zathura
->
document
,
page_id
);
statusbar_page_number_update
(
zathura
);
}
void
cb_view_
h
adjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
cb_view_
v
adjustment_
value_
changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
if
(
zathura
==
NULL
||
zathura
->
document
==
NULL
)
{
return
;
}
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
/* Do nothing in index mode */
if
(
girara_mode_get
(
zathura
->
ui
.
session
)
==
zathura
->
modes
.
index
)
{
return
;
}
gdouble
lower
,
upper
,
page_size
,
value
,
ratio
;
bool
zoom_center
=
false
;
switch
(
adjust_mode
)
{
center:
case
ZATHURA_ADJUST_BESTFIT
:
case
ZATHURA_ADJUST_WIDTH
:
lower
=
gtk_adjustment_get_lower
(
adjustment
);
upper
=
gtk_adjustment_get_upper
(
adjustment
);
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
value
=
((
upper
-
lower
)
-
page_size
)
/
2
.
0
;
zathura_adjustment_set_value
(
adjustment
,
value
);
break
;
default:
girara_setting_get
(
zathura
->
ui
.
session
,
"zoom-center"
,
&
zoom_center
);
if
(
zoom_center
)
{
goto
center
;
}
update_visible_pages
(
zathura
);
ratio
=
zathura_adjustment_get_ratio
(
zathura
->
ui
.
hadjustment
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
break
;
}
double
position_x
=
zathura_document_get_position_x
(
zathura
->
document
);
double
position_y
=
zathura_adjustment_get_ratio
(
adjustment
);
unsigned
int
page_id
=
position_to_page_number
(
zathura
->
document
,
position_x
,
position_y
);
zathura_document_set_position_x
(
zathura
->
document
,
position_x
);
zathura_document_set_position_y
(
zathura
->
document
,
position_y
);
zathura_document_set_current_page_number
(
zathura
->
document
,
page_id
);
statusbar_page_number_update
(
zathura
);
}
void
cb_view_
v
adjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
cb_view_
h
adjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
...
...
@@ -167,93 +145,99 @@ cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
/* Do nothing in index mode */
if
(
girara_mode_get
(
zathura
->
ui
.
session
)
==
zathura
->
modes
.
index
)
{
return
;
}
/* Don't scroll we're focusing the inputbar. */
if
(
adjust_mode
==
ZATHURA_ADJUST_INPUTBAR
)
{
return
;
}
double
ratio
=
zathura_adjustment_get_ratio
(
zathura
->
ui
.
vadjustment
);
/* save the viewport size */
unsigned
int
view_width
=
(
unsigned
int
)
floor
(
gtk_adjustment_get_page_size
(
adjustment
));
zathura_document_set_viewport_width
(
zathura
->
document
,
view_width
);
/* reset the adjustment, in case bounds have changed */
double
ratio
=
zathura_document_get_position_x
(
zathura
->
document
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
}
void
cb_adjustment_
track_value
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
cb_
view_v
adjustment_
changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
GtkAdjustment
*
tracker
=
data
;
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
if
(
lower
!=
gtk_adjustment_get_lower
(
tracker
)
||
upper
!=
gtk_adjustment_get_upper
(
tracker
))
{
/* Do nothing in index mode */
if
(
girara_mode_get
(
zathura
->
ui
.
session
)
==
zathura
->
modes
.
index
)
{
return
;
}
gdouble
value
=
gtk_adjustment_get_value
(
adjustment
);
gtk_adjustment_set_value
(
tracker
,
value
);
}
/* Don't scroll we're focusing the inputbar. */
if
(
adjust_mode
==
ZATHURA_ADJUST_INPUTBAR
)
{
return
;
}
void
cb_adjustment_track_bounds
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
GtkAdjustment
*
tracker
=
data
;
gdouble
value
=
gtk_adjustment_get_value
(
adjustment
);
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
gdouble
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
gtk_adjustment_set_value
(
tracker
,
value
);
gtk_adjustment_set_lower
(
tracker
,
lower
);
gtk_adjustment_set_upper
(
tracker
,
upper
);
gtk_adjustment_set_page_size
(
tracker
,
page_size
);
/* save the viewport size */
unsigned
int
view_height
=
(
unsigned
int
)
floor
(
gtk_adjustment_get_page_size
(
adjustment
));
zathura_document_set_viewport_height
(
zathura
->
document
,
view_height
);
/* reset the adjustment, in case bounds have changed */
double
ratio
=
zathura_document_get_position_y
(
zathura
->
document
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
}
void
cb_
pages_per_row_value_changed
(
girara_session_t
*
session
,
const
char
*
UNUSED
(
name
),
girara_setting_type_t
UNUSED
(
type
),
void
*
value
,
void
*
UNUSED
(
data
)
)
cb_
refresh_view
(
GtkWidget
*
GIRARA_UNUSED
(
view
),
gpointer
data
)
{
g_return_if_fail
(
value
!=
NULL
);
g_return_if_fail
(
session
!=
NULL
);
g_return_if_fail
(
session
->
global
.
data
!=
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
int
pages_per_row
=
*
(
int
*
)
value
;
zathura_t
*
zathura
=
data
;
if
(
zathura
==
NULL
||
zathura
->
document
==
NULL
)
{
return
;
}
if
(
pages_per_row
<
1
)
{
pages_per_row
=
1
;
unsigned
int
page_id
=
zathura_document_get_current_page_number
(
zathura
->
document
);
zathura_page_t
*
page
=
zathura_document_get_page
(
zathura
->
document
,
page_id
);
if
(
page
==
NULL
)
{
return
;
}
unsigned
int
first_page_column
=
1
;
girara_setting_get
(
session
,
"first-page-column"
,
&
first_page_column
);
GtkAdjustment
*
vadj
=
gtk_scrolled_window_get_vadjustment
(
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
))
;
GtkAdjustment
*
hadj
=
gtk_scrolled_window_get_hadjustment
(
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
)
);
page_widget_set_mode
(
zathura
,
pages_per_row
,
first_page_column
);
double
position_x
=
zathura_document_get_position_x
(
zathura
->
document
);
double
position_y
=
zathura_document_get_position_y
(
zathura
->
document
);
if
(
zathura
->
document
!=
NULL
)
{
unsigned
int
current_page
=
zathura_document_get_current_page_number
(
zathura
->
document
);
page_set_delayed
(
zathura
,
current_page
);
}
zathura
_adjustment_set_value_from_ratio
(
vadj
,
position_y
);
zathura_adjustment_set_value_from_ratio
(
hadj
,
position_x
);
statusbar_page_number_update
(
zathura
);
}
void
cb_
first_page_column
_value_changed
(
girara_session_t
*
session
,
const
char
*
UNUSED
(
name
),
girara_setting_type_t
UNUSED
(
type
),
void
*
value
,
void
*
UNUSED
(
data
))
cb_
page_layout
_value_changed
(
girara_session_t
*
session
,
const
char
*
UNUSED
(
name
),
girara_setting_type_t
UNUSED
(
type
),
void
*
value
,
void
*
UNUSED
(
data
))
{
g_return_if_fail
(
value
!=
NULL
);
g_return_if_fail
(
session
!=
NULL
);
g_return_if_fail
(
session
->
global
.
data
!=
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
int
first_page_column
=
*
(
int
*
)
value
;
if
(
first_page_column
<
1
)
{
first_page_column
=
1
;
}
unsigned
int
pages_per_row
=
1
;
girara_setting_get
(
session
,
"pages-per-row"
,
&
pages_per_row
);
page_widget_set_mode
(
zathura
,
pages_per_row
,
first_page_column
);
unsigned
int
first_page_column
=
1
;
girara_setting_get
(
session
,
"first-page-column"
,
&
first_page_column
);
if
(
zathura
->
document
!=
NULL
)
{
unsigned
int
current_page
=
zathura_document_get_current_page_number
(
zathura
->
document
);
page_set_delayed
(
zathura
,
current_page
);
}
unsigned
int
page_padding
=
1
;
girara_setting_get
(
zathura
->
ui
.
session
,
"page-padding"
,
&
page_padding
);
page_widget_set_mode
(
zathura
,
page_padding
,
pages_per_row
,
first_page_column
);
zathura_document_set_page_layout
(
zathura
->
document
,
page_padding
,
pages_per_row
,
first_page_column
);
}
void
...
...
@@ -461,23 +445,19 @@ error_ret:
}
bool
cb_view_resized
(
GtkWidget
*
UNUSED
(
widget
),
GtkAllocation
*
allocation
,
zathura_t
*
zathura
)
cb_view_resized
(
GtkWidget
*
UNUSED
(
widget
),
GtkAllocation
*
UNUSED
(
allocation
)
,
zathura_t
*
zathura
)
{
if
(
zathura
==
NULL
||
zathura
->
document
==
NULL
)
{
return
false
;
}
static
int
height
=
-
1
;
static
int
width
=
-
1
;
/* adjust the scale according to settings. If nothing needs to be resized,
it does not trigger the resize event.
/* adjust only if the allocation changed */
if
(
width
!=
allocation
->
width
||
height
!=
allocation
->
height
)
{
girara_argument_t
argument
=
{
zathura_document_get_adjust_mode
(
zathura
->
document
),
NULL
};
sc_adjust_window
(
zathura
->
ui
.
session
,
&
argument
,
NULL
,
0
);
width
=
allocation
->
width
;
height
=
allocation
->
height
;
}
The right viewport size is already in the document object, due to a
previous call to adjustment_changed. We don't want to use the allocation in
here, because we would have to subtract scrollbars, etc. */
adjust_view
(
zathura
);
return
false
;
}
...
...
callbacks.h
View file @
1241afbe
...
...
@@ -27,6 +27,15 @@ gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura);
*/
void
cb_buffer_changed
(
girara_session_t
*
session
);