[gnome-screenshot/wip/christopherdavis/screenshot-redesign: 5/5] screenshot-application: Use accel for help



commit 0fc1835e723e49d3456a9ccb005a5df4d49a00b8
Author: Christopher Davis <brainblasted disroot org>
Date:   Fri Jan 4 02:09:30 2019 -0500

    screenshot-application: Use accel for help
    
    Code was duplicated across both dialogs to handle the F1 shortcut for help. This is now handled as an 
accel for the app.help action.

 src/screenshot-application.c        |  3 +++
 src/screenshot-dialog.c             |  6 ------
 src/screenshot-interactive-dialog.c | 17 -----------------
 3 files changed, 3 insertions(+), 23 deletions(-)
---
diff --git a/src/screenshot-application.c b/src/screenshot-application.c
index e6b4b13..b588437 100644
--- a/src/screenshot-application.c
+++ b/src/screenshot-application.c
@@ -786,6 +786,7 @@ static GActionEntry action_entries[] = {
 static void
 screenshot_application_startup (GApplication *app)
 {
+  const gchar *help_accels[2] = { "F1", NULL };
   const gchar *quit_accels[2] = { "<Primary>q", NULL };
   ScreenshotApplication *self = SCREENSHOT_APPLICATION (app);
   g_application_set_resource_base_path (app, "/org/gnome/screenshot");
@@ -799,6 +800,8 @@ screenshot_application_startup (GApplication *app)
 
   g_action_map_add_action_entries (G_ACTION_MAP (self), action_entries,
                                    G_N_ELEMENTS (action_entries), self);
+
+  gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.quit", quit_accels);
 }
 
diff --git a/src/screenshot-dialog.c b/src/screenshot-dialog.c
index ebeab64..91ef333 100644
--- a/src/screenshot-dialog.c
+++ b/src/screenshot-dialog.c
@@ -91,12 +91,6 @@ dialog_key_press_cb (GtkWidget *widget,
                      GdkEventKey *event,
                      gpointer user_data)
 {
-  if (event->keyval == GDK_KEY_F1)
-    {
-      screenshot_display_help (GTK_WINDOW (widget));
-      return TRUE;
-    }
-
   if (event->keyval == GDK_KEY_Escape)
     {
       gtk_widget_destroy (widget);
diff --git a/src/screenshot-interactive-dialog.c b/src/screenshot-interactive-dialog.c
index 99cfd0e..9888f90 100644
--- a/src/screenshot-interactive-dialog.c
+++ b/src/screenshot-interactive-dialog.c
@@ -98,20 +98,6 @@ use_shadow_toggled_cb (GtkSwitch *toggle,
   gtk_switch_set_state (toggle, gtk_switch_get_active (toggle));
 }
 
-static gint
-interactive_dialog_key_press_cb (GtkWidget   *widget,
-                                 GdkEventKey *event,
-                                 gpointer    user_data)
-{
-  if (event->keyval == GDK_KEY_F1)
-    {
-      screenshot_display_help (GTK_WINDOW (widget));
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
 static void
 connect_effects_frame (GtkBuilder *ui)
 {
@@ -275,9 +261,6 @@ screenshot_interactive_dialog_new (CaptureClickedCallback f, gpointer user_data)
   g_signal_connect (capture_button, "clicked", G_CALLBACK (capture_button_clicked_cb), data);
   gtk_widget_set_can_default (capture_button, TRUE);
   gtk_widget_grab_default (capture_button);
-  g_signal_connect (dialog, "key-press-event",
-                    G_CALLBACK (interactive_dialog_key_press_cb),
-                    NULL);
 
   gtk_widget_show_all (dialog);
 


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