Add callback that clears highlighted links when inputbar is hidden

Since hiding the inputbar marks the end of the `follow a link` action,
clearing all links at that event ensures that it will work in all
possible situations.
This commit is contained in:
Sebastian Ramacher 2023-12-04 23:01:34 +01:00
parent 1e9b6a904f
commit 2b9b8a9c70
2 changed files with 29 additions and 0 deletions

View File

@ -834,3 +834,24 @@ cb_gesture_zoom_scale_changed(GtkGestureZoom* UNUSED(self), gdouble scale, void*
render_all(zathura);
refresh_view(zathura);
}
void cb_hide_links(GtkWidget* widget, gpointer data) {
g_return_if_fail(widget != NULL);
g_return_if_fail(data != NULL);
/* disconnect from signal */
gulong handler_id = GPOINTER_TO_UINT(g_object_steal_data(G_OBJECT(widget), "handler_id"));
g_signal_handler_disconnect(G_OBJECT(widget), handler_id);
zathura_t* zathura = data;
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++) {
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
if (page == NULL) {
continue;
}
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
g_object_set(G_OBJECT(page_widget), "draw-links", FALSE, NULL);
}
}

View File

@ -285,4 +285,12 @@ void cb_gesture_zoom_begin(GtkGesture* self, GdkEventSequence* sequence, void* d
void cb_gesture_zoom_scale_changed(GtkGestureZoom* self, gdouble scale, void* data);
/**
* Clears all highlighted links when the inputbar gets closed
*
* @param GtkWidget* Inputbar widget
* @param data The zathura instance
*/
void cb_hide_links(GtkWidget* widget, gpointer data);
#endif // CALLBACKS_H