[network-manager-netbook] A few fixes for the connection details widget



commit 336f29474093c7a85ebb807e6380ff2843094c77
Author: Tambet Ingo <tambet gmail com>
Date:   Thu Jan 28 16:08:35 2010 -0400

    A few fixes for the connection details widget
    
    Don't create the expanded widget every time we connect.
    Update it after the item's connection is deleted.

 src/nmn-item-renderer.c |   42 ++++++++++++++++--------------------------
 1 files changed, 16 insertions(+), 26 deletions(-)
---
diff --git a/src/nmn-item-renderer.c b/src/nmn-item-renderer.c
index b679a2c..7438041 100644
--- a/src/nmn-item-renderer.c
+++ b/src/nmn-item-renderer.c
@@ -104,28 +104,25 @@ update_details (NmnItemRenderer *self)
 {
     NmnItemRendererPrivate *priv = GET_PRIVATE (self);
     NMConnection *connection;
-    NMDevice *device;
-    NMSettingIP4Config *setting;
-    NMIP4Config *config;
     const char *hw_address;
+    NMSettingIP4Config *setting = NULL;
+    NMIP4Config *config = NULL;
 
     if (!priv->details)
         return;
 
     connection = (NMConnection *) nm_connection_item_get_connection (NM_CONNECTION_ITEM (priv->item));
-    if (!connection)
-        return;
+    if (connection) {
+        NMDevice *device;
 
-    device = nm_device_item_get_device (NM_DEVICE_ITEM (priv->item));
-    setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
+        device = nm_device_item_get_device (NM_DEVICE_ITEM (priv->item));
+        setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
     
-    if (device && nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED)
-        config = nm_device_get_ip4_config (device);
-    else
-        config = NULL;
+        if (device && nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED)
+            config = nm_device_get_ip4_config (device);
+    }
 
     hw_address = nm_device_item_get_hw_address (NM_DEVICE_ITEM (priv->item));
-
     nmn_connection_details_set_data (priv->details, setting, config, hw_address);
 }
 
@@ -139,7 +136,8 @@ item_changed (NMListItem *item,
     const char *property = spec ? spec->name : NULL;
     char *str;
 
-    if (!property || !strcmp (property, NM_LIST_ITEM_NAME) || !strcmp (property, NM_LIST_ITEM_STATUS)) {
+    if (!property || !strcmp (property, NM_LIST_ITEM_NAME) ||
+        !strcmp (property, NM_LIST_ITEM_STATUS) || !strcmp (property, NM_CONNECTION_ITEM_CONNECTION)) {
         const char *status_str;
         const char *button_label;
         NMListItemStatus status;
@@ -175,6 +173,7 @@ item_changed (NMListItem *item,
 
         gtk_button_set_label (GTK_BUTTON (priv->connect_button), button_label);
         update_details (self);
+        update_background (self);
     }
 
     if (!property || !strcmp (property, NM_LIST_ITEM_ICON))
@@ -182,17 +181,6 @@ item_changed (NMListItem *item,
 
     if (!property || !strcmp (property, NM_LIST_ITEM_SECURITY))
         gtk_label_set_text (priv->security_label, nm_list_item_get_security (item));
-
-    if (!property || !strcmp (property, NM_CONNECTION_ITEM_CONNECTION)) {
-        update_background (self);
-
-        if (property && NM_IS_CONNECTION_ITEM (item) && 
-            !nm_connection_item_get_connection (NM_CONNECTION_ITEM (item))) {
-            str = g_strdup_printf ("<big><b>%s</b></big>", nm_list_item_get_name (item));
-            gtk_label_set_markup (priv->name_and_status, str);
-            g_free (str);
-        }
-    }
 }
 
 static void
@@ -219,6 +207,10 @@ details_need_updating (NmnItemRenderer *self)
     NMSetting *new_config;
     gboolean new_connection = FALSE;
 
+    details = GET_PRIVATE (self)->details;
+    if (!details)
+        return FALSE;
+
     connection_item = NM_CONNECTION_ITEM (nmn_item_renderer_get_item (self));
     connection = (NMConnection *) nm_connection_item_get_connection (connection_item);
     if (!connection) {
@@ -232,8 +224,6 @@ details_need_updating (NmnItemRenderer *self)
     }
 
     current_config = nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
-
-    details = get_details (self);
     new_config = NM_SETTING (nmn_connection_details_get_data (NMN_CONNECTION_DETAILS (details)));
     g_assert (new_config);
 



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