Merge lp:~robert-ancell/indicator-bluetooth/only-show-when-adapter-present into lp:indicator-bluetooth/13.10

Proposed by Robert Ancell on 2013-02-07
Status: Merged
Approved by: Robert Ancell on 2013-02-11
Approved revision: 48
Merged at revision: 47
Proposed branch: lp:~robert-ancell/indicator-bluetooth/only-show-when-adapter-present
Merge into: lp:indicator-bluetooth/13.10
Diff against target: 138 lines (+60/-5)
3 files modified
NEWS (+5/-0)
src/indicator-bluetooth-service.vala (+50/-5)
src/indicator-bluetooth.vala (+5/-0)
To merge this branch: bzr merge lp:~robert-ancell/indicator-bluetooth/only-show-when-adapter-present
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing on 2013-02-11
Mathieu Trudel-Lapierre 2013-02-07 Approve on 2013-02-11
Review via email: mp+147248@code.launchpad.net

Commit message

Only show indicator if Bluetooth adapter present

To post a comment you must log in.
Mathieu Trudel-Lapierre (cyphermox) wrote :

Approve. Hopefully jenkins will understand how to merge this once r. 47 is merged.

review: Approve
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal; hit 'Add commit message' on the merge proposal web page and approve the merge proposal again yourself to rerun.

review: Needs Fixing (continuous-integration)
Martin Pitt (pitti) wrote :

Please note that this caused a regression: bug 1126108

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2013-01-31 19:54:53 +0000
3+++ NEWS 2013-02-07 22:40:26 +0000
4@@ -1,3 +1,8 @@
5+Overview of changes in indicator-bluetooth 0.0.6
6+
7+ * Add "Set Up New Device" menu item
8+ * Only show indicator if Bluetooth adapter present
9+
10 Overview of changes in indicator-bluetooth 0.0.5
11
12 * Add license file
13
14=== modified file 'src/indicator-bluetooth-service.vala'
15--- src/indicator-bluetooth-service.vala 2013-02-06 03:16:55 +0000
16+++ src/indicator-bluetooth-service.vala 2013-02-07 22:40:26 +0000
17@@ -22,7 +22,6 @@
18 private bool updating_visible = false;
19 private Dbusmenu.Menuitem devices_separator;
20 private List<BluetoothMenuItem> device_items;
21- private Dbusmenu.Menuitem settings_item;
22 private Dbusmenu.Menuitem menu;
23
24 public BluetoothIndicator () throws Error
25@@ -106,12 +105,21 @@
26 sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR);
27 menu.child_append (sep);
28
29- settings_item = new Dbusmenu.Menuitem ();
30- settings_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…"));
31- settings_item.item_activated.connect (() => { show_control_center ("bluetooth"); });
32- menu.child_append (settings_item);
33+ var item = new Dbusmenu.Menuitem ();
34+ item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Set Up New Device…"));
35+ item.item_activated.connect (() => { set_up_new_device (); });
36+ menu.child_append (item);
37+
38+ item = new Dbusmenu.Menuitem ();
39+ item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…"));
40+ item.item_activated.connect (() => { show_control_center ("bluetooth"); });
41+ menu.child_append (item);
42
43 killswitch_state_changed_cb (killswitch.state);
44+
45+ client.adapter_model.row_inserted.connect (adapters_changed_cb);
46+ client.adapter_model.row_deleted.connect (adapters_changed_cb);
47+ adapters_changed_cb ();
48 }
49
50 private BluetoothMenuItem? find_menu_item (string address)
51@@ -168,6 +176,26 @@
52 item.update (type, proxy, alias, icon, connected, services, uuids);
53 }
54
55+ private void adapters_changed_cb ()
56+ {
57+ bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0;
58+ var builder = new VariantBuilder (VariantType.ARRAY);
59+ builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible));
60+ try
61+ {
62+ var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null);
63+ bus.emit_signal (null,
64+ "/com/canonical/indicator/bluetooth/service",
65+ "org.freedesktop.DBus.Properties",
66+ "PropertiesChanged",
67+ properties);
68+ }
69+ catch (Error e)
70+ {
71+ warning ("Failed to emit signal: %s", e.message);
72+ }
73+ }
74+
75 private void device_removed_cb (Gtk.TreePath path)
76 {
77 Gtk.TreeIter iter;
78@@ -334,6 +362,18 @@
79 }
80 }
81
82+private void set_up_new_device ()
83+{
84+ try
85+ {
86+ Process.spawn_command_line_async ("bluetooth-wizard");
87+ }
88+ catch (GLib.SpawnError e)
89+ {
90+ warning ("Failed to open bluetooth-wizard: %s", e.message);
91+ }
92+}
93+
94 private void show_control_center (string panel)
95 {
96 try
97@@ -377,6 +417,11 @@
98 [DBus (name = "com.canonical.indicator.bluetooth.service")]
99 private class BluetoothService : Object
100 {
101+ internal bool _visible = false;
102+ public bool visible
103+ {
104+ get { return _visible; }
105+ }
106 internal string _icon_name = "bluetooth-active";
107 public string icon_name
108 {
109
110=== modified file 'src/indicator-bluetooth.vala'
111--- src/indicator-bluetooth.vala 2013-02-06 03:16:55 +0000
112+++ src/indicator-bluetooth.vala 2013-02-07 22:40:26 +0000
113@@ -26,6 +26,9 @@
114
115 var menu_client = menu.get_client ();
116 menu_client.add_type_handler_full ("x-canonical-switch", new_switch_cb);
117+
118+ /* Hide until ready */
119+ set_visible (false);
120 }
121
122 private bool new_switch_cb (Dbusmenu.Menuitem newitem, Dbusmenu.Menuitem parent, Dbusmenu.Client client)
123@@ -80,6 +83,7 @@
124
125 private void server_properties_changed_cb ()
126 {
127+ set_visible (proxy.visible);
128 Indicator.image_helper_update (image, proxy.icon_name);
129 accessible_description = proxy.accessible_description;
130 }
131@@ -122,6 +126,7 @@
132 [DBus (name = "com.canonical.indicator.bluetooth.service")]
133 public interface BluetoothService : DBusProxy
134 {
135+ public abstract bool visible { owned get; }
136 public abstract string icon_name { owned get; }
137 public abstract string accessible_description { owned get; }
138 }

Subscribers

People subscribed via source and target branches