[network-manager-applet/editor-bluetooth-rh1271581] editor: populate available Bluetooth devices in Bluetooth page (rh #1271581)
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/editor-bluetooth-rh1271581] editor: populate available Bluetooth devices in Bluetooth page (rh #1271581)
- Date: Thu, 17 Dec 2015 12:18:19 +0000 (UTC)
commit f2d52a49519840c8aaae223badc1c9003abab42b
Author: Jiří Klimeš <jklimes redhat com>
Date: Thu Dec 17 13:13:51 2015 +0100
editor: populate available Bluetooth devices in Bluetooth page (rh #1271581)
src/connection-editor/ce-page-bluetooth.ui | 17 +++++----
src/connection-editor/page-bluetooth.c | 51 +++++++++++++++++++++++-----
2 files changed, 51 insertions(+), 17 deletions(-)
---
diff --git a/src/connection-editor/ce-page-bluetooth.ui b/src/connection-editor/ce-page-bluetooth.ui
index f67ef9b..e72a3c6 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/page-bluetooth.c b/src/connection-editor/page-bluetooth.c
index de51127..ffaa4bb 100644
--- a/src/connection-editor/page-bluetooth.c
+++ b/src/connection-editor/page-bluetooth.c
@@ -40,7 +40,7 @@ G_DEFINE_TYPE (CEPageBluetooth, ce_page_bluetooth, CE_TYPE_PAGE)
typedef struct {
NMSettingBluetooth *setting;
- GtkEntry *bdaddr;
+ GtkComboBoxText *bdaddr;
gboolean disposed;
} CEPageBluetoothPrivate;
@@ -50,10 +50,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));
}
@@ -65,8 +79,10 @@ populate_ui (CEPageBluetooth *self, NMConnection *connection)
const char *bdaddr;
bdaddr = nm_setting_bluetooth_get_bdaddr (setting);
- if (bdaddr)
- gtk_entry_set_text (priv->bdaddr, bdaddr);
+ ce_page_setup_device_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->bdaddr),
+ NM_TYPE_DEVICE_BT, NULL,
+ bdaddr, NM_DEVICE_BT_HW_ADDRESS, FALSE);
+ g_signal_connect_swapped (priv->bdaddr, "changed", G_CALLBACK (ce_page_changed), self);
}
static void
@@ -133,12 +149,17 @@ static void
ui_to_setting (CEPageBluetooth *self)
{
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
- const char *bdaddr;
+ GtkWidget *entry;
+ char *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 = gtk_entry_get_text (priv->bdaddr);
g_object_set (priv->setting,
NM_SETTING_BLUETOOTH_BDADDR, bdaddr && *bdaddr ? bdaddr : NULL,
NULL);
+ g_free (bdaddr);
}
static gboolean
@@ -146,9 +167,21 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
CEPageBluetooth *self = CE_PAGE_BLUETOOTH (page);
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
-
- if (!ce_page_mac_entry_valid (priv->bdaddr, ARPHRD_ETHER, _("bdaddr"), error))
- return FALSE;
+ GtkWidget *entry;
+ char *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);
+ if (!bdaddr || !nm_utils_hwaddr_valid (bdaddr, nm_utils_hwaddr_len (ARPHRD_ETHER))) {
+ g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC,
+ _("invalid Bluetooth device (%s)"),
+ bdaddr ? bdaddr : "null");
+ g_free (bdaddr);
+ return FALSE;
+ }
+ g_free (bdaddr);
+ }
ui_to_setting (self);
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]