[gnome-control-center] network: Refresh UI when active connections change



commit e2a2d4f00e754494a2266a38c0e54eeb03d6a37a
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 15 21:08:53 2011 -0400

    network: Refresh UI when active connections change
    
    This makes us pick up vpn connection state changes.

 panels/network/cc-network-panel.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index feefb9d..74370eb 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -131,6 +131,10 @@ cc_network_panel_dispose (GObject *object)
                 g_object_unref (priv->client);
                 priv->client = NULL;
         }
+        if (priv->remote_settings != NULL) {
+                g_object_unref (priv->remote_settings);
+                priv->remote_settings = NULL;
+        }
 
         G_OBJECT_CLASS (cc_network_panel_parent_class)->dispose (object);
 }
@@ -1319,25 +1323,27 @@ nm_device_refresh_vpn_ui (CcNetworkPanel *panel, NetVpn *vpn)
 }
 
 static void
-nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *panel)
+refresh_ui (CcNetworkPanel *panel)
 {
+        GtkTreeSelection *selection;
         GtkTreeIter iter;
         GtkTreeModel *model;
         GtkWidget *widget;
         NMDevice *device;
-        NetObject *object;
+        NetDevice *object = NULL;
         CcNetworkPanelPrivate *priv = panel->priv;
 
+        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
+                                                     "treeview_devices"));
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+
         /* will only work in single or browse selection mode! */
         if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
                 g_debug ("no row selected");
                 goto out;
         }
 
-        /* get id */
-        gtk_tree_model_get (model, &iter,
-                            PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, &object,
-                            -1);
+        object = get_selected_composite_device (panel);
 
         /* this is the proxy settings device */
         if (object == NULL) {
@@ -1375,6 +1381,12 @@ out:
 }
 
 static void
+nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *panel)
+{
+        refresh_ui (panel);
+}
+
+static void
 panel_add_proxy_device (CcNetworkPanel *panel)
 {
         gchar *title;
@@ -1414,6 +1426,7 @@ cc_network_panel_notify_enable_active_cb (GtkSwitch *sw,
 static void
 active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_data)
 {
+        CcNetworkPanel *panel = user_data;
         const GPtrArray *connections;
         int i, j;
 
@@ -1431,6 +1444,8 @@ active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_d
                 if (NM_IS_VPN_CONNECTION (connection))
                         g_debug ("           VPN base connection: %s", nm_active_connection_get_specific_object (connection));
         }
+
+        refresh_ui (panel);
 }
 
 static void



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