[evince] view: Don't look for annotation windows twice



commit d4b76d5ca904d5dc28d3f96d35fbb63e9d5c2874
Author: Jose Aliste <jaliste src gnome org>
Date:   Sat Jul 23 08:55:49 2016 -0400

    view: Don't look for annotation windows twice
    
    The only way to create an annotation window is through
    create_annotation_window. As this function always set
    the annot_window_map, we can always use this map to get the annotation
    window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760299

 libview/ev-view.c |   42 ++++++++++++------------------------------
 1 files changed, 12 insertions(+), 30 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index bec6a85..1b26449 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -2999,10 +2999,10 @@ ev_view_window_child_put (EvView    *view,
        view->window_children = g_list_append (view->window_children, child);
 }
 
-static EvViewWindowChild *
-ev_view_find_window_child_for_annot (EvView       *view,
-                                    guint         page,
-                                    EvAnnotation *annot)
+static void
+ev_view_remove_window_child_for_annot (EvView       *view,
+                                      guint         page,
+                                      EvAnnotation *annot)
 {
        GList *children = view->window_children;
 
@@ -3011,17 +3011,18 @@ ev_view_find_window_child_for_annot (EvView       *view,
                EvAnnotation      *wannot;
 
                child = (EvViewWindowChild *)children->data;
-               children = children->next;
 
                if (child->page != page)
                        continue;
 
                wannot = ev_annotation_window_get_annotation (EV_ANNOTATION_WINDOW (child->window));
-               if (ev_annotation_equal (wannot, annot))
-                       return child;
+               if (ev_annotation_equal (wannot, annot)) {
+                       gtk_widget_destroy (child->window);
+                       view->window_children = g_list_delete_link (view->window_children, children);
+                       break;
+               }
+               children = children->next;
        }
-
-       return NULL;
 }
 
 static void
@@ -3165,7 +3166,6 @@ show_annotation_windows (EvView *view,
 
        for (l = ev_mapping_list_get_list (annots); l && l->data; l = g_list_next (l)) {
                EvAnnotation      *annot;
-               EvViewWindowChild *child;
                GtkWidget         *window;
 
                annot = ((EvMapping *)(l->data))->data;
@@ -3179,16 +3179,6 @@ show_annotation_windows (EvView *view,
                window = get_window_for_annot (view, annot);
                if (window) {
                        ev_view_window_child_move_with_parent (view, window);
-                       continue;
-               }
-
-               /* Look if we already have a popup for this annot */
-               child = ev_view_find_window_child_for_annot (view, page, annot);
-               window = child ? child->window : NULL;
-               if (window) {
-                       ev_annotation_window_set_annotation (EV_ANNOTATION_WINDOW (window), annot);
-                       map_annot_to_window (view, annot, window);
-                       ev_view_window_child_move_with_parent (view, window);
                } else {
                        ev_view_create_annotation_window (view, annot, parent);
                }
@@ -3473,16 +3463,8 @@ ev_view_remove_annotation (EvView       *view,
 
         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);
-               }
-        }
+        if (EV_IS_ANNOTATION_MARKUP (annot))
+               ev_view_remove_window_child_for_annot (view, page, annot);
        if (view->annot_window_map != NULL)
                g_hash_table_remove (view->annot_window_map, annot);
 


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