~azzar1/unity/lp-1226116

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/Introspectable.h

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
MergedĀ latestĀ lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#ifndef _INTROSPECTABLE_H
21
 
#define _INTROSPECTABLE_H 1
 
21
#define _INTROSPECTABLE_H
22
22
 
23
23
#include <glib.h>
24
24
#include <list>
30
30
{
31
31
class Introspectable
32
32
{
33
 
typedef std::list<Introspectable*> IntrospectableList;
34
 
 
35
33
public:
 
34
  typedef std::list<Introspectable*> IntrospectableList;
 
35
  
36
36
  Introspectable();
37
37
  virtual ~Introspectable();
38
38
  GVariant* Introspect();
39
39
  virtual std::string GetName() const = 0;
40
40
  void AddChild(Introspectable* child);
41
41
  void RemoveChild(Introspectable* child);
42
 
  IntrospectableList const& GetIntrospectableChildren() { return _children; };
43
42
  virtual void AddProperties(GVariantBuilder* builder) = 0;
44
 
  
 
43
  virtual IntrospectableList const& GetIntrospectableChildren();
 
44
  guint64 GetIntrospectionId() const;
 
45
 
45
46
protected:
 
47
  /// Please don't override this unless you really need to. The only valid reason
 
48
  /// is if you have a property that simply *must* be called 'Children'.
46
49
  virtual std::string GetChildsName() const;
47
 
  
48
50
 
49
51
  /*
50
52
   * AddProperties should be implemented as such ...
51
53
   * void ClassFoo::AddProperties (GVariantBuilder *builder)
52
54
   * {
53
 
   *  g_variant_builder_add (builder, "{sv}", "label", g_variant_new_string ("_File") );
54
 
   *  g_variant_builder_add (builder, "{sv}", "image", g_variant_new_string ("") );
55
 
   *  g_variant_builder_add (builder, "{sv}", "visible", g_variant_new_boolean (TRUE) );
56
 
   *    g_variant_builder_add (builder, "{sv}", "sensitive", g_variant_new_boolean (TRUE) );
57
 
   *    g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (FALSE) );
58
 
   *    g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (34) );
59
 
   *    g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (24) );
 
55
   *  unity::variant::BuilderWrapper wrapper(builder);
 
56
   *  wrapper.add("label", some_value);
60
57
   * }
61
58
   * That's all. Just add a bunch of key-value properties to the builder.
62
59
   */
64
61
private:
65
62
  std::list<Introspectable*> _children;
66
63
  std::list<Introspectable*> _parents;
 
64
  guint64 _id;
67
65
};
68
66
}
69
67
}