Add 'recolor' setting

This commit is contained in:
Moritz Lipp 2012-03-14 17:33:35 +01:00
parent 737f312e6c
commit 9265c9473a
5 changed files with 37 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;

View File

@ -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/) */

View File

@ -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;
}