Skip to content

Commit

Permalink
Use the 'alias' property instead of the 'name' property for devices (#…
Browse files Browse the repository at this point in the history
…189)

Closes #188.
  • Loading branch information
stan-janssen authored Mar 31, 2023
1 parent a1b46af commit 23d2560
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ebt/Application.vala
Original file line number Diff line number Diff line change
@@ -235,7 +235,7 @@ public class BluetoothApp : Gtk.Application {
});
});
Bluetooth.Device device = object_manager.get_device (address);
var devicename = device.name;
var devicename = device.alias;
var deviceicon = device.icon;
bt_receiver.set_transfer (
devicename == null ? get_device_description_from_icon (device) : devicename,
@@ -246,7 +246,7 @@ public class BluetoothApp : Gtk.Application {

private void response_notify (string address, GLib.ObjectPath objectpath) {
Bluetooth.Device device = object_manager.get_device (address);
var devicename = device.name;
var devicename = device.alias;
var deviceicon = device.icon;
try {
transfer = Bus.get_proxy_sync (BusType.SESSION, "org.bluez.obex", objectpath);
14 changes: 7 additions & 7 deletions ebt/Dialog/BtSender.vala
Original file line number Diff line number Diff line change
@@ -223,9 +223,9 @@ public class BtSender : Granite.Dialog {
"org.bluez.obex.Client1"
);
path_label.set_markup (GLib.Markup.printf_escaped (_("<b>From</b>: %s"), file_path.get_parent ().get_path ()));
device_label.set_markup (GLib.Markup.printf_escaped (_("<b>To</b>: %s"), device.name));
device_label.set_markup (GLib.Markup.printf_escaped (_("<b>To</b>: %s"), device.alias));
icon_label.set_from_gicon (new ThemedIcon (device.icon == null? "bluetooth" : device.icon), Gtk.IconSize.LARGE_TOOLBAR);
progress_label.label = _("Trying to connect to %s").printf (device.name);
progress_label.label = _("Trying to connect to %s").printf (device.alias);
VariantBuilder builder = new VariantBuilder (VariantType.DICTIONARY);
builder.add ("{sv}", "Target", new Variant.string ("opp"));
Variant parameters = new Variant ("(sa{sv})", device.address, builder);
@@ -243,7 +243,7 @@ public class BtSender : Granite.Dialog {
} catch (Error e) {
hide_on_delete ();
var bt_retry = new Granite.MessageDialog (
_("Connecting to '%s' failed.").printf (device.name),
_("Connecting to '%s' failed.").printf (device.alias),
"%s\n%s".printf (
_("The transfer of '%s' failed.").printf (
file_path.get_basename ()
@@ -283,9 +283,9 @@ public class BtSender : Granite.Dialog {
}
private async void send_file () {
path_label.set_markup (GLib.Markup.printf_escaped (_("<b>From</b>: %s"), file_path.get_parent ().get_path ()));
device_label.set_markup (GLib.Markup.printf_escaped (_("<b>To</b>: %s"), device.name));
device_label.set_markup (GLib.Markup.printf_escaped (_("<b>To</b>: %s"), device.alias));
icon_label.set_from_gicon (new ThemedIcon (device.icon == null? "bluetooth" : device.icon), Gtk.IconSize.LARGE_TOOLBAR);
progress_label.label = _("Waiting for acceptance on %s").printf (device.name);
progress_label.label = _("Waiting for acceptance on %s").printf (device.alias);
try {
Variant variant = yield session.call ("SendFile", new Variant ("(s)", file_path.get_path ()), GLib.DBusCallFlags.NONE, -1);
start_time = (int) get_real_time ();
@@ -310,7 +310,7 @@ public class BtSender : Granite.Dialog {
_("The transfer of '%s' failed.").printf (file_path.get_basename ()),
"%s\n%s".printf (
_("The transfer was interrupted or it was declined by %s.").printf (
device.name
device.alias
),
_("The file has not been transferred")
),
@@ -356,7 +356,7 @@ public class BtSender : Granite.Dialog {
notification.set_icon (new ThemedIcon (device.icon));
notification.set_priority (NotificationPriority.NORMAL);
notification.set_title (_("File transferred successfully"));
notification.set_body (GLib.Markup.printf_escaped (_("<b>From:</b> %s <b>Send to:</b> %s"), file_path.get_path (), device.name));
notification.set_body (GLib.Markup.printf_escaped (_("<b>From:</b> %s <b>Send to:</b> %s"), file_path.get_path (), device.alias));
((Gtk.Window)get_toplevel ()).application.send_notification ("io.elementary.bluetooth", notification);
}

4 changes: 2 additions & 2 deletions ebt/Dialog/DeviceRow.vala
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ public class DeviceRow : Gtk.ListBoxRow {
overlay.add (image);
overlay.add_overlay (state);

string? device_name = device.name;
string? device_name = device.alias;
if (device_name == null) {
if (device.icon != null) {
device_name = device_icon ();
@@ -106,7 +106,7 @@ public class DeviceRow : Gtk.ListBoxRow {

var name = changed.lookup_value ("Name", new VariantType ("s"));
if (name != null) {
label.label = device.name;
label.label = device.alias;
}

var icon = changed.lookup_value ("Icon", new VariantType ("s"));
2 changes: 1 addition & 1 deletion src/Widgets/Device.vala
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ public class BluetoothIndicator.Widgets.Device : Gtk.ListBoxRow {
}

private void update_status () {
string? device_name = device.name;
string? device_name = device.alias;
if (device_name == null) {
if (device.icon != null) {
switch (device.icon) {

0 comments on commit 23d2560

Please sign in to comment.