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
1=== modified file 'lib/GtkNode.cpp'
2--- lib/GtkNode.cpp 2013-06-27 07:16:45 +0000
3+++ lib/GtkNode.cpp 2013-06-27 09:47:28 +0000
4@@ -65,6 +65,25 @@
5 g_value_init(value, G_TYPE_UINT);
6 g_value_set_uint(value, flags);
7 }
8+
9+ if (pspec->value_type == GTK_TYPE_TEXT_BUFFER) {
10+ GtkTextBuffer *buf = GTK_TEXT_BUFFER(g_value_get_object(value));
11+ if (buf != NULL) {
12+ //g_debug("attribute %s of type %s holds GtkTextBuffer", g_param_spec_get_name(pspec),
13+ // g_type_name(pspec->value_type));
14+ GtkTextIter start, end;
15+ gtk_text_buffer_get_start_iter(buf, &start);
16+ gtk_text_buffer_get_end_iter(buf, &end);
17+ gchar* text = gtk_text_iter_get_text(&start, &end);
18+
19+ g_value_unset(value);
20+ *value = G_VALUE_INIT;
21+ g_value_init(value, G_TYPE_STRING);
22+ g_value_set_string(value, (text != NULL) ? text : "");
23+
24+ g_free(text);
25+ }
26+ }
27 }
28
29 GVariant* GtkNode::Introspect() const
30
31=== modified file 'tests/autopilot/tests/test_properties.py'
32--- tests/autopilot/tests/test_properties.py 2013-06-27 06:07:01 +0000
33+++ tests/autopilot/tests/test_properties.py 2013-06-27 09:47:28 +0000
34@@ -121,3 +121,18 @@
35
36 res = self.app.select_many('GtkButton', events=btn_greet.events)
37 self.assertGreater(len(res), 0)
38+
39+ def test_textview_properties(self):
40+ """GtkTextView properties"""
41+
42+ t = self.app.select_single(BuilderName='textview_demo')
43+ self.assertNotEqual(t, None)
44+ self.assertEqual(t.editable, True)
45+ self.assertEqual(t.overwrite, False)
46+ # the buffer property points to a GtkTextBuffer object, which we want
47+ # to translate to a plain string
48+ self.assertEqual(t.buffer, 'This is a test application.')
49+
50+ # select by buffer contents
51+ w = self.app.select_single(buffer='This is a test application.')
52+ self.assertEqual(w.BuilderName, 'textview_demo')
53
54=== modified file 'tests/hello_color.ui'
55--- tests/hello_color.ui 2013-06-25 10:39:16 +0000
56+++ tests/hello_color.ui 2013-06-27 09:47:28 +0000
57@@ -10,8 +10,29 @@
58 <property name="authors">Martin Pitt</property>
59 <property name="license_type">gpl-3-0</property>
60 </object>
61+ <object class="GtkWindow" id="window_textview">
62+ <property name="can_focus">False</property>
63+ <property name="title" translatable="yes">TextView Demo</property>
64+ <child>
65+ <object class="GtkScrolledWindow" id="scrolledwindow1">
66+ <property name="visible">True</property>
67+ <property name="can_focus">False</property>
68+ <child>
69+ <object class="GtkTextView" id="textview_demo">
70+ <property name="visible">True</property>
71+ <property name="can_focus">False</property>
72+ <property name="buffer">textbuffer_demo</property>
73+ </object>
74+ </child>
75+ </object>
76+ </child>
77+ </object>
78+ <object class="GtkTextBuffer" id="textbuffer_demo">
79+ <property name="text">This is a test application.</property>
80+ </object>
81 <object class="GtkWindow" id="window_app">
82 <property name="can_focus">False</property>
83+ <property name="title" translatable="yes">Hello Color</property>
84 <signal name="destroy" handler="on_quit" swapped="no"/>
85 <child>
86 <object class="GtkBox" id="box1">

Subscribers

People subscribed via source and target branches

to all changes: