[evince/wip/gpoo/new-annotation-action: 3/4] shell: Integrate EvAnnotationAction into the headerbar
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/new-annotation-action: 3/4] shell: Integrate EvAnnotationAction into the headerbar
- Date: Fri, 29 May 2020 05:31:59 +0000 (UTC)
commit 72550c0dd77a1c2839c6da6bc169c1c9d04bd888
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Fri May 29 01:27:49 2020 -0400
shell: Integrate EvAnnotationAction into the headerbar
shell/ev-toolbar.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++-
shell/evince-menus.ui | 17 +++++++++++++
shell/evince.css | 7 ++++++
3 files changed, 93 insertions(+), 1 deletion(-)
---
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index a91c7c86..96723587 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -30,6 +30,7 @@
#include "ev-stock-icons.h"
#include "ev-zoom-action.h"
#include "ev-application.h"
+#include "ev-annotation-action.h"
#include "ev-page-action-widget.h"
#include <math.h>
@@ -48,6 +49,7 @@ typedef struct {
GtkWidget *navigation_action;
GtkWidget *find_button;
GtkWidget *open_button;
+ GtkWidget *annots_action;
GtkWidget *annots_button;
GtkWidget *sidebar_button;
@@ -161,6 +163,40 @@ zoom_selector_activated (GtkWidget *zoom_action,
ev_window_focus_view (priv->window);
}
+static void
+ev_toolbar_begin_add_annot (EvToolbar *ev_toolbar,
+ EvAnnotationType annot_type)
+{
+ EvToolbarPrivate *priv = GET_PRIVATE (ev_toolbar);
+ EvView *view = ev_window_get_view (priv->window);
+
+ if (annot_type == EV_ANNOTATION_TYPE_TEXT_MARKUP &&
+ ev_view_get_has_selection (view)) {
+ ev_view_add_text_markup_annotation_for_selected_text (view);
+ return;
+ }
+
+ ev_view_begin_add_annotation (view, annot_type);
+}
+
+static void
+ev_toolbar_cancel_add_annot (EvToolbar *ev_toolbar)
+{
+ EvToolbarPrivate *priv = GET_PRIVATE (ev_toolbar);
+ EvView *view = ev_window_get_view (priv->window);
+
+ ev_view_cancel_add_annotation (view);
+}
+
+static void
+annotation_selector_activated (GtkWidget *annotation_action,
+ EvToolbar *ev_toolbar)
+{
+ EvToolbarPrivate *priv = GET_PRIVATE (ev_toolbar);
+
+ ev_window_focus_view (priv->window);
+}
+
static void
ev_toolbar_find_button_sensitive_changed (GtkWidget *find_button,
GParamSpec *pspec,
@@ -222,6 +258,24 @@ ev_toolbar_constructed (GObject *object)
ev_window_get_document_model (priv->window));
gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
+ /* New edit annotations */
+ vbox = ev_annotation_action_new ();
+ priv->annots_action = vbox;
+ gtk_widget_set_tooltip_text (vbox, _("Select or set the tool to annotate the document"));
+ atk_object_set_name (gtk_widget_get_accessible (vbox), _("Set annotation tool"));
+ g_signal_connect_swapped (priv->annots_action,
+ "begin-add-annot",
+ G_CALLBACK (ev_toolbar_begin_add_annot),
+ ev_toolbar);
+ g_signal_connect_swapped (priv->annots_action,
+ "cancel-add-annot",
+ G_CALLBACK (ev_toolbar_cancel_add_annot),
+ ev_toolbar);
+ g_signal_connect (vbox, "activated",
+ G_CALLBACK (annotation_selector_activated),
+ ev_toolbar);
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), vbox);
+
/* Edit Annots */
button = ev_toolbar_create_toggle_button (ev_toolbar, "win.toggle-edit-annots",
"document-edit-symbolic",
_("Annotate the document"));
@@ -345,12 +399,24 @@ ev_toolbar_get_page_selector (EvToolbar *ev_toolbar)
return priv->page_selector;
}
+void
+ev_toolbar_select_annotation_type (EvToolbar *ev_toolbar,
+ EvAnnotationActionType annot_type)
+{
+ EvToolbarPrivate *priv;
+
+ g_return_if_fail (EV_IS_TOOLBAR (ev_toolbar));
+
+ priv = GET_PRIVATE (ev_toolbar);
+ ev_annotation_action_select_annotation (EV_ANNOTATION_ACTION (priv->annots_action),
+ annot_type);
+}
+
void
ev_toolbar_set_mode (EvToolbar *ev_toolbar,
EvToolbarMode mode)
{
EvToolbarPrivate *priv;
-
g_return_if_fail (EV_IS_TOOLBAR (ev_toolbar));
priv = GET_PRIVATE (ev_toolbar);
@@ -364,6 +430,7 @@ ev_toolbar_set_mode (EvToolbar *ev_toolbar,
gtk_widget_show (priv->zoom_action);
gtk_widget_show (priv->page_selector);
gtk_widget_show (priv->find_button);
+ gtk_widget_show (priv->annots_action);
gtk_widget_show (priv->annots_button);
gtk_widget_hide (priv->open_button);
break;
@@ -373,6 +440,7 @@ ev_toolbar_set_mode (EvToolbar *ev_toolbar,
gtk_widget_hide (priv->zoom_action);
gtk_widget_hide (priv->page_selector);
gtk_widget_hide (priv->find_button);
+ gtk_widget_hide (priv->annots_action);
gtk_widget_hide (priv->annots_button);
gtk_widget_show (priv->open_button);
break;
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index adf566c4..a0a16189 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -143,6 +143,23 @@
</section>
</menu>
+ <menu id="annotation-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Note Text</attribute>
+ <attribute name="action">win.select-annotation</attribute>
+ <attribute name="target">note</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Highlight Text</attribute>
+ <attribute name="action">win.select-annotation</attribute>
+ <attribute name="target">highlight</attribute>
+ </item>
+ </section>
+ <section>
+ </section>
+ </menu>
+
<menu id="view-popup-menu">
<section>
<item>
diff --git a/shell/evince.css b/shell/evince.css
index 02501d26..9a24c306 100644
--- a/shell/evince.css
+++ b/shell/evince.css
@@ -85,3 +85,10 @@ evannotationwindow label {
padding-left: 2px;
padding-right: 2px;
}
+
+.disclosure-button
+{
+ padding-left: 4px;
+ padding-right: 4px;
+ min-width: 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]