Merge branch 'develop' of pwmt.org:zathura into develop

This commit is contained in:
Sebastian Ramacher 2012-03-14 22:05:41 +01:00
commit 05b92f5417
5 changed files with 67 additions and 16 deletions

View File

@ -325,3 +325,21 @@ cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t*
return false; 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); 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 #endif // CALLBACKS_H

View File

@ -6,6 +6,7 @@
#include "callbacks.h" #include "callbacks.h"
#include "shortcuts.h" #include "shortcuts.h"
#include "zathura.h" #include "zathura.h"
#include "render.h"
#include <girara/settings.h> #include <girara/settings.h>
#include <girara/session.h> #include <girara/session.h>
@ -16,7 +17,8 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
static void 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(value != NULL);
g_return_if_fail(session != 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)); gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
} }
/* TODO: cause a redraw here? */ render_all(zathura);
} }
void void
config_load_default(zathura_t* zathura) 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_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-active-color", "#00BC00"); 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; float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL); girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true; 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); unsigned char* image = cairo_image_surface_get_data(surface);
/* recolor */ /* recolor */
if (zathura->global.recolor) { if (zathura->global.recolor == true) {
/* recolor code based on qimageblitz library flatten() function /* recolor code based on qimageblitz library flatten() function
(http://sourceforge.net/projects/qimageblitz/) */ (http://sourceforge.net/projects/qimageblitz/) */

View File

@ -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(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false); g_return_val_if_fail(zathura->document != NULL, false);
unsigned int number_of_pages = zathura->document->number_of_pages; int number_of_pages = zathura->document->number_of_pages;
unsigned int new_page = zathura->document->current_page_number; 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; t = (t == 0) ? 1 : t;
if (argument->n == NEXT) { 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) { } 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); 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)) girara_event_t* UNUSED(event), unsigned int UNUSED(t))
{ {
g_return_val_if_fail(session != NULL, false); 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; bool value = false;
render_all(zathura); girara_setting_get(session, "recolor", &value);
value = !value;
girara_setting_set(session, "recolor", &value);
return false; 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)); 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 view_size = gtk_adjustment_get_page_size(adjustment);
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size; gdouble value = gtk_adjustment_get_value(adjustment);
unsigned int padding = zathura->global.page_padding; gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
unsigned int padding = zathura->global.page_padding;
zathura->global.update_page_number = true; zathura->global.update_page_number = true;
float scroll_step = 40; float scroll_step = 40;