[bijiben] Trigger Help on F1



commit c9a73efd977be01dc466637fe3b8bb42dabbba04
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Wed Jul 30 00:54:02 2014 +0200

    Trigger Help on F1

 src/bjb-app-menu.c    |    2 +-
 src/bjb-app-menu.h    |    8 ++++++--
 src/bjb-window-base.c |   26 ++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/src/bjb-app-menu.c b/src/bjb-app-menu.c
index 643ea75..9c40701 100644
--- a/src/bjb-app-menu.c
+++ b/src/bjb-app-menu.c
@@ -118,7 +118,7 @@ about_activated (GSimpleAction *action,
 }
 
 
-static void
+void
 help_activated (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
diff --git a/src/bjb-app-menu.h b/src/bjb-app-menu.h
index bf7113b..ed6ce02 100644
--- a/src/bjb-app-menu.h
+++ b/src/bjb-app-menu.h
@@ -20,10 +20,14 @@
 
 #include <gtk/gtk.h>
 
-void show_about_dialog(GtkApplication *app);
+void          show_about_dialog            (GtkApplication *app);
 
-void bjb_app_menu_set(GApplication *application) ;
 
+void          bjb_app_menu_set             (GApplication *application) ;
 
 
+void          help_activated               (GSimpleAction *action,
+                                            GVariant      *parameter,
+                                            gpointer       user_data);
+
 #endif /*_APP_MENU_H*/
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index c9fabb0..8c7b211 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -6,6 +6,7 @@
 #include <libbiji/libbiji.h>
 #include <libgd/gd.h>
 
+#include "bjb-app-menu.h"
 #include "bjb-bijiben.h"
 #include "bjb-empty-results-box.h"
 #include "bjb-window-base.h"
@@ -137,6 +138,21 @@ bjb_window_base_set_property (GObject  *object,
 
 
 
+static gboolean
+on_key_pressed_cb (GtkWidget *w, GdkEvent *event, gpointer user_data)
+{
+  switch (event->key.keyval)
+  {
+    case GDK_KEY_F1:
+      help_activated (NULL, NULL, NULL);
+      return TRUE;
+
+    default:
+      return FALSE;
+  }
+
+  return FALSE;
+}
 
 
 
@@ -316,6 +332,9 @@ bjb_window_base_constructed (GObject *obj)
   gtk_stack_add_named (priv->stack, GTK_WIDGET (priv->view), "main-view");
   gtk_widget_show (GTK_WIDGET (priv->stack));
 
+
+  /* Connection to window signals */
+
   g_signal_connect (GTK_WIDGET (self),
                     "destroy",
                     G_CALLBACK (bjb_window_base_destroy),
@@ -331,6 +350,13 @@ bjb_window_base_constructed (GObject *obj)
                     G_CALLBACK (bjb_application_window_configured),
                     self);
 
+  /* Keys */
+
+  g_signal_connect (GTK_WIDGET (self),
+                    "key-press-event",
+                    G_CALLBACK(on_key_pressed_cb),
+                   self);
+
   /* If a note is requested at creation, show it
    * This is a specific type of window not associated with any view */
   if (priv->note == NULL)


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