From 5891c789db9e0d6828a4ab0a9b4c77d57138ae0f Mon Sep 17 00:00:00 2001 From: raveit65 Date: Tue, 22 Aug 2017 17:24:33 +0200 Subject: Add an option to remove annotations to the view popup menu https://bugzilla.gnome.org/show_bug.cgi?id=649044 inspired by: https://git.gnome.org/browse/evince/commit/?id=0f19833 --- data/atril-ui.xml | 1 + shell/ev-window.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/data/atril-ui.xml b/data/atril-ui.xml index d6161396..579651e5 100644 --- a/data/atril-ui.xml +++ b/data/atril-ui.xml @@ -95,6 +95,7 @@ + diff --git a/shell/ev-window.c b/shell/ev-window.c index f15a74da..13870211 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -336,6 +336,8 @@ static void ev_view_popup_cmd_copy_image (GtkAction *actio EvWindow *window); static void ev_view_popup_cmd_annot_properties (GtkAction *action, EvWindow *window); +static void ev_view_popup_cmd_remove_annotation (GtkAction *action, + EvWindow *window); static void ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window); static void ev_attachment_popup_cmd_save_attachment_as (GtkAction *action, @@ -5359,6 +5361,7 @@ view_menu_annot_popup (EvWindow *ev_window, { GtkAction *action; gboolean show_annot = FALSE; + gboolean can_remove_annots; if (ev_window->priv->document->iswebdocument == TRUE ) return ; if (ev_window->priv->annot) g_object_unref (ev_window->priv->annot); @@ -5368,6 +5371,12 @@ view_menu_annot_popup (EvWindow *ev_window, "AnnotProperties"); gtk_action_set_visible (action, (annot != NULL && EV_IS_ANNOTATION_MARKUP (annot))); + can_remove_annots = ev_document_annotations_can_remove_annotation (EV_DOCUMENT_ANNOTATIONS (ev_window->priv->document)); + + action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group, + "RemoveAnnot"); + gtk_action_set_visible (action, (annot != NULL && can_remove_annots)); + if (annot && EV_IS_ANNOTATION_ATTACHMENT (annot)) { EvAttachment *attachment; @@ -6336,7 +6345,9 @@ static const GtkActionEntry view_popup_entries [] = { { "CopyImage", NULL, N_("Copy _Image"), NULL, NULL, G_CALLBACK (ev_view_popup_cmd_copy_image) }, { "AnnotProperties", NULL, N_("Annotation Properties…"), NULL, - NULL, G_CALLBACK (ev_view_popup_cmd_annot_properties) } + NULL, G_CALLBACK (ev_view_popup_cmd_annot_properties) }, + { "RemoveAnnot", NULL, N_("Remove Annot…"), NULL, + NULL, G_CALLBACK (ev_view_popup_cmd_remove_annotation) } }; static const GtkActionEntry attachment_popup_entries [] = { @@ -7125,6 +7136,14 @@ ev_view_popup_cmd_annot_properties (GtkAction *action, gtk_widget_destroy (GTK_WIDGET (dialog)); } +static void +ev_view_popup_cmd_remove_annotation (GtkAction *action, + EvWindow *window) +{ + ev_view_remove_annotation (EV_VIEW (window->priv->view), + window->priv->annot); +} + static void ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window) { -- cgit v1.2.1