[evince/wip/gpoo/new-annotation-action: 3/3] shell: Integrate EvAnnotationAction into the shell



commit 76b5eeda207e4607f043a498da8dfa4a7bf5eabc
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Fri May 29 01:28:22 2020 -0400

    shell: Integrate EvAnnotationAction into the shell

 shell/ev-application.c |  2 ++
 shell/ev-toolbar.h     |  4 +++-
 shell/ev-window.c      | 26 ++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 2085ba60..5dc4c934 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -983,6 +983,8 @@ ev_application_startup (GApplication *gapplication)
           "win.reload",                 "<Ctrl>R", NULL,
           "win.add-annotation",         "s", NULL,
           "win.highlight-annotation",   "<Ctrl>H", NULL,
+          "win.select-annotation::highlight", NULL, NULL,
+          "win.select-annotation::note", NULL, NULL,
           "win.help",                   "F1", NULL,
           "win.about",                  NULL, NULL,
           NULL
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index b278e9dc..93967aeb 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -23,6 +23,7 @@
 
 #include <gtk/gtk.h>
 #include "ev-window.h"
+#include "ev-annotation-action.h"
 
 G_BEGIN_DECLS
 
@@ -58,7 +59,8 @@ GtkWidget    *ev_toolbar_get_page_selector  (EvToolbar *ev_toolbar);
 void          ev_toolbar_set_mode           (EvToolbar     *ev_toolbar,
                                             EvToolbarMode  mode);
 EvToolbarMode ev_toolbar_get_mode           (EvToolbar     *ev_toolbar);
-
+void          ev_toolbar_select_annotation_type (EvToolbar              *ev_toolbar,
+                                                 EvAnnotationActionType  annot_type);
 G_END_DECLS
 
 #endif /* __EV_TOOLBAR_H__ */
diff --git a/shell/ev-window.c b/shell/ev-window.c
index af14dc8f..406dfc41 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -43,6 +43,7 @@
 
 #include "ev-find-sidebar.h"
 #include "ev-annotations-toolbar.h"
+#include "ev-annotation-action.h"
 #include "ev-application.h"
 #include "ev-document-factory.h"
 #include "ev-document-find.h"
@@ -6014,6 +6015,30 @@ ev_window_cmd_toggle_edit_annots (GSimpleAction *action,
        g_simple_action_set_state (action, state);
 }
 
+static void
+ev_window_change_select_annotation_action_state (GSimpleAction *action,
+                                                GVariant      *state,
+                                                gpointer       user_data)
+{
+       EvWindow  *ev_window = user_data;
+       EvWindowPrivate *priv = GET_PRIVATE (ev_window);
+       EvToolbar *toolbar;
+       const gchar *mode;
+
+       toolbar = priv->fs_toolbar ? EV_TOOLBAR (priv->fs_toolbar) : EV_TOOLBAR (priv->toolbar);
+
+       mode = g_variant_get_string (state, NULL);
+
+       if (g_str_equal (mode, "note"))
+               ev_toolbar_select_annotation_type (toolbar, EV_ANNOTATION_ACTION_TYPE_NOTE);
+       else if (g_str_equal (mode, "highlight"))
+               ev_toolbar_select_annotation_type (toolbar, EV_ANNOTATION_ACTION_TYPE_HIGHLIGHT);
+       else
+               g_assert_not_reached ();
+
+       g_simple_action_set_state (action, state);
+}
+
 static void
 ev_window_dispose (GObject *object)
 {
@@ -6346,6 +6371,7 @@ static const GActionEntry actions[] = {
        { "add-annotation", NULL, NULL, "false", ev_window_cmd_add_annotation },
        { "highlight-annotation", NULL, NULL, "false", ev_window_cmd_add_highlight_annotation },
        { "toggle-edit-annots", NULL, NULL, "false", ev_window_cmd_toggle_edit_annots },
+       { "select-annotation", NULL, "s", "'note'", ev_window_change_select_annotation_action_state },
        { "about", ev_window_cmd_about },
        { "help", ev_window_cmd_help },
        /* Popups specific items */


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