Merge lp:~paulliu/unity/add-super-gconf-support into lp:unity

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 540
Proposed branch: lp:~paulliu/unity/add-super-gconf-support
Merge into: lp:unity
Diff against target: 137 lines (+57/-5)
3 files modified
data/unity.schemas (+12/-1)
targets/mutter/Makefile.am (+1/-0)
targets/mutter/plugin.vala (+44/-4)
To merge this branch: bzr merge lp:~paulliu/unity/add-super-gconf-support
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+36302@code.launchpad.net

Description of the change

I've add a gconf key to enable/disable the super key function.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/unity.schemas'
2--- data/unity.schemas 2010-05-26 14:00:57 +0000
3+++ data/unity.schemas 2010-09-22 14:03:40 +0000
4@@ -41,6 +41,17 @@
5 </locale>
6 </schema>
7
8+ <schema>
9+ <key>/schemas/desktop/unity/launcher/super_key_enable</key>
10+ <applyto>/desktop/unity/launcher/super_key_enable</applyto>
11+ <owner>unity</owner>
12+ <type>bool</type>
13+ <default>1</default>
14+ <locale name="C">
15+ <short>Enable super key or not</short>
16+ <long>Enable/disable super key. If this is False, super key will not function.</long>
17+ </locale>
18+ </schema>
19+
20 </schemalist>
21 </gconfschemafile>
22-
23
24=== modified file 'targets/mutter/Makefile.am'
25--- targets/mutter/Makefile.am 2010-08-18 13:53:39 +0000
26+++ targets/mutter/Makefile.am 2010-09-22 14:03:40 +0000
27@@ -51,6 +51,7 @@
28 --pkg unity-const \
29 --pkg unity \
30 --pkg unity-private \
31+ --pkg gconf-2.0 \
32 $(MAINTAINER_VALAFLAGS)
33
34 libunity_mutter_la_LIBADD = \
35
36=== modified file 'targets/mutter/plugin.vala'
37--- targets/mutter/plugin.vala 2010-09-22 04:36:17 +0000
38+++ targets/mutter/plugin.vala 2010-09-22 14:03:40 +0000
39@@ -16,6 +16,8 @@
40 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
41 *
42 */
43+
44+using GConf;
45 using Unity;
46 using Unity.Testing;
47
48@@ -106,6 +108,11 @@
49 get { return _plugin; }
50 set { _plugin = value; Idle.add (real_construct); }
51 }
52+ private bool _super_key_enable=true;
53+ public bool super_key_enable {
54+ get { return _super_key_enable; }
55+ set { _super_key_enable = value; }
56+ }
57
58 public ExposeManager expose_manager { get; private set; }
59 public Background background { get; private set; }
60@@ -185,7 +192,11 @@
61 RIGHT
62 }
63 private MaximizeType maximize_type = MaximizeType.NONE;
64-
65+
66+ /* const */
67+ private const string GCONF_DIR = "/desktop/unity/launcher";
68+ private const string GCONF_SUPER_KEY_ENABLE_KEY = "super_key_enable";
69+
70 construct
71 {
72 is_starting = true;
73@@ -223,7 +234,7 @@
74 this.screensaver = this.screensaver_conn.get_object ("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver");
75 this.screensaver.ActiveChanged.connect (got_screensaver_changed);
76 }
77- catch (Error e)
78+ catch (GLib.Error e)
79 {
80 warning (e.message);
81 }
82@@ -269,9 +280,26 @@
83 /* we need to hook into the super key bound by mutter for g-shell.
84 don't ask me why mutter binds things for g-shell explictly...
85 */
86+ var gc = GConf.Client.get_default();
87 Mutter.MetaDisplay display = Mutter.MetaScreen.get_display (plugin.get_screen ());
88+
89+ try {
90+ super_key_enable = gc.get_bool(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY);
91+ } catch (GLib.Error e) {
92+ super_key_enable = true;
93+ warning("Cannot find super_key_enable gconf key");
94+ }
95+ try {
96+ gc.add_dir(GCONF_DIR, GConf.ClientPreloadType.ONELEVEL);
97+ gc.notify_add(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY, this.gconf_super_key_enable_cb);
98+ } catch (GLib.Error e) {
99+ warning("Cannot set gconf callback function of super_key_enable");
100+ }
101+
102 display.overlay_key_down.connect (() => {
103- super_key_active = true;
104+ if (super_key_enable) {
105+ super_key_active = true;
106+ }
107 });
108
109 display.overlay_key.connect (() => {
110@@ -283,7 +311,9 @@
111 });
112
113 display.overlay_key_with_modifier_down.connect ((keysym) => {
114- super_key_modifier_press (keysym);
115+ if (super_key_enable) {
116+ super_key_modifier_press (keysym);
117+ }
118 });
119
120 this.background = new Background ();
121@@ -354,6 +384,16 @@
122
123 }
124
125+ private void gconf_super_key_enable_cb(GConf.Client gc, uint cxnid, GConf.Entry entry) {
126+ bool new_value = true;
127+ try {
128+ new_value = gc.get_bool(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY);
129+ } catch (GLib.Error e) {
130+ new_value = true;
131+ }
132+ super_key_enable = new_value;
133+ }
134+
135 private void on_focus_window_changed ()
136 {
137 check_fullscreen_obstruction ();