diff options
| author | Ying-Chun Liu (PaulLiu) <grandpaul@gmail.com> | 2010-09-22 21:38:06 +0800 |
|---|---|---|
| committer | Ying-Chun Liu (PaulLiu) <grandpaul@gmail.com> | 2010-09-22 21:38:06 +0800 |
| commit | 159a1c6f20f0d5ee470f24e9894419977b6622d8 (patch) | |
| tree | 9825d30de629e1281ad41770a24edc239d0a740d | |
| parent | eb8ceac4ae2fdee66cfd8875fcbccc9e2a030834 (diff) | |
Add gconf key to disable/enable super key.
(bzr r535.2.1)
| -rw-r--r-- | data/unity.schemas | 13 | ||||
| -rw-r--r-- | targets/mutter/Makefile.am | 1 | ||||
| -rw-r--r-- | targets/mutter/plugin.vala | 48 |
3 files changed, 57 insertions, 5 deletions
diff --git a/data/unity.schemas b/data/unity.schemas index 405226e32..0ca280caf 100644 --- a/data/unity.schemas +++ b/data/unity.schemas @@ -41,6 +41,17 @@ </locale> </schema> + <schema> + <key>/schemas/desktop/unity/launcher/super_key_enable</key> + <applyto>/desktop/unity/launcher/super_key_enable</applyto> + <owner>unity</owner> + <type>bool</type> + <default>1</default> + <locale name="C"> + <short>Enable super key or not</short> + <long>Enable/disable super key. If this is False, super key will not function.</long> + </locale> + </schema> + </schemalist> </gconfschemafile> - diff --git a/targets/mutter/Makefile.am b/targets/mutter/Makefile.am index 1e34e1d33..aa224cd2c 100644 --- a/targets/mutter/Makefile.am +++ b/targets/mutter/Makefile.am @@ -51,6 +51,7 @@ libunity_mutter_la_VALAFLAGS = \ --pkg unity-const \ --pkg unity \ --pkg unity-private \ + --pkg gconf-2.0 \ $(MAINTAINER_VALAFLAGS) libunity_mutter_la_LIBADD = \ diff --git a/targets/mutter/plugin.vala b/targets/mutter/plugin.vala index 3a407c414..697ddcc43 100644 --- a/targets/mutter/plugin.vala +++ b/targets/mutter/plugin.vala @@ -16,6 +16,8 @@ * Authored by Neil Jagdish Patel <neil.patel@canonical.com> * */ + +using GConf; using Unity; using Unity.Testing; @@ -106,6 +108,11 @@ namespace Unity get { return _plugin; } set { _plugin = value; Idle.add (real_construct); } } + private bool _super_key_enable=true; + public bool super_key_enable { + get { return _super_key_enable; } + set { _super_key_enable = value; } + } public ExposeManager expose_manager { get; private set; } public Background background { get; private set; } @@ -185,7 +192,11 @@ namespace Unity RIGHT } private MaximizeType maximize_type = MaximizeType.NONE; - + + /* const */ + private const string GCONF_DIR = "/desktop/unity/launcher"; + private const string GCONF_SUPER_KEY_ENABLE_KEY = "super_key_enable"; + construct { is_starting = true; @@ -223,7 +234,7 @@ namespace Unity this.screensaver = this.screensaver_conn.get_object ("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver"); this.screensaver.ActiveChanged.connect (got_screensaver_changed); } - catch (Error e) + catch (GLib.Error e) { warning (e.message); } @@ -269,9 +280,26 @@ namespace Unity /* we need to hook into the super key bound by mutter for g-shell. don't ask me why mutter binds things for g-shell explictly... */ + var gc = GConf.Client.get_default(); Mutter.MetaDisplay display = Mutter.MetaScreen.get_display (plugin.get_screen ()); + + try { + super_key_enable = gc.get_bool(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY); + } catch (GLib.Error e) { + super_key_enable = true; + warning("Cannot find super_key_enable gconf key"); + } + try { + gc.add_dir(GCONF_DIR, GConf.ClientPreloadType.ONELEVEL); + gc.notify_add(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY, this.gconf_super_key_enable_cb); + } catch (GLib.Error e) { + warning("Cannot set gconf callback function of super_key_enable"); + } + display.overlay_key_down.connect (() => { - super_key_active = true; + if (super_key_enable) { + super_key_active = true; + } }); display.overlay_key.connect (() => { @@ -283,7 +311,9 @@ namespace Unity }); display.overlay_key_with_modifier_down.connect ((keysym) => { - super_key_modifier_press (keysym); + if (super_key_enable) { + super_key_modifier_press (keysym); + } }); this.background = new Background (); @@ -354,6 +384,16 @@ namespace Unity } + private void gconf_super_key_enable_cb(GConf.Client gc, uint cxnid, GConf.Entry entry) { + bool new_value = true; + try { + new_value = gc.get_bool(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY); + } catch (GLib.Error e) { + new_value = true; + } + super_key_enable = new_value; + } + private void on_focus_window_changed () { check_fullscreen_obstruction (); |
