aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-08-06 15:33:26 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-08-06 15:33:26 -0500
commitb82c9a9de54e3659386a178926dc8ce99917c6f6 (patch)
tree3811f467837cd2cc49e0c2ef3872fdc156e24a4c /src
parentdf2bb3084af551770e9cd3f3e9b4cf59c439041b (diff)
downloadayatana-indicator-bluetooth-b82c9a9de54e3659386a178926dc8ce99917c6f6.tar.gz
ayatana-indicator-bluetooth-b82c9a9de54e3659386a178926dc8ce99917c6f6.tar.bz2
ayatana-indicator-bluetooth-b82c9a9de54e3659386a178926dc8ce99917c6f6.zip
copyediting: whitespace, type inference
Diffstat (limited to 'src')
-rw-r--r--src/bluez.vala40
-rw-r--r--src/desktop.vala27
-rw-r--r--src/killswitch.vala2
-rw-r--r--src/profile.vala6
-rw-r--r--src/service.vala2
5 files changed, 41 insertions, 36 deletions
diff --git a/src/bluez.vala b/src/bluez.vala
index 42166fb..9baacd5 100644
--- a/src/bluez.vala
+++ b/src/bluez.vala
@@ -77,10 +77,10 @@ public class Bluez: KillswitchBluetooth
"org.bluez",
object_path);
- default_adapter.property_changed.connect(()
- => on_default_adapter_properties_changed());
+ default_adapter.property_changed.connect (()
+ => on_default_adapter_properties_changed ());
- default_adapter.device_removed.connect((adapter, path) => {
+ default_adapter.device_removed.connect ((adapter, path) => {
var id = path_to_id.lookup (path);
path_to_id.remove (path);
id_to_path.remove (id);
@@ -88,10 +88,10 @@ public class Bluez: KillswitchBluetooth
devices_changed ();
});
- default_adapter.device_created.connect((adapter, path)
+ default_adapter.device_created.connect ((adapter, path)
=> add_device (path));
- foreach (string device_path in default_adapter.list_devices())
+ foreach (var device_path in default_adapter.list_devices ())
add_device (device_path);
}
catch (Error e)
@@ -109,12 +109,12 @@ public class Bluez: KillswitchBluetooth
if (default_adapter != null) try
{
- var properties = default_adapter.get_properties();
+ var properties = default_adapter.get_properties ();
- var v = properties.lookup("Discoverable");
+ var v = properties.lookup ("Discoverable");
is_discoverable = (v != null) && v.get_boolean ();
- v = properties.lookup("Powered");
+ v = properties.lookup ("Powered");
is_powered = (v != null) && v.get_boolean ();
}
catch (Error e)
@@ -146,7 +146,7 @@ public class Bluez: KillswitchBluetooth
// 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)
+ foreach (var uuid16 in uuids)
if (uuid16 == 0x1105) // OBEXObjectPush
return true;
@@ -156,7 +156,7 @@ public class Bluez: KillswitchBluetooth
// A device supports browsing if OBEXFileTransfer is in its uuid list
private bool device_supports_browsing (uint16[] uuids)
{
- foreach (uint16 uuid16 in uuids)
+ foreach (var uuid16 in uuids)
if (uuid16 == 0x1106) // OBEXFileTransfer
return true;
@@ -182,11 +182,11 @@ public class Bluez: KillswitchBluetooth
if ((intro != null) && (intro.n_children() > 0))
{
- string xml = intro.get_child_value(0).get_string();
+ var xml = intro.get_child_value(0).get_string();
var info = new DBusNodeInfo.for_xml (xml);
if (info != null)
{
- foreach (DBusInterfaceInfo i in info.interfaces)
+ foreach (var i in info.interfaces)
{
if ((i.name == "org.bluez.AudioSink") ||
(i.name == "org.bluez.Headset") ||
@@ -317,32 +317,28 @@ public class Bluez: KillswitchBluetooth
v = properties.lookup ("Alias");
if (v == null)
v = properties.lookup ("Name");
- string name = v == null ? _("Unknown") : v.get_string ();
+ var name = v == null ? _("Unknown") : v.get_string ();
// look up the device's bus address
v = properties.lookup ("Address");
- string address = v.get_string ();
+ var address = v.get_string ();
// look up the device's bus address
- Icon icon;
v = properties.lookup ("Icon");
- if (v == null)
- icon = new ThemedIcon ("unknown");
- else
- icon = new ThemedIcon (v.get_string());
+ var icon = new ThemedIcon (v != null ? v.get_string() : "unknown");
// derive a Connectable flag for this device
var is_connectable = device_is_connectable (device_proxy as DBusProxy);
// look up the device's Connected flag
v = properties.lookup ("Connected");
- bool is_connected = (v != null) && v.get_boolean ();
+ var is_connected = (v != null) && v.get_boolean ();
// derive the uuid-related attributes we care about
v = properties.lookup ("UUIDs");
string[] uuid_strings = v.dup_strv ();
uint16[] uuids = {};
- foreach (string s in uuid_strings)
+ foreach (var s in uuid_strings)
uuids += get_uuid16_from_uuid_string (s);
var supports_browsing = device_supports_browsing (uuids);
var supports_file_transfer = device_supports_file_transfer (uuids);
@@ -386,7 +382,7 @@ public class Bluez: KillswitchBluetooth
{
if (discoverable != b) try
{
- default_adapter.set_property ("Discoverable", new Variant.boolean(b));
+ default_adapter.set_property ("Discoverable", new Variant.boolean (b));
}
catch (Error e)
{
diff --git a/src/desktop.vala b/src/desktop.vala
index e4e7d04..588a584 100644
--- a/src/desktop.vala
+++ b/src/desktop.vala
@@ -72,7 +72,7 @@ class Desktop: Profile
bluetooth.devices_changed.connect (()=> {
if (idle_rebuild_id == 0)
idle_rebuild_id = Idle.add (() => {
- rebuild_device_section();
+ rebuild_device_section ();
idle_rebuild_id = 0;
return false;
});
@@ -90,20 +90,29 @@ class Desktop: Profile
MenuItem create_device_connection_menuitem (Device device)
{
- var action_name = @"desktop-device-$(device.id)-connected";
+ var id = device.id;
+ var action_name = @"desktop-device-$(id)-connected";
var item = new MenuItem (_("Connection"), @"indicator.$action_name");
- item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch");
+ item.set_attribute ("x-canonical-type",
+ "s", "com.canonical.indicator.switch");
// if this doesn't already have an action, create one
- if (!connect_actions.contains (device.id))
+ if (!connect_actions.contains (id))
{
debug (@"creating action for $action_name");
- var action = new SimpleAction.stateful (action_name, null, device.is_connected);
- action.activate.connect (() => action.set_state (!action.get_state().get_boolean()));
- action.notify["state"].connect (() => bluetooth.set_device_connected (device.id, action.get_state().get_boolean()));
- connect_actions.insert (device.id, action);
- action_group.insert (action);
+ var a = new SimpleAction.stateful (action_name,
+ null,
+ device.is_connected);
+
+ a.activate.connect (()
+ => a.set_state (!a.get_state().get_boolean()));
+
+ a.notify["state"].connect (()
+ => bluetooth.set_device_connected (id, a.get_state().get_boolean()));
+
+ connect_actions.insert (device.id, a);
+ action_group.insert (a);
}
else
{
diff --git a/src/killswitch.vala b/src/killswitch.vala
index 6d8f195..08ee0cc 100644
--- a/src/killswitch.vala
+++ b/src/killswitch.vala
@@ -159,7 +159,7 @@ public class RfKillSwitch: KillSwitch, Object
/* update our blocked property.
it should be true if any bluetooth entry is hard- or soft-blocked */
var b = false;
- foreach (Entry entry in entries.get_values())
+ foreach (var entry in entries.get_values ())
if ((b = (entry.soft || entry.hard)))
break;
blocked = b;
diff --git a/src/profile.vala b/src/profile.vala
index 03c7b8b..96d1b5c 100644
--- a/src/profile.vala
+++ b/src/profile.vala
@@ -68,7 +68,7 @@ class Profile: Object
protected MenuItem create_enabled_menuitem ()
{
- MenuItem item = new MenuItem ("Bluetooth", "indicator.bluetooth-enabled");
+ var item = new MenuItem ("Bluetooth", "indicator.bluetooth-enabled");
item.set_attribute ("x-canonical-type", "s",
"com.canonical.indicator.switch");
@@ -131,8 +131,8 @@ class Profile: Object
protected Variant action_state_for_root ()
{
- bool blocked = bluetooth.blocked;
- bool powered = bluetooth.powered;
+ var blocked = bluetooth.blocked;
+ var powered = bluetooth.powered;
string a11y;
string icon_name;
diff --git a/src/service.vala b/src/service.vala
index e6d217a..0c18b36 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -71,7 +71,7 @@ public class Service: Object
critical (@"Unable to export actions on $object_path: $(e.message)");
}
- profiles.for_each ((name,profile) => {
+ profiles.for_each ((name, profile) => {
var path = @"$object_path/$name";
debug (@"exporting menu '$path'");
profile.export_menu (connection, path);