[evince] Refreshing annotations' sidebar upon deletion



commit 13defb2c083b923b20c5413218309e15d75932f6
Author: Giselle Machado <giselle mnr gmail com>
Date:   Sun Jun 22 18:39:58 2014 +0200

    Refreshing annotations' sidebar upon deletion
    
    When an annotation is deleted, the sidebar needs to
    be refreshed so that the annotation is removed from
    the list
    
    See item 3 in this comment:
    https://bugzilla.gnome.org/show_bug.cgi?id=649044#c33

 libview/ev-view-private.h      |    2 ++
 libview/ev-view.c              |   14 ++++++++++++++
 shell/ev-sidebar-annotations.c |    6 ++++++
 shell/ev-sidebar-annotations.h |    9 +++++----
 shell/ev-window.c              |   11 +++++++++++
 5 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 72121cf..2b9e6a7 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -253,6 +253,8 @@ struct _EvViewClass {
                                       EvSourceLink   *link);
         void     (*annot_added)       (EvView         *view,
                                       EvAnnotation   *annot);
+        void     (*annot_removed)     (EvView         *view,
+                                      EvAnnotation   *annot);
         void     (*layers_changed)    (EvView         *view);
         gboolean (*move_cursor)       (EvView         *view,
                                       GtkMovementStep step,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index fadeeae..77eedca 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -53,6 +53,7 @@ enum {
        SIGNAL_SELECTION_CHANGED,
        SIGNAL_SYNC_SOURCE,
        SIGNAL_ANNOT_ADDED,
+       SIGNAL_ANNOT_REMOVED,
        SIGNAL_LAYERS_CHANGED,
        SIGNAL_MOVE_CURSOR,
        SIGNAL_CURSOR_MOVED,
@@ -3266,6 +3267,8 @@ ev_view_remove_annotation (EvView       *view,
         g_return_if_fail (EV_IS_VIEW (view));
         g_return_if_fail (EV_IS_ANNOTATION (annot));
 
+       g_object_ref (annot);
+
         page = ev_annotation_get_page_index (annot);
 
         if (EV_IS_ANNOTATION_MARKUP (annot)) {
@@ -3289,6 +3292,9 @@ ev_view_remove_annotation (EvView       *view,
 
        /* FIXME: only redraw the annot area */
         ev_view_reload_page (view, page, NULL);
+
+       g_signal_emit (view, signals[SIGNAL_ANNOT_REMOVED], 0, annot);
+       g_object_unref (annot);
 }
 
 static gboolean
@@ -6995,6 +7001,14 @@ ev_view_class_init (EvViewClass *class)
                         g_cclosure_marshal_VOID__OBJECT,
                         G_TYPE_NONE, 1,
                         EV_TYPE_ANNOTATION);
+       signals[SIGNAL_ANNOT_REMOVED] = g_signal_new ("annot-removed",
+                        G_TYPE_FROM_CLASS (object_class),
+                        G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                        G_STRUCT_OFFSET (EvViewClass, annot_removed),
+                        NULL, NULL,
+                        g_cclosure_marshal_VOID__OBJECT,
+                        G_TYPE_NONE, 1,
+                        EV_TYPE_ANNOTATION);
        signals[SIGNAL_LAYERS_CHANGED] = g_signal_new ("layers-changed",
                         G_TYPE_FROM_CLASS (object_class),
                         G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
diff --git a/shell/ev-sidebar-annotations.c b/shell/ev-sidebar-annotations.c
index 354d81b..f40aba4 100644
--- a/shell/ev-sidebar-annotations.c
+++ b/shell/ev-sidebar-annotations.c
@@ -325,6 +325,12 @@ ev_sidebar_annotations_annot_added (EvSidebarAnnotations *sidebar_annots,
        ev_sidebar_annotations_load (sidebar_annots);
 }
 
+void
+ev_sidebar_annotations_annot_removed (EvSidebarAnnotations *sidebar_annots)
+{
+       ev_sidebar_annotations_load (sidebar_annots);
+}
+
 static void
 selection_changed_cb (GtkTreeSelection     *selection,
                      EvSidebarAnnotations *sidebar_annots)
diff --git a/shell/ev-sidebar-annotations.h b/shell/ev-sidebar-annotations.h
index 7a73330..a78e89a 100644
--- a/shell/ev-sidebar-annotations.h
+++ b/shell/ev-sidebar-annotations.h
@@ -53,10 +53,11 @@ struct _EvSidebarAnnotationsClass {
        void    (* annot_add_cancelled) (EvSidebarAnnotations *sidebar_annots);
 };
 
-GType      ev_sidebar_annotations_get_type    (void) G_GNUC_CONST;
-GtkWidget *ev_sidebar_annotations_new         (void);
-void       ev_sidebar_annotations_annot_added (EvSidebarAnnotations *sidebar_annots,
-                                              EvAnnotation         *annot);
+GType      ev_sidebar_annotations_get_type      (void) G_GNUC_CONST;
+GtkWidget *ev_sidebar_annotations_new           (void);
+void       ev_sidebar_annotations_annot_added   (EvSidebarAnnotations *sidebar_annots,
+                                                EvAnnotation         *annot);
+void       ev_sidebar_annotations_annot_removed (EvSidebarAnnotations *sidebar_annots);
 G_END_DECLS
 
 #endif /* __EV_SIDEBAR_ANNOTATIONS_H__ */
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 74d1fcd..f53e994 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -5887,6 +5887,14 @@ view_annot_added (EvView       *view,
 }
 
 static void
+view_annot_removed (EvView       *view,
+                   EvAnnotation *annot,
+                   EvWindow     *window)
+{
+       ev_sidebar_annotations_annot_removed (EV_SIDEBAR_ANNOTATIONS (window->priv->sidebar_annots));
+}
+
+static void
 sidebar_annots_annot_add_cancelled (EvSidebarAnnotations *sidebar_annots,
                                    EvWindow             *window)
 {
@@ -7043,6 +7051,9 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect_object (ev_window->priv->view, "annot-added",
                                 G_CALLBACK (view_annot_added),
                                 ev_window, 0);
+       g_signal_connect_object (ev_window->priv->view, "annot-removed",
+                                G_CALLBACK (view_annot_removed),
+                                ev_window, 0);
        g_signal_connect_object (ev_window->priv->view, "layers-changed",
                                 G_CALLBACK (view_layers_changed_cb),
                                 ev_window, 0);


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