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
=== modified file 'data/unity.schemas'
--- data/unity.schemas 2010-05-26 14:00:57 +0000
+++ data/unity.schemas 2010-09-22 14:03:40 +0000
@@ -41,6 +41,17 @@
41 </locale>41 </locale>
42 </schema>42 </schema>
4343
44 <schema>
45 <key>/schemas/desktop/unity/launcher/super_key_enable</key>
46 <applyto>/desktop/unity/launcher/super_key_enable</applyto>
47 <owner>unity</owner>
48 <type>bool</type>
49 <default>1</default>
50 <locale name="C">
51 <short>Enable super key or not</short>
52 <long>Enable/disable super key. If this is False, super key will not function.</long>
53 </locale>
54 </schema>
55
44 </schemalist>56 </schemalist>
45</gconfschemafile>57</gconfschemafile>
46
4758
=== modified file 'targets/mutter/Makefile.am'
--- targets/mutter/Makefile.am 2010-08-18 13:53:39 +0000
+++ targets/mutter/Makefile.am 2010-09-22 14:03:40 +0000
@@ -51,6 +51,7 @@
51 --pkg unity-const \51 --pkg unity-const \
52 --pkg unity \52 --pkg unity \
53 --pkg unity-private \53 --pkg unity-private \
54 --pkg gconf-2.0 \
54 $(MAINTAINER_VALAFLAGS)55 $(MAINTAINER_VALAFLAGS)
5556
56libunity_mutter_la_LIBADD = \57libunity_mutter_la_LIBADD = \
5758
=== modified file 'targets/mutter/plugin.vala'
--- targets/mutter/plugin.vala 2010-09-22 04:36:17 +0000
+++ targets/mutter/plugin.vala 2010-09-22 14:03:40 +0000
@@ -16,6 +16,8 @@
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *17 *
18 */18 */
19
20using GConf;
19using Unity;21using Unity;
20using Unity.Testing;22using Unity.Testing;
2123
@@ -106,6 +108,11 @@
106 get { return _plugin; }108 get { return _plugin; }
107 set { _plugin = value; Idle.add (real_construct); }109 set { _plugin = value; Idle.add (real_construct); }
108 }110 }
111 private bool _super_key_enable=true;
112 public bool super_key_enable {
113 get { return _super_key_enable; }
114 set { _super_key_enable = value; }
115 }
109116
110 public ExposeManager expose_manager { get; private set; }117 public ExposeManager expose_manager { get; private set; }
111 public Background background { get; private set; }118 public Background background { get; private set; }
@@ -185,7 +192,11 @@
185 RIGHT192 RIGHT
186 }193 }
187 private MaximizeType maximize_type = MaximizeType.NONE;194 private MaximizeType maximize_type = MaximizeType.NONE;
188 195
196 /* const */
197 private const string GCONF_DIR = "/desktop/unity/launcher";
198 private const string GCONF_SUPER_KEY_ENABLE_KEY = "super_key_enable";
199
189 construct200 construct
190 {201 {
191 is_starting = true;202 is_starting = true;
@@ -223,7 +234,7 @@
223 this.screensaver = this.screensaver_conn.get_object ("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver");234 this.screensaver = this.screensaver_conn.get_object ("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver");
224 this.screensaver.ActiveChanged.connect (got_screensaver_changed);235 this.screensaver.ActiveChanged.connect (got_screensaver_changed);
225 }236 }
226 catch (Error e)237 catch (GLib.Error e)
227 {238 {
228 warning (e.message);239 warning (e.message);
229 }240 }
@@ -269,9 +280,26 @@
269 /* we need to hook into the super key bound by mutter for g-shell.280 /* we need to hook into the super key bound by mutter for g-shell.
270 don't ask me why mutter binds things for g-shell explictly...281 don't ask me why mutter binds things for g-shell explictly...
271 */282 */
283 var gc = GConf.Client.get_default();
272 Mutter.MetaDisplay display = Mutter.MetaScreen.get_display (plugin.get_screen ());284 Mutter.MetaDisplay display = Mutter.MetaScreen.get_display (plugin.get_screen ());
285
286 try {
287 super_key_enable = gc.get_bool(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY);
288 } catch (GLib.Error e) {
289 super_key_enable = true;
290 warning("Cannot find super_key_enable gconf key");
291 }
292 try {
293 gc.add_dir(GCONF_DIR, GConf.ClientPreloadType.ONELEVEL);
294 gc.notify_add(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY, this.gconf_super_key_enable_cb);
295 } catch (GLib.Error e) {
296 warning("Cannot set gconf callback function of super_key_enable");
297 }
298
273 display.overlay_key_down.connect (() => {299 display.overlay_key_down.connect (() => {
274 super_key_active = true;300 if (super_key_enable) {
301 super_key_active = true;
302 }
275 });303 });
276304
277 display.overlay_key.connect (() => {305 display.overlay_key.connect (() => {
@@ -283,7 +311,9 @@
283 });311 });
284312
285 display.overlay_key_with_modifier_down.connect ((keysym) => {313 display.overlay_key_with_modifier_down.connect ((keysym) => {
286 super_key_modifier_press (keysym);314 if (super_key_enable) {
315 super_key_modifier_press (keysym);
316 }
287 });317 });
288318
289 this.background = new Background ();319 this.background = new Background ();
@@ -354,6 +384,16 @@
354 384
355 }385 }
356386
387 private void gconf_super_key_enable_cb(GConf.Client gc, uint cxnid, GConf.Entry entry) {
388 bool new_value = true;
389 try {
390 new_value = gc.get_bool(GCONF_DIR + "/" + GCONF_SUPER_KEY_ENABLE_KEY);
391 } catch (GLib.Error e) {
392 new_value = true;
393 }
394 super_key_enable = new_value;
395 }
396
357 private void on_focus_window_changed ()397 private void on_focus_window_changed ()
358 {398 {
359 check_fullscreen_obstruction ();399 check_fullscreen_obstruction ();