aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bluez.vala38
-rw-r--r--src/desktop.vala64
-rw-r--r--src/phone.vala8
-rw-r--r--src/profile.vala31
4 files changed, 101 insertions, 40 deletions
diff --git a/src/bluez.vala b/src/bluez.vala
index d84d869..42166fb 100644
--- a/src/bluez.vala
+++ b/src/bluez.vala
@@ -55,9 +55,10 @@ public class Bluez: KillswitchBluetooth
{
manager = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", "/");
- // get the current default adapter, and watch for future default adapters
+ // get the current default adapter & watch for future default adapters
adapter_path = manager.default_adapter ();
- manager.default_adapter_changed.connect ((object_path) => on_default_adapter_changed (object_path));
+ manager.default_adapter_changed.connect ((object_path)
+ => on_default_adapter_changed (object_path));
}
catch (Error e)
{
@@ -72,8 +73,12 @@ public class Bluez: KillswitchBluetooth
if (object_path != null) try
{
debug (@"using default adapter at $object_path");
- default_adapter = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", object_path);
- default_adapter.property_changed.connect(() => on_default_adapter_properties_changed());
+ default_adapter = Bus.get_proxy_sync (BusType.SYSTEM,
+ "org.bluez",
+ object_path);
+
+ default_adapter.property_changed.connect(()
+ => on_default_adapter_properties_changed());
default_adapter.device_removed.connect((adapter, path) => {
var id = path_to_id.lookup (path);
@@ -83,7 +88,9 @@ public class Bluez: KillswitchBluetooth
devices_changed ();
});
- default_adapter.device_created.connect((adapter, path) => add_device (path));
+ default_adapter.device_created.connect((adapter, path)
+ => add_device (path));
+
foreach (string device_path in default_adapter.list_devices())
add_device (device_path);
}
@@ -136,7 +143,7 @@ public class Bluez: KillswitchBluetooth
return uuid16;
}
- /* A device supports file transfer if OBEXObjectPush is in its uuid list */
+ // A device supports file transfer if OBEXObjectPush is in its uuid list
private bool device_supports_file_transfer (uint16[] uuids)
{
foreach (uint16 uuid16 in uuids)
@@ -146,7 +153,7 @@ public class Bluez: KillswitchBluetooth
return false;
}
- /* A device supports browsing if OBEXFileTransfer is in its uuid list */
+ // A device supports browsing if OBEXFileTransfer is in its uuid list
private bool device_supports_browsing (uint16[] uuids)
{
foreach (uint16 uuid16 in uuids)
@@ -205,7 +212,8 @@ public class Bluez: KillswitchBluetooth
}
// call "Connect" on the specified interface
- private void device_connect_on_interface (DBusProxy proxy, string interface_name)
+ private void device_connect_on_interface (DBusProxy proxy,
+ string interface_name)
{
var bus = proxy.get_connection ();
var object_path = proxy.get_object_path ();
@@ -219,7 +227,7 @@ public class Bluez: KillswitchBluetooth
}
catch (Error e)
{
- debug (@"Unable to call $interface_name.Connect() on $object_path: $(e.message)");
+ debug (@"$object_path $interface_name.Connect() failed: $(e.message)");
}
}
@@ -255,7 +263,9 @@ public class Bluez: KillswitchBluetooth
{
try
{
- org.bluez.Device device = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", object_path);
+ org.bluez.Device device = Bus.get_proxy_sync (BusType.SYSTEM,
+ "org.bluez",
+ object_path);
path_to_proxy.insert (object_path, device);
device.property_changed.connect(() => update_device (device));
update_device (device);
@@ -358,10 +368,12 @@ public class Bluez: KillswitchBluetooth
public override void set_device_connected (uint id, bool connected)
{
var device = id_to_device.lookup (id);
- var object_path = id_to_path.lookup (id);
- var proxy = (object_path != null) ? path_to_proxy.lookup (object_path) : null;
+ var path = id_to_path.lookup (id);
+ var proxy = (path != null) ? path_to_proxy.lookup (path) : null;
- if ((proxy != null) && (device != null) && (device.is_connected != connected))
+ if ((proxy != null)
+ && (device != null)
+ && (device.is_connected != connected))
{
if (connected)
device_connect (proxy);
diff --git a/src/desktop.vala b/src/desktop.vala
index 24d7f9f..8f4a9c8 100644
--- a/src/desktop.vala
+++ b/src/desktop.vala
@@ -128,30 +128,35 @@ class Desktop: Profile
submenu.append_item (create_device_connection_menuitem (device));
if (device.supports_browsing)
- submenu.append (_("Browse files…"), @"indicator.desktop-browse-files::$(device.address)");
+ submenu.append (_("Browse files…"),
+ @"indicator.desktop-browse-files::$(device.address)");
if (device.supports_file_transfer)
- submenu.append (_("Send files…"), @"indicator.desktop-send-file::$(device.address)");
+ submenu.append (_("Send files…"),
+ @"indicator.desktop-send-file::$(device.address)");
switch (device.device_type)
{
case Device.Type.KEYBOARD:
- submenu.append (_("Keyboard Settings…"), "indicator.desktop-show-settings::keyboard");
+ submenu.append (_("Keyboard Settings…"),
+ "indicator.desktop-show-settings::keyboard");
break;
case Device.Type.MOUSE:
case Device.Type.TABLET:
- submenu.append (_("Mouse and Touchpad Settings…"), "indicator.desktop-show-settings::mouse");
+ submenu.append (_("Mouse and Touchpad Settings…"),
+ "indicator.desktop-show-settings::mouse");
break;
case Device.Type.HEADSET:
case Device.Type.HEADPHONES:
case Device.Type.OTHER_AUDIO:
- submenu.append (_("Sound Settings…"), "indicator.desktop-show-settings::sound");
+ submenu.append (_("Sound Settings…"),
+ "indicator.desktop-show-settings::sound");
break;
}
- /* only show the device if it's got actions that we can perform on it */
+ // only show the device if it's got actions that we can perform on it
if (submenu.get_n_items () > 0)
{
item = new MenuItem (device.name, null);
@@ -171,7 +176,8 @@ class Desktop: Profile
section = new Menu ();
section.append_item (create_enabled_menuitem ());
item = new MenuItem ("Visible", "indicator.desktop-discoverable");
- item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch");
+ item.set_attribute ("x-canonical-type", "s",
+ "com.canonical.indicator.switch");
section.append_item (item);
menu.append_section (null, section);
@@ -182,8 +188,10 @@ class Desktop: Profile
// settings section
section = new Menu ();
- section.append (_("Set Up New Device…"), "indicator.desktop-wizard");
- section.append (_("Bluetooth Settings…"), "indicator.desktop-show-settings::bluetooth");
+ section.append (_("Set Up New Device…"),
+ "indicator.desktop-wizard");
+ section.append (_("Bluetooth Settings…"),
+ "indicator.desktop-show-settings::bluetooth");
menu.append_section (null, section);
}
@@ -198,19 +206,32 @@ class Desktop: Profile
Action create_discoverable_action (Bluetooth bluetooth)
{
- var action = new SimpleAction.stateful ("desktop-discoverable", null, bluetooth.discoverable);
+ var action = new SimpleAction.stateful ("desktop-discoverable",
+ null,
+ bluetooth.discoverable);
+
+ action.activate.connect (()
+ => action.set_state (!action.get_state().get_boolean()));
+
+ action.notify["state"].connect (()
+ => bluetooth.try_set_discoverable (action.get_state().get_boolean()));
+
+ bluetooth.notify["discoverable"].connect (()
+ => action.set_state (bluetooth.discoverable));
+
action.set_enabled (bluetooth.powered);
- action.activate.connect (() => action.set_state (!action.get_state().get_boolean()));
- action.notify["state"].connect (() => bluetooth.try_set_discoverable (action.get_state().get_boolean()));
- bluetooth.notify["discoverable"].connect (() => action.set_state (bluetooth.discoverable));
- bluetooth.notify["powered"].connect (() => action.set_enabled (bluetooth.powered));
+ bluetooth.notify["powered"].connect (()
+ => action.set_enabled (bluetooth.powered));
+
return action;
}
Action create_wizard_action ()
{
var action = new SimpleAction ("desktop-wizard", null);
- action.activate.connect (() => spawn_command_line_async ("bluetooth-wizard"));
+
+ action.activate.connect (()
+ => spawn_command_line_async ("bluetooth-wizard"));
return action;
}
@@ -220,7 +241,8 @@ class Desktop: Profile
action.activate.connect ((action, address) => {
var uri = @"obex://[$(address.get_string())]/";
var file = File.new_for_uri (uri);
- file.mount_enclosing_volume.begin (MountMountFlags.NONE, null, null, (obj, res) => {
+ file.mount_enclosing_volume.begin (MountMountFlags.NONE,
+ null, null, (obj, res) => {
try {
AppInfo.launch_default_for_uri (uri, null);
} catch (Error e) {
@@ -234,16 +256,22 @@ class Desktop: Profile
Action create_send_file_action ()
{
var action = new SimpleAction ("desktop-send-file", VariantType.STRING);
+
action.activate.connect ((action, address) => {
- spawn_command_line_async ("bluetooth-sendto --device=$(address.get_string())");
+ var cmd = @"bluetooth-sendto --device=$(address.get_string())";
+ spawn_command_line_async (cmd);
});
+
return action;
}
Action create_show_settings_action ()
{
var action = new SimpleAction ("desktop-show-settings", VariantType.STRING);
- action.activate.connect ((action, panel) => show_settings (panel.get_string()));
+
+ action.activate.connect ((action, panel)
+ => show_settings (panel.get_string()));
+
return action;
}
}
diff --git a/src/phone.vala b/src/phone.vala
index 05e6b9d..8adc111 100644
--- a/src/phone.vala
+++ b/src/phone.vala
@@ -39,7 +39,8 @@ class Phone: Profile
var section = new Menu ();
section.append_item (create_enabled_menuitem ());
- section.append (_("Bluetooth settings…"), "indicator.phone-show-settings::bluetooth");
+ section.append (_("Bluetooth settings…"),
+ "indicator.phone-show-settings::bluetooth");
menu.append_section (null, section);
// know when to show the indicator & when to hide it
@@ -66,7 +67,10 @@ class Phone: Profile
Action create_settings_action ()
{
var action = new SimpleAction ("phone-show-settings", VariantType.STRING);
- action.activate.connect ((action, panel) => show_settings (panel.get_string()));
+
+ action.activate.connect ((action, panel)
+ => show_settings (panel.get_string()));
+
return action;
}
}
diff --git a/src/profile.vala b/src/profile.vala
index 91a0f8e..03c7b8b 100644
--- a/src/profile.vala
+++ b/src/profile.vala
@@ -69,14 +69,20 @@ class Profile: Object
protected MenuItem create_enabled_menuitem ()
{
MenuItem item = new MenuItem ("Bluetooth", "indicator.bluetooth-enabled");
- item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch");
+
+ item.set_attribute ("x-canonical-type", "s",
+ "com.canonical.indicator.switch");
+
return item;
}
private MenuItem create_root_menuitem ()
{
var item = new MenuItem (null, @"indicator.root-$profile_name");
- item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
+
+ item.set_attribute ("x-canonical-type", "s",
+ "com.canonical.indicator.root");
+
return item;
}
@@ -86,10 +92,19 @@ class Profile: Object
protected Action create_enabled_action (Bluetooth bluetooth)
{
- var action = new SimpleAction.stateful ("bluetooth-enabled", null, !bluetooth.blocked);
- action.activate.connect (() => action.set_state (!action.get_state().get_boolean()));
- action.notify["state"].connect (() => bluetooth.try_set_blocked (!action.get_state().get_boolean()));
- bluetooth.notify["blocked"].connect (() => action.set_state (!bluetooth.blocked));
+ var action = new SimpleAction.stateful ("bluetooth-enabled",
+ null,
+ !bluetooth.blocked);
+
+ action.activate.connect (()
+ => action.set_state (!action.get_state().get_boolean()));
+
+ action.notify["state"].connect (()
+ => bluetooth.try_set_blocked (!action.get_state().get_boolean()));
+
+ bluetooth.notify["blocked"].connect (()
+ => action.set_state (!bluetooth.blocked));
+
return action;
}
@@ -99,7 +114,9 @@ class Profile: Object
{
if (root_action == null)
{
- root_action = new SimpleAction.stateful (@"root-$profile", null, action_state_for_root());
+ root_action = new SimpleAction.stateful (@"root-$profile",
+ null,
+ action_state_for_root());
notify["visible"].connect (() => update_root_action_state());
}