mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 06:46:00 +01:00
Refactor handle_links
As soon as we found the link, we do not need to look any further.
This commit is contained in:
parent
a6859512b5
commit
bb84bb4eaa
1 changed files with 25 additions and 32 deletions
|
@ -408,26 +408,24 @@ handle_link(GtkEntry* entry, girara_session_t* session,
|
||||||
index = index - 1;
|
index = index - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set pages to draw links */
|
/* find the link*/
|
||||||
bool invalid_index = true;
|
zathura_link_t* link = NULL;
|
||||||
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
||||||
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
|
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
|
||||||
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
|
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
|
||||||
if (page == NULL || zathura_page_get_visibility(page) == false) {
|
if (page == NULL || zathura_page_get_visibility(page) == false || eval == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
|
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
|
||||||
g_object_set(G_OBJECT(page_widget), "draw-links", FALSE, NULL);
|
link = zathura_page_widget_link_get(ZATHURA_PAGE(page_widget), index);
|
||||||
|
if (link != NULL) {
|
||||||
if (eval == FALSE) {
|
break;
|
||||||
/* nothing to evaluate */
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_link_t* link = zathura_page_widget_link_get(ZATHURA_PAGE(page_widget), index);
|
if (eval == TRUE && link == NULL) {
|
||||||
if (link != NULL) {
|
girara_notify(session, GIRARA_WARNING, _("Invalid index '%s' given."), input);
|
||||||
invalid_index = false;
|
} else {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ZATHURA_LINK_ACTION_FOLLOW:
|
case ZATHURA_LINK_ACTION_FOLLOW:
|
||||||
zathura_link_evaluate(zathura, link);
|
zathura_link_evaluate(zathura, link);
|
||||||
|
@ -447,11 +445,6 @@ handle_link(GtkEntry* entry, girara_session_t* session,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (eval == TRUE && invalid_index == true) {
|
|
||||||
girara_notify(session, GIRARA_WARNING, _("Invalid index '%s' given."), input);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free(input);
|
g_free(input);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue