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
=== modified file 'src/Plug.vala'
--- src/Plug.vala 2015-06-24 21:21:36 +0000
+++ src/Plug.vala 2015-08-13 00:13:44 +0000
@@ -139,16 +139,35 @@
139139
140 settings.bind ("idle-dim", dim_switch, "active", SettingsBindFlags.DEFAULT);140 settings.bind ("idle-dim", dim_switch, "active", SettingsBindFlags.DEFAULT);
141141
142 // Checking if device is a laptop or desktop. If it's a desktop, hide the brightness scale
143 // Prevents plug freezing on desktops.
144 bool show_brightness = false;
142 try {145 try {
143 // scale.set_value (screen.Brightness);146 var power_devices = upower.EnumerateDevices ();
144 scale.set_value (screen.GetPercentage ());147 foreach (string device in power_devices) {
148 if (device.contains ("battery")) {
149 show_brightness = true;
150 }
151 }
152
153 if (show_brightness) {
154 scale.set_value (screen.GetPercentage ());
155 } else {
156 warning ("No battery found, hiding brightness settings");
157 }
158
145 } catch (Error e) {159 } catch (Error e) {
146 warning ("Brightness setter not available, hiding brightness settings");160 warning ("Brightness setter not available, hiding brightness settings");
161 show_brightness = false;
162 }
163
164 if (show_brightness == false) {
147 brightness_label.no_show_all = true;165 brightness_label.no_show_all = true;
148 scale.no_show_all = true;166 scale.no_show_all = true;
149 dim_label.no_show_all = true;167 dim_label.no_show_all = true;
150 dim_switch.no_show_all = true;168 dim_switch.no_show_all = true;
151 }169 }
170
152 scale.value_changed.connect (() => {171 scale.value_changed.connect (() => {
153 var val = (int) scale.get_value ();172 var val = (int) scale.get_value ();
154 try {173 try {

Subscribers

People subscribed via source and target branches

to all changes: