[evince/unpress_button_on_cancel_annotation] New EvView signal to inform EvWindow we cancelled adding annotation




commit b76b317f712542ee8e5e17f8a0816197a329ecc0
Author: Nelson Benítez León <nbenitezl gmail com>
Date:   Tue Jan 25 00:17:09 2022 -0400

    New EvView signal to inform EvWindow we cancelled adding annotation
    
    EvView have signals 'annot-added', 'annot-removed', 'annot-changed'
    which EvWindow connects to update the window widgets accordingly.
    
    When cancelling an ongoing add-annotation operation through eg.
    not highlighting any text when adding a markup annotation, we
    don't have any corresponding signal to let EvWindow know of this
    cancel (as 'annot-added' is only for when it's created
    succesfully).
    
    So we add a new EvView 'annot-cancel-add' signal which is
    emitted for this case and that EvWindow can respond to it
    by updating the ui accordingly i.e. unpressing button in
    EvAnnotationsToolbar.
    
    Fixes part of #1730

 libview/ev-view-private.h |  1 +
 libview/ev-view.c         | 11 +++++++++++
 shell/ev-window.c         | 11 +++++++++++
 3 files changed, 23 insertions(+)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index c73e2f482..5e60b1af7 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -293,6 +293,7 @@ struct _EvViewClass {
                                       EvSourceLink   *link);
         void     (*annot_added)       (EvView         *view,
                                       EvAnnotation   *annot);
+        void     (*annot_cancel_add)  (EvView         *view);
         void     (*annot_changed)     (EvView         *view,
                                       EvAnnotation   *annot);
         void     (*annot_removed)     (EvView         *view,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 0924b0cc2..a95751ea0 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -59,6 +59,7 @@ enum {
        SIGNAL_SELECTION_CHANGED,
        SIGNAL_SYNC_SOURCE,
        SIGNAL_ANNOT_ADDED,
+       SIGNAL_ANNOT_CANCEL_ADD,
        SIGNAL_ANNOT_CHANGED,
        SIGNAL_ANNOT_REMOVED,
        SIGNAL_LAYERS_CHANGED,
@@ -6467,6 +6468,8 @@ ev_view_button_release_event (GtkWidget      *widget,
                view->adding_annot_info.stop.y = event->y + view->scroll_y;
                if (annot_added)
                        g_signal_emit (view, signals[SIGNAL_ANNOT_ADDED], 0, view->adding_annot_info.annot);
+               else
+                       g_signal_emit (view, signals[SIGNAL_ANNOT_CANCEL_ADD], 0, NULL);
 
                view->adding_annot_info.adding_annot = FALSE;
                view->adding_annot_info.annot = NULL;
@@ -8298,6 +8301,14 @@ ev_view_class_init (EvViewClass *class)
                         g_cclosure_marshal_VOID__OBJECT,
                         G_TYPE_NONE, 1,
                         EV_TYPE_ANNOTATION);
+       signals[SIGNAL_ANNOT_CANCEL_ADD] = g_signal_new ("annot-cancel-add",
+                         G_TYPE_FROM_CLASS (object_class),
+                         G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                         G_STRUCT_OFFSET (EvViewClass, annot_cancel_add),
+                         NULL, NULL,
+                        g_cclosure_marshal_VOID__VOID,
+                         G_TYPE_NONE, 0,
+                         G_TYPE_NONE);
        signals[SIGNAL_ANNOT_CHANGED] = g_signal_new ("annot-changed",
                         G_TYPE_FROM_CLASS (object_class),
                         G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
diff --git a/shell/ev-window.c b/shell/ev-window.c
index a92795b38..de2ac7a3c 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -6507,6 +6507,14 @@ view_annot_added (EvView       *view,
        ev_annotations_toolbar_add_annot_finished (EV_ANNOTATIONS_TOOLBAR (priv->annots_toolbar));
 }
 
+static void
+view_annot_cancel_add (EvView   *view,
+                      EvWindow *window)
+{
+       EvWindowPrivate *priv = GET_PRIVATE (window);
+       ev_annotations_toolbar_add_annot_finished (EV_ANNOTATIONS_TOOLBAR (priv->annots_toolbar));
+}
+
 static void
 view_annot_changed (EvView       *view,
                    EvAnnotation *annot,
@@ -7731,6 +7739,9 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect_object (priv->view, "annot-added",
                                 G_CALLBACK (view_annot_added),
                                 ev_window, 0);
+       g_signal_connect_object (priv->view, "annot-cancel-add",
+                                G_CALLBACK (view_annot_cancel_add),
+                                ev_window, 0);
        g_signal_connect_object (priv->view, "annot-changed",
                                 G_CALLBACK (view_annot_changed),
                                 ev_window, 0);


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