1
From b21275ac750465c36370834daf537b8a05adf4ad Mon Sep 17 00:00:00 2001
2
From: Tim Lunn <tim@feathertop.org>
3
Date: Thu, 18 Sep 2014 09:26:50 +1000
4
Subject: [PATCH] Copy power panel from 3.10
8
panels/power/cc-power-panel.c | 450 ++++++++++++++-------------
9
panels/power/cc-power-panel.h | 3 +-
10
panels/power/gnome-power-panel.desktop.in.in | 1 -
11
panels/power/power.ui | 13 +-
12
5 files changed, 254 insertions(+), 215 deletions(-)
14
Index: gnome-control-center/configure.ac
15
===================================================================
16
--- gnome-control-center.orig/configure.ac
17
+++ gnome-control-center/configure.ac
18
@@ -128,7 +128,7 @@ PKG_CHECK_MODULES(DATETIME_PANEL, $COMMO
19
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
20
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
21
PKG_CHECK_MODULES(DISPLAY_PANEL, $COMMON_MODULES gnome-desktop-3.0 >= 3.1.0
22
- upower-glib >= 0.99.0)
23
+ upower-glib >= 0.9.0)
24
PKG_CHECK_MODULES(INFO_PANEL, $COMMON_MODULES libgtop-2.0 gl
25
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
26
PKG_CHECK_MODULES(KEYBOARD_PANEL, $COMMON_MODULES
27
@@ -140,7 +140,7 @@ PKG_CHECK_MODULES(MOUSE_PANEL, $COMMON_M
28
PKG_CHECK_MODULES(NETWORK_PANEL, $COMMON_MODULES gmodule-2.0)
29
PKG_CHECK_MODULES(NOTIFICATIONS_PANEL, $COMMON_MODULES libgnome-menu-3.0)
30
PKG_CHECK_MODULES(ONLINE_ACCOUNTS_PANEL, $COMMON_MODULES goa-1.0 goa-backend-1.0 >= $GOA_REQUIRED_VERSION)
31
-PKG_CHECK_MODULES(POWER_PANEL, $COMMON_MODULES upower-glib >= 0.99.0
32
+PKG_CHECK_MODULES(POWER_PANEL, $COMMON_MODULES upower-glib >= 0.9.0
33
gnome-settings-daemon >= $GSD_REQUIRED_VERSION)
34
PKG_CHECK_MODULES(COLOR_PANEL, $COMMON_MODULES
35
colord >= $COLORD_REQUIRED_VERSION
36
Index: gnome-control-center/panels/power/cc-power-panel.c
37
===================================================================
38
--- gnome-control-center.orig/panels/power/cc-power-panel.c
39
+++ gnome-control-center/panels/power/cc-power-panel.c
41
* GNU General Public License for more details.
43
* You should have received a copy of the GNU General Public License
44
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
45
+ * along with this program; if not, write to the Free Software
46
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51
#include <glib/gi18n.h>
52
#include <gnome-settings-daemon/gsd-enums.h>
54
+#ifdef HAVE_BLUETOOTH
55
+/* Handling is broken:
56
+ * https://bugzilla.gnome.org/show_bug.cgi?id=691730
57
+ * https://bugzilla.gnome.org/show_bug.cgi?id=691151
58
+ * #include <bluetooth-client.h> */
59
+#undef HAVE_BLUETOOTH
64
#ifdef HAVE_NETWORK_MANAGER
65
#include <nm-client.h>
67
@@ -59,7 +70,6 @@ struct _CcPowerPanelPrivate
69
GtkWidget *automatic_suspend_dialog;
72
GDBusProxy *screen_proxy;
73
GDBusProxy *kbd_proxy;
74
gboolean has_batteries;
75
@@ -93,9 +103,10 @@ struct _CcPowerPanelPrivate
76
GtkWidget *critical_battery_row;
77
GtkWidget *critical_battery_combo;
79
- GDBusProxy *bt_rfkill;
80
- GDBusProxy *bt_properties;
81
- GtkWidget *bt_switch;
82
+#ifdef HAVE_BLUETOOTH
83
+ BluetoothClient *bt_client;
84
+ GtkWidget *bt_switch;
87
#ifdef HAVE_NETWORK_MANAGER
89
@@ -131,14 +142,10 @@ cc_power_panel_dispose (GObject *object)
90
g_clear_object (&priv->builder);
91
g_clear_object (&priv->screen_proxy);
92
g_clear_object (&priv->kbd_proxy);
95
- g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL);
96
- g_clear_pointer (&priv->devices, g_ptr_array_unref);
98
g_clear_object (&priv->up_client);
99
- g_clear_object (&priv->bt_rfkill);
100
- g_clear_object (&priv->bt_properties);
101
+#ifdef HAVE_BLUETOOTH
102
+ g_clear_object (&priv->bt_client);
104
#ifdef HAVE_NETWORK_MANAGER
105
g_clear_object (&priv->nm_client);
107
@@ -324,8 +331,8 @@ set_primary (CcPowerPanel *panel, UpDevi
108
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
109
gtk_container_add (GTK_CONTAINER (row), box);
111
- gtk_widget_set_margin_start (box, 20);
112
- gtk_widget_set_margin_end (box, 20);
113
+ gtk_widget_set_margin_left (box, 20);
114
+ gtk_widget_set_margin_right (box, 20);
115
gtk_widget_set_margin_top (box, 6);
116
gtk_widget_set_margin_bottom (box, 6);
118
@@ -380,7 +387,6 @@ add_battery (CcPowerPanel *panel, UpDevi
125
g_object_get (device,
126
@@ -388,7 +394,6 @@ add_battery (CcPowerPanel *panel, UpDevi
128
"percentage", &percentage,
129
"native-path", &native_path,
130
- "icon-name", &icon_name,
133
if (native_path && strstr (native_path, "BAT0"))
134
@@ -404,17 +409,18 @@ add_battery (CcPowerPanel *panel, UpDevi
135
label = gtk_label_new (name);
136
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
137
gtk_size_group_add_widget (priv->battery_sizegroup, box2);
138
- gtk_widget_set_margin_start (label, 20);
139
- gtk_widget_set_margin_end (label, 20);
140
+ gtk_widget_set_margin_left (label, 20);
141
+ gtk_widget_set_margin_right (label, 20);
142
gtk_widget_set_margin_top (label, 6);
143
gtk_widget_set_margin_bottom (label, 6);
144
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0);
145
gtk_box_pack_start (GTK_BOX (box), box2, FALSE, TRUE, 0);
148
- if (icon_name != NULL && *icon_name != '\0')
149
+ if (state == UP_DEVICE_STATE_DISCHARGING ||
150
+ state == UP_DEVICE_STATE_CHARGING)
152
- widget = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
153
+ widget = gtk_image_new_from_icon_name ("battery-good-charging-symbolic", GTK_ICON_SIZE_BUTTON);
154
gtk_style_context_add_class (gtk_widget_get_style_context (widget), GTK_STYLE_CLASS_DIM_LABEL);
155
gtk_widget_set_halign (widget, GTK_ALIGN_END);
156
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
157
@@ -423,8 +429,8 @@ add_battery (CcPowerPanel *panel, UpDevi
160
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
161
- gtk_widget_set_margin_start (box2, 20);
162
- gtk_widget_set_margin_end (box2, 20);
163
+ gtk_widget_set_margin_left (box2, 20);
164
+ gtk_widget_set_margin_right (box2, 20);
166
s = g_strdup_printf ("%d%%", (int)percentage);
167
label = gtk_label_new (s);
168
@@ -454,7 +460,6 @@ add_battery (CcPowerPanel *panel, UpDevi
169
gtk_widget_show_all (row);
171
g_free (native_path);
172
- g_free (icon_name);
174
gtk_widget_set_visible (priv->battery_section, TRUE);
176
@@ -578,16 +583,16 @@ add_device (CcPowerPanel *panel, UpDevic
177
widget = gtk_label_new ("");
178
gtk_misc_set_alignment (GTK_MISC (widget), 0.0f, 0.5f);
179
gtk_label_set_markup (GTK_LABEL (widget), description->str);
180
- gtk_widget_set_margin_start (widget, 20);
181
- gtk_widget_set_margin_end (widget, 20);
182
+ gtk_widget_set_margin_left (widget, 20);
183
+ gtk_widget_set_margin_right (widget, 20);
184
gtk_widget_set_margin_top (widget, 6);
185
gtk_widget_set_margin_bottom (widget, 6);
186
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, TRUE, 0);
187
gtk_size_group_add_widget (priv->battery_sizegroup, widget);
189
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
190
- gtk_widget_set_margin_start (box2, 20);
191
- gtk_widget_set_margin_end (box2, 20);
192
+ gtk_widget_set_margin_left (box2, 20);
193
+ gtk_widget_set_margin_right (box2, 20);
194
s = g_strdup_printf ("%d%%", (int)percentage);
195
widget = gtk_label_new (s);
197
@@ -622,12 +627,26 @@ up_client_changed (UpClient *client,
200
CcPowerPanelPrivate *priv = self->priv;
201
+ GPtrArray *devices;
205
+ UpDeviceState state;
209
+ gdouble percentage = 0.0;
210
+ gdouble energy = 0.0;
211
+ gdouble energy_full = 0.0;
212
+ gdouble energy_rate = 0.0;
213
+ gdouble energy_total = 0.0;
214
+ gdouble energy_full_total = 0.0;
215
+ gdouble energy_rate_total = 0.0;
216
+ gint64 time_to_empty = 0;
217
+ gint64 time_to_full = 0;
218
+ gboolean is_charging = FALSE;
219
+ gboolean is_discharging = FALSE;
220
+ gboolean is_fully_charged = TRUE;
223
children = gtk_container_get_children (GTK_CONTAINER (priv->battery_list));
224
@@ -642,6 +661,8 @@ up_client_changed (UpClient *client,
225
g_list_free (children);
226
gtk_widget_hide (priv->device_section);
228
+ devices = up_client_get_devices (client);
230
#ifdef TEST_FAKE_DEVICES
232
static gboolean fake_devices_added = FALSE;
233
@@ -653,60 +674,68 @@ up_client_changed (UpClient *client,
234
device = up_device_new ();
235
g_object_set (device,
236
"kind", UP_DEVICE_KIND_MOUSE,
237
- "native-path", "dummy:native-path1",
238
- "model", "My mouse",
240
"state", UP_DEVICE_STATE_DISCHARGING,
241
"time-to-empty", 287,
242
- "icon-name", "battery-full-symbolic",
244
- g_ptr_array_add (priv->devices, device);
245
+ g_ptr_array_add (devices, device);
246
device = up_device_new ();
247
g_object_set (device,
248
"kind", UP_DEVICE_KIND_KEYBOARD,
249
- "native-path", "dummy:native-path2",
250
- "model", "My keyboard",
251
- "percentage", 59.0,
252
+ "percentage", 69.0,
253
"state", UP_DEVICE_STATE_DISCHARGING,
254
"time-to-empty", 250,
255
- "icon-name", "battery-good-symbolic",
257
- g_ptr_array_add (priv->devices, device);
258
+ g_ptr_array_add (devices, device);
259
device = up_device_new ();
260
g_object_set (device,
261
"kind", UP_DEVICE_KIND_BATTERY,
262
- "native-path", "dummy:native-path3",
263
- "model", "Battery from some factory",
265
"state", UP_DEVICE_STATE_FULLY_CHARGED,
269
"time-to-empty", 400,
270
- "icon-name", "battery-full-charged-symbolic",
272
- g_ptr_array_add (priv->devices, device);
273
+ g_ptr_array_add (devices, device);
280
- composite = up_client_get_display_device (priv->up_client);
281
- g_object_get (composite, "kind", &kind, NULL);
282
- if (kind == UP_DEVICE_KIND_UPS)
287
+ composite = up_device_new ();
288
+ g_object_set (composite,
289
+ "kind", UP_DEVICE_KIND_BATTERY,
290
+ "is-rechargeable", TRUE,
291
+ "native-path", "dummy:composite_battery",
292
+ "power-supply", TRUE,
293
+ "is-present", TRUE,
295
+ for (i = 0; devices != NULL && i < devices->len; i++)
297
- /* Count the batteries */
298
- for (i = 0; priv->devices != NULL && i < priv->devices->len; i++)
299
+ UpDevice *device = (UpDevice*) g_ptr_array_index (devices, i);
300
+ g_object_get (device,
304
+ "energy-full", &energy_full,
305
+ "energy-rate", &energy_rate,
307
+ if (kind == UP_DEVICE_KIND_UPS && state == UP_DEVICE_STATE_DISCHARGING)
309
+ if (kind == UP_DEVICE_KIND_BATTERY)
311
- UpDevice *device = (UpDevice*) g_ptr_array_index (priv->devices, i);
312
- g_object_get (device, "kind", &kind, NULL);
313
- if (kind == UP_DEVICE_KIND_BATTERY)
315
+ if (state == UP_DEVICE_STATE_CHARGING)
316
+ is_charging = TRUE;
317
+ if (state == UP_DEVICE_STATE_DISCHARGING)
318
+ is_discharging = TRUE;
319
+ if (state != UP_DEVICE_STATE_FULLY_CHARGED)
320
+ is_fully_charged = FALSE;
321
+ energy_total += energy;
322
+ energy_full_total += energy_full;
323
+ energy_rate_total += energy_rate;
328
@@ -717,12 +746,42 @@ up_client_changed (UpClient *client,
329
gtk_label_set_label (GTK_LABEL (priv->battery_heading), s);
332
+ if (energy_full_total > 0.0)
333
+ percentage = 100.0 * energy_total / energy_full_total;
336
+ state = UP_DEVICE_STATE_CHARGING;
337
+ else if (is_discharging)
338
+ state = UP_DEVICE_STATE_DISCHARGING;
339
+ else if (is_fully_charged)
340
+ state = UP_DEVICE_STATE_FULLY_CHARGED;
342
+ state = UP_DEVICE_STATE_UNKNOWN;
344
+ if (energy_rate_total > 0)
346
+ if (state == UP_DEVICE_STATE_DISCHARGING)
347
+ time_to_empty = 3600 * (energy_total / energy_rate_total);
348
+ else if (state == UP_DEVICE_STATE_CHARGING)
349
+ time_to_full = 3600 * ((energy_full_total - energy_total) / energy_rate_total);
352
+ g_object_set (composite,
353
+ "energy", energy_total,
354
+ "energy-full", energy_full_total,
355
+ "energy-rate", energy_rate_total,
356
+ "time-to-empty", time_to_empty,
357
+ "time-to-full", time_to_full,
358
+ "percentage", percentage,
362
if (!on_ups && n_batteries > 1)
363
set_primary (self, composite);
365
- for (i = 0; priv->devices != NULL && i < priv->devices->len; i++)
366
+ for (i = 0; devices != NULL && i < devices->len; i++)
368
- UpDevice *device = (UpDevice*) g_ptr_array_index (priv->devices, i);
369
+ UpDevice *device = (UpDevice*) g_ptr_array_index (devices, i);
370
g_object_get (device, "kind", &kind, NULL);
371
if (kind == UP_DEVICE_KIND_LINE_POWER)
373
@@ -746,49 +805,11 @@ up_client_changed (UpClient *client,
377
+ g_clear_pointer (&devices, g_ptr_array_unref);
378
g_object_unref (composite);
382
-up_client_device_removed (UpClient *client,
383
- const char *object_path,
384
- CcPowerPanel *self)
386
- CcPowerPanelPrivate *priv = self->priv;
389
- if (priv->devices == NULL)
392
- for (i = 0; i < priv->devices->len; i++)
394
- UpDevice *device = g_ptr_array_index (priv->devices, i);
396
- if (g_strcmp0 (object_path, up_device_get_object_path (device)) == 0)
398
- g_object_unref (device);
399
- g_ptr_array_remove_index (priv->devices, i);
404
- up_client_changed (self->priv->up_client, NULL, self);
408
-up_client_device_added (UpClient *client,
410
- CcPowerPanel *self)
412
- CcPowerPanelPrivate *priv = self->priv;
414
- g_ptr_array_add (priv->devices, g_object_ref (device));
415
- g_signal_connect (G_OBJECT (device), "notify",
416
- G_CALLBACK (up_client_changed), self);
417
- up_client_changed (priv->up_client, NULL, self);
421
set_brightness_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
423
GError *error = NULL;
424
@@ -1077,11 +1098,22 @@ static void
425
set_ac_battery_ui_mode (CcPowerPanel *self)
427
gboolean has_batteries = FALSE;
429
+ GError *error = NULL;
435
+ /* this is sync, but it's cached in the daemon and so quick */
436
+ ret = up_client_enumerate_devices_sync (self->priv->up_client, NULL, &error);
439
+ g_warning ("failed to get device list: %s", error->message);
440
+ g_error_free (error);
444
devices = up_client_get_devices (self->priv->up_client);
445
g_debug ("got %d devices from upower\n", devices->len);
447
@@ -1102,6 +1134,7 @@ set_ac_battery_ui_mode (CcPowerPanel *se
448
has_batteries = FALSE;
452
self->priv->has_batteries = has_batteries;
454
gtk_widget_set_visible (self->priv->critical_battery_row, has_batteries);
455
@@ -1136,18 +1169,41 @@ update_header_func (GtkListBoxRow *row,
459
+#ifdef HAVE_BLUETOOTH
461
-bt_set_powered (CcPowerPanel *self,
463
+bt_set_powered (BluetoothClient *client,
466
- g_dbus_proxy_call (self->priv->bt_properties,
468
- g_variant_new_parsed ("('org.gnome.SettingsDaemon.Rfkill', 'BluetoothAirplaneMode', %v)",
469
- g_variant_new_boolean (!powered)),
470
- G_DBUS_CALL_FLAGS_NONE,
472
- self->priv->cancellable,
475
+ const gchar *adapter_path;
476
+ GDBusConnection *bus;
478
+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
480
+ ret = g_dbus_connection_call_sync (bus,
483
+ "org.bluez.Manager",
490
+ g_variant_get (ret, "(&o)", &adapter_path);
492
+ g_dbus_connection_call (bus,
495
+ "org.freedesktop.Properties",
497
+ g_variant_new ("(sv)", "Powered", g_variant_new_boolean (powered)),
503
+ g_variant_unref (ret);
507
@@ -1161,26 +1217,25 @@ bt_switch_changed (GtkSwitch *sw,
509
g_debug ("Setting bt power %s", powered ? "on" : "off");
511
- bt_set_powered (panel, powered);
512
+ bt_set_powered (panel->priv->bt_client, powered);
516
-bt_powered_state_changed (CcPowerPanel *panel)
517
+bt_powered_state_changed (GObject *client,
519
+ CcPowerPanel *panel)
521
CcPowerPanelPrivate *priv = panel->priv;
525
- v = g_dbus_proxy_get_cached_property (priv->bt_rfkill, "BluetoothAirplaneMode");
526
- powered = !g_variant_get_boolean (v);
527
- g_variant_unref (v);
529
+ g_object_get (client, "default-adapter-powered", &powered, NULL);
530
g_debug ("bt powered state changed to %s", powered ? "on" : "off");
532
g_signal_handlers_block_by_func (priv->bt_switch, bt_switch_changed, panel);
533
gtk_switch_set_active (GTK_SWITCH (priv->bt_switch), powered);
534
g_signal_handlers_unblock_by_func (priv->bt_switch, bt_switch_changed, panel);
538
#ifdef HAVE_NETWORK_MANAGER
540
@@ -1419,8 +1474,8 @@ add_brightness_row (CcPowerPanel *self,
541
label = gtk_label_new (text);
542
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
543
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
544
- gtk_widget_set_margin_start (label, 20);
545
- gtk_widget_set_margin_end (label, 20);
546
+ gtk_widget_set_margin_left (label, 20);
547
+ gtk_widget_set_margin_right (label, 20);
548
gtk_widget_set_margin_top (label, 6);
549
gtk_widget_set_margin_bottom (label, 6);
550
gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
551
@@ -1433,8 +1488,8 @@ add_brightness_row (CcPowerPanel *self,
552
*brightness_scale = scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
553
gtk_label_set_mnemonic_widget (GTK_LABEL (label), scale);
554
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
555
- gtk_widget_set_margin_start (scale, 20);
556
- gtk_widget_set_margin_end (scale, 20);
557
+ gtk_widget_set_margin_left (scale, 20);
558
+ gtk_widget_set_margin_right (scale, 20);
559
gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0);
560
gtk_size_group_add_widget (priv->level_sizegroup, scale);
561
g_signal_connect (scale, "value-changed",
562
@@ -1465,8 +1520,8 @@ add_power_saving_section (CcPowerPanel *
564
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
565
gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
566
- gtk_widget_set_margin_start (widget, 56);
567
- gtk_widget_set_margin_end (widget, 56);
568
+ gtk_widget_set_margin_left (widget, 56);
569
+ gtk_widget_set_margin_right (widget, 56);
570
gtk_widget_set_margin_bottom (widget, 6);
571
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 0);
572
gtk_widget_show (widget);
573
@@ -1481,8 +1536,8 @@ add_power_saving_section (CcPowerPanel *
575
box = gtk_frame_new (NULL);
576
gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_IN);
577
- gtk_widget_set_margin_start (box, 50);
578
- gtk_widget_set_margin_end (box, 50);
579
+ gtk_widget_set_margin_left (box, 50);
580
+ gtk_widget_set_margin_right (box, 50);
581
gtk_widget_set_margin_bottom (box, 24);
582
gtk_widget_show (box);
583
gtk_container_add (GTK_CONTAINER (box), widget);
584
@@ -1507,8 +1562,8 @@ add_power_saving_section (CcPowerPanel *
585
label = gtk_label_new (_("_Dim screen when inactive"));
586
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
587
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
588
- gtk_widget_set_margin_start (label, 20);
589
- gtk_widget_set_margin_end (label, 20);
590
+ gtk_widget_set_margin_left (label, 20);
591
+ gtk_widget_set_margin_right (label, 20);
592
gtk_widget_set_margin_top (label, 6);
593
gtk_widget_set_margin_bottom (label, 6);
594
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
595
@@ -1517,8 +1572,8 @@ add_power_saving_section (CcPowerPanel *
596
g_settings_bind (priv->gsd_settings, "idle-dim",
598
G_SETTINGS_BIND_DEFAULT);
599
- gtk_widget_set_margin_start (sw, 20);
600
- gtk_widget_set_margin_end (sw, 20);
601
+ gtk_widget_set_margin_left (sw, 20);
602
+ gtk_widget_set_margin_right (sw, 20);
603
gtk_widget_set_valign (sw, GTK_ALIGN_CENTER);
604
gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
605
gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw);
606
@@ -1532,8 +1587,8 @@ add_power_saving_section (CcPowerPanel *
607
label = gtk_label_new (_("_Blank screen"));
608
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
609
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
610
- gtk_widget_set_margin_start (label, 20);
611
- gtk_widget_set_margin_end (label, 20);
612
+ gtk_widget_set_margin_left (label, 20);
613
+ gtk_widget_set_margin_right (label, 20);
614
gtk_widget_set_margin_top (label, 6);
615
gtk_widget_set_margin_bottom (label, 6);
616
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
617
@@ -1546,8 +1601,8 @@ add_power_saving_section (CcPowerPanel *
618
set_value_for_combo (GTK_COMBO_BOX (combo), value);
619
g_signal_connect (combo, "changed",
620
G_CALLBACK (combo_idle_delay_changed_cb), self);
621
- gtk_widget_set_margin_start (combo, 20);
622
- gtk_widget_set_margin_end (combo, 20);
623
+ gtk_widget_set_margin_left (combo, 20);
624
+ gtk_widget_set_margin_right (combo, 20);
625
gtk_widget_set_valign (combo, GTK_ALIGN_CENTER);
626
gtk_box_pack_start (GTK_BOX (box), combo, FALSE, TRUE, 0);
627
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
628
@@ -1560,8 +1615,8 @@ add_power_saving_section (CcPowerPanel *
629
gtk_container_add (GTK_CONTAINER (row), box);
631
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
632
- gtk_widget_set_margin_start (box2, 20);
633
- gtk_widget_set_margin_end (box2, 20);
634
+ gtk_widget_set_margin_left (box2, 20);
635
+ gtk_widget_set_margin_right (box2, 20);
636
gtk_widget_set_margin_top (box2, 6);
637
gtk_widget_set_margin_bottom (box2, 6);
638
gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0);
639
@@ -1577,8 +1632,8 @@ add_power_saving_section (CcPowerPanel *
640
gtk_box_pack_start (GTK_BOX (box2), w, TRUE, TRUE, 0);
642
priv->wifi_switch = sw = gtk_switch_new ();
643
- gtk_widget_set_margin_start (sw, 20);
644
- gtk_widget_set_margin_end (sw, 20);
645
+ gtk_widget_set_margin_left (sw, 20);
646
+ gtk_widget_set_margin_right (sw, 20);
647
gtk_widget_set_valign (sw, GTK_ALIGN_CENTER);
648
gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
649
gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw);
650
@@ -1590,8 +1645,8 @@ add_power_saving_section (CcPowerPanel *
651
gtk_container_add (GTK_CONTAINER (row), box);
653
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
654
- gtk_widget_set_margin_start (box2, 20);
655
- gtk_widget_set_margin_end (box2, 20);
656
+ gtk_widget_set_margin_left (box2, 20);
657
+ gtk_widget_set_margin_right (box2, 20);
658
gtk_widget_set_margin_top (box2, 6);
659
gtk_widget_set_margin_bottom (box2, 6);
660
gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0);
661
@@ -1607,8 +1662,8 @@ add_power_saving_section (CcPowerPanel *
662
gtk_box_pack_start (GTK_BOX (box2), w, TRUE, TRUE, 0);
664
priv->mobile_switch = sw = gtk_switch_new ();
665
- gtk_widget_set_margin_start (sw, 20);
666
- gtk_widget_set_margin_end (sw, 20);
667
+ gtk_widget_set_margin_left (sw, 20);
668
+ gtk_widget_set_margin_right (sw, 20);
669
gtk_widget_set_valign (sw, GTK_ALIGN_CENTER);
670
gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
671
gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw);
672
@@ -1631,47 +1686,33 @@ add_power_saving_section (CcPowerPanel *
673
G_CALLBACK (wifi_switch_changed), self);
676
- priv->bt_rfkill = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
677
- G_DBUS_PROXY_FLAGS_NONE,
679
- "org.gnome.SettingsDaemon.Rfkill",
680
- "/org/gnome/SettingsDaemon/Rfkill",
681
- "org.gnome.SettingsDaemon.Rfkill",
683
- if (priv->bt_rfkill)
685
- priv->bt_properties = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
686
- G_DBUS_PROXY_FLAGS_NONE,
688
- "org.gnome.SettingsDaemon.Rfkill",
689
- "/org/gnome/SettingsDaemon/Rfkill",
690
- "org.freedesktop.DBus.Properties",
692
- row = gtk_list_box_row_new ();
693
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 50);
694
- gtk_container_add (GTK_CONTAINER (row), box);
695
- label = gtk_label_new (_("_Bluetooth"));
696
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
697
- gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
698
- gtk_widget_set_margin_start (label, 20);
699
- gtk_widget_set_margin_end (label, 20);
700
- gtk_widget_set_margin_top (label, 6);
701
- gtk_widget_set_margin_bottom (label, 6);
702
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
704
- priv->bt_switch = sw = gtk_switch_new ();
705
- gtk_widget_set_margin_start (sw, 20);
706
- gtk_widget_set_margin_end (sw, 20);
707
- gtk_widget_set_valign (sw, GTK_ALIGN_CENTER);
708
- gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
709
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw);
710
- gtk_container_add (GTK_CONTAINER (widget), row);
711
- gtk_size_group_add_widget (priv->row_sizegroup, row);
712
- g_signal_connect_swapped (G_OBJECT (priv->bt_rfkill), "g-properties-changed",
713
- G_CALLBACK (bt_powered_state_changed), self);
714
- g_signal_connect (G_OBJECT (priv->bt_switch), "notify::active",
715
- G_CALLBACK (bt_switch_changed), self);
717
+#ifdef HAVE_BLUETOOTH
718
+ priv->bt_client = bluetooth_client_new ();
719
+ row = gtk_list_box_row_new ();
720
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 50);
721
+ gtk_container_add (GTK_CONTAINER (row), box);
722
+ label = gtk_label_new (_("_Bluetooth"));
723
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
724
+ gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
725
+ gtk_widget_set_margin_left (label, 20);
726
+ gtk_widget_set_margin_right (label, 20);
727
+ gtk_widget_set_margin_top (label, 6);
728
+ gtk_widget_set_margin_bottom (label, 6);
729
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
731
+ priv->bt_switch = sw = gtk_switch_new ();
732
+ gtk_widget_set_margin_left (sw, 20);
733
+ gtk_widget_set_margin_right (sw, 20);
734
+ gtk_widget_set_valign (sw, GTK_ALIGN_CENTER);
735
+ gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
736
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw);
737
+ gtk_container_add (GTK_CONTAINER (widget), row);
738
+ gtk_size_group_add_widget (priv->row_sizegroup, row);
739
+ g_signal_connect (G_OBJECT (priv->bt_client), "notify::default-adapter-powered",
740
+ G_CALLBACK (bt_powered_state_changed), self);
741
+ g_signal_connect (G_OBJECT (priv->bt_switch), "notify::active",
742
+ G_CALLBACK (bt_switch_changed), self);
745
gtk_widget_show_all (widget);
747
@@ -1837,8 +1878,8 @@ add_automatic_suspend_section (CcPowerPa
749
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
750
gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
751
- gtk_widget_set_margin_start (widget, 56);
752
- gtk_widget_set_margin_end (widget, 50);
753
+ gtk_widget_set_margin_left (widget, 56);
754
+ gtk_widget_set_margin_right (widget, 50);
755
gtk_widget_set_margin_bottom (widget, 6);
756
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 0);
757
gtk_widget_show (widget);
758
@@ -1855,8 +1896,8 @@ add_automatic_suspend_section (CcPowerPa
760
box = gtk_frame_new (NULL);
761
gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_IN);
762
- gtk_widget_set_margin_start (box, 50);
763
- gtk_widget_set_margin_end (box, 50);
764
+ gtk_widget_set_margin_left (box, 50);
765
+ gtk_widget_set_margin_right (box, 50);
766
gtk_widget_set_margin_bottom (box, 24);
767
gtk_widget_show (box);
768
gtk_container_add (GTK_CONTAINER (box), widget);
769
@@ -1868,8 +1909,8 @@ add_automatic_suspend_section (CcPowerPa
770
label = gtk_label_new (_("_Automatic suspend"));
771
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
772
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
773
- gtk_widget_set_margin_start (label, 20);
774
- gtk_widget_set_margin_end (label, 20);
775
+ gtk_widget_set_margin_left (label, 20);
776
+ gtk_widget_set_margin_right (label, 20);
777
gtk_widget_set_margin_top (label, 6);
778
gtk_widget_set_margin_bottom (label, 6);
779
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
780
@@ -1879,8 +1920,8 @@ add_automatic_suspend_section (CcPowerPa
781
g_signal_connect (sw, "mnemonic-activate",
782
G_CALLBACK (automatic_suspend_activate), self);
783
gtk_misc_set_alignment (GTK_MISC (sw), 1, 0.5);
784
- gtk_widget_set_margin_start (sw, 24);
785
- gtk_widget_set_margin_end (sw, 24);
786
+ gtk_widget_set_margin_left (sw, 24);
787
+ gtk_widget_set_margin_right (sw, 24);
788
gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
789
gtk_container_add (GTK_CONTAINER (widget), row);
790
gtk_size_group_add_widget (priv->row_sizegroup, row);
791
@@ -1892,8 +1933,8 @@ add_automatic_suspend_section (CcPowerPa
792
label = gtk_label_new (_("When battery power is _critical"));
793
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
794
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
795
- gtk_widget_set_margin_start (label, 20);
796
- gtk_widget_set_margin_end (label, 20);
797
+ gtk_widget_set_margin_left (label, 20);
798
+ gtk_widget_set_margin_right (label, 20);
799
gtk_widget_set_margin_top (label, 6);
800
gtk_widget_set_margin_bottom (label, 6);
801
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
802
@@ -1930,8 +1971,8 @@ add_automatic_suspend_section (CcPowerPa
803
cell = gtk_cell_renderer_text_new ();
804
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (sw), cell, TRUE);
805
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (sw), cell, "text", 0);
806
- gtk_widget_set_margin_start (sw, 20);
807
- gtk_widget_set_margin_end (sw, 20);
808
+ gtk_widget_set_margin_left (sw, 20);
809
+ gtk_widget_set_margin_right (sw, 20);
810
gtk_widget_set_valign (sw, GTK_ALIGN_CENTER);
812
g_object_set_data (G_OBJECT (sw), "_gsettings_key", "critical-battery-action");
813
@@ -1947,8 +1988,8 @@ add_automatic_suspend_section (CcPowerPa
816
label = gtk_label_new (_("Power Off"));
817
- gtk_widget_set_margin_start (label, 20);
818
- gtk_widget_set_margin_end (label, 20);
819
+ gtk_widget_set_margin_left (label, 20);
820
+ gtk_widget_set_margin_right (label, 20);
821
gtk_widget_set_margin_top (label, 6);
822
gtk_widget_set_margin_bottom (label, 6);
823
gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
824
@@ -2030,8 +2071,8 @@ add_battery_section (CcPowerPanel *self)
825
vbox = WID (priv->builder, "vbox_power");
827
priv->battery_section = box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
828
- gtk_widget_set_margin_start (box, 50);
829
- gtk_widget_set_margin_end (box, 50);
830
+ gtk_widget_set_margin_left (box, 50);
831
+ gtk_widget_set_margin_right (box, 50);
832
gtk_widget_set_margin_bottom (box, 6);
833
gtk_widget_set_margin_bottom (box, 24);
834
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0);
835
@@ -2041,8 +2082,8 @@ add_battery_section (CcPowerPanel *self)
837
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
838
gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
839
- gtk_widget_set_margin_start (widget, 6);
840
- gtk_widget_set_margin_end (widget, 6);
841
+ gtk_widget_set_margin_left (widget, 6);
842
+ gtk_widget_set_margin_right (widget, 6);
843
gtk_widget_set_margin_bottom (widget, 6);
844
gtk_widget_set_margin_bottom (box, 24);
845
gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);
846
@@ -2077,8 +2118,8 @@ add_device_section (CcPowerPanel *self)
847
vbox = WID (priv->builder, "vbox_power");
849
priv->device_section = box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
850
- gtk_widget_set_margin_start (box, 50);
851
- gtk_widget_set_margin_end (box, 50);
852
+ gtk_widget_set_margin_left (box, 50);
853
+ gtk_widget_set_margin_right (box, 50);
854
gtk_widget_set_margin_top (box, 6);
855
gtk_widget_set_margin_bottom (box, 24);
856
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0);
857
@@ -2088,8 +2129,8 @@ add_device_section (CcPowerPanel *self)
859
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
860
gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
861
- gtk_widget_set_margin_start (widget, 6);
862
- gtk_widget_set_margin_end (widget, 6);
863
+ gtk_widget_set_margin_left (widget, 6);
864
+ gtk_widget_set_margin_right (widget, 6);
865
gtk_widget_set_margin_bottom (widget, 6);
866
gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);
868
@@ -2137,7 +2178,6 @@ cc_power_panel_init (CcPowerPanel *self)
874
priv = self->priv = POWER_PANEL_PRIVATE (self);
875
g_resources_register (cc_power_get_resource ());
876
@@ -2201,15 +2241,9 @@ cc_power_panel_init (CcPowerPanel *self)
877
update_automatic_suspend_label (self);
879
/* populate batteries */
880
- g_signal_connect (priv->up_client, "device-added", G_CALLBACK (up_client_device_added), self);
881
- g_signal_connect (priv->up_client, "device-removed", G_CALLBACK (up_client_device_removed), self);
883
- priv->devices = up_client_get_devices (priv->up_client);
884
- for (i = 0; priv->devices != NULL && i < priv->devices->len; i++) {
885
- UpDevice *device = g_ptr_array_index (priv->devices, i);
886
- g_signal_connect (G_OBJECT (device), "notify",
887
- G_CALLBACK (up_client_changed), self);
889
+ g_signal_connect (priv->up_client, "device-added", G_CALLBACK (up_client_changed), self);
890
+ g_signal_connect (priv->up_client, "device-changed", G_CALLBACK (up_client_changed), self);
891
+ g_signal_connect (priv->up_client, "device-removed", G_CALLBACK (up_client_changed), self);
892
up_client_changed (priv->up_client, NULL, self);
894
widget = WID (priv->builder, "vbox_power");
895
Index: gnome-control-center/panels/power/cc-power-panel.h
896
===================================================================
897
--- gnome-control-center.orig/panels/power/cc-power-panel.h
898
+++ gnome-control-center/panels/power/cc-power-panel.h
900
* GNU General Public License for more details.
902
* You should have received a copy of the GNU General Public License
903
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
904
+ * along with this program; if not, write to the Free Software
905
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
909
Index: gnome-control-center/panels/power/gnome-power-panel.desktop.in.in
910
===================================================================
911
--- gnome-control-center.orig/panels/power/gnome-power-panel.desktop.in.in
912
+++ gnome-control-center/panels/power/gnome-power-panel.desktop.in.in
913
@@ -5,7 +5,6 @@ Exec=gnome-control-center power
914
Icon=gnome-power-manager
919
Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;HardwareSettings;
920
OnlyShowIn=GNOME;Unity;
921
Index: gnome-control-center/panels/power/power.ui
922
===================================================================
923
--- gnome-control-center.orig/panels/power/power.ui
924
+++ gnome-control-center/panels/power/power.ui
926
<child internal-child="vbox">
927
<object class="GtkBox" id="asdf">
928
<property name="can_focus">False</property>
929
+ <property name="resize_mode">immediate</property>
930
<property name="orientation">vertical</property>
931
<property name="spacing">2</property>
932
<child internal-child="action_area">
934
<object class="GtkGrid" id="grid1">
935
<property name="visible">True</property>
936
<property name="can_focus">False</property>
937
- <property name="margin_start">12</property>
938
- <property name="margin_end">6</property>
939
+ <property name="margin_left">12</property>
940
+ <property name="margin_right">6</property>
941
<property name="margin_top">12</property>
942
<property name="margin_bottom">12</property>
943
<property name="row_spacing">12</property>
945
<object class="GtkComboBoxText" id="suspend_on_battery_delay_combo">
946
<property name="visible">True</property>
947
<property name="can_focus">False</property>
948
+ <property name="margin_left">4</property>
949
+ <property name="margin_right">4</property>
950
<property name="entry_text_column">0</property>
951
<property name="id_column">1</property>
952
<property name="model">liststore_time</property>
954
<object class="GtkLabel" id="suspend_on_battery_delay_label">
955
<property name="visible">True</property>
956
<property name="can_focus">False</property>
957
- <property name="margin_start">20</property>
958
+ <property name="margin_left">20</property>
959
<property name="xalign">1</property>
960
<property name="label" translatable="yes">Delay</property>
961
<property name="mnemonic_widget">suspend_on_battery_delay_combo</property>
963
<object class="GtkComboBoxText" id="suspend_on_ac_delay_combo">
964
<property name="visible">True</property>
965
<property name="can_focus">False</property>
966
+ <property name="margin_left">4</property>
967
+ <property name="margin_right">4</property>
968
<property name="entry_text_column">0</property>
969
<property name="id_column">1</property>
970
<property name="model">liststore_time</property>
972
<object class="GtkLabel" id="suspend_on_ac_delay_label">
973
<property name="visible">True</property>
974
<property name="can_focus">False</property>
975
- <property name="margin_start">20</property>
976
+ <property name="margin_left">20</property>
977
<property name="xalign">1</property>
978
<property name="label" translatable="yes">Delay</property>
979
<property name="mnemonic_widget">suspend_on_ac_delay_combo</property>