[gnome-control-center] network: Add a GCancellable property to NetObject for future use



commit b48fc1b65c5781a4da1fe51941d02daa2c9abc9a
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 16 17:14:01 2012 +0100

    network: Add a GCancellable property to NetObject for future use

 panels/network/net-object.c |   23 ++++++++++++++++++++++-
 panels/network/net-object.h |    1 +
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index b501d6c..dba6b23 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -33,6 +33,7 @@ struct _NetObjectPrivate
         gchar                           *id;
         gchar                           *title;
         gboolean                         removable;
+        GCancellable                    *cancellable;
         NMClient                        *client;
 };
 
@@ -42,6 +43,7 @@ enum {
         PROP_TITLE,
         PROP_REMOVABLE,
         PROP_CLIENT,
+        PROP_CANCELLABLE,
         PROP_LAST
 };
 
@@ -126,6 +128,13 @@ net_object_set_client (NetObject *object, NMClient *client)
         object->priv->client = g_object_ref (client);
 }
 
+GCancellable *
+net_object_get_cancellable (NetObject *object)
+{
+        g_return_val_if_fail (NET_IS_OBJECT (object), NULL);
+        return object->priv->cancellable;
+}
+
 GtkWidget *
 net_object_add_to_notebook (NetObject *object,
                             GtkNotebook *notebook,
@@ -187,6 +196,9 @@ net_object_get_property (GObject *object_,
         case PROP_CLIENT:
                 g_value_set_object (value, priv->client);
                 break;
+        case PROP_CANCELLABLE:
+                g_value_set_object (value, priv->cancellable);
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -222,6 +234,9 @@ net_object_set_property (GObject *object_,
                         g_object_unref (priv->client);
                 priv->client = g_object_ref (g_value_get_object (value));
                 break;
+        case PROP_CANCELLABLE:
+                priv->cancellable = g_value_dup_object (value);
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -238,7 +253,8 @@ net_object_finalize (GObject *object)
         g_free (priv->title);
         if (priv->client != NULL)
                 g_object_unref (priv->client);
-
+        if (priv->cancellable != NULL)
+                g_object_unref (priv->cancellable);
         G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
 }
 
@@ -271,6 +287,11 @@ net_object_class_init (NetObjectClass *klass)
                                      G_PARAM_READWRITE);
         g_object_class_install_property (object_class, PROP_CLIENT, pspec);
 
+        pspec = g_param_spec_object ("cancellable", NULL, NULL,
+                                     G_TYPE_CANCELLABLE,
+                                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+        g_object_class_install_property (object_class, PROP_CANCELLABLE, 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 06499d1..b4b9967 100644
--- a/panels/network/net-object.h
+++ b/panels/network/net-object.h
@@ -72,6 +72,7 @@ void             net_object_set_title                   (NetObject      *object,
 NMClient        *net_object_get_client                  (NetObject      *object);
 void             net_object_set_client                  (NetObject      *object,
                                                          NMClient       *client);
+GCancellable    *net_object_get_cancellable             (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]