~azzar1/unity/lp-1226116

« back to all changes in this revision

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

  • 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:
26
26
 
27
27
Introspectable::Introspectable()
28
28
{
 
29
  static guint64 unique_id=0;
 
30
  _id = unique_id++;
29
31
}
30
32
 
31
33
Introspectable::~Introspectable()
32
34
{
33
35
  for (auto parent : _parents)
34
36
    parent->_children.remove(this);
 
37
  for (auto child : _children)
 
38
    child->_parents.remove(this);
 
39
}
 
40
 
 
41
Introspectable::IntrospectableList const& Introspectable::GetIntrospectableChildren()
 
42
{
 
43
  return _children;
35
44
}
36
45
 
37
46
GVariant*
42
51
  gint             n_children = 0;
43
52
 
44
53
  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
 
54
  g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id));
45
55
 
46
56
  AddProperties(&builder);
47
57
 
48
58
  g_variant_builder_init(&child_builder, G_VARIANT_TYPE("a(sv)"));
49
59
 
50
 
  for (auto it = _children.begin(); it != _children.end(); it++)
 
60
  auto children = GetIntrospectableChildren();
 
61
  for (auto it = children.begin(); it != children.end(); it++)
51
62
  {
52
63
    if ((*it)->GetName() != "")
53
64
    {
57
68
  }
58
69
 
59
70
  GVariant* child_results = g_variant_builder_end(&child_builder);
60
 
  
 
71
 
61
72
  if (n_children > 0)
62
73
    g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results);
63
74
  return g_variant_builder_end(&builder);
82
93
{
83
94
  return "Children";
84
95
}
85
 
}
86
 
}
 
96
 
 
97
guint64 Introspectable::GetIntrospectionId() const
 
98
{
 
99
  return _id;
 
100
}
 
101
 
 
102
}
 
103
}
 
104