mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 09:16:00 +01:00
Allow changing of "pages-per-row" variable at runtime
This commit is contained in:
parent
230ac06957
commit
32d90379bc
4 changed files with 40 additions and 6 deletions
12
callbacks.c
12
callbacks.c
|
@ -78,3 +78,15 @@ cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
||||||
free(offset);
|
free(offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cb_pages_per_row_value_changed(girara_session_t* session, girara_setting_t* setting)
|
||||||
|
{
|
||||||
|
int pages_per_row = setting->value.i;
|
||||||
|
zathura_t* zathura = setting->data;
|
||||||
|
|
||||||
|
if (pages_per_row < 1)
|
||||||
|
pages_per_row = 1;
|
||||||
|
|
||||||
|
page_view_set_mode(zathura, pages_per_row);
|
||||||
|
}
|
||||||
|
|
10
callbacks.h
10
callbacks.h
|
@ -23,12 +23,20 @@ gboolean cb_destroy(GtkWidget* widget, gpointer data);
|
||||||
void buffer_changed(girara_session_t* session);
|
void buffer_changed(girara_session_t* session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function gets called when the the value of the vertical scrollbars
|
* This function gets called when the value of the vertical scrollbars
|
||||||
* changes (e.g.: by scrolling, moving to another page)
|
* changes (e.g.: by scrolling, moving to another page)
|
||||||
*
|
*
|
||||||
* @param adjustment The vadjustment of the page view
|
* @param adjustment The vadjustment of the page view
|
||||||
* @param data NULL
|
* @param data NULL
|
||||||
*/
|
*/
|
||||||
void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data);
|
void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data);
|
||||||
|
/**
|
||||||
|
* This function gets called when the value of the "pages-per-row"
|
||||||
|
* variable changes
|
||||||
|
*
|
||||||
|
* @param session The current girara session
|
||||||
|
* @param setting The "pages-per-row" setting
|
||||||
|
*/
|
||||||
|
void cb_pages_per_row_value_changed(girara_session_t* session, girara_setting_t* setting);
|
||||||
|
|
||||||
#endif // CALLBACKS_H
|
#endif // CALLBACKS_H
|
||||||
|
|
11
config.c
11
config.c
|
@ -3,6 +3,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
#include "callbacks.h"
|
||||||
#include "shortcuts.h"
|
#include "shortcuts.h"
|
||||||
#include "zathura.h"
|
#include "zathura.h"
|
||||||
|
|
||||||
|
@ -32,16 +33,16 @@ config_load_default(zathura_t* zathura)
|
||||||
|
|
||||||
/* zathura settings */
|
/* zathura settings */
|
||||||
int_value = 10;
|
int_value = 10;
|
||||||
girara_setting_add(gsession, "zoom-step", &int_value, INT, false, "Zoom step", NULL);
|
girara_setting_add(gsession, "zoom-step", &int_value, INT, false, "Zoom step", NULL, NULL);
|
||||||
int_value = 1;
|
int_value = 1;
|
||||||
girara_setting_add(gsession, "page-padding", &int_value, INT, true, "Padding between pages", NULL);
|
girara_setting_add(gsession, "page-padding", &int_value, INT, true, "Padding between pages", NULL, NULL);
|
||||||
int_value = 2;
|
int_value = 2;
|
||||||
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", NULL);
|
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, zathura);
|
||||||
|
|
||||||
string_value = "#FFFFFF";
|
string_value = "#FFFFFF";
|
||||||
girara_setting_add(gsession, "recolor-dark-color", string_value, STRING, false, "Recoloring (dark color)", NULL);
|
girara_setting_add(gsession, "recolor-dark-color", string_value, STRING, false, "Recoloring (dark color)", NULL, NULL);
|
||||||
string_value = "#000000";
|
string_value = "#000000";
|
||||||
girara_setting_add(gsession, "recolor-light-color", string_value, STRING, false, "Recoloring (light color)", NULL);
|
girara_setting_add(gsession, "recolor-light-color", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
|
||||||
|
|
||||||
/* define default shortcuts */
|
/* define default shortcuts */
|
||||||
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
|
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
|
||||||
|
|
13
zathura.c
13
zathura.c
|
@ -378,11 +378,24 @@ statusbar_page_number_update(zathura_t* zathura)
|
||||||
void
|
void
|
||||||
page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row)
|
page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row)
|
||||||
{
|
{
|
||||||
|
GList* child;
|
||||||
|
|
||||||
/* show at least one page */
|
/* show at least one page */
|
||||||
if (pages_per_row == 0) {
|
if (pages_per_row == 0) {
|
||||||
pages_per_row = 1;
|
pages_per_row = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zathura->document == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
child = gtk_container_get_children(GTK_CONTAINER(zathura->ui.page_view));
|
||||||
|
while (child) {
|
||||||
|
g_object_ref(G_OBJECT(child->data));
|
||||||
|
gtk_container_remove(GTK_CONTAINER(zathura->ui.page_view), GTK_WIDGET(child->data));
|
||||||
|
child = g_list_next(child);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_table_resize(GTK_TABLE(zathura->ui.page_view), zathura->document->number_of_pages / pages_per_row + 1, pages_per_row);
|
gtk_table_resize(GTK_TABLE(zathura->ui.page_view), zathura->document->number_of_pages / pages_per_row + 1, pages_per_row);
|
||||||
for (unsigned int i = 0; i < zathura->document->number_of_pages; i++)
|
for (unsigned int i = 0; i < zathura->document->number_of_pages; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue