[evince] libview: add ev_view_remove_annotation



commit 927e956fef4a33b95c53e57ab6036c422527dbed
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Fri May 2 18:25:30 2014 -0700

    libview: add ev_view_remove_annotation
    
    Hide annotation windows if necessary and unset selected
    element before removing an annotation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649044

 libview/ev-view.c |   34 ++++++++++++++++++++++++++++++++++
 libview/ev-view.h |    2 ++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 3ab2fc6..d79d758 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3257,6 +3257,40 @@ ev_view_cancel_add_annotation (EvView *view)
        ev_view_handle_cursor_over_xy (view, x, y);
 }
 
+void
+ev_view_remove_annotation (EvView       *view,
+                           EvAnnotation *annot)
+{
+        guint page;
+
+        g_return_if_fail (EV_IS_VIEW (view));
+        g_return_if_fail (EV_IS_ANNOTATION (annot));
+
+        page = ev_annotation_get_page_index (annot);
+
+        if (EV_IS_ANNOTATION_MARKUP (annot)) {
+               EvViewWindowChild *child;
+
+               child = ev_view_find_window_child_for_annot (view, page, annot);
+               if (child) {
+                       view->window_children = g_list_remove (view->window_children, child);
+                       gtk_widget_destroy (child->window);
+                       g_free (child);
+               }
+        }
+        _ev_view_set_focused_element (view, NULL, -1);
+
+        ev_document_doc_mutex_lock ();
+        ev_document_annotations_remove_annotation (EV_DOCUMENT_ANNOTATIONS (view->document),
+                                                   annot);
+        ev_document_doc_mutex_unlock ();
+
+        ev_page_cache_mark_dirty (view->page_cache, page);
+
+       /* FIXME: only redraw the annot area */
+        ev_view_reload_page (view, page, NULL);
+}
+
 static gboolean
 ev_view_synctex_backward_search (EvView *view,
                                 gdouble x,
diff --git a/libview/ev-view.h b/libview/ev-view.h
index 193bcce..9baa97d 100644
--- a/libview/ev-view.h
+++ b/libview/ev-view.h
@@ -119,6 +119,8 @@ void           ev_view_focus_annotation      (EvView          *view,
 void           ev_view_begin_add_annotation  (EvView          *view,
                                              EvAnnotationType annot_type);
 void           ev_view_cancel_add_annotation (EvView          *view);
+void           ev_view_remove_annotation     (EvView          *view,
+                                             EvAnnotation    *annot);
 
 /* Caret navigation */
 gboolean       ev_view_supports_caret_navigation    (EvView  *view);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]