mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 21:46:01 +01:00
page_widget_set_mode now sets the page-padding too
- fix the computation of the number of rows in the table. Doing a ceil of an integer division has no effect... - set the page_padding in page_widget_set_mode function, instead of doing it independently. - call zathura_document_set_layout after calling page_widget_set_mode to save the page layout settings into the document object.
This commit is contained in:
parent
25998f8320
commit
c5930c900a
3 changed files with 34 additions and 21 deletions
12
callbacks.c
12
callbacks.c
|
@ -223,7 +223,11 @@ cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(nam
|
||||||
unsigned int first_page_column = 1;
|
unsigned int first_page_column = 1;
|
||||||
girara_setting_get(session, "first-page-column", &first_page_column);
|
girara_setting_get(session, "first-page-column", &first_page_column);
|
||||||
|
|
||||||
page_widget_set_mode(zathura, pages_per_row, first_page_column);
|
unsigned int page_padding = 1;
|
||||||
|
girara_setting_get(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);
|
||||||
|
|
||||||
if (zathura->document != NULL) {
|
if (zathura->document != NULL) {
|
||||||
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
|
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
|
||||||
|
@ -248,7 +252,11 @@ cb_first_page_column_value_changed(girara_session_t* session, const char* UNUSED
|
||||||
unsigned int pages_per_row = 1;
|
unsigned int pages_per_row = 1;
|
||||||
girara_setting_get(session, "pages-per-row", &pages_per_row);
|
girara_setting_get(session, "pages-per-row", &pages_per_row);
|
||||||
|
|
||||||
page_widget_set_mode(zathura, pages_per_row, first_page_column);
|
unsigned int page_padding = 1;
|
||||||
|
girara_setting_get(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);
|
||||||
|
|
||||||
if (zathura->document != NULL) {
|
if (zathura->document != NULL) {
|
||||||
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
|
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
|
||||||
|
|
39
zathura.c
39
zathura.c
|
@ -225,18 +225,6 @@ zathura_init(zathura_t* zathura)
|
||||||
/* signals */
|
/* signals */
|
||||||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), zathura);
|
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), zathura);
|
||||||
|
|
||||||
/* set page padding */
|
|
||||||
int page_padding = 1;
|
|
||||||
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
|
|
||||||
|
|
||||||
#if (GTK_MAJOR_VERSION == 3)
|
|
||||||
gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), page_padding);
|
|
||||||
gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), page_padding);
|
|
||||||
#else
|
|
||||||
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding);
|
|
||||||
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* database */
|
/* database */
|
||||||
char* database = NULL;
|
char* database = NULL;
|
||||||
girara_setting_get(zathura->ui.session, "database", &database);
|
girara_setting_get(zathura->ui.session, "database", &database);
|
||||||
|
@ -759,8 +747,12 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* view mode */
|
/* view mode */
|
||||||
int pages_per_row = 1;
|
unsigned int pages_per_row = 1;
|
||||||
int first_page_column = 1;
|
unsigned int first_page_column = 1;
|
||||||
|
unsigned int page_padding = 1;
|
||||||
|
|
||||||
|
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
|
||||||
|
|
||||||
if (file_info.pages_per_row > 0) {
|
if (file_info.pages_per_row > 0) {
|
||||||
pages_per_row = file_info.pages_per_row;
|
pages_per_row = file_info.pages_per_row;
|
||||||
} else {
|
} else {
|
||||||
|
@ -775,7 +767,9 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
|
|
||||||
girara_setting_set(zathura->ui.session, "pages-per-row", &pages_per_row);
|
girara_setting_set(zathura->ui.session, "pages-per-row", &pages_per_row);
|
||||||
girara_setting_set(zathura->ui.session, "first-page-column", &first_page_column);
|
girara_setting_set(zathura->ui.session, "first-page-column", &first_page_column);
|
||||||
page_widget_set_mode(zathura, pages_per_row, first_page_column);
|
|
||||||
|
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);
|
||||||
|
|
||||||
girara_set_view(zathura->ui.session, zathura->ui.page_widget_alignment);
|
girara_set_view(zathura->ui.session, zathura->ui.page_widget_alignment);
|
||||||
|
|
||||||
|
@ -1092,7 +1086,8 @@ statusbar_page_number_update(zathura_t* zathura)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned int first_page_column)
|
page_widget_set_mode(zathura_t* zathura, unsigned int page_padding,
|
||||||
|
unsigned int pages_per_row, unsigned int first_page_column)
|
||||||
{
|
{
|
||||||
/* show at least one page */
|
/* show at least one page */
|
||||||
if (pages_per_row == 0) {
|
if (pages_per_row == 0) {
|
||||||
|
@ -1103,7 +1098,6 @@ page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned in
|
||||||
if (first_page_column < 1) {
|
if (first_page_column < 1) {
|
||||||
first_page_column = 1;
|
first_page_column = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_page_column > pages_per_row) {
|
if (first_page_column > pages_per_row) {
|
||||||
first_page_column = ((first_page_column - 1) % pages_per_row) + 1;
|
first_page_column = ((first_page_column - 1) % pages_per_row) + 1;
|
||||||
}
|
}
|
||||||
|
@ -1115,9 +1109,18 @@ page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned in
|
||||||
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, (gpointer)0);
|
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, (gpointer)0);
|
||||||
|
|
||||||
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
||||||
|
|
||||||
#if (GTK_MAJOR_VERSION == 3)
|
#if (GTK_MAJOR_VERSION == 3)
|
||||||
|
gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), page_padding);
|
||||||
|
gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), page_padding);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
gtk_table_resize(GTK_TABLE(zathura->ui.page_widget), ceil((number_of_pages + first_page_column - 1) / pages_per_row), pages_per_row);
|
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding);
|
||||||
|
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding);
|
||||||
|
|
||||||
|
unsigned int ncol = pages_per_row;
|
||||||
|
unsigned int nrow = (number_of_pages + first_page_column - 1 + ncol - 1) / ncol;
|
||||||
|
gtk_table_resize(GTK_TABLE(zathura->ui.page_widget), nrow, ncol);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (unsigned int i = 0; i < number_of_pages; i++) {
|
for (unsigned int i = 0; i < number_of_pages; i++) {
|
||||||
|
|
|
@ -325,10 +325,12 @@ void position_set(zathura_t* zathura, double position_x, double position_y);
|
||||||
* Builds the box structure to show the rendered pages
|
* Builds the box structure to show the rendered pages
|
||||||
*
|
*
|
||||||
* @param zathura The zathura session
|
* @param zathura The zathura session
|
||||||
|
* @param page_padding padding in pixels between pages
|
||||||
* @param pages_per_row Number of shown pages per row
|
* @param pages_per_row Number of shown pages per row
|
||||||
* @param first_page_column Column on which first page start
|
* @param first_page_column Column on which first page start
|
||||||
*/
|
*/
|
||||||
void page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned int first_page_column);
|
void page_widget_set_mode(zathura_t* zathura, unsigned int page_padding,
|
||||||
|
unsigned int pages_per_row, unsigned int first_page_column);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the page number in the statusbar. Note that 1 will be added to the
|
* Updates the page number in the statusbar. Note that 1 will be added to the
|
||||||
|
|
Loading…
Reference in a new issue