[network-manager-applet/bg/editor-ipv4-addresses-bgo763937: 2/4] editor: allow specifying static IP addresses for automatic methods



commit 650b79e4116ac470641d23a10f380904b4d6e8f3
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Mon Sep 12 14:20:05 2016 +0200

    editor: allow specifying static IP addresses for automatic methods
    
    Allow users to add static IP addresses when the "Automatic" and
    "Automatic, addresses only" method are selected in the "IPv4 settings"
    and "IPv6 settings" pages.

 src/connection-editor/ce-page-ip4.ui |    3 ---
 src/connection-editor/ce-page-ip6.ui |    3 ---
 src/connection-editor/ce-page.h      |    8 ++++++++
 src/connection-editor/page-ip4.c     |   15 +++++++++++++--
 src/connection-editor/page-ip6.c     |   16 ++++++++++++++--
 5 files changed, 35 insertions(+), 10 deletions(-)
---
diff --git a/src/connection-editor/ce-page-ip4.ui b/src/connection-editor/ce-page-ip4.ui
index 7acaab5..11c077f 100644
--- a/src/connection-editor/ce-page-ip4.ui
+++ b/src/connection-editor/ce-page-ip4.ui
@@ -84,7 +84,6 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="xalign">0</property>
-            <property name="label" translatable="yes">Addresses</property>
             <attributes>
               <attribute name="weight" value="bold"/>
             </attributes>
@@ -117,8 +116,6 @@
                         <property name="height_request">100</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="has_tooltip">True</property>
-                        <property name="tooltip_text" translatable="yes">IP addresses identify your computer 
on the network.  Click the "Add" button to add an IP address.</property>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection1"/>
                         </child>
diff --git a/src/connection-editor/ce-page-ip6.ui b/src/connection-editor/ce-page-ip6.ui
index e3b94b0..511383b 100644
--- a/src/connection-editor/ce-page-ip6.ui
+++ b/src/connection-editor/ce-page-ip6.ui
@@ -101,7 +101,6 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="xalign">0</property>
-            <property name="label" translatable="yes">Addresses</property>
             <attributes>
               <attribute name="weight" value="bold"/>
             </attributes>
@@ -134,8 +133,6 @@
                         <property name="height_request">100</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="has_tooltip">True</property>
-                        <property name="tooltip_text" translatable="yes">IP addresses identify your computer 
on the network.  Click the "Add" button to add an IP address.</property>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection1"/>
                         </child>
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index 6fdb33c..7670f1f 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -99,6 +99,14 @@ typedef CEPage* (*CEPageNewFunc)(NMConnectionEditor *editor,
                                  const char **out_secrets_setting_name,
                                  GError **error);
 
+#define CE_TOOLTIP_ADDR_AUTO _("IP addresses identify your computer on the network.  " \
+                               "Click the \"Add\" button to add static IP address to be " \
+                               "configured in addition to the automatic ones.")
+#define CE_TOOLTIP_ADDR_MANUAL _("IP addresses identify your computer on the network.  " \
+                                 "Click the \"Add\" button to add an IP address.")
+
+#define CE_LABEL_ADDR_AUTO _("Additional static addresses")
+#define CE_LABEL_ADDR_MANUAL _("Addresses")
 
 GType ce_page_get_type (void);
 
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 4efadd3..9427723 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -248,6 +248,7 @@ method_changed (GtkComboBox *combo, gpointer user_data)
        gboolean method_auto = FALSE;
        GtkTreeIter iter;
        GtkListStore *store;
+       const char *tooltip = NULL, *label = NULL;
 
        if (gtk_combo_box_get_active_iter (priv->method, &iter)) {
                gtk_tree_model_get (GTK_TREE_MODEL (priv->method_store), &iter,
@@ -256,18 +257,25 @@ method_changed (GtkComboBox *combo, gpointer user_data)
 
        switch (method) {
        case IP4_METHOD_AUTO:
-               addr_enabled = FALSE;
+               addr_enabled = TRUE;
                dhcp_enabled = routes_enabled = TRUE;
                dns_enabled = TRUE;
                method_auto = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_AUTO;
+               label = CE_LABEL_ADDR_AUTO;
                break;
        case IP4_METHOD_AUTO_ADDRESSES:
-               addr_enabled = FALSE;
+               addr_enabled = TRUE;
                dns_enabled = dhcp_enabled = routes_enabled = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_AUTO;
+               label = CE_LABEL_ADDR_AUTO;
                break;
        case IP4_METHOD_MANUAL:
                addr_enabled = dns_enabled = routes_enabled = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_MANUAL;
+               label = CE_LABEL_ADDR_MANUAL;
                break;
+       case IP4_METHOD_SHARED:
        case IP4_METHOD_DISABLED:
                addr_enabled = dns_enabled = dhcp_enabled = routes_enabled = ip4_required_enabled = FALSE;
                break;
@@ -275,6 +283,9 @@ method_changed (GtkComboBox *combo, gpointer user_data)
                break;
        }
 
+       gtk_widget_set_tooltip_text (GTK_WIDGET (priv->addr_list), tooltip);
+       gtk_label_set_text (GTK_LABEL (priv->addr_label), label);
+
        /* Disable DHCP stuff for VPNs (though in the future we should support
         * DHCP over tap interfaces for OpenVPN and vpnc).
         */
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 8564285..85bac54 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -248,6 +248,7 @@ method_changed (GtkComboBox *combo, gpointer user_data)
        gboolean method_auto = FALSE;
        GtkTreeIter iter;
        GtkListStore *store;
+       const char *tooltip = NULL, *label = NULL;
 
        if (gtk_combo_box_get_active_iter (priv->method, &iter)) {
                gtk_tree_model_get (GTK_TREE_MODEL (priv->method_store), &iter,
@@ -256,23 +257,31 @@ method_changed (GtkComboBox *combo, gpointer user_data)
 
        switch (method) {
        case IP6_METHOD_AUTO:
-               addr_enabled = FALSE;
+               addr_enabled = TRUE;
                routes_enabled = TRUE;
                dns_enabled = TRUE;
                method_auto = TRUE;
                ip6_privacy_enabled = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_AUTO;
+               label = CE_LABEL_ADDR_AUTO;
                break;
        case IP6_METHOD_AUTO_ADDRESSES:
-               addr_enabled = FALSE;
+               addr_enabled = TRUE;
                dns_enabled = routes_enabled = TRUE;
                ip6_privacy_enabled = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_AUTO;
+               label = CE_LABEL_ADDR_AUTO;
                break;
        case IP6_METHOD_AUTO_DHCP_ONLY:
                addr_enabled = FALSE;
                routes_enabled = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_AUTO;
+               label = CE_LABEL_ADDR_AUTO;
                break;
        case IP6_METHOD_MANUAL:
                addr_enabled = dns_enabled = routes_enabled = TRUE;
+               tooltip = CE_TOOLTIP_ADDR_MANUAL;
+               label = CE_LABEL_ADDR_MANUAL;
                break;
        case IP6_METHOD_IGNORE:
                ip6_required_enabled = FALSE;
@@ -281,6 +290,9 @@ method_changed (GtkComboBox *combo, gpointer user_data)
                break;
        }
 
+       gtk_widget_set_tooltip_text (GTK_WIDGET (priv->addr_list), tooltip);
+       gtk_label_set_text (GTK_LABEL (priv->addr_label), label);
+
        gtk_widget_set_sensitive (priv->addr_label, addr_enabled);
        gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_add), addr_enabled);
        gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_delete), addr_enabled);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]