Merge lp:~pitti/autopilot-gtk/gtktextbuffer into lp:autopilot-gtk

Proposed by Martin Pitt
Status: Merged
Approved by: Francis Ginther
Approved revision: 51
Merged at revision: 51
Proposed branch: lp:~pitti/autopilot-gtk/gtktextbuffer
Merge into: lp:autopilot-gtk
Diff against target: 86 lines (+55/-0)
3 files modified
lib/GtkNode.cpp (+19/-0)
tests/autopilot/tests/test_properties.py (+15/-0)
tests/hello_color.ui (+21/-0)
To merge this branch: bzr merge lp:~pitti/autopilot-gtk/gtktextbuffer
Reviewer Review Type Date Requested Status
Francis Ginther Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+171752@code.launchpad.net

Commit message

Support GtkTextBuffer properties, to introspect GtkTextView contents.

Description of the change

This adds support for GtkTextBuffer property types, most importantly to
introspect GtkTextView.buffer properties.

To post a comment you must log in.
51. By Martin Pitt

fix memory leak in previous commit

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Revied and tested. All looks good. Confirmed that test case failed without lib update.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/GtkNode.cpp'
--- lib/GtkNode.cpp 2013-06-27 07:16:45 +0000
+++ lib/GtkNode.cpp 2013-06-27 09:47:28 +0000
@@ -65,6 +65,25 @@
65 g_value_init(value, G_TYPE_UINT);65 g_value_init(value, G_TYPE_UINT);
66 g_value_set_uint(value, flags);66 g_value_set_uint(value, flags);
67 }67 }
68
69 if (pspec->value_type == GTK_TYPE_TEXT_BUFFER) {
70 GtkTextBuffer *buf = GTK_TEXT_BUFFER(g_value_get_object(value));
71 if (buf != NULL) {
72 //g_debug("attribute %s of type %s holds GtkTextBuffer", g_param_spec_get_name(pspec),
73 // g_type_name(pspec->value_type));
74 GtkTextIter start, end;
75 gtk_text_buffer_get_start_iter(buf, &start);
76 gtk_text_buffer_get_end_iter(buf, &end);
77 gchar* text = gtk_text_iter_get_text(&start, &end);
78
79 g_value_unset(value);
80 *value = G_VALUE_INIT;
81 g_value_init(value, G_TYPE_STRING);
82 g_value_set_string(value, (text != NULL) ? text : "");
83
84 g_free(text);
85 }
86 }
68}87}
6988
70GVariant* GtkNode::Introspect() const89GVariant* GtkNode::Introspect() const
7190
=== modified file 'tests/autopilot/tests/test_properties.py'
--- tests/autopilot/tests/test_properties.py 2013-06-27 06:07:01 +0000
+++ tests/autopilot/tests/test_properties.py 2013-06-27 09:47:28 +0000
@@ -121,3 +121,18 @@
121121
122 res = self.app.select_many('GtkButton', events=btn_greet.events)122 res = self.app.select_many('GtkButton', events=btn_greet.events)
123 self.assertGreater(len(res), 0)123 self.assertGreater(len(res), 0)
124
125 def test_textview_properties(self):
126 """GtkTextView properties"""
127
128 t = self.app.select_single(BuilderName='textview_demo')
129 self.assertNotEqual(t, None)
130 self.assertEqual(t.editable, True)
131 self.assertEqual(t.overwrite, False)
132 # the buffer property points to a GtkTextBuffer object, which we want
133 # to translate to a plain string
134 self.assertEqual(t.buffer, 'This is a test application.')
135
136 # select by buffer contents
137 w = self.app.select_single(buffer='This is a test application.')
138 self.assertEqual(w.BuilderName, 'textview_demo')
124139
=== modified file 'tests/hello_color.ui'
--- tests/hello_color.ui 2013-06-25 10:39:16 +0000
+++ tests/hello_color.ui 2013-06-27 09:47:28 +0000
@@ -10,8 +10,29 @@
10 <property name="authors">Martin Pitt</property>10 <property name="authors">Martin Pitt</property>
11 <property name="license_type">gpl-3-0</property>11 <property name="license_type">gpl-3-0</property>
12 </object>12 </object>
13 <object class="GtkWindow" id="window_textview">
14 <property name="can_focus">False</property>
15 <property name="title" translatable="yes">TextView Demo</property>
16 <child>
17 <object class="GtkScrolledWindow" id="scrolledwindow1">
18 <property name="visible">True</property>
19 <property name="can_focus">False</property>
20 <child>
21 <object class="GtkTextView" id="textview_demo">
22 <property name="visible">True</property>
23 <property name="can_focus">False</property>
24 <property name="buffer">textbuffer_demo</property>
25 </object>
26 </child>
27 </object>
28 </child>
29 </object>
30 <object class="GtkTextBuffer" id="textbuffer_demo">
31 <property name="text">This is a test application.</property>
32 </object>
13 <object class="GtkWindow" id="window_app">33 <object class="GtkWindow" id="window_app">
14 <property name="can_focus">False</property>34 <property name="can_focus">False</property>
35 <property name="title" translatable="yes">Hello Color</property>
15 <signal name="destroy" handler="on_quit" swapped="no"/>36 <signal name="destroy" handler="on_quit" swapped="no"/>
16 <child>37 <child>
17 <object class="GtkBox" id="box1">38 <object class="GtkBox" id="box1">

Subscribers

People subscribed via source and target branches

to all changes: