summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2016-11-25 12:58:05 +0100
committerFrancesco Giudici <fgiudici@redhat.com>2016-11-30 16:11:45 +0100
commit997a0a3a2f1be608524438c7a12e65aa229b4ac3 (patch)
treea78a4709d0640cf6ea91b49c5b091063751fef01
parentc5cc03c068957d5e050992dc89b08e5fac247788 (diff)
downloadnetwork-manager-applet-997a0a3a2f1be608524438c7a12e65aa229b4ac3.tar.gz
c-e: rework ethernet link negotiation
Change the autonegotiate CheckButton with a link negotiation ComboBox allowing the "Ignore", "Automatic" and "Manual" values. In this way it is possible to remove the "Default" value from the Duplex and Speed boxes. They will be enabled to enforce the specified values only when "Manual" is selected. Move the link negotiation section on bottom.
-rw-r--r--src/connection-editor/ce-page-ethernet.ui260
-rw-r--r--src/connection-editor/page-ethernet.c140
2 files changed, 232 insertions, 168 deletions
diff --git a/src/connection-editor/ce-page-ethernet.ui b/src/connection-editor/ce-page-ethernet.ui
index d9a0dad5..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>
@@ -59,9 +56,6 @@
</columns>
<data>
<row>
- <col id="0" translatable="yes">Automatic</col>
- </row>
- <row>
<col id="0" translatable="yes">Half</col>
</row>
<row>
@@ -69,6 +63,23 @@
</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>
@@ -110,95 +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="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="mnemonic_widget">ethernet_duplex</property>
- </object>
- <packing>
- <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="GtkComboBox" id="ethernet_duplex">
- <property name="visible">True</property>
- <property name="can_focus">False</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">2</property>
- <property name="bottom_attach">3</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>
@@ -207,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>
@@ -224,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>
@@ -239,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>
@@ -254,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>
@@ -269,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>
@@ -309,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>
@@ -323,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>
@@ -461,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>
@@ -476,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>
@@ -491,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 d960e332..8b7cf66a 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -39,7 +39,7 @@ typedef struct {
GtkComboBox *port;
GtkComboBox *speed;
GtkComboBox *duplex;
- GtkToggleButton *autonegotiate;
+ GtkComboBox *linkneg;
GtkSpinButton *mtu;
GtkToggleButton *wol_default, *wol_ignore, *wol_phy, *wol_unicast, *wol_multicast,
*wol_broadcast, *wol_arp, *wol_magic;
@@ -47,21 +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 DUPLEX_DEFAULT 0
-#define DUPLEX_HALF 1
-#define DUPLEX_FULL 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)
@@ -93,7 +95,7 @@ ethernet_private_init (CEPageEthernet *self)
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_COMBO_BOX (gtk_builder_get_object (builder, "ethernet_duplex"));
- priv->autonegotiate = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "ethernet_autonegotiate"));
+ 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"));
@@ -115,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);
@@ -163,10 +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 duplex_idx = DUPLEX_DEFAULT;
+ 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;
@@ -186,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;
@@ -199,9 +219,6 @@ 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);
@@ -215,9 +232,12 @@ populate_ui (CEPageEthernet *self)
}
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);
@@ -283,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, "changed", G_CALLBACK (stuff_changed), self);
- g_signal_connect (priv->autonegotiate, "toggled", 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);
@@ -319,8 +340,11 @@ finish_setup (CEPageEthernet *self, gpointer unused, GError *error, gpointer use
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"));
+ widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_linkneg_label"));
+ gtk_widget_hide (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_linkneg"));
gtk_widget_hide (widget);
+
}
CEPage *
@@ -405,36 +429,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 */
- switch (gtk_combo_box_get_active (priv->duplex)) {
- case DUPLEX_HALF:
- duplex = "half";
- break;
- case DUPLEX_FULL:
- duplex = "full";
- break;
- default:
duplex = NULL;
- break;
+ } 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));
@@ -474,7 +504,7 @@ ui_to_setting (CEPageEthernet *self)
NM_SETTING_WIRED_PORT, port,
NM_SETTING_WIRED_SPEED, speed,
NM_SETTING_WIRED_DUPLEX, duplex,
- NM_SETTING_WIRED_AUTO_NEGOTIATE, gtk_toggle_button_get_active (priv->autonegotiate),
+ 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);