summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-12-17 13:13:51 +0100
committerDan Williams <dcbw@redhat.com>2015-12-18 15:09:30 -0600
commit5b0badecb6454776ac9faa85a06b951ec4a9a75b (patch)
treedd5e6aaef90d3c5ab8fe1cb48ced6a1ae9ea1aba
parentc4c12fd553a89f7c977274a3a2e55d083bcbfb01 (diff)
downloadnetwork-manager-applet-dcbw/nma10-editor-bluetooth-rh1271581.tar.gz
editor: populate available Bluetooth devices in Bluetooth page (rh #1271581)dcbw/nma10-editor-bluetooth-rh1271581
-rw-r--r--src/connection-editor/ce-page-bluetooth.ui17
-rw-r--r--src/connection-editor/ce-page.c6
-rw-r--r--src/connection-editor/page-bluetooth.c43
3 files changed, 49 insertions, 17 deletions
diff --git a/src/connection-editor/ce-page-bluetooth.ui b/src/connection-editor/ce-page-bluetooth.ui
index f67ef9b0..e72a3c6f 100644
--- a/src/connection-editor/ce-page-bluetooth.ui
+++ b/src/connection-editor/ce-page-bluetooth.ui
@@ -10,13 +10,15 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkEntry" id="bluetooth_bdaddr">
+ <object class="GtkBox" id="bluetooth_device_vbox">
+ <property name="orientation">vertical</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="spacing">12</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
@@ -25,13 +27,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label1">
+ <object class="GtkLabel" id="bluetooth_device_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Device:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">bluetooth_bdaddr</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index f837a221..02cabb31 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -31,6 +31,7 @@
#include <nm-setting-connection.h>
#include <nm-utils.h>
+#include <nm-device-bt.h>
#include "ce-page.h"
#include "nma-marshal.h"
@@ -425,7 +426,10 @@ _get_device_list (CEPage *self,
if (!G_TYPE_CHECK_INSTANCE_TYPE (dev, device_type))
continue;
- ifname = nm_device_get_iface (NM_DEVICE (dev));
+ if (device_type == NM_TYPE_DEVICE_BT)
+ ifname = nm_device_bt_get_name (NM_DEVICE_BT (dev));
+ else
+ ifname = nm_device_get_iface (NM_DEVICE (dev));
if (mac_property)
g_object_get (G_OBJECT (dev), mac_property, &mac, NULL);
diff --git a/src/connection-editor/page-bluetooth.c b/src/connection-editor/page-bluetooth.c
index d2b3ae44..d2f7e729 100644
--- a/src/connection-editor/page-bluetooth.c
+++ b/src/connection-editor/page-bluetooth.c
@@ -29,6 +29,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-bluetooth.h>
+#include <nm-device-bt.h>
#include "page-bluetooth.h"
#include "nm-connection-editor.h"
@@ -41,7 +42,7 @@ G_DEFINE_TYPE (CEPageBluetooth, ce_page_bluetooth, CE_TYPE_PAGE)
typedef struct {
NMSettingBluetooth *setting;
- GtkEntry *bdaddr;
+ GtkComboBoxText *bdaddr;
gboolean disposed;
} CEPageBluetoothPrivate;
@@ -51,10 +52,24 @@ bluetooth_private_init (CEPageBluetooth *self)
{
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
GtkBuilder *builder;
+ GtkWidget *vbox;
+ GtkLabel *label;
builder = CE_PAGE (self)->builder;
- priv->bdaddr = GTK_ENTRY (gtk_builder_get_object (builder, "bluetooth_bdaddr"));
+ priv->bdaddr = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ());
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->bdaddr), 0);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->bdaddr),
+ _("MAC address of the Bluetooth device. Example: 00:11:22:33:44:55"));
+
+ vbox = GTK_WIDGET (gtk_builder_get_object (builder, "bluetooth_device_vbox"));
+ gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (priv->bdaddr));
+ gtk_widget_set_halign (GTK_WIDGET (priv->bdaddr), GTK_ALIGN_FILL);
+ gtk_widget_show_all (GTK_WIDGET (priv->bdaddr));
+
+ /* Set mnemonic widget for Device label */
+ label = GTK_LABEL (gtk_builder_get_object (builder, "bluetooth_device_label"));
+ gtk_label_set_mnemonic_widget (label, GTK_WIDGET (priv->bdaddr));
}
@@ -63,9 +78,13 @@ populate_ui (CEPageBluetooth *self, NMConnection *connection)
{
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
NMSettingBluetooth *setting = priv->setting;
+ const GByteArray *bdaddr;
- ce_page_mac_to_entry (nm_setting_bluetooth_get_bdaddr (setting),
- ARPHRD_ETHER, priv->bdaddr);
+ bdaddr = nm_setting_bluetooth_get_bdaddr (setting);
+ ce_page_setup_device_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->bdaddr),
+ NM_TYPE_DEVICE_BT, NULL,
+ bdaddr, ARPHRD_ETHER, NM_DEVICE_BT_HW_ADDRESS, TRUE);
+ g_signal_connect_swapped (priv->bdaddr, "changed", G_CALLBACK (ce_page_changed), self);
}
static void
@@ -134,9 +153,13 @@ static void
ui_to_setting (CEPageBluetooth *self)
{
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
- GByteArray *bdaddr;
+ GtkWidget *entry;
+ GByteArray *bdaddr = NULL;
+
+ entry = gtk_bin_get_child (GTK_BIN (priv->bdaddr));
+ if (entry)
+ ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, &bdaddr, NULL, NULL);
- bdaddr = ce_page_entry_to_mac (priv->bdaddr, ARPHRD_ETHER, NULL);
g_object_set (priv->setting,
NM_SETTING_BLUETOOTH_BDADDR, bdaddr,
NULL);
@@ -149,9 +172,13 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
CEPageBluetooth *self = CE_PAGE_BLUETOOTH (page);
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
+ GtkWidget *entry;
- if (!ce_page_mac_entry_valid (priv->bdaddr, ARPHRD_ETHER, _("bdaddr"), error))
- return FALSE;
+ entry = gtk_bin_get_child (GTK_BIN (priv->bdaddr));
+ if (entry) {
+ if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL, _("Bluetooth device"), error))
+ return FALSE;
+ }
ui_to_setting (self);
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);