Merge lp:~robert-ancell/indicator-bluetooth/dont-hide-on-rfkill into lp:indicator-bluetooth/14.04
- dont-hide-on-rfkill
- Merge into trunk.14.04
Proposed by
Sir Charlemagne
Status: | Work in progress |
---|---|
Proposed branch: | lp:~robert-ancell/indicator-bluetooth/dont-hide-on-rfkill |
Merge into: | lp:indicator-bluetooth/14.04 |
Diff against target: |
427 lines (+411/-0) (has conflicts) 1 file modified
src/service.vala (+411/-0) Text conflict in src/service.vala |
To merge this branch: | bzr merge lp:~robert-ancell/indicator-bluetooth/dont-hide-on-rfkill |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Needs Fixing | ||
Review via email: mp+197346@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
- 51. By Robert Ancell
-
Show the bluetooth indicator if bluetooth is disabled - assume there are devices present
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/service.vala' | |||
2 | --- src/service.vala 2013-08-09 23:18:59 +0000 | |||
3 | +++ src/service.vala 2013-12-02 11:30:31 +0000 | |||
4 | @@ -18,6 +18,7 @@ | |||
5 | 18 | * Robert Ancell <robert.ancell@canonical.com> | 18 | * Robert Ancell <robert.ancell@canonical.com> |
6 | 19 | */ | 19 | */ |
7 | 20 | 20 | ||
8 | 21 | <<<<<<< TREE | ||
9 | 21 | /** | 22 | /** |
10 | 22 | * Boilerplate class to own the name on the bus, | 23 | * Boilerplate class to own the name on the bus, |
11 | 23 | * to create the profiles, and to export them on the bus. | 24 | * to create the profiles, and to export them on the bus. |
12 | @@ -61,6 +62,416 @@ | |||
13 | 61 | if (loop != null) | 62 | if (loop != null) |
14 | 62 | { | 63 | { |
15 | 63 | warning ("service is already running"); | 64 | warning ("service is already running"); |
16 | 65 | ======= | ||
17 | 66 | public class BluetoothIndicator | ||
18 | 67 | { | ||
19 | 68 | private Settings settings; | ||
20 | 69 | private DBusConnection bus; | ||
21 | 70 | private Indicator.Service indicator_service; | ||
22 | 71 | private Dbusmenu.Server menu_server; | ||
23 | 72 | private BluetoothService bluetooth_service; | ||
24 | 73 | private GnomeBluetooth.Client client; | ||
25 | 74 | private GnomeBluetooth.Killswitch killswitch; | ||
26 | 75 | private bool updating_killswitch = false; | ||
27 | 76 | private Dbusmenu.Menuitem enable_item; | ||
28 | 77 | private Dbusmenu.Menuitem visible_item; | ||
29 | 78 | private bool updating_visible = false; | ||
30 | 79 | private Dbusmenu.Menuitem devices_separator; | ||
31 | 80 | private List<BluetoothMenuItem> device_items; | ||
32 | 81 | private Dbusmenu.Menuitem menu; | ||
33 | 82 | |||
34 | 83 | public BluetoothIndicator () throws Error | ||
35 | 84 | { | ||
36 | 85 | settings = new Settings ("com.canonical.indicator.bluetooth"); | ||
37 | 86 | settings.changed.connect ((key) => | ||
38 | 87 | { | ||
39 | 88 | if (key == "visible") | ||
40 | 89 | update_visible (); | ||
41 | 90 | }); | ||
42 | 91 | |||
43 | 92 | bus = Bus.get_sync (BusType.SESSION); | ||
44 | 93 | |||
45 | 94 | indicator_service = new Indicator.Service ("com.canonical.indicator.bluetooth"); | ||
46 | 95 | menu_server = new Dbusmenu.Server ("/com/canonical/indicator/bluetooth/menu"); | ||
47 | 96 | |||
48 | 97 | bluetooth_service = new BluetoothService (); | ||
49 | 98 | bus.register_object ("/com/canonical/indicator/bluetooth/service", bluetooth_service); | ||
50 | 99 | |||
51 | 100 | killswitch = new GnomeBluetooth.Killswitch (); | ||
52 | 101 | killswitch.state_changed.connect (killswitch_state_changed_cb); | ||
53 | 102 | |||
54 | 103 | client = new GnomeBluetooth.Client (); | ||
55 | 104 | |||
56 | 105 | menu = new Dbusmenu.Menuitem (); | ||
57 | 106 | menu_server.set_root (menu); | ||
58 | 107 | |||
59 | 108 | enable_item = new Dbusmenu.Menuitem (); | ||
60 | 109 | enable_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth")); | ||
61 | 110 | enable_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); | ||
62 | 111 | enable_item.item_activated.connect (() => | ||
63 | 112 | { | ||
64 | 113 | if (updating_killswitch) | ||
65 | 114 | return; | ||
66 | 115 | if (killswitch.state == GnomeBluetooth.KillswitchState.UNBLOCKED) | ||
67 | 116 | killswitch.state = GnomeBluetooth.KillswitchState.SOFT_BLOCKED; | ||
68 | 117 | else | ||
69 | 118 | killswitch.state = GnomeBluetooth.KillswitchState.UNBLOCKED; | ||
70 | 119 | }); | ||
71 | 120 | menu.child_append (enable_item); | ||
72 | 121 | |||
73 | 122 | visible_item = new Dbusmenu.Menuitem (); | ||
74 | 123 | visible_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Visible")); | ||
75 | 124 | visible_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); | ||
76 | 125 | bool discoverable; | ||
77 | 126 | client.get ("default-adapter-discoverable", out discoverable); | ||
78 | 127 | visible_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, discoverable ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
79 | 128 | client.notify["default-adapter-discoverable"].connect (() => | ||
80 | 129 | { | ||
81 | 130 | updating_visible = true; | ||
82 | 131 | bool is_discoverable; | ||
83 | 132 | client.get ("default-adapter-discoverable", out is_discoverable); | ||
84 | 133 | visible_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, is_discoverable ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
85 | 134 | updating_visible = false; | ||
86 | 135 | }); | ||
87 | 136 | visible_item.item_activated.connect (() => | ||
88 | 137 | { | ||
89 | 138 | if (updating_visible) | ||
90 | 139 | return; | ||
91 | 140 | client.set ("default-adapter-discoverable", visible_item.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) != Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); | ||
92 | 141 | }); | ||
93 | 142 | menu.child_append (visible_item); | ||
94 | 143 | |||
95 | 144 | devices_separator = new Dbusmenu.Menuitem (); | ||
96 | 145 | devices_separator.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); | ||
97 | 146 | menu.child_append (devices_separator); | ||
98 | 147 | |||
99 | 148 | device_items = new List<BluetoothMenuItem> (); | ||
100 | 149 | |||
101 | 150 | client.model.row_inserted.connect (device_changed_cb); | ||
102 | 151 | client.model.row_changed.connect (device_changed_cb); | ||
103 | 152 | client.model.row_deleted.connect (device_removed_cb); | ||
104 | 153 | Gtk.TreeIter iter; | ||
105 | 154 | var have_iter = client.model.get_iter_first (out iter); | ||
106 | 155 | while (have_iter) | ||
107 | 156 | { | ||
108 | 157 | Gtk.TreeIter child_iter; | ||
109 | 158 | var have_child_iter = client.model.iter_children (out child_iter, iter); | ||
110 | 159 | while (have_child_iter) | ||
111 | 160 | { | ||
112 | 161 | device_changed_cb (null, child_iter); | ||
113 | 162 | have_child_iter = client.model.iter_next (ref child_iter); | ||
114 | 163 | } | ||
115 | 164 | have_iter = client.model.iter_next (ref iter); | ||
116 | 165 | } | ||
117 | 166 | |||
118 | 167 | var sep = new Dbusmenu.Menuitem (); | ||
119 | 168 | sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); | ||
120 | 169 | menu.child_append (sep); | ||
121 | 170 | |||
122 | 171 | var item = new Dbusmenu.Menuitem (); | ||
123 | 172 | item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Set Up New Device…")); | ||
124 | 173 | item.item_activated.connect (() => { set_up_new_device (); }); | ||
125 | 174 | menu.child_append (item); | ||
126 | 175 | |||
127 | 176 | item = new Dbusmenu.Menuitem (); | ||
128 | 177 | item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…")); | ||
129 | 178 | item.item_activated.connect (() => { show_control_center ("bluetooth"); }); | ||
130 | 179 | menu.child_append (item); | ||
131 | 180 | |||
132 | 181 | killswitch_state_changed_cb (killswitch.state); | ||
133 | 182 | |||
134 | 183 | client.adapter_model.row_inserted.connect (update_visible); | ||
135 | 184 | client.adapter_model.row_deleted.connect (update_visible); | ||
136 | 185 | update_visible (); | ||
137 | 186 | } | ||
138 | 187 | |||
139 | 188 | private BluetoothMenuItem? find_menu_item (string address) | ||
140 | 189 | { | ||
141 | 190 | foreach (var item in device_items) | ||
142 | 191 | if (item.address == address) | ||
143 | 192 | return item; | ||
144 | 193 | |||
145 | 194 | return null; | ||
146 | 195 | } | ||
147 | 196 | |||
148 | 197 | private void device_changed_cb (Gtk.TreePath? path, Gtk.TreeIter iter) | ||
149 | 198 | { | ||
150 | 199 | /* Ignore adapters */ | ||
151 | 200 | Gtk.TreeIter parent_iter; | ||
152 | 201 | if (!client.model.iter_parent (out parent_iter, iter)) | ||
153 | 202 | return; | ||
154 | 203 | |||
155 | 204 | DBusProxy proxy; | ||
156 | 205 | string address; | ||
157 | 206 | string alias; | ||
158 | 207 | GnomeBluetooth.Type type; | ||
159 | 208 | string icon; | ||
160 | 209 | bool connected; | ||
161 | 210 | HashTable services; | ||
162 | 211 | string[] uuids; | ||
163 | 212 | client.model.get (iter, | ||
164 | 213 | GnomeBluetooth.Column.PROXY, out proxy, | ||
165 | 214 | GnomeBluetooth.Column.ADDRESS, out address, | ||
166 | 215 | GnomeBluetooth.Column.ALIAS, out alias, | ||
167 | 216 | GnomeBluetooth.Column.TYPE, out type, | ||
168 | 217 | GnomeBluetooth.Column.ICON, out icon, | ||
169 | 218 | GnomeBluetooth.Column.CONNECTED, out connected, | ||
170 | 219 | GnomeBluetooth.Column.SERVICES, out services, | ||
171 | 220 | GnomeBluetooth.Column.UUIDS, out uuids); | ||
172 | 221 | |||
173 | 222 | /* Skip if haven't actually got any information yet */ | ||
174 | 223 | if (proxy == null) | ||
175 | 224 | return; | ||
176 | 225 | |||
177 | 226 | /* Find or create menu item */ | ||
178 | 227 | var item = find_menu_item (address); | ||
179 | 228 | if (item == null) | ||
180 | 229 | { | ||
181 | 230 | item = new BluetoothMenuItem (client, address); | ||
182 | 231 | item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, killswitch.state == GnomeBluetooth.KillswitchState.UNBLOCKED); | ||
183 | 232 | var last_item = devices_separator as Dbusmenu.Menuitem; | ||
184 | 233 | if (device_items != null) | ||
185 | 234 | last_item = device_items.last ().data; | ||
186 | 235 | device_items.append (item); | ||
187 | 236 | menu.child_add_position (item, last_item.get_position (menu) + 1); | ||
188 | 237 | } | ||
189 | 238 | |||
190 | 239 | item.update (type, proxy, alias, icon, connected, services, uuids); | ||
191 | 240 | } | ||
192 | 241 | |||
193 | 242 | private void update_visible () | ||
194 | 243 | { | ||
195 | 244 | /* Show if: | ||
196 | 245 | * - There are bluetooth devices | ||
197 | 246 | * - Bluetooth is disabled (for some hardware this means there are no devices reported but we should assume there are if it is disabled) | ||
198 | 247 | * - It has been enabled in settings | ||
199 | 248 | */ | ||
200 | 249 | bluetooth_service._visible = (client.adapter_model.iter_n_children (null) > 0 || killswitch.state != GnomeBluetooth.KillswitchState.UNBLOCKED) && settings.get_boolean ("visible"); | ||
201 | 250 | var builder = new VariantBuilder (VariantType.ARRAY); | ||
202 | 251 | builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible)); | ||
203 | 252 | try | ||
204 | 253 | { | ||
205 | 254 | var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); | ||
206 | 255 | bus.emit_signal (null, | ||
207 | 256 | "/com/canonical/indicator/bluetooth/service", | ||
208 | 257 | "org.freedesktop.DBus.Properties", | ||
209 | 258 | "PropertiesChanged", | ||
210 | 259 | properties); | ||
211 | 260 | } | ||
212 | 261 | catch (Error e) | ||
213 | 262 | { | ||
214 | 263 | warning ("Failed to emit signal: %s", e.message); | ||
215 | 264 | } | ||
216 | 265 | } | ||
217 | 266 | |||
218 | 267 | private void device_removed_cb (Gtk.TreePath path) | ||
219 | 268 | { | ||
220 | 269 | Gtk.TreeIter iter; | ||
221 | 270 | if (!client.model.get_iter (out iter, path)) | ||
222 | 271 | return; | ||
223 | 272 | |||
224 | 273 | string address; | ||
225 | 274 | client.model.get (iter, GnomeBluetooth.Column.ADDRESS, out address); | ||
226 | 275 | |||
227 | 276 | var item = find_menu_item (address); | ||
228 | 277 | if (item == null) | ||
229 | 278 | return; | ||
230 | 279 | |||
231 | 280 | device_items.remove (item); | ||
232 | 281 | menu.child_delete (item); | ||
233 | 282 | } | ||
234 | 283 | |||
235 | 284 | private void killswitch_state_changed_cb (GnomeBluetooth.KillswitchState state) | ||
236 | 285 | { | ||
237 | 286 | updating_killswitch = true; | ||
238 | 287 | |||
239 | 288 | var enabled = state == GnomeBluetooth.KillswitchState.UNBLOCKED; | ||
240 | 289 | |||
241 | 290 | bluetooth_service._icon_name = enabled ? "bluetooth-active" : "bluetooth-disabled"; | ||
242 | 291 | bluetooth_service._accessible_description = enabled ? _("Bluetooth: On") : _("Bluetooth: Off"); | ||
243 | 292 | |||
244 | 293 | var builder = new VariantBuilder (VariantType.ARRAY); | ||
245 | 294 | builder.add ("{sv}", "IconName", new Variant.string (bluetooth_service._icon_name)); | ||
246 | 295 | builder.add ("{sv}", "AccessibleDescription", new Variant.string (bluetooth_service._accessible_description)); | ||
247 | 296 | try | ||
248 | 297 | { | ||
249 | 298 | var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); | ||
250 | 299 | bus.emit_signal (null, | ||
251 | 300 | "/com/canonical/indicator/bluetooth/service", | ||
252 | 301 | "org.freedesktop.DBus.Properties", | ||
253 | 302 | "PropertiesChanged", | ||
254 | 303 | properties); | ||
255 | 304 | } | ||
256 | 305 | catch (Error e) | ||
257 | 306 | { | ||
258 | 307 | warning ("Failed to emit signal: %s", e.message); | ||
259 | 308 | } | ||
260 | 309 | |||
261 | 310 | enable_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, enabled ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
262 | 311 | |||
263 | 312 | /* Disable devices when locked */ | ||
264 | 313 | visible_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled); | ||
265 | 314 | devices_separator.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled); | ||
266 | 315 | foreach (var item in device_items) | ||
267 | 316 | item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled && item.get_children () != null); | ||
268 | 317 | |||
269 | 318 | updating_killswitch = false; | ||
270 | 319 | } | ||
271 | 320 | } | ||
272 | 321 | |||
273 | 322 | private class BluetoothMenuItem : Dbusmenu.Menuitem | ||
274 | 323 | { | ||
275 | 324 | private GnomeBluetooth.Client client; | ||
276 | 325 | public string address; | ||
277 | 326 | private Dbusmenu.Menuitem? connect_item = null; | ||
278 | 327 | private bool make_submenu = false; | ||
279 | 328 | |||
280 | 329 | public BluetoothMenuItem (GnomeBluetooth.Client client, string address) | ||
281 | 330 | { | ||
282 | 331 | this.client = client; | ||
283 | 332 | this.address = address; | ||
284 | 333 | } | ||
285 | 334 | |||
286 | 335 | public void update (GnomeBluetooth.Type type, DBusProxy proxy, string alias, string icon, bool connected, HashTable? services, string[] uuids) | ||
287 | 336 | { | ||
288 | 337 | property_set (Dbusmenu.MENUITEM_PROP_LABEL, alias); | ||
289 | 338 | property_set (Dbusmenu.MENUITEM_PROP_ICON_NAME, icon); | ||
290 | 339 | if (connect_item != null) | ||
291 | 340 | connect_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, connected ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
292 | 341 | |||
293 | 342 | /* FIXME: Not sure if the GUI elements below can change over time */ | ||
294 | 343 | if (make_submenu) | ||
295 | 344 | return; | ||
296 | 345 | make_submenu = true; | ||
297 | 346 | |||
298 | 347 | if (services != null) | ||
299 | 348 | { | ||
300 | 349 | connect_item = new Dbusmenu.Menuitem (); | ||
301 | 350 | connect_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Connection")); | ||
302 | 351 | connect_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); | ||
303 | 352 | connect_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, connected ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
304 | 353 | connect_item.item_activated.connect (() => { connect_service (proxy.get_object_path (), connect_item.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) != Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); }); | ||
305 | 354 | child_append (connect_item); | ||
306 | 355 | } | ||
307 | 356 | |||
308 | 357 | var can_send = false; | ||
309 | 358 | var can_browse = false; | ||
310 | 359 | if (uuids != null) | ||
311 | 360 | { | ||
312 | 361 | for (var i = 0; uuids[i] != null; i++) | ||
313 | 362 | { | ||
314 | 363 | if (uuids[i] == "OBEXObjectPush") | ||
315 | 364 | can_send = true; | ||
316 | 365 | if (uuids[i] == "OBEXFileTransfer") | ||
317 | 366 | can_browse = true; | ||
318 | 367 | } | ||
319 | 368 | } | ||
320 | 369 | |||
321 | 370 | if (can_send) | ||
322 | 371 | { | ||
323 | 372 | var send_item = new Dbusmenu.Menuitem (); | ||
324 | 373 | send_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Send files…")); | ||
325 | 374 | send_item.item_activated.connect (() => { GnomeBluetooth.send_to_address (address, alias); }); | ||
326 | 375 | child_append (send_item); | ||
327 | 376 | } | ||
328 | 377 | |||
329 | 378 | if (can_browse) | ||
330 | 379 | { | ||
331 | 380 | var browse_item = new Dbusmenu.Menuitem (); | ||
332 | 381 | browse_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Browse files…")); | ||
333 | 382 | browse_item.item_activated.connect (() => { GnomeBluetooth.browse_address (null, address, Gdk.CURRENT_TIME, null); }); | ||
334 | 383 | child_append (browse_item); | ||
335 | 384 | } | ||
336 | 385 | |||
337 | 386 | switch (type) | ||
338 | 387 | { | ||
339 | 388 | case GnomeBluetooth.Type.KEYBOARD: | ||
340 | 389 | var keyboard_item = new Dbusmenu.Menuitem (); | ||
341 | 390 | keyboard_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Keyboard Settings…")); | ||
342 | 391 | keyboard_item.item_activated.connect (() => { show_control_center ("keyboard"); }); | ||
343 | 392 | child_append (keyboard_item); | ||
344 | 393 | break; | ||
345 | 394 | |||
346 | 395 | case GnomeBluetooth.Type.MOUSE: | ||
347 | 396 | case GnomeBluetooth.Type.TABLET: | ||
348 | 397 | var mouse_item = new Dbusmenu.Menuitem (); | ||
349 | 398 | mouse_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Mouse and Touchpad Settings…")); | ||
350 | 399 | mouse_item.item_activated.connect (() => { show_control_center ("mouse"); }); | ||
351 | 400 | child_append (mouse_item); | ||
352 | 401 | break; | ||
353 | 402 | |||
354 | 403 | case GnomeBluetooth.Type.HEADSET: | ||
355 | 404 | case GnomeBluetooth.Type.HEADPHONES: | ||
356 | 405 | case GnomeBluetooth.Type.OTHER_AUDIO: | ||
357 | 406 | var sound_item = new Dbusmenu.Menuitem (); | ||
358 | 407 | sound_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Sound Settings…")); | ||
359 | 408 | sound_item.item_activated.connect (() => { show_control_center ("sound"); }); | ||
360 | 409 | child_append (sound_item); | ||
361 | 410 | break; | ||
362 | 411 | } | ||
363 | 412 | |||
364 | 413 | property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, get_children () != null); | ||
365 | 414 | } | ||
366 | 415 | |||
367 | 416 | private void connect_service (string device, bool connect) | ||
368 | 417 | { | ||
369 | 418 | client.connect_service.begin (device, connect, null, (object, result) => | ||
370 | 419 | { | ||
371 | 420 | var connected = false; | ||
372 | 421 | try | ||
373 | 422 | { | ||
374 | 423 | connected = client.connect_service.end (result); | ||
375 | 424 | } | ||
376 | 425 | catch (Error e) | ||
377 | 426 | { | ||
378 | 427 | warning ("Failed to connect service: %s", e.message); | ||
379 | 428 | } | ||
380 | 429 | }); | ||
381 | 430 | } | ||
382 | 431 | } | ||
383 | 432 | |||
384 | 433 | private void set_up_new_device () | ||
385 | 434 | { | ||
386 | 435 | try | ||
387 | 436 | { | ||
388 | 437 | Process.spawn_command_line_async ("bluetooth-wizard"); | ||
389 | 438 | } | ||
390 | 439 | catch (GLib.SpawnError e) | ||
391 | 440 | { | ||
392 | 441 | warning ("Failed to open bluetooth-wizard: %s", e.message); | ||
393 | 442 | } | ||
394 | 443 | } | ||
395 | 444 | |||
396 | 445 | private void show_control_center (string panel) | ||
397 | 446 | { | ||
398 | 447 | try | ||
399 | 448 | { | ||
400 | 449 | Process.spawn_command_line_async ("gnome-control-center %s".printf (panel)); | ||
401 | 450 | } | ||
402 | 451 | catch (GLib.SpawnError e) | ||
403 | 452 | { | ||
404 | 453 | warning ("Failed to open control center: %s", e.message); | ||
405 | 454 | } | ||
406 | 455 | } | ||
407 | 456 | |||
408 | 457 | public static int main (string[] args) | ||
409 | 458 | { | ||
410 | 459 | Intl.setlocale (LocaleCategory.ALL, ""); | ||
411 | 460 | Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); | ||
412 | 461 | Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); | ||
413 | 462 | Intl.textdomain (GETTEXT_PACKAGE); | ||
414 | 463 | |||
415 | 464 | var loop = new MainLoop (); | ||
416 | 465 | |||
417 | 466 | BluetoothIndicator indicator; | ||
418 | 467 | try | ||
419 | 468 | { | ||
420 | 469 | indicator = new BluetoothIndicator (); | ||
421 | 470 | } | ||
422 | 471 | catch (Error e) | ||
423 | 472 | { | ||
424 | 473 | warning ("Failed to start bluetooth indicator service: %s", e.message); | ||
425 | 474 | >>>>>>> MERGE-SOURCE | ||
426 | 64 | return Posix.EXIT_FAILURE; | 475 | return Posix.EXIT_FAILURE; |
427 | 65 | } | 476 | } |
428 | 66 | 477 |
This MR has conflicts with trunk and appears to reintroduce a Gnome dependency, even on the phone...?