diff options
-rw-r--r-- | src/connection-editor/ce-page-bluetooth.ui | 17 | ||||
-rw-r--r-- | src/connection-editor/ce-page.c | 14 | ||||
-rw-r--r-- | src/connection-editor/ce-page.h | 1 | ||||
-rw-r--r-- | src/connection-editor/page-bluetooth.c | 51 | ||||
-rw-r--r-- | src/connection-editor/page-ethernet.c | 4 | ||||
-rw-r--r-- | src/connection-editor/page-infiniband.c | 4 | ||||
-rw-r--r-- | src/connection-editor/page-wifi.c | 4 |
7 files changed, 67 insertions, 28 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 3f79c22b..d8425d8e 100644 --- a/src/connection-editor/ce-page.c +++ b/src/connection-editor/ce-page.c @@ -308,7 +308,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); @@ -340,7 +343,7 @@ _device_entry_parse (const char *entry_text, char **first, char **second) return TRUE; } - sp = strchr (entry_text, ' '); + sp = strstr (entry_text, " ("); if (sp) { *first = g_strndup (entry_text, sp - entry_text); left = sp + 1; @@ -432,7 +435,8 @@ ce_page_setup_device_combo (CEPage *self, } gboolean -ce_page_device_entry_get (GtkEntry *entry, int type, char **ifname, char **mac, const char *device_name, GError **error) +ce_page_device_entry_get (GtkEntry *entry, int type, gboolean check_ifname, + char **ifname, char **mac, const char *device_name, GError **error) { char *first, *second; const char *ifname_tmp = NULL, *mac_tmp = NULL; @@ -449,7 +453,7 @@ ce_page_device_entry_get (GtkEntry *entry, int type, char **ifname, char **mac, if (first) { if (nm_utils_hwaddr_valid (first, nm_utils_hwaddr_len (type))) mac_tmp = first; - else if (nm_utils_iface_valid_name (first)) + else if (!check_ifname || nm_utils_iface_valid_name (first)) ifname_tmp = first; else valid = FALSE; @@ -460,7 +464,7 @@ ce_page_device_entry_get (GtkEntry *entry, int type, char **ifname, char **mac, mac_tmp = second; else valid = FALSE; - } else if (nm_utils_iface_valid_name (second)) { + } else if (!check_ifname || nm_utils_iface_valid_name (second)) { if (!ifname_tmp) ifname_tmp = second; else diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h index efafc03f..ffc17676 100644 --- a/src/connection-editor/ce-page.h +++ b/src/connection-editor/ce-page.h @@ -123,6 +123,7 @@ void ce_page_setup_device_combo (CEPage *self, gboolean ce_page_mac_entry_valid (GtkEntry *entry, int type, const char *property_name, GError **error); gboolean ce_page_interface_name_valid (const char *iface, const char *property_name, GError **error); gboolean ce_page_device_entry_get (GtkEntry *entry, int type, + gboolean check_ifname, char **ifname, char **mac, const char *device_name, GError **error); diff --git a/src/connection-editor/page-bluetooth.c b/src/connection-editor/page-bluetooth.c index de51127b..5bcded79 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, TRUE); + 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, FALSE, 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, FALSE, 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); diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c index cc754b99..0baf5cce 100644 --- a/src/connection-editor/page-ethernet.c +++ b/src/connection-editor/page-ethernet.c @@ -392,7 +392,7 @@ ui_to_setting (CEPageEthernet *self) entry = gtk_bin_get_child (GTK_BIN (priv->device_combo)); if (entry) - ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac, NULL, NULL); + ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, TRUE, &ifname, &device_mac, NULL, NULL); cloned_mac = gtk_entry_get_text (priv->cloned_mac); /* Wake-on-LAN */ @@ -444,7 +444,7 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error) entry = gtk_bin_get_child (GTK_BIN (priv->device_combo)); if (entry) { - if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL, _("Ethernet device"), error)) + if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, TRUE, NULL, NULL, _("Ethernet device"), error)) return FALSE; } diff --git a/src/connection-editor/page-infiniband.c b/src/connection-editor/page-infiniband.c index a0ce48ad..76ecdb5c 100644 --- a/src/connection-editor/page-infiniband.c +++ b/src/connection-editor/page-infiniband.c @@ -192,7 +192,7 @@ ui_to_setting (CEPageInfiniband *self) entry = gtk_bin_get_child (GTK_BIN (priv->device_combo)); if (entry) - ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, &ifname, &device_mac, NULL, NULL); + ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, TRUE, &ifname, &device_mac, NULL, NULL); g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, @@ -216,7 +216,7 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error) entry = gtk_bin_get_child (GTK_BIN (priv->device_combo)); if (entry) { - if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, NULL, NULL, _("infiniband device"), error)) + if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, TRUE, NULL, NULL, _("infiniband device"), error)) return FALSE; } diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c index 63367c61..7b326737 100644 --- a/src/connection-editor/page-wifi.c +++ b/src/connection-editor/page-wifi.c @@ -536,7 +536,7 @@ ui_to_setting (CEPageWifi *self) bssid = gtk_entry_get_text (GTK_ENTRY (entry)); entry = gtk_bin_get_child (GTK_BIN (priv->device_combo)); if (entry) - ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac, NULL, NULL); + ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, TRUE, &ifname, &device_mac, NULL, NULL); cloned_mac = gtk_entry_get_text (priv->cloned_mac); g_object_set (s_con, @@ -576,7 +576,7 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error) entry = gtk_bin_get_child (GTK_BIN (priv->device_combo)); if (entry) { - if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL, _("Wi-Fi device"), error)) + if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, TRUE, NULL, NULL, _("Wi-Fi device"), error)) return FALSE; } |