Merge lp:~donadigo/switchboard-plug-mouse-touchpad/mouse-hide-section into lp:~elementary-pantheon/switchboard-plug-mouse-touchpad/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Cody Garver
Approved revision: 47
Merged at revision: 42
Proposed branch: lp:~donadigo/switchboard-plug-mouse-touchpad/mouse-hide-section
Merge into: lp:~elementary-pantheon/switchboard-plug-mouse-touchpad/trunk
Diff against target: 48 lines (+34/-0)
1 file modified
src/mouse-touchpad.vala (+34/-0)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-mouse-touchpad/mouse-hide-section
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+286689@code.launchpad.net

Commit message

Fix bug #1487959 "Don't show "Mouse" header if no mouse".

Description of the change

Fix bug #1487959 "Don't show "Mouse" header if no mouse".

If there is no mouse type of device present, hide mouse section.

To post a comment you must log in.
43. By Adam Bieńkowski

Remove comment

Revision history for this message
Danielle Foré (danrabbit) wrote :

Hm I can't confirm that this hides the mouse section. Anything I can do to help debug?

44. By Adam Bieńkowski

MASTER to SLAVES

45. By Adam Bieńkowski

Add debug

46. By Adam Bieńkowski

Name info

47. By Adam Bieńkowski

Ignore virtual devices

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mouse-touchpad.vala'
2--- src/mouse-touchpad.vala 2015-12-20 03:34:56 +0000
3+++ src/mouse-touchpad.vala 2016-02-19 20:56:16 +0000
4@@ -76,11 +76,45 @@
5 mouse_section = new Widgets.MouseSection (mouse_settings);
6 touchpad_section = new Widgets.TouchpadSection (touchpad_settings);
7
8+ var display = Gdk.Display.get_default ();
9+ if (display != null) {
10+ var manager = Gdk.Display.get_default ().get_device_manager ();
11+ manager.device_added.connect (() => {
12+ update_ui (manager);
13+ });
14+
15+ manager.device_removed.connect (() => {
16+ update_ui (manager);
17+ });
18+
19+ update_ui (manager);
20+ }
21+
22 main_grid.attach (general_section, 0, 0, 1, 1);
23 main_grid.attach (mouse_section, 0, 1, 1, 1);
24 main_grid.attach (touchpad_section, 0, 2, 1, 1);
25 main_grid.show_all ();
26 }
27+
28+ private void update_ui (Gdk.DeviceManager manager) {
29+ if (has_mouse (manager)) {
30+ mouse_section.no_show_all = false;
31+ mouse_section.show_all ();
32+ } else {
33+ mouse_section.no_show_all = true;
34+ mouse_section.hide ();
35+ }
36+ }
37+
38+ private bool has_mouse (Gdk.DeviceManager manager) {
39+ foreach (var device in manager.list_devices (Gdk.DeviceType.SLAVE)) {
40+ if (device.get_source () == Gdk.InputSource.MOUSE && !device.get_name ().has_prefix ("Virtual core")) {
41+ return true;
42+ }
43+ }
44+
45+ return false;
46+ }
47 }
48 }
49

Subscribers

People subscribed via source and target branches

to all changes: