[gnome-builder/wip/project-selector: 35/67] project-selector: add some keyboard helpers



commit 5f1e4174917600e0e951f7a856d8c4684b68e31a
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 2 16:45:43 2015 -0700

    project-selector: add some keyboard helpers
    
    All of this stuff shall be cleaned up if we deem this the design to use.
    In particular, a bunch of this should be done as stateful actions.

 src/workbench/gb-project-window.c |   46 +++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/src/workbench/gb-project-window.c b/src/workbench/gb-project-window.c
index fde9039..6bc7f77 100644
--- a/src/workbench/gb-project-window.c
+++ b/src/workbench/gb-project-window.c
@@ -614,6 +614,49 @@ gb_project_window_constructed (GObject *object)
   G_OBJECT_CLASS (gb_project_window_parent_class)->constructed (object);
 }
 
+static gboolean
+gb_project_window_key_press_event (GtkWidget   *widget,
+                                   GdkEventKey *event)
+{
+  GbProjectWindow *self = (GbProjectWindow *)widget;
+  gboolean ret;
+
+  ret = GTK_WIDGET_CLASS (gb_project_window_parent_class)->key_press_event (widget, event);
+
+  if (!ret)
+    {
+      switch (event->keyval)
+        {
+        case GDK_KEY_Escape:
+          if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->select_button)))
+            {
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->select_button), FALSE);
+              ret = TRUE;
+            }
+          if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->search_button)))
+            {
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->search_button), FALSE);
+              ret = TRUE;
+            }
+          break;
+
+        case GDK_KEY_f:
+          if ((event->state & GDK_CONTROL_MASK) != 0)
+            {
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->search_button), TRUE);
+              ret = TRUE;
+            }
+          break;
+
+        default:
+          break;
+        }
+    }
+
+
+  return ret;
+}
+
 static void
 gb_project_window_finalize (GObject *object)
 {
@@ -630,10 +673,13 @@ static void
 gb_project_window_class_init (GbProjectWindowClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->constructed = gb_project_window_constructed;
   object_class->finalize = gb_project_window_finalize;
 
+  widget_class->key_press_event = gb_project_window_key_press_event;
+
   GB_WIDGET_CLASS_TEMPLATE (klass, "gb-project-window.ui");
 
   GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, action_bar);


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