Merge lp:~philip.scott/switchboard-plug-power/Desktop-freeze-fix into lp:~elementary-apps/switchboard-plug-power/trunk

Proposed by Felipe Escoto
Status: Merged
Approved by: Cody Garver
Approved revision: 247
Merged at revision: 247
Proposed branch: lp:~philip.scott/switchboard-plug-power/Desktop-freeze-fix
Merge into: lp:~elementary-apps/switchboard-plug-power/trunk
Diff against target: 41 lines (+21/-2)
1 file modified
src/Plug.vala (+21/-2)
To merge this branch: bzr merge lp:~philip.scott/switchboard-plug-power/Desktop-freeze-fix
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+267852@code.launchpad.net

Commit message

Enumerate battery devices when determining show/hide brightness UI instead of waiting for GetPercentage alone to timeout (lp:1406058)

To post a comment you must log in.
247. By Felipe Escoto

Desktop freeze fix

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Plug.vala'
2--- src/Plug.vala 2015-06-24 21:21:36 +0000
3+++ src/Plug.vala 2015-08-13 00:13:44 +0000
4@@ -139,16 +139,35 @@
5
6 settings.bind ("idle-dim", dim_switch, "active", SettingsBindFlags.DEFAULT);
7
8+ // Checking if device is a laptop or desktop. If it's a desktop, hide the brightness scale
9+ // Prevents plug freezing on desktops.
10+ bool show_brightness = false;
11 try {
12- // scale.set_value (screen.Brightness);
13- scale.set_value (screen.GetPercentage ());
14+ var power_devices = upower.EnumerateDevices ();
15+ foreach (string device in power_devices) {
16+ if (device.contains ("battery")) {
17+ show_brightness = true;
18+ }
19+ }
20+
21+ if (show_brightness) {
22+ scale.set_value (screen.GetPercentage ());
23+ } else {
24+ warning ("No battery found, hiding brightness settings");
25+ }
26+
27 } catch (Error e) {
28 warning ("Brightness setter not available, hiding brightness settings");
29+ show_brightness = false;
30+ }
31+
32+ if (show_brightness == false) {
33 brightness_label.no_show_all = true;
34 scale.no_show_all = true;
35 dim_label.no_show_all = true;
36 dim_switch.no_show_all = true;
37 }
38+
39 scale.value_changed.connect (() => {
40 var val = (int) scale.get_value ();
41 try {

Subscribers

People subscribed via source and target branches

to all changes: