mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 22:56:00 +01:00
Implement first page column list
This commit is contained in:
parent
7e2a18f7a8
commit
a9aa7e4ad2
4 changed files with 59 additions and 5 deletions
|
@ -243,8 +243,13 @@ cb_page_layout_value_changed(girara_session_t* session, const char* name, girara
|
||||||
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);
|
||||||
|
|
||||||
unsigned int first_page_column = 1;
|
/* get list of first_page_column settings */
|
||||||
girara_setting_get(session, "first-page-column", &first_page_column);
|
char* first_page_column_list = NULL;
|
||||||
|
girara_setting_get(session, "first-page-column", &first_page_column_list);
|
||||||
|
|
||||||
|
/* find value for first_page_column */
|
||||||
|
unsigned int first_page_column = find_first_page_column(first_page_column_list, pages_per_row);
|
||||||
|
g_free(first_page_column_list);
|
||||||
|
|
||||||
unsigned int page_padding = 1;
|
unsigned int page_padding = 1;
|
||||||
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
|
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
|
||||||
|
|
|
@ -253,3 +253,33 @@ get_selection(zathura_t* zathura)
|
||||||
|
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
find_first_page_column(const char* first_page_column_list,
|
||||||
|
const unsigned int pages_per_row)
|
||||||
|
{
|
||||||
|
/* sanity checks */
|
||||||
|
unsigned int first_page_column = 1;
|
||||||
|
g_return_val_if_fail(first_page_column_list != NULL, first_page_column);
|
||||||
|
g_return_val_if_fail(strcmp(first_page_column_list, ""), first_page_column);
|
||||||
|
g_return_val_if_fail(pages_per_row > 0, first_page_column);
|
||||||
|
|
||||||
|
/* split settings list */
|
||||||
|
char** settings = g_strsplit(first_page_column_list, ":", pages_per_row+1);
|
||||||
|
|
||||||
|
size_t settings_size = 0;
|
||||||
|
while (settings[settings_size] != NULL) {
|
||||||
|
++settings_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read setting value corresponding to the specified pages per row */
|
||||||
|
unsigned int index = pages_per_row - 1;
|
||||||
|
if (settings_size > index && strcmp(settings[index], "")) {
|
||||||
|
first_page_column = atoi(settings[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free buffers */
|
||||||
|
g_strfreev(settings);
|
||||||
|
|
||||||
|
return first_page_column;
|
||||||
|
}
|
||||||
|
|
|
@ -107,4 +107,17 @@ GdkAtom* get_selection(zathura_t* zathura);
|
||||||
double zathura_correct_scale_value(girara_session_t* session, const double
|
double zathura_correct_scale_value(girara_session_t* session, const double
|
||||||
scale);
|
scale);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the column the first page should be rendered in from the specified
|
||||||
|
* list of settings corresponding to the specified pages per row
|
||||||
|
*
|
||||||
|
* @param[in] first_page_column_list The settings list
|
||||||
|
* @param[in] pages_per_row The current pages per row
|
||||||
|
*
|
||||||
|
* @return The column the first page should be rendered in
|
||||||
|
*/
|
||||||
|
unsigned int find_first_page_column(const char* first_page_column_list,
|
||||||
|
const unsigned int pages_per_row);
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
|
|
@ -857,7 +857,6 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
|
|
||||||
/* view mode */
|
/* view mode */
|
||||||
unsigned int pages_per_row = 1;
|
unsigned int pages_per_row = 1;
|
||||||
unsigned int first_page_column = 1;
|
|
||||||
char* first_page_column_list = first_page_column_list_default;
|
char* first_page_column_list = first_page_column_list_default;
|
||||||
unsigned int page_padding = 1;
|
unsigned int page_padding = 1;
|
||||||
|
|
||||||
|
@ -873,11 +872,15 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
if (strcmp(file_info.first_page_column_list, "")) {
|
if (strcmp(file_info.first_page_column_list, "")) {
|
||||||
first_page_column_list = file_info.first_page_column_list;
|
first_page_column_list = file_info.first_page_column_list;
|
||||||
} else {
|
} else {
|
||||||
girara_setting_get(zathura->ui.session, "first-page-column", &first_page_column);
|
girara_setting_get(zathura->ui.session, "first-page-column", &first_page_column_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* find value for first_page_column */
|
||||||
|
unsigned int first_page_column = find_first_page_column(first_page_column_list, pages_per_row);
|
||||||
|
|
||||||
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_list);
|
||||||
|
g_free(first_page_column_list);
|
||||||
|
|
||||||
page_widget_set_mode(zathura, page_padding, 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);
|
zathura_document_set_page_layout(zathura->document, page_padding, pages_per_row, first_page_column);
|
||||||
|
@ -1097,6 +1100,9 @@ document_close(zathura_t* zathura, bool keep_monitor)
|
||||||
zathura_db_save_jumplist(zathura->database, path, zathura->jumplist.list);
|
zathura_db_save_jumplist(zathura->database, path, zathura->jumplist.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free buffers */
|
||||||
|
g_free(file_info.first_page_column_list);
|
||||||
|
|
||||||
girara_list_iterator_free(zathura->jumplist.cur);
|
girara_list_iterator_free(zathura->jumplist.cur);
|
||||||
zathura->jumplist.cur = NULL;
|
zathura->jumplist.cur = NULL;
|
||||||
girara_list_free(zathura->jumplist.list);
|
girara_list_free(zathura->jumplist.list);
|
||||||
|
|
Loading…
Reference in a new issue