From 5a0e067dce6f55d9a78865c381b19282a5ebfd1d Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 11 May 2010 20:45:47 +0200 Subject: [PATCH] Highlight search results again This commit is a incomplete patch to highlight the search results again. --- zathura.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/zathura.c b/zathura.c index f3e1197..491489e 100644 --- a/zathura.c +++ b/zathura.c @@ -244,6 +244,12 @@ struct GStaticMutex search_lock; } Lock; + struct + { + GList* results; + int page; + } Search; + struct { GThread* search_thread; @@ -427,6 +433,9 @@ init_zathura() Zathura.Marker.number_of_markers = 0; Zathura.Marker.last = -1; + Zathura.Search.results = NULL; + Zathura.Search.page = 0; + Zathura.Inotify.fd = inotify_init(); /* UI */ @@ -1135,7 +1144,6 @@ search(void* parameter) static int next_page = 0; int page_counter; GList* results = NULL; - GList* list = NULL; if(argument->data) search_item = g_strdup((char*) argument->data); @@ -1151,10 +1159,19 @@ search(void* parameter) } g_static_mutex_unlock(&(Zathura.Lock.document_lock)); + /* delete old results */ + if(Zathura.Search.results) + { + g_list_free(Zathura.Search.results); + Zathura.Search.results = NULL; + } + /* search document */ if(argument->n) direction = (argument->n == BACKWARD) ? -1 : 1; + printf("%s\n", search_item); + int number_of_pages = Zathura.PDF.number_of_pages; int page_number = Zathura.PDF.page_number; @@ -1193,8 +1210,8 @@ search(void* parameter) set_page(next_page); - for(list = results; list && list->data; list = g_list_next(list)) - highlight_result(next_page, (PopplerRectangle*) list->data); + Zathura.Search.results = results; + Zathura.Search.page = next_page; gdk_threads_leave(); } @@ -3004,6 +3021,9 @@ gboolean cb_draw(GtkWidget* widget, GdkEventExpose* expose, gpointer data) else offset_y = 0; + GList* list; + for(list = Zathura.Search.results; list && list->data; list = g_list_next(list)) + highlight_result(Zathura.Search.page, (PopplerRectangle*) list->data); cairo_set_source_surface(cairo, Zathura.PDF.surface, offset_x, offset_y); cairo_paint(cairo);