mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-11 02:13:45 +01:00
merge callbacks for pages-per-row, first-page-column and page-padding
All of those callbacks are conceptually related (change the page layout), and depend from one another. Now the single callback page_layout_value_changed defers to page_widget_set_mode to change whatever is needed in the GTK widgets.
This commit is contained in:
parent
c5930c900a
commit
0da491f78b
44
callbacks.c
44
callbacks.c
@ -207,61 +207,25 @@ cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data)
|
||||
}
|
||||
|
||||
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_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 pages_per_row = *(int*) value;
|
||||
|
||||
if (pages_per_row < 1) {
|
||||
pages_per_row = 1;
|
||||
}
|
||||
unsigned int pages_per_row = 1;
|
||||
girara_setting_get(session, "pages-per-row", &pages_per_row);
|
||||
|
||||
unsigned int first_page_column = 1;
|
||||
girara_setting_get(session, "first-page-column", &first_page_column);
|
||||
|
||||
unsigned int page_padding = 1;
|
||||
girara_setting_get(session, "page-padding", &page_padding);
|
||||
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);
|
||||
|
||||
if (zathura->document != NULL) {
|
||||
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
|
||||
page_set_delayed(zathura, current_page);
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
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);
|
||||
|
||||
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) {
|
||||
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
|
||||
page_set_delayed(zathura, current_page);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
14
callbacks.h
14
callbacks.h
@ -92,19 +92,7 @@ void cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data);
|
||||
* @param value The value
|
||||
* @param data Custom data
|
||||
*/
|
||||
void cb_pages_per_row_value_changed(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t type, void* value, void* data);
|
||||
/**
|
||||
* This function gets called when the value of the "first-page-column"
|
||||
* variable changes
|
||||
*
|
||||
* @param session The current girara session
|
||||
* @param name The name of the row
|
||||
* @param type The settings type
|
||||
* @param value The value
|
||||
* @param data Custom data
|
||||
*/
|
||||
void cb_first_page_column_value_changed(girara_session_t* session, const char* name,
|
||||
void cb_page_layout_value_changed(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t type, void* value, void* data);
|
||||
|
||||
/**
|
||||
|
27
config.c
27
config.c
@ -73,27 +73,6 @@ cb_color_change(girara_session_t* session, const char* name,
|
||||
render_all(zathura);
|
||||
}
|
||||
|
||||
static void
|
||||
cb_page_padding_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 val = *(int*) value;
|
||||
if (GTK_IS_TABLE(zathura->ui.page_widget) == TRUE) {
|
||||
#if (GTK_MAJOR_VERSION == 3)
|
||||
gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), val);
|
||||
gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), val);
|
||||
#else
|
||||
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), val);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), val);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cb_nohlsearch_changed(girara_session_t* session, const char* UNUSED(name),
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
@ -153,11 +132,11 @@ config_load_default(zathura_t* zathura)
|
||||
int_value = 10;
|
||||
girara_setting_add(gsession, "zoom-step", &int_value, INT, false, _("Zoom step"), NULL, NULL);
|
||||
int_value = 1;
|
||||
girara_setting_add(gsession, "page-padding", &int_value, INT, false, _("Padding between pages"), cb_page_padding_changed, NULL);
|
||||
girara_setting_add(gsession, "page-padding", &int_value, INT, false, _("Padding between pages"), cb_page_layout_value_changed, NULL);
|
||||
int_value = 1;
|
||||
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, _("Number of pages per row"), cb_pages_per_row_value_changed, NULL);
|
||||
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, _("Number of pages per row"), cb_page_layout_value_changed, NULL);
|
||||
int_value = 1;
|
||||
girara_setting_add(gsession, "first-page-column", &int_value, INT, false, _("Column of the first page"),cb_first_page_column_value_changed, NULL);
|
||||
girara_setting_add(gsession, "first-page-column", &int_value, INT, false, _("Column of the first page"),cb_page_layout_value_changed, NULL);
|
||||
float_value = 40;
|
||||
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, _("Scroll step"), NULL, NULL);
|
||||
float_value = 40;
|
||||
|
Loading…
Reference in New Issue
Block a user