mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-28 00:14:39 +01:00
Evaluate sc_follow input correctly
This commit is contained in:
parent
86ce201ec9
commit
0b88e118a5
5 changed files with 18 additions and 9 deletions
|
@ -177,6 +177,8 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
|
||||||
continue;
|
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);
|
zathura_link_t* link = zathura_page_view_link_get(ZATHURA_PAGE_VIEW(page->drawing_area), index);
|
||||||
if (link != NULL) {
|
if (link != NULL) {
|
||||||
switch (link->type) {
|
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) {
|
if (priv->draw_links == true && priv->links_got == false) {
|
||||||
priv->links = zathura_page_links_get(priv->page);
|
priv->links = zathura_page_links_get(priv->page);
|
||||||
priv->links_got = true;
|
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) {
|
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)
|
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, link->position);
|
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 */
|
/* draw position */
|
||||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
||||||
cairo_fill(cairo);
|
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);
|
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
|
* 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
|
* only has to be resized. The widget also manages and handles all the
|
||||||
* rectangles for highlighting.
|
* 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_s ZathuraPageView;
|
||||||
typedef struct zathura_page_view_class_s ZathuraPageViewClass;
|
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);
|
g_object_set(page->drawing_area, "search-results", NULL, NULL);
|
||||||
if (page->visible == true) {
|
if (page->visible == true) {
|
||||||
|
g_object_set(page->drawing_area, "draw-links", TRUE, NULL);
|
||||||
|
|
||||||
int number_of_links = 0;
|
int number_of_links = 0;
|
||||||
g_object_get(page->drawing_area, "number-of-links", &number_of_links, NULL);
|
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);
|
g_object_set(page->drawing_area, "offset-links", page_offset, NULL);
|
||||||
page_offset += number_of_links;
|
page_offset += number_of_links;
|
||||||
} else {
|
} else {
|
||||||
|
|
3
utils.c
3
utils.c
|
@ -185,7 +185,8 @@ page_calculate_offset(zathura_page_t* page, page_offset_t* offset)
|
||||||
zathura_document_t* document = page->document;
|
zathura_document_t* document = page->document;
|
||||||
zathura_t* zathura = document->zathura;
|
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
|
zathura_rectangle_t
|
||||||
|
|
Loading…
Add table
Reference in a new issue