[gnome-documents/gnome-3-6] embed: enable key navigation



commit 171a70a28be36840bed114f216f2bc4adeb101f2
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Sep 27 17:04:02 2012 -0400

    embed: enable key navigation
    
    Taken from a patch for gnome-boxes by Alexander Larsson.
    
    We derive from GtkClutterEmbed and remove focusability and key event
    handling. This means that to Gtk+ it looks like a dumb container
    which never gets any key events. This makes Gtk+ keynav work just
    like in any other container, although it means there will never
    be any Clutter key events. Thats fine though, as we just use
    Clutter as a rendering layer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669617

 src/embed.js |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 46f4b97..137b7e2 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -283,6 +283,34 @@ const EmptyResultsBox = new Lang.Class({
     }
 });
 
+const EmbedWidget = new Lang.Class({
+    Name: 'EmbedWidget',
+    Extends: GtkClutter.Embed,
+
+    _init: function() {
+        this.parent({ use_layout_size: true,
+                      can_focus: false });
+    },
+
+    /* We overide all keyboard handling of GtkClutter.Embed, as it interfers
+     * with the key event propagation and thus focus navigation in gtk+.
+     * We also make the embed itself non-focusable, as we want to treat it
+     * like a container of Gtk+ widget rather than an edge widget which gets
+     * keyboard events.
+     * This means we will never get any Clutter key events, but that is
+     * fine, as all our keyboard input is into GtkClutterActors, and clutter
+     * is just used as a nice way of animating and rendering Gtk+ widgets
+     * and some non-active graphical things.
+     */
+    vfunc_key_press_event: function(event) {
+        return false;
+    },
+
+    vfunc_key_release_event: function(event) {
+        return false;
+    }
+});
+
 const Embed = new Lang.Class({
     Name: 'Embed',
 
@@ -290,7 +318,7 @@ const Embed = new Lang.Class({
         this._queryErrorId = 0;
         this._noResultsChangeId = 0;
 
-        this.widget = new GtkClutter.Embed({ use_layout_size: true });
+        this.widget = new EmbedWidget();
         this.widget.show();
 
         // the embed is a vertical ClutterBox



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