Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libview
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2010-07-12 17:06:21 (GMT)
committer Carlos Garcia Campos <carlosgc@gnome.org>2010-07-12 17:12:02 (GMT)
commit726e082719d0148eae6744b962ee1fc05b5af5a4 (patch)
tree97de8c7fc285c3db8f5b15d6892a5ee01f87e9ab /libview
parentc497b6a969f916a476d0bb01e38ff6584ff4bfe5 (diff)
[libview] Add ev_view_focus_annotation() to focus the given annotation
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-view-private.h1
-rw-r--r--libview/ev-view.c55
-rw-r--r--libview/ev-view.h3
3 files changed, 59 insertions, 0 deletions
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 79e6cdb..0630908 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 1d6377f..61e4c0c 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);
}
@@ -4053,6 +4085,29 @@ highlight_forward_search_results (EvView *view, int page)
}
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)
{
GtkWidget *widget = GTK_WIDGET (view);
diff --git a/libview/ev-view.h b/libview/ev-view.h
index d4ee577..712d554 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__ */