mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 22:53:47 +01:00
Merge branch 'develop' of pwmt.org:zathura into develop
This commit is contained in:
commit
05b92f5417
18
callbacks.c
18
callbacks.c
@ -325,3 +325,21 @@ cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t*
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
cb_setting_recolor_change(girara_session_t* session, const char* 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);
|
||||
g_return_if_fail(name != NULL);
|
||||
zathura_t* zathura = session->global.data;
|
||||
|
||||
bool bool_value = *((bool*) value);
|
||||
|
||||
if (zathura->global.recolor != bool_value) {
|
||||
zathura->global.recolor = bool_value;
|
||||
render_all(zathura);
|
||||
}
|
||||
}
|
||||
|
12
callbacks.h
12
callbacks.h
@ -98,4 +98,16 @@ bool cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog)
|
||||
*/
|
||||
bool cb_view_resized(GtkWidget* widget, GtkAllocation* allocation, zathura_t* zathura);
|
||||
|
||||
/**
|
||||
* Emitted when the 'recolor' setting is changed
|
||||
*
|
||||
* @param session Girara session
|
||||
* @param name Name of the setting ("recolor")
|
||||
* @param type Type of the setting (BOOLEAN)
|
||||
* @param value New value
|
||||
* @param data Custom data
|
||||
*/
|
||||
void cb_setting_recolor_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t type, void* value, void* data);
|
||||
|
||||
#endif // CALLBACKS_H
|
||||
|
11
config.c
11
config.c
@ -6,6 +6,7 @@
|
||||
#include "callbacks.h"
|
||||
#include "shortcuts.h"
|
||||
#include "zathura.h"
|
||||
#include "render.h"
|
||||
|
||||
#include <girara/settings.h>
|
||||
#include <girara/session.h>
|
||||
@ -16,7 +17,8 @@
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static void
|
||||
cb_color_change(girara_session_t* session, const char* name, girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
cb_color_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
@ -35,10 +37,9 @@ cb_color_change(girara_session_t* session, const char* name, girara_setting_type
|
||||
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
|
||||
}
|
||||
|
||||
/* TODO: cause a redraw here? */
|
||||
render_all(zathura);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
config_load_default(zathura_t* zathura)
|
||||
{
|
||||
@ -88,6 +89,10 @@ config_load_default(zathura_t* zathura)
|
||||
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
|
||||
girara_setting_set(gsession, "highlight-active-color", "#00BC00");
|
||||
|
||||
bool_value = false;
|
||||
girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
|
||||
bool_value = false;
|
||||
girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
|
||||
float_value = 0.5;
|
||||
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
|
||||
bool_value = true;
|
||||
|
2
render.c
2
render.c
@ -132,7 +132,7 @@ render(zathura_t* zathura, zathura_page_t* page)
|
||||
unsigned char* image = cairo_image_surface_get_data(surface);
|
||||
|
||||
/* recolor */
|
||||
if (zathura->global.recolor) {
|
||||
if (zathura->global.recolor == true) {
|
||||
/* recolor code based on qimageblitz library flatten() function
|
||||
(http://sourceforge.net/projects/qimageblitz/) */
|
||||
|
||||
|
40
shortcuts.c
40
shortcuts.c
@ -339,14 +339,29 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument,
|
||||
g_return_val_if_fail(argument != NULL, false);
|
||||
g_return_val_if_fail(zathura->document != NULL, false);
|
||||
|
||||
unsigned int number_of_pages = zathura->document->number_of_pages;
|
||||
unsigned int new_page = zathura->document->current_page_number;
|
||||
int number_of_pages = zathura->document->number_of_pages;
|
||||
int new_page = zathura->document->current_page_number;
|
||||
|
||||
bool scroll_wrap = false;
|
||||
girara_setting_get(session, "scroll-wrap", &scroll_wrap);
|
||||
|
||||
t = (t == 0) ? 1 : t;
|
||||
if (argument->n == NEXT) {
|
||||
new_page = (new_page + t) % number_of_pages;
|
||||
if (scroll_wrap == true) {
|
||||
new_page = new_page + t;
|
||||
} else {
|
||||
new_page = (new_page + t) % number_of_pages;
|
||||
}
|
||||
} else if (argument->n == PREVIOUS) {
|
||||
new_page = (new_page + number_of_pages - t) % number_of_pages;
|
||||
if (scroll_wrap == true) {
|
||||
new_page = new_page - t;
|
||||
} else {
|
||||
new_page = (new_page + number_of_pages - t) % number_of_pages;
|
||||
}
|
||||
}
|
||||
|
||||
if (scroll_wrap == true && (new_page < 0 || new_page >= number_of_pages)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
page_set(zathura, new_page);
|
||||
@ -359,11 +374,11 @@ sc_recolor(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
zathura_t* zathura = session->global.data;
|
||||
|
||||
zathura->global.recolor = !zathura->global.recolor;
|
||||
render_all(zathura);
|
||||
bool value = false;
|
||||
girara_setting_get(session, "recolor", &value);
|
||||
value = !value;
|
||||
girara_setting_set(session, "recolor", &value);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -431,10 +446,11 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
|
||||
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
}
|
||||
|
||||
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
|
||||
gdouble value = gtk_adjustment_get_value(adjustment);
|
||||
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
|
||||
unsigned int padding = zathura->global.page_padding;
|
||||
|
||||
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
|
||||
gdouble value = gtk_adjustment_get_value(adjustment);
|
||||
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
|
||||
unsigned int padding = zathura->global.page_padding;
|
||||
zathura->global.update_page_number = true;
|
||||
|
||||
float scroll_step = 40;
|
||||
|
Loading…
Reference in New Issue
Block a user