From: Carlos Garcia Campos Date: Mon, 12 Jul 2010 17:06:21 +0000 (+0200) Subject: [libview] Add ev_view_focus_annotation() to focus the given annotation X-Git-Tag: EVINCE_2_31_5~10 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=726e082719d0148eae6744b962ee1fc05b5af5a4;p=evince.git [libview] Add ev_view_focus_annotation() to focus the given annotation --- diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h index 79e6cdb7..06309082 100644 --- a/libview/ev-view-private.h +++ b/libview/ev-view-private.h @@ -184,6 +184,7 @@ struct _EvView { /* Annotations */ GList *window_children; EvViewWindowChild *window_child_focus; + EvMapping *focus_annotation; /* Synctex */ EvMapping *synctex_result; diff --git a/libview/ev-view.c b/libview/ev-view.c index 1d6377f7..61e4c0c6 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -178,6 +178,9 @@ static void highlight_find_results (EvView int page); static void highlight_forward_search_results (EvView *view, int page); +static void focus_annotation (EvView *view, + int page, + GdkRectangle *clip); static void draw_one_page (EvView *view, gint page, cairo_t *cr, @@ -2746,6 +2749,30 @@ ev_view_handle_annotation (EvView *view, } } +void +ev_view_focus_annotation (EvView *view, + EvMapping *annot_mapping) +{ + GdkRectangle view_rect; + EvAnnotation *annot; + + if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document)) + return; + + if (view->focus_annotation == annot_mapping) + return; + + view->focus_annotation = annot_mapping; + annot = (EvAnnotation *)annot_mapping->data; + + ev_document_model_set_page (view->model, annot->page->index); + + doc_rect_to_view_rect (view, annot->page->index, + &annot_mapping->area, &view_rect); + ensure_rectangle_is_visible (view, &view_rect); + gtk_widget_queue_draw (GTK_WIDGET (view)); +} + static gboolean ev_view_synctex_backward_search (EvView *view, gdouble x, @@ -3175,6 +3202,8 @@ ev_view_expose_event (GtkWidget *widget, highlight_find_results (view, i); if (page_ready && EV_IS_DOCUMENT_ANNOTATIONS (view->document)) show_annotation_windows (view, i); + if (page_ready && view->focus_annotation) + focus_annotation (view, i, &event->area); if (page_ready && view->synctex_result) highlight_forward_search_results (view, i); } @@ -3411,6 +3440,9 @@ ev_view_button_press_event (GtkWidget *widget, gtk_widget_queue_draw (widget); } + if (view->focus_annotation) + view->focus_annotation = NULL; + if (EV_IS_SELECTION (view->document)) start_selection_for_event (view, event); } @@ -4052,6 +4084,29 @@ highlight_forward_search_results (EvView *view, int page) cairo_destroy (cr); } +static void +focus_annotation (EvView *view, + gint page, + GdkRectangle *clip) +{ + GtkWidget *widget = GTK_WIDGET (view); + GdkRectangle rect; + EvMapping *mapping = view->focus_annotation; + EvAnnotation *annot = (EvAnnotation *)mapping->data; + + if (annot->page->index != page) + return; + + doc_rect_to_view_rect (view, page, &mapping->area, &rect); + gtk_paint_focus (gtk_widget_get_style (widget), + gtk_layout_get_bin_window (GTK_LAYOUT (view)), + gtk_widget_get_state (widget), + NULL, widget, NULL, + rect.x - view->scroll_x, + rect.y - view->scroll_y, + rect.width + 1, rect.height + 1); +} + static void ev_view_loading_window_move (EvView *view) { diff --git a/libview/ev-view.h b/libview/ev-view.h index d4ee577e..712d5546 100644 --- a/libview/ev-view.h +++ b/libview/ev-view.h @@ -104,6 +104,9 @@ gboolean ev_view_get_page_extents (EvView *view, GdkRectangle *page_area, GtkBorder *border); +void ev_view_focus_annotation (EvView *view, + EvMapping *annot_mapping); + G_END_DECLS #endif /* __EV_VIEW_H__ */