[evince] Add an option to remove annotations to the view popup menu



commit 0f19833da90418d76f99c8e1fcf1ebfd67714754
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Fri Aug 15 12:21:52 2014 +0200

    Add an option to remove annotations to the view popup menu
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649044

 shell/ev-window.c     |   24 +++++++++++++++++++++++-
 shell/evince-menus.ui |    5 +++++
 2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 613e994..74d1fcd 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -337,6 +337,9 @@ static void     ev_window_popup_cmd_copy_image          (GSimpleAction    *actio
 static void     ev_window_popup_cmd_annot_properties    (GSimpleAction    *action,
                                                         GVariant         *parameter,
                                                         gpointer          user_data);
+static void     ev_window_popup_cmd_remove_annotation   (GSimpleAction    *action,
+                                                        GVariant         *parameter,
+                                                        gpointer          user_data);
 static void    ev_window_popup_cmd_open_attachment     (GSimpleAction    *action,
                                                         GVariant         *parameter,
                                                         gpointer          user_data);
@@ -552,6 +555,7 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
        ev_window_set_action_enabled (ev_window, "open-attachment", !recent_view_mode);
        ev_window_set_action_enabled (ev_window, "save-attachment", !recent_view_mode);
        ev_window_set_action_enabled (ev_window, "annot-properties", !recent_view_mode);
+       ev_window_set_action_enabled (ev_window, "remove-annot", !recent_view_mode);
 
        can_find_in_page = (ev_window->priv->find_job &&
                            ev_job_find_has_results (EV_JOB_FIND (ev_window->priv->find_job)));
@@ -4994,6 +4998,7 @@ view_menu_annot_popup (EvWindow     *ev_window,
        GAction *action;
        gboolean show_annot_props = FALSE;
        gboolean show_attachment = FALSE;
+       gboolean can_remove_annots;
 
        g_clear_object (&ev_window->priv->annot);
        if (annot) {
@@ -5017,9 +5022,14 @@ view_menu_annot_popup (EvWindow     *ev_window,
                }
        }
 
+       can_remove_annots = ev_document_annotations_can_remove_annotation (EV_DOCUMENT_ANNOTATIONS 
(ev_window->priv->document));
+
        action = g_action_map_lookup_action (G_ACTION_MAP (ev_window), "annot-properties");
        g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_annot_props);
 
+       action = g_action_map_lookup_action (G_ACTION_MAP (ev_window), "remove-annot");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), annot != NULL && can_remove_annots);
+
        action = g_action_map_lookup_action (G_ACTION_MAP (ev_window), "open-attachment");
        g_simple_action_set_enabled (G_SIMPLE_ACTION (action), show_attachment);
 
@@ -5817,7 +5827,8 @@ static const GActionEntry actions[] = {
        { "copy-image", ev_window_popup_cmd_copy_image },
        { "open-attachment", ev_window_popup_cmd_open_attachment },
        { "save-attachment", ev_window_popup_cmd_save_attachment_as },
-       { "annot-properties", ev_window_popup_cmd_annot_properties }
+       { "annot-properties", ev_window_popup_cmd_annot_properties },
+       { "remove-annot", ev_window_popup_cmd_remove_annotation }
 };
 
 static void
@@ -6459,6 +6470,17 @@ ev_window_popup_cmd_annot_properties (GSimpleAction *action,
 }
 
 static void
+ev_window_popup_cmd_remove_annotation (GSimpleAction *action,
+                                      GVariant      *parameter,
+                                      gpointer       user_data)
+{
+       EvWindow *window = user_data;
+
+       ev_view_remove_annotation (EV_VIEW (window->priv->view),
+                                  window->priv->annot);
+}
+
+static void
 ev_window_popup_cmd_open_attachment (GSimpleAction *action,
                                     GVariant      *parameter,
                                     gpointer       user_data)
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index 48f0f23..a62821c 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -282,6 +282,11 @@
         <attribute name='hidden-when'>action-disabled</attribute>
       </item>
       <item>
+        <attribute name="label" translatable="yes">Remove Annotation</attribute>
+        <attribute name="action">win.remove-annot</attribute>
+        <attribute name='hidden-when'>action-disabled</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">Open Containing _Folder</attribute>
         <attribute name="action">win.open-containing-folder</attribute>
       </item>


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