summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2016-12-01 11:10:59 +0100
committerFrancesco Giudici <fgiudici@redhat.com>2016-12-01 11:10:59 +0100
commit8c44cbeba2084f5fe915068c9e2bf13abd509e7c (patch)
tree99b2eb5340074bae3cfd441a7bb1b9d5894a2eec
parentb94ae0fcced78c4493ddf2326f18c127f7d80e1e (diff)
parent9eba8582d3fe3a64b923b0f54359285cd25f6993 (diff)
downloadnetwork-manager-applet-8c44cbeba2084f5fe915068c9e2bf13abd509e7c.tar.gz
c-e: merge branch 'fg/c-e-ethernet-link2'
expose 802.3 link negotiation options implemented in: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=e0c50a97
-rw-r--r--src/connection-editor/ce-page-ethernet.ui252
-rw-r--r--src/connection-editor/page-ethernet.c150
2 files changed, 256 insertions, 146 deletions
diff --git a/src/connection-editor/ce-page-ethernet.ui b/src/connection-editor/ce-page-ethernet.ui
index 6b20a07c..29b15c5e 100644
--- a/src/connection-editor/ce-page-ethernet.ui
+++ b/src/connection-editor/ce-page-ethernet.ui
@@ -36,9 +36,6 @@
</columns>
<data>
<row>
- <col id="0" translatable="yes">Automatic</col>
- </row>
- <row>
<col id="0" translatable="yes">10 Mb/s</col>
</row>
<row>
@@ -52,6 +49,37 @@
</row>
</data>
</object>
+ <object class="GtkListStore" id="model3">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Half</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Full</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkListStore" id="model4">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Ignore</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Automatic</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Manual</col>
+ </row>
+ </data>
+ </object>
<object class="GtkTable" id="EthernetPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -93,76 +121,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="ethernet_speed_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Speed:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">ethernet_speed</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="ethernet_speed">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="model">model2</property>
- <child>
- <object class="GtkCellRendererText" id="renderer2"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="ethernet_duplex">
- <property name="label" translatable="yes">Full duple_x</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="ethernet_autonegotiate">
- <property name="label" translatable="yes">Aut_onegotiate</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="ethernet_device_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -171,8 +129,8 @@
<property name="use_underline">True</property>
</object>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -188,8 +146,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="y_options"/>
</packing>
</child>
@@ -203,8 +161,8 @@
<property name="mnemonic_widget">ethernet_cloned_mac</property>
</object>
<packing>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -218,8 +176,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options"/>
</packing>
</child>
@@ -233,8 +191,8 @@
<property name="mnemonic_widget">ethernet_mtu</property>
</object>
<packing>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -273,8 +231,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -287,8 +245,8 @@
<property name="label" translatable="yes">Wake on LAN:</property>
</object>
<packing>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -425,8 +383,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="y_options"/>
</packing>
</child>
@@ -440,8 +398,8 @@
<property name="mnemonic_widget">ethernet_wol_passwd</property>
</object>
<packing>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -455,6 +413,118 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="ethernet_linkneg_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Link negotiation:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="ethernet_linkneg">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Device link negotiation. If "Manual" is chosen, "Speed" and "Duplex" values will be forced without checking the device compatibility. If unsure, leave here "Ignore" or pick "Automatic".</property>
+ <property name="model">model4</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer4"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="ethernet_speed_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Speed:</property>
+ <property name="use_underline">True</property>
+ <property name="margin_left">26</property>
+ <property name="mnemonic_widget">ethernet_speed</property>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="ethernet_speed">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Speed value for static link negotiation, required only when "Ignore" and "Automatic" options are not selected. Before specifying a speed value be sure your device supports it.</property>
+ <property name="model">model2</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="ethernet_duplex_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Duplex:</property>
+ <property name="use_underline">True</property>
+ <property name="margin_left">26</property>
+ <property name="mnemonic_widget">ethernet_duplex</property>
+ </object>
+ <packing>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="ethernet_duplex">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Duplex value for static link negotiation, required only when "Ignore" and "Automatic" options are not selected. Before specifying a duplex mode be sure your device supports it.</property>
+ <property name="model">model3</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer3"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="y_options"/>
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index af455854..d35a0a35 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -38,8 +38,8 @@ typedef struct {
GtkEntry *cloned_mac; /* Cloned MAC - used for MAC spoofing */
GtkComboBox *port;
GtkComboBox *speed;
- GtkToggleButton *duplex;
- GtkToggleButton *autonegotiate;
+ GtkComboBox *duplex;
+ GtkComboBox *linkneg;
GtkSpinButton *mtu;
GtkToggleButton *wol_default, *wol_ignore, *wol_phy, *wol_unicast, *wol_multicast,
*wol_broadcast, *wol_arp, *wol_magic;
@@ -47,17 +47,23 @@ typedef struct {
gboolean mtu_enabled;
} CEPageEthernetPrivate;
-#define PORT_DEFAULT 0
-#define PORT_TP 1
-#define PORT_AUI 2
-#define PORT_BNC 3
-#define PORT_MII 4
+#define PORT_DEFAULT 0
+#define PORT_TP 1
+#define PORT_AUI 2
+#define PORT_BNC 3
+#define PORT_MII 4
-#define SPEED_DEFAULT 0
-#define SPEED_10 1
-#define SPEED_100 2
-#define SPEED_1000 3
-#define SPEED_10000 4
+#define LINKNEG_IGNORE 0
+#define LINKNEG_AUTO 1
+#define LINKNEG_MANUAL 2
+
+#define SPEED_10 0
+#define SPEED_100 1
+#define SPEED_1000 2
+#define SPEED_10000 3
+
+#define DUPLEX_HALF 0
+#define DUPLEX_FULL 1
static void
ethernet_private_init (CEPageEthernet *self)
@@ -88,8 +94,8 @@ ethernet_private_init (CEPageEthernet *self)
priv->cloned_mac = GTK_ENTRY (gtk_builder_get_object (builder, "ethernet_cloned_mac"));
priv->port = GTK_COMBO_BOX (gtk_builder_get_object (builder, "ethernet_port"));
priv->speed = GTK_COMBO_BOX (gtk_builder_get_object (builder, "ethernet_speed"));
- priv->duplex = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "ethernet_duplex"));
- priv->autonegotiate = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "ethernet_autonegotiate"));
+ priv->duplex = GTK_COMBO_BOX (gtk_builder_get_object (builder, "ethernet_duplex"));
+ priv->linkneg = GTK_COMBO_BOX (gtk_builder_get_object (builder, "ethernet_linkneg"));
priv->mtu = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "ethernet_mtu"));
priv->wol_default = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_default"));
priv->wol_ignore = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_ignore"));
@@ -111,6 +117,21 @@ stuff_changed (GtkWidget *w, gpointer user_data)
}
static void
+link_special_changed_cb (GtkWidget *widget, gpointer user_data)
+{
+ CEPageEthernet *self = CE_PAGE_ETHERNET (user_data);
+ CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
+ gboolean enable = false;
+
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == LINKNEG_MANUAL)
+ enable = true;
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->speed), enable);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->duplex), enable);
+
+ stuff_changed (NULL, self);
+}
+
+static void
wol_special_toggled_cb (GtkWidget *widget, gpointer user_data)
{
CEPageEthernet *self = CE_PAGE_ETHERNET (user_data);
@@ -159,9 +180,12 @@ populate_ui (CEPageEthernet *self)
CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
NMSettingWired *setting = priv->setting;
const char *port;
+ guint32 speed;
const char *duplex;
int port_idx = PORT_DEFAULT;
- int speed_idx;
+ int speed_idx = SPEED_100;
+ int duplex_idx = DUPLEX_FULL;
+ int linkneg_idx = LINKNEG_IGNORE;
int mtu_def;
const char *s_mac, *s_ifname, *s_wol_passwd;
NMSettingWiredWakeOnLan wol;
@@ -181,7 +205,8 @@ populate_ui (CEPageEthernet *self)
gtk_combo_box_set_active (priv->port, port_idx);
/* Speed */
- switch (nm_setting_wired_get_speed (setting)) {
+ speed = nm_setting_wired_get_speed (setting);
+ switch (speed) {
case 10:
speed_idx = SPEED_10;
break;
@@ -194,22 +219,25 @@ populate_ui (CEPageEthernet *self)
case 10000:
speed_idx = SPEED_10000;
break;
- default:
- speed_idx = SPEED_DEFAULT;
- break;
}
gtk_combo_box_set_active (priv->speed, speed_idx);
/* Duplex */
duplex = nm_setting_wired_get_duplex (setting);
- if (duplex && !strcmp (duplex, "half"))
- gtk_toggle_button_set_active (priv->duplex, FALSE);
- else
- gtk_toggle_button_set_active (priv->duplex, TRUE);
+ if (duplex) {
+ if (!strcmp (duplex, "half"))
+ duplex_idx = DUPLEX_HALF;
+ else
+ duplex_idx = DUPLEX_FULL;
+ }
+ gtk_combo_box_set_active (priv->duplex, duplex_idx);
- /* Autonegotiate */
- gtk_toggle_button_set_active (priv->autonegotiate,
- nm_setting_wired_get_auto_negotiate (setting));
+ /* Link Negotiation */
+ if (nm_setting_wired_get_auto_negotiate (setting))
+ linkneg_idx = LINKNEG_AUTO;
+ else if (speed && duplex)
+ linkneg_idx = LINKNEG_MANUAL;
+ gtk_combo_box_set_active (priv->linkneg, linkneg_idx);
/* Device ifname/MAC */
s_ifname = nm_connection_get_interface_name (CE_PAGE (self)->connection);
@@ -275,10 +303,11 @@ finish_setup (CEPageEthernet *self, gpointer unused, GError *error, gpointer use
populate_ui (self);
+ g_signal_connect (priv->linkneg, "changed", G_CALLBACK (link_special_changed_cb), self);
+ link_special_changed_cb (GTK_WIDGET (priv->linkneg), self);
g_signal_connect (priv->port, "changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->speed, "changed", G_CALLBACK (stuff_changed), self);
- g_signal_connect (priv->duplex, "toggled", G_CALLBACK (stuff_changed), self);
- g_signal_connect (priv->autonegotiate, "toggled", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->duplex, "changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->wol_default, "toggled", G_CALLBACK (wol_special_toggled_cb), self);
@@ -300,16 +329,6 @@ finish_setup (CEPageEthernet *self, gpointer unused, GError *error, gpointer use
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_port"));
gtk_widget_hide (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_speed_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_speed"));
- gtk_widget_hide (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_duplex"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_autonegotiate"));
- gtk_widget_hide (widget);
}
CEPage *
@@ -364,6 +383,7 @@ ui_to_setting (CEPageEthernet *self)
NMSettingConnection *s_con;
const char *port;
guint32 speed;
+ const char *duplex;
char *ifname = NULL;
char *device_mac = NULL;
const char *cloned_mac;
@@ -393,23 +413,42 @@ ui_to_setting (CEPageEthernet *self)
break;
}
- /* Speed */
- switch (gtk_combo_box_get_active (priv->speed)) {
- case SPEED_10:
- speed = 10;
- break;
- case SPEED_100:
- speed = 100;
- break;
- case SPEED_1000:
- speed = 1000;
- break;
- case SPEED_10000:
- speed = 10000;
- break;
- default:
+ /* Speed & Duplex */
+ if (gtk_combo_box_get_active (priv->linkneg) != LINKNEG_MANUAL) {
speed = 0;
- break;
+ duplex = NULL;
+ } else {
+ switch (gtk_combo_box_get_active (priv->speed)) {
+ case SPEED_10:
+ speed = 10;
+ break;
+ case SPEED_100:
+ speed = 100;
+ break;
+ case SPEED_1000:
+ speed = 1000;
+ break;
+ case SPEED_10000:
+ speed = 10000;
+ break;
+ default:
+ g_warn_if_reached();
+ speed = 0;
+ break;
+ }
+
+ switch (gtk_combo_box_get_active (priv->duplex)) {
+ case DUPLEX_HALF:
+ duplex = "half";
+ break;
+ case DUPLEX_FULL:
+ duplex = "full";
+ break;
+ default:
+ g_warn_if_reached();
+ duplex = NULL;
+ break;
+ }
}
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
@@ -448,7 +487,8 @@ ui_to_setting (CEPageEthernet *self)
NM_SETTING_WIRED_CLONED_MAC_ADDRESS, cloned_mac && *cloned_mac ? cloned_mac : NULL,
NM_SETTING_WIRED_PORT, port,
NM_SETTING_WIRED_SPEED, speed,
- NM_SETTING_WIRED_AUTO_NEGOTIATE, gtk_toggle_button_get_active (priv->autonegotiate),
+ NM_SETTING_WIRED_DUPLEX, duplex,
+ NM_SETTING_WIRED_AUTO_NEGOTIATE, (gtk_combo_box_get_active (priv->linkneg) == LINKNEG_AUTO),
NM_SETTING_WIRED_WAKE_ON_LAN, wol,
NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, wol_passwd && *wol_passwd ? wol_passwd : NULL,
NULL);