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

[Workman-devel] [PATCH 3/4] Add state property to WorkmanObject



Add the WorkmanState property to WorkmanObject.  Also remove get_state()
from the class struct since the subclasses won't override it.
---
 workman/workman-object.c | 21 +++++++++++++++++++--
 workman/workman-object.h |  3 ---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/workman/workman-object.c b/workman/workman-object.c
index 55aa7cf..11bf434 100644
--- a/workman/workman-object.c
+++ b/workman/workman-object.c
@@ -31,12 +31,14 @@ G_DEFINE_ABSTRACT_TYPE(WorkmanObject, workman_object, G_TYPE_OBJECT);
 
 struct _WorkmanObjectPrivate {
     gchar *name;
+    WorkmanState state;
 };
 
 
 enum {
     PROP_0,
     PROP_NAME,
+    PROP_STATE,
 };
 
 
@@ -53,6 +55,9 @@ workman_object_get_property(GObject *object,
         case PROP_NAME:
             g_value_set_string(value, self->priv->name);
             break;
+        case PROP_STATE:
+            g_value_set_uint(value, self->priv->state);
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
             break;
@@ -72,6 +77,9 @@ workman_object_set_property(GObject *object,
         case PROP_NAME:
             self->priv->name = g_value_dup_string(value);
             break;
+        case PROP_STATE:
+            self->priv->state = g_value_get_uint(value);
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
             break;
@@ -109,6 +117,16 @@ workman_object_class_init(WorkmanObjectClass *klass)
                                 G_PARAM_STATIC_STRINGS);
     g_object_class_install_property(g_klass, PROP_NAME, pspec);
 
+    pspec = g_param_spec_uint("state",
+                              "State",
+                              "The object's WorkmanState",
+                              0,
+                              G_MAXUINT,
+                              0,
+                              G_PARAM_READWRITE |
+                              G_PARAM_CONSTRUCT_ONLY |
+                              G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(g_klass, PROP_STATE, pspec);
 
     g_type_class_add_private(klass, sizeof(WorkmanObjectPrivate));
 }
@@ -178,8 +196,7 @@ gboolean workman_object_save_attributes(WorkmanObject *obj,
 WorkmanState workman_object_get_state(WorkmanObject *self,
                                       GError **error)
 {
-    WorkmanObjectClass *obj_class = WORKMAN_OBJECT_GET_CLASS(self);
-    return obj_class->get_state(self, error);
+    return self->priv->state;
 }
 
 
diff --git a/workman/workman-object.h b/workman/workman-object.h
index f939e58..7754783 100644
--- a/workman/workman-object.h
+++ b/workman/workman-object.h
@@ -74,9 +74,6 @@ struct _WorkmanObjectClass
                                 WorkmanState state,
                                 GError **error);
 
-    WorkmanState (*get_state)(WorkmanObject *self,
-                              GError **error);
-
 
     /* Remove from padding when adding new virtual functions */
     gpointer padding[20];
-- 
1.7.11.7


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