Commit 9265c947 authored by Moritz Lipp's avatar Moritz Lipp

Add 'recolor' setting

parent 737f312e
......@@ -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);
}
}
......@@ -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
......@@ -38,7 +38,6 @@ cb_color_change(girara_session_t* session, const char* name, girara_setting_type
/* TODO: cause a redraw here? */
}
void
config_load_default(zathura_t* zathura)
{
......@@ -88,6 +87,8 @@ 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);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true;
......
......@@ -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/) */
......
......@@ -359,11 +359,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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment