[gnome-font-viewer: 1/2] Add shortcut for back button
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-font-viewer: 1/2] Add shortcut for back button
- Date: Tue, 21 May 2019 00:06:29 +0000 (UTC)
commit a8478e21bea3f781a02854147a538721dc600331
Author: James Westman <flyingpimonster flyingpimonster net>
Date: Mon May 20 17:39:43 2019 -0500
Add shortcut for back button
Press <Alt>Left to go back to the overview. Uses a GAction.
Fixes #9.
src/font-view.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index 3c431ec..7a2ae25 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -669,14 +669,6 @@ install_button_clicked_cb (GtkButton *button,
g_object_unref (dest_location);
}
-static void
-back_button_clicked_cb (GtkButton *button,
- gpointer user_data)
-{
- FontViewApplication *self = user_data;
- font_view_application_do_overview (self);
-}
-
static void
font_view_show_font_error (FontViewApplication *self,
const gchar *message)
@@ -883,8 +875,7 @@ font_view_application_do_open (FontViewApplication *self,
"image-button");
gtk_header_bar_pack_start (GTK_HEADER_BAR (self->header), self->back_button);
- g_signal_connect (self->back_button, "clicked",
- G_CALLBACK (back_button_clicked_cb), self);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (self->back_button), "app.back");
}
gtk_widget_hide (self->search_toggle);
@@ -1125,8 +1116,18 @@ action_about (GSimpleAction *action,
}
+static void
+action_back (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ FontViewApplication *self = user_data;
+ font_view_application_do_overview (self);
+}
+
static GActionEntry action_entries[] = {
{ "about", action_about, NULL, NULL, NULL },
+ { "back", action_back, NULL, NULL, NULL },
{ "quit", action_quit, NULL, NULL, NULL }
};
@@ -1236,6 +1237,11 @@ font_view_application_startup (GApplication *application)
g_action_map_add_action_entries (G_ACTION_MAP (self), action_entries,
G_N_ELEMENTS (action_entries), self);
+
+ const gchar *back_accels[] = { "<Alt>Left", NULL };
+ gtk_application_set_accels_for_action (GTK_APPLICATION (application),
+ "app.back",
+ back_accels);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]