~autopilot/autopilot-gtk/1.3-add-GetPath

« back to all changes in this revision

Viewing changes to lib/GtkNode.cpp

  • Committer: Tarmac
  • Author(s): Thomi Richards
  • Date: 2013-01-30 21:11:02 UTC
  • mfrom: (20.1.2 trunk)
  • Revision ID: tarmac-20130130211102-yst22z6bwl4kq35v
Various c++ and whitespace fixes.

Approved by Allan LeSage, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
const std::string GtkNode::AP_ID_NAME = "id";
28
28
 
29
 
 
30
29
GtkNode::GtkNode(GObject* obj)
31
30
  : object_(obj) {
32
31
}
33
32
 
34
 
 
35
33
GVariant* GtkNode::Introspect() const
36
34
{
37
35
  GVariantBuilder builder;
38
36
  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
39
37
 
40
38
  // add a GVariant of all our properties
41
 
  GObjectClass* klass = G_OBJECT_GET_CLASS(object_);
42
 
  GParamSpec** properties;
43
39
  guint length;
44
 
  properties = g_object_class_list_properties(klass, &length);
45
 
  variant::BuilderWrapper builder_wrapper = variant::BuilderWrapper(&builder);
46
 
  for (uint i = 0; i < length; i++) {
 
40
  GParamSpec** properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(object_), &length);
 
41
  variant::BuilderWrapper builder_wrapper(&builder);
 
42
  for (uint i = 0; i < length; ++i) {
47
43
    GParamSpec* param_spec = properties[i];
48
44
    // see Launchpad bug #1108155: GtkTreePath mis-casts while copying, actuates here in "root" property
49
45
    if (std::string(g_type_name(param_spec->value_type)) != "GtkTreePath") {
83
79
  return g_variant_builder_end(&builder);
84
80
}
85
81
 
86
 
 
87
82
GVariant* GtkNode::ComposeRectVariant(gint x, gint y, gint height, gint width) const
88
83
{
89
84
  g_debug("composing a rect variant");
96
91
  return g_variant_builder_end(&builder);
97
92
}
98
93
 
99
 
 
100
94
intptr_t GtkNode::GetObjectId() const {
101
95
  return reinterpret_cast<intptr_t>(object_);
102
96
}
103
97
 
104
 
 
105
 
 
106
98
void GtkNode::GetGlobalRect(GdkRectangle* rect) const
107
99
{
108
 
  GtkWidget *widget = GTK_WIDGET (object_);
 
100
  GtkWidget *widget = GTK_WIDGET(object_);
109
101
  GdkWindow *gdk_window = gtk_widget_get_window(widget);
110
102
  GtkAllocation allocation;
111
103
  gint x, y;
124
116
  return;
125
117
}
126
118
 
127
 
 
128
119
std::string GtkNode::GetName() const {
129
120
  // autopilot uses the name of the GObject type
130
121
  return G_OBJECT_TYPE_NAME(object_);
131
122
}
132
123
 
133
 
 
134
124
bool GtkNode::MatchProperty(const std::string& name,
135
125
                            const std::string& value) const {
136
126
  g_debug("attempting to match a node's property");
155
145
  }
156
146
}
157
147
 
158
 
 
159
148
xpathselect::NodeList GtkNode::Children() const {
160
149
  g_debug("getting the children of a node");
161
150
  xpathselect::NodeList children;
162
151
  if (GTK_IS_CONTAINER(object_)) {
163
152
    GList* gtk_children = gtk_container_get_children(GTK_CONTAINER(object_));
164
 
    GList* elem;
165
 
    for (elem = gtk_children; elem; elem = elem->next) {
166
 
      GtkNode node = GtkNode(G_OBJECT(elem->data));
167
 
      children.push_back(std::make_shared<GtkNode>(node));
 
153
    for (GList* elem = gtk_children; elem; elem = elem->next) {
 
154
      children.push_back(std::make_shared<GtkNode>(G_OBJECT(elem->data)));
168
155
    }
169
156
    g_list_free(gtk_children);
170
157
  }
171
 
  
 
158
 
172
159
  return children;
173
160
}
174
161
 
175
 
 
176
162
GVariant* GtkNode::GetChildNodeNames() const {
177
163
  g_debug("getting the names of a node's children");
178
164
  GVariantBuilder builder;
179
165
  g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY);
180
 
  for (std::shared_ptr<xpathselect::Node> child : Children()) {
 
166
  for (xpathselect::Node::Ptr child : Children()) {
181
167
    g_variant_builder_add(&builder, "s", child->GetName().c_str());
182
168
  }
183
169
  return g_variant_builder_end(&builder);