[evince] [PATCH] Add accelerator hotkeys for annotations toolbar buttons.
- From: "Benjamin A. Braun" <bjmnbraun gmail com>
- To: evince-list gnome org
- Subject: [evince] [PATCH] Add accelerator hotkeys for annotations toolbar buttons.
- Date: Tue, 24 Jan 2017 21:05:04 -0800
---
shell/ev-annotations-toolbar.c | 25 +++++++++++++++++++++++++
shell/ev-annotations-toolbar.h | 3 +++
shell/ev-application.c | 2 ++
shell/ev-window.c | 30 +++++++++++++++++++++++++++++-
4 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/shell/ev-annotations-toolbar.c b/shell/ev-annotations-toolbar.c
index e973c72..cec8c7b 100644
--- a/shell/ev-annotations-toolbar.c
+++ b/shell/ev-annotations-toolbar.c
@@ -70,6 +70,17 @@ ev_annotations_toolbar_annot_button_toggled (GtkWidget *button,
g_signal_emit (toolbar, signals[BEGIN_ADD_ANNOT], 0, annot_type);
}
+//Also fires the associated signal
+static void
+ev_annotations_toolbar_toggle_button (EvAnnotationsToolbar *toolbar,
+ GtkToggleToolButton *button)
+{
+ gboolean state = gtk_toggle_tool_button_get_active (button);
+
+ gtk_toggle_tool_button_set_active (button, !state);
+}
+
+//Toggles the button without sending the signal
static gboolean
ev_annotations_toolbar_toggle_button_if_active (EvAnnotationsToolbar *toolbar,
GtkToggleToolButton *button)
@@ -162,6 +173,20 @@ ev_annotations_toolbar_new (void)
}
void
+ev_annotations_toolbar_toggle_annot_text (EvAnnotationsToolbar *toolbar){
+ g_return_if_fail (EV_IS_ANNOTATIONS_TOOLBAR (toolbar));
+
+ ev_annotations_toolbar_toggle_button (toolbar, GTK_TOGGLE_TOOL_BUTTON(toolbar->text_button));
+}
+
+void
+ev_annotations_toolbar_toggle_annot_highlight (EvAnnotationsToolbar *toolbar){
+ g_return_if_fail (EV_IS_ANNOTATIONS_TOOLBAR (toolbar));
+
+ ev_annotations_toolbar_toggle_button (toolbar, GTK_TOGGLE_TOOL_BUTTON (toolbar->highlight_button));
+}
+
+void
ev_annotations_toolbar_add_annot_finished (EvAnnotationsToolbar *toolbar)
{
g_return_if_fail (EV_IS_ANNOTATIONS_TOOLBAR (toolbar));
diff --git a/shell/ev-annotations-toolbar.h b/shell/ev-annotations-toolbar.h
index 7690ac3..498ae07 100644
--- a/shell/ev-annotations-toolbar.h
+++ b/shell/ev-annotations-toolbar.h
@@ -39,6 +39,9 @@ GType ev_annotations_toolbar_get_type (void) G_GNUC_CONST;
GtkWidget *ev_annotations_toolbar_new (void);
void ev_annotations_toolbar_add_annot_finished (EvAnnotationsToolbar *toolbar);
+void ev_annotations_toolbar_toggle_annot_text (EvAnnotationsToolbar *toolbar);
+void ev_annotations_toolbar_toggle_annot_highlight (EvAnnotationsToolbar *toolbar);
+
G_END_DECLS
#endif /* __EV_ANNOTATIONS_TOOLBAR_H__ */
diff --git a/shell/ev-application.c b/shell/ev-application.c
index eb5a94b..23825f0 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -1085,6 +1085,8 @@ ev_application_startup (GApplication *gapplication)
"win.rotate-right", "<Ctrl>Right", NULL,
"win.inverted-colors", "<Ctrl>I", NULL,
"win.reload", "<Ctrl>R", NULL,
+ "win.toggle-highlight-annot", "<Ctrl>H", NULL,
+ "win.toggle-text-annot", "<Ctrl>J", NULL,
NULL
};
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 06dcf25..ca31e9d 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -374,6 +374,12 @@ static void recent_view_item_activated_cb (EvRecentView *recen
const char *uri,
EvWindow *ev_window);
+static void
+ev_window_begin_add_annot (EvWindow *window,
+ EvAnnotationType annot_type);
+static void
+ev_window_cancel_add_annot(EvWindow *window);
+
static gchar *nautilus_sendto = NULL;
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -3866,6 +3872,26 @@ ev_window_cmd_toggle_find (GSimpleAction *action,
}
static void
+ev_window_cmd_toggle_highlight_annot (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ EvWindow *ev_window = user_data;
+
+ ev_annotations_toolbar_toggle_annot_highlight (EV_ANNOTATIONS_TOOLBAR
(ev_window->priv->annots_toolbar));
+}
+
+static void
+ev_window_cmd_toggle_text_annot (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ EvWindow *ev_window = user_data;
+
+ ev_annotations_toolbar_toggle_annot_text (EV_ANNOTATIONS_TOOLBAR (ev_window->priv->annots_toolbar));
+}
+
+static void
ev_window_cmd_find (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -5696,7 +5722,9 @@ static const GActionEntry actions[] = {
{ "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 },
- { "remove-annot", ev_window_popup_cmd_remove_annotation }
+ { "remove-annot", ev_window_popup_cmd_remove_annotation },
+ { "toggle-highlight-annot", ev_window_cmd_toggle_highlight_annot},
+ { "toggle-text-annot", ev_window_cmd_toggle_text_annot },
};
static void
--
2.10.2
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]