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

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
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
Mathieu Trudel-Lapierre Approve
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

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

review: Approve
Revision history for this message
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)
Revision history for this message
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
=== modified file 'NEWS'
--- NEWS 2013-01-31 19:54:53 +0000
+++ NEWS 2013-02-07 22:40:26 +0000
@@ -1,3 +1,8 @@
1Overview of changes in indicator-bluetooth 0.0.6
2
3 * Add "Set Up New Device" menu item
4 * Only show indicator if Bluetooth adapter present
5
1Overview of changes in indicator-bluetooth 0.0.56Overview of changes in indicator-bluetooth 0.0.5
27
3 * Add license file8 * Add license file
49
=== modified file 'src/indicator-bluetooth-service.vala'
--- src/indicator-bluetooth-service.vala 2013-02-06 03:16:55 +0000
+++ src/indicator-bluetooth-service.vala 2013-02-07 22:40:26 +0000
@@ -22,7 +22,6 @@
22 private bool updating_visible = false;22 private bool updating_visible = false;
23 private Dbusmenu.Menuitem devices_separator;23 private Dbusmenu.Menuitem devices_separator;
24 private List<BluetoothMenuItem> device_items;24 private List<BluetoothMenuItem> device_items;
25 private Dbusmenu.Menuitem settings_item;
26 private Dbusmenu.Menuitem menu;25 private Dbusmenu.Menuitem menu;
2726
28 public BluetoothIndicator () throws Error27 public BluetoothIndicator () throws Error
@@ -106,12 +105,21 @@
106 sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR);105 sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR);
107 menu.child_append (sep);106 menu.child_append (sep);
108107
109 settings_item = new Dbusmenu.Menuitem ();108 var item = new Dbusmenu.Menuitem ();
110 settings_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…"));109 item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Set Up New Device…"));
111 settings_item.item_activated.connect (() => { show_control_center ("bluetooth"); });110 item.item_activated.connect (() => { set_up_new_device (); });
112 menu.child_append (settings_item);111 menu.child_append (item);
112
113 item = new Dbusmenu.Menuitem ();
114 item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…"));
115 item.item_activated.connect (() => { show_control_center ("bluetooth"); });
116 menu.child_append (item);
113117
114 killswitch_state_changed_cb (killswitch.state);118 killswitch_state_changed_cb (killswitch.state);
119
120 client.adapter_model.row_inserted.connect (adapters_changed_cb);
121 client.adapter_model.row_deleted.connect (adapters_changed_cb);
122 adapters_changed_cb ();
115 }123 }
116124
117 private BluetoothMenuItem? find_menu_item (string address)125 private BluetoothMenuItem? find_menu_item (string address)
@@ -168,6 +176,26 @@
168 item.update (type, proxy, alias, icon, connected, services, uuids);176 item.update (type, proxy, alias, icon, connected, services, uuids);
169 }177 }
170178
179 private void adapters_changed_cb ()
180 {
181 bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0;
182 var builder = new VariantBuilder (VariantType.ARRAY);
183 builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible));
184 try
185 {
186 var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null);
187 bus.emit_signal (null,
188 "/com/canonical/indicator/bluetooth/service",
189 "org.freedesktop.DBus.Properties",
190 "PropertiesChanged",
191 properties);
192 }
193 catch (Error e)
194 {
195 warning ("Failed to emit signal: %s", e.message);
196 }
197 }
198
171 private void device_removed_cb (Gtk.TreePath path)199 private void device_removed_cb (Gtk.TreePath path)
172 {200 {
173 Gtk.TreeIter iter;201 Gtk.TreeIter iter;
@@ -334,6 +362,18 @@
334 }362 }
335}363}
336364
365private void set_up_new_device ()
366{
367 try
368 {
369 Process.spawn_command_line_async ("bluetooth-wizard");
370 }
371 catch (GLib.SpawnError e)
372 {
373 warning ("Failed to open bluetooth-wizard: %s", e.message);
374 }
375}
376
337private void show_control_center (string panel)377private void show_control_center (string panel)
338{378{
339 try379 try
@@ -377,6 +417,11 @@
377[DBus (name = "com.canonical.indicator.bluetooth.service")]417[DBus (name = "com.canonical.indicator.bluetooth.service")]
378private class BluetoothService : Object418private class BluetoothService : Object
379{419{
420 internal bool _visible = false;
421 public bool visible
422 {
423 get { return _visible; }
424 }
380 internal string _icon_name = "bluetooth-active";425 internal string _icon_name = "bluetooth-active";
381 public string icon_name426 public string icon_name
382 {427 {
383428
=== modified file 'src/indicator-bluetooth.vala'
--- src/indicator-bluetooth.vala 2013-02-06 03:16:55 +0000
+++ src/indicator-bluetooth.vala 2013-02-07 22:40:26 +0000
@@ -26,6 +26,9 @@
2626
27 var menu_client = menu.get_client ();27 var menu_client = menu.get_client ();
28 menu_client.add_type_handler_full ("x-canonical-switch", new_switch_cb);28 menu_client.add_type_handler_full ("x-canonical-switch", new_switch_cb);
29
30 /* Hide until ready */
31 set_visible (false);
29 }32 }
3033
31 private bool new_switch_cb (Dbusmenu.Menuitem newitem, Dbusmenu.Menuitem parent, Dbusmenu.Client client)34 private bool new_switch_cb (Dbusmenu.Menuitem newitem, Dbusmenu.Menuitem parent, Dbusmenu.Client client)
@@ -80,6 +83,7 @@
8083
81 private void server_properties_changed_cb ()84 private void server_properties_changed_cb ()
82 {85 {
86 set_visible (proxy.visible);
83 Indicator.image_helper_update (image, proxy.icon_name);87 Indicator.image_helper_update (image, proxy.icon_name);
84 accessible_description = proxy.accessible_description;88 accessible_description = proxy.accessible_description;
85 }89 }
@@ -122,6 +126,7 @@
122[DBus (name = "com.canonical.indicator.bluetooth.service")]126[DBus (name = "com.canonical.indicator.bluetooth.service")]
123public interface BluetoothService : DBusProxy127public interface BluetoothService : DBusProxy
124{128{
129 public abstract bool visible { owned get; }
125 public abstract string icon_name { owned get; }130 public abstract string icon_name { owned get; }
126 public abstract string accessible_description { owned get; }131 public abstract string accessible_description { owned get; }
127}132}

Subscribers

People subscribed via source and target branches