Commit 0b88e118 authored by Moritz Lipp's avatar Moritz Lipp
Browse files

Evaluate sc_follow input correctly

parent 86ce201e
......@@ -177,6 +177,8 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
continue;
}
g_object_set(page->drawing_area, "draw-links", FALSE, NULL);
zathura_link_t* link = zathura_page_view_link_get(ZATHURA_PAGE_VIEW(page->drawing_area), index);
if (link != NULL) {
switch (link->type) {
......
......@@ -129,6 +129,7 @@ zathura_page_view_set_property(GObject* object, guint prop_id, const GValue* val
if (priv->draw_links == true && priv->links_got == false) {
priv->links = zathura_page_links_get(priv->page);
priv->links_got = true;
priv->number_of_links = (priv->links == NULL) ? 0 : girara_list_size(priv->links);
}
if (priv->links_got == true && priv->links != NULL) {
......@@ -235,19 +236,20 @@ zathura_page_view_expose(GtkWidget* widget, GdkEventExpose* event)
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, link->position);
/* draw text */
cairo_set_font_size(cairo, 10);
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y1 - 1);
char* link_number = g_strdup_printf("%i", priv->link_offset + ++link_counter);
cairo_show_text(cairo, link_number);
g_free(link_number);
/* draw position */
GdkColor color = priv->zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
cairo_fill(cairo);
/* draw text */
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
cairo_set_font_size(cairo, 10);
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y1 - 1);
char* link_number = g_strdup_printf("%i", priv->link_offset + ++link_counter);
cairo_show_text(cairo, link_number);
g_free(link_number);
GIRARA_LIST_FOREACH_END(priv->links, zathura_link_t*, iter, link);
}
......
......@@ -10,6 +10,9 @@
* The page view widget. The widget handles all the rendering on its own. It
* only has to be resized. The widget also manages and handles all the
* rectangles for highlighting.
*
* Before the properties contain the correct values, 'draw-links' has to be set
* to TRUE at least one time.
* */
typedef struct zathura_page_view_s ZathuraPageView;
typedef struct zathura_page_view_class_s ZathuraPageViewClass;
......
......@@ -131,9 +131,10 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
g_object_set(page->drawing_area, "search-results", NULL, NULL);
if (page->visible == true) {
g_object_set(page->drawing_area, "draw-links", TRUE, NULL);
int number_of_links = 0;
g_object_get(page->drawing_area, "number-of-links", &number_of_links, NULL);
g_object_set(page->drawing_area, "draw-links", TRUE, NULL);
g_object_set(page->drawing_area, "offset-links", page_offset, NULL);
page_offset += number_of_links;
} else {
......
......@@ -185,7 +185,8 @@ page_calculate_offset(zathura_page_t* page, page_offset_t* offset)
zathura_document_t* document = page->document;
zathura_t* zathura = document->zathura;
g_return_if_fail(gtk_widget_translate_coordinates(page->drawing_area, zathura->ui.page_view, 0, 0, &(offset->x), &(offset->y)) == true);
g_return_if_fail(gtk_widget_translate_coordinates(page->drawing_area,
zathura->ui.page_view, 0, 0, &(offset->x), &(offset->y)) == true);
}
zathura_rectangle_t
......
Supports Markdown
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