[gnome-control-center] network: Allow NetObjects to get the main panel object so they can show modal dialogs



commit de8993eddbbea7a67e5de590913ce4563363b256
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jul 20 09:28:26 2012 +0100

    network: Allow NetObjects to get the main panel object so they can show modal dialogs

 panels/network/cc-network-panel.c  |    2 ++
 panels/network/net-device-mobile.c |    5 +++--
 panels/network/net-object.c        |   22 ++++++++++++++++++++++
 panels/network/net-object.h        |    3 +++
 4 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 92aad09..a5bac59 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -468,6 +468,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
         /* create device */
         title = panel_device_to_localized_string (device);
         net_device = g_object_new (device_g_type,
+                                   "panel", panel,
                                    "removable", FALSE,
                                    "cancellable", panel->priv->cancellable,
                                    "client", panel->priv->client,
@@ -1852,6 +1853,7 @@ panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
 
         /* add as a virtual object */
         net_vpn = g_object_new (NET_TYPE_VPN,
+                                "panel", panel,
                                 "removable", TRUE,
                                 "id", id,
                                 "connection", connection,
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 9c08a3c..8c06529 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -30,6 +30,7 @@
 #include <nm-remote-connection.h>
 
 #include "panel-common.h"
+#include "network-dialogs.h"
 
 #include "net-device-mobile.h"
 
@@ -105,6 +106,7 @@ mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mo
         NMDevice *device;
         NMClient *client;
         NMRemoteSettings *remote_settings;
+        CcNetworkPanel *panel;
 
         if (device_mobile->priv->updating_device)
                 goto out;
@@ -125,12 +127,11 @@ mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mo
                             COLUMN_ID, &object_path,
                             -1);
         if (g_strcmp0 (object_path, NULL) == 0) {
-#if 0
+                panel = net_object_get_panel (NET_OBJECT (device_mobile));
                 cc_network_panel_connect_to_3g_network (panel,
                                                         client,
                                                         remote_settings,
                                                         device);
-#endif
                 goto out;
         }
 
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index d28f5d1..02388b9 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -36,6 +36,7 @@ struct _NetObjectPrivate
         GCancellable                    *cancellable;
         NMClient                        *client;
         NMRemoteSettings                *remote_settings;
+        CcNetworkPanel                  *panel;
 };
 
 enum {
@@ -46,6 +47,7 @@ enum {
         PROP_CLIENT,
         PROP_REMOTE_SETTINGS,
         PROP_CANCELLABLE,
+        PROP_PANEL,
         PROP_LAST
 };
 
@@ -130,6 +132,13 @@ net_object_get_cancellable (NetObject *object)
         return object->priv->cancellable;
 }
 
+CcNetworkPanel *
+net_object_get_panel (NetObject *object)
+{
+        g_return_val_if_fail (NET_IS_OBJECT (object), NULL);
+        return object->priv->panel;
+}
+
 GtkWidget *
 net_object_add_to_notebook (NetObject *object,
                             GtkNotebook *notebook,
@@ -206,6 +215,9 @@ net_object_get_property (GObject *object_,
         case PROP_CANCELLABLE:
                 g_value_set_object (value, priv->cancellable);
                 break;
+        case PROP_PANEL:
+                g_value_set_object (value, priv->panel);
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -245,6 +257,9 @@ net_object_set_property (GObject *object_,
         case PROP_CANCELLABLE:
                 priv->cancellable = g_value_dup_object (value);
                 break;
+        case PROP_PANEL:
+                priv->panel = g_value_dup_object (value);
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -265,6 +280,8 @@ net_object_finalize (GObject *object)
                 g_object_unref (priv->remote_settings);
         if (priv->cancellable != NULL)
                 g_object_unref (priv->cancellable);
+        if (priv->panel != NULL)
+                g_object_unref (priv->panel);
         G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
 }
 
@@ -307,6 +324,11 @@ net_object_class_init (NetObjectClass *klass)
                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
         g_object_class_install_property (object_class, PROP_CANCELLABLE, pspec);
 
+        pspec = g_param_spec_object ("panel", NULL, NULL,
+                                     CC_TYPE_NETWORK_PANEL,
+                                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+        g_object_class_install_property (object_class, PROP_PANEL, pspec);
+
         signals[SIGNAL_CHANGED] =
                 g_signal_new ("changed",
                               G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/panels/network/net-object.h b/panels/network/net-object.h
index 0b91e0c..fb3bb6b 100644
--- a/panels/network/net-object.h
+++ b/panels/network/net-object.h
@@ -27,6 +27,8 @@
 #include <nm-client.h>
 #include <nm-remote-settings.h>
 
+#include "cc-network-panel.h"
+
 G_BEGIN_DECLS
 
 #define NET_TYPE_OBJECT          (net_object_get_type ())
@@ -73,6 +75,7 @@ void             net_object_set_title                   (NetObject      *object,
 NMClient        *net_object_get_client                  (NetObject      *object);
 NMRemoteSettings *net_object_get_remote_settings        (NetObject      *object);
 GCancellable    *net_object_get_cancellable             (NetObject      *object);
+CcNetworkPanel  *net_object_get_panel                   (NetObject      *object);
 void             net_object_emit_changed                (NetObject      *object);
 void             net_object_emit_removed                (NetObject      *object);
 void             net_object_delete                      (NetObject      *object);



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