mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-26 23:34:40 +01:00
Begin to draw sc_follow results
This commit is contained in:
parent
8ce61ed633
commit
3311038681
5 changed files with 71 additions and 3 deletions
8
config.c
8
config.c
|
@ -43,17 +43,21 @@ config_load_default(zathura_t* zathura)
|
|||
girara_setting_add(gsession, "zoom-step", &int_value, INT, false, "Zoom step", NULL, NULL);
|
||||
int_value = 1;
|
||||
girara_setting_add(gsession, "page-padding", &int_value, INT, true, "Padding between pages", NULL, NULL);
|
||||
int_value = 2;
|
||||
int_value = 1;
|
||||
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, zathura);
|
||||
float_value = 40;
|
||||
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, "Scroll step", NULL, NULL);
|
||||
|
||||
|
||||
string_value = "#FFFFFF";
|
||||
girara_setting_add(gsession, "recolor-darkcolor", string_value, STRING, false, "Recoloring (dark color)", NULL, NULL);
|
||||
string_value = "#000000";
|
||||
girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
|
||||
|
||||
string_value = "#9FBC00";
|
||||
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL);
|
||||
float_value = 0.5;
|
||||
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
|
||||
|
||||
/* define default shortcuts */
|
||||
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
|
||||
girara_shortcut_add(gsession, 0, GDK_Escape, NULL, sc_abort, 0, 0, NULL);
|
||||
|
|
2
render.c
2
render.c
|
@ -298,7 +298,7 @@ page_expose_event(GtkWidget* UNUSED(widget), GdkEventExpose* UNUSED(event),
|
|||
if (page->surface != NULL) {
|
||||
cairo_save(cairo);
|
||||
|
||||
switch(page->document->rotate) {
|
||||
switch (page->document->rotate) {
|
||||
case 90:
|
||||
cairo_translate(cairo, page_width, 0);
|
||||
break;
|
||||
|
|
57
shortcuts.c
57
shortcuts.c
|
@ -103,6 +103,63 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
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;
|
||||
|
||||
if (zathura->document == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* font = girara_setting_get(session, "font");
|
||||
|
||||
float transparency = 0.5;
|
||||
float* tmp = girara_setting_get(session, "highlight-transparency");
|
||||
if (tmp != NULL) {
|
||||
transparency = *tmp;
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
unsigned int link_id = 0;
|
||||
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) {
|
||||
zathura_page_t* page = zathura->document->pages[page_id];
|
||||
if (page == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: is page visible?
|
||||
girara_list_t* links = zathura_page_links_get(page);
|
||||
if (links == NULL || girara_list_size(links) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GIRARA_LIST_FOREACH(links, zathura_link_t*, iter, link)
|
||||
cairo_t* cairo = gdk_cairo_create(page->drawing_area->window);
|
||||
if (font != NULL) {
|
||||
cairo_select_font_face(cairo, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
}
|
||||
|
||||
zathura_rectangle_t position = recalc_rectangle(page, link->position);
|
||||
|
||||
/* draw text */
|
||||
cairo_set_font_size(cairo, 10);
|
||||
cairo_move_to(cairo, position.x1 + 1, position.y1 - 1);
|
||||
char* link_number = g_strdup_printf("%i", ++link_id);
|
||||
cairo_show_text(cairo, link_number);
|
||||
|
||||
/* draw rectangle */
|
||||
GdkColor color = zathura->ui.colors.highlight_color;
|
||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||
cairo_rectangle(cairo, position.x1, position.y1, (position.x2 - position.x1), (position.y2 - position.y1));
|
||||
cairo_fill(cairo);
|
||||
|
||||
cairo_destroy(cairo);
|
||||
|
||||
GIRARA_LIST_FOREACH_END(links, zathura_link_t*, iter, link);
|
||||
}
|
||||
|
||||
if (font != NULL) {
|
||||
free(font);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -217,6 +217,12 @@ zathura_init(int argc, char* argv[])
|
|||
g_free(string_value);
|
||||
}
|
||||
|
||||
string_value = girara_setting_get(zathura->ui.session, "highlight-color");
|
||||
if (string_value != NULL) {
|
||||
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
|
||||
g_free(string_value);
|
||||
}
|
||||
|
||||
/* database */
|
||||
zathura->database = zathura_db_init(zathura->config.data_dir);
|
||||
if (zathura->database == NULL) {
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct zathura_s
|
|||
{
|
||||
GdkColor recolor_dark_color; /**> Dark color for recoloring */
|
||||
GdkColor recolor_light_color; /**> Light color for recoloring */
|
||||
GdkColor highlight_color; /**> Color for highlighting */
|
||||
} colors;
|
||||
|
||||
GtkWidget *page_view_alignment;
|
||||
|
|
Loading…
Add table
Reference in a new issue