Merge lp:~bregma/geis/geisview-class-display into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 167
Proposed branch: lp:~bregma/geis/geisview-class-display
Merge into: lp:geis
Diff against target: 203 lines (+89/-1)
6 files modified
python/geis/geis_v2.py (+8/-0)
tools/geisview/Makefile.am (+1/-0)
tools/geisview/classview.py (+53/-0)
tools/geisview/deviceview.py (+1/-1)
tools/geisview/geisview (+9/-0)
tools/geisview/geisview.ui (+17/-0)
To merge this branch: bzr merge lp:~bregma/geis/geisview-class-display
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
Review via email: mp+66619@code.launchpad.net

Description of the change

Displays the frame's class(es) in the geisview tool.

To post a comment you must log in.
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Looking good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'python/geis/geis_v2.py'
2--- python/geis/geis_v2.py 2011-05-27 15:35:07 +0000
3+++ python/geis/geis_v2.py 2011-07-01 14:44:36 +0000
4@@ -121,6 +121,7 @@
5 _geis_frame_attr_count = _geis_lib.geis_frame_attr_count
6 _geis_frame_attr = _geis_lib.geis_frame_attr
7 _geis_frame_attr.restype = ctypes.c_void_p
8+ _geis_frame_is_class = _geis_lib.geis_frame_is_class
9 _geis_frame_touchid_count = _geis_lib.geis_frame_touchid_count
10 _geis_frame_touchid = _geis_lib.geis_frame_touchid
11
12@@ -145,6 +146,10 @@
13 self._attrs[attr_name] = _attr_types.get(_geis_attr_type(attr),
14 _attr_type_unknown)(attr)
15
16+ @property
17+ def _as_parameter_(self):
18+ return self._class
19+
20 def id(self):
21 """ Gets the gesture class's system identifier (an integer).
22 """
23@@ -329,6 +334,9 @@
24 _attr_type_unknown)(attr)
25 return attr_list
26
27+ def is_class(self, gclass):
28+ return _geis_frame_is_class(self._frame, gclass)
29+
30 def touches(self):
31 touch_list = []
32 for i in range(_geis_frame_touchid_count(self._frame)):
33
34=== modified file 'tools/geisview/Makefile.am'
35--- tools/geisview/Makefile.am 2011-04-27 14:19:58 +0000
36+++ tools/geisview/Makefile.am 2011-07-01 14:44:36 +0000
37@@ -30,6 +30,7 @@
38
39 geisview_PYTHON = \
40 __init__.py \
41+ classview.py \
42 defaults.py \
43 deviceview.py \
44 filter_definition.py \
45
46=== added file 'tools/geisview/classview.py'
47--- tools/geisview/classview.py 1970-01-01 00:00:00 +0000
48+++ tools/geisview/classview.py 2011-07-01 14:44:36 +0000
49@@ -0,0 +1,53 @@
50+#
51+# @file geisview/gesture_classview.py
52+# @brief GestureClass viewer for geisview.
53+#
54+# Copyright (C) 2011 Canonical Ltd
55+#
56+# This program is free software; you can redistribute it and/or modify
57+# it under the terms of the GNU General Public License as published by
58+# the Free Software Foundation; either version 3 of the License, or
59+# (at your option) any later version.
60+#
61+# This program is distributed in the hope that it will be useful,
62+# but WITHOUT ANY WARRANTY; without even the implied warranty of
63+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+# GNU General Public License for more details.
65+#
66+# You should have received a copy of the GNU General Public License
67+# along with this program. If not, see <http://www.gnu.org/licenses/>.
68+#
69+
70+import pygtk
71+pygtk.require('2.0')
72+import gtk
73+
74+class GestureClassView(gtk.Window):
75+
76+ def __init__(self, gesture_classes):
77+ gtk.Window.__init__(self)
78+ self.set_title("GEIS GestureClasss")
79+ self.set_size_request(200, 200)
80+
81+ self._tree_store = gtk.TreeStore(str, str)
82+ for (class_id, gclass) in gesture_classes.iteritems():
83+ it = self._tree_store.append(None, ["%s" % gclass.id(),
84+ "%s" % gclass.name()])
85+ self._tree_view = gtk.TreeView(self._tree_store)
86+# self._tree_view.set_mode(gtk.SELECTION_SINGLE)
87+
88+ cell = gtk.CellRendererText()
89+ col = gtk.TreeViewColumn('ID')
90+ col.pack_start(cell, True)
91+ col.add_attribute(cell, 'text', 0)
92+ self._tree_view.append_column(col)
93+
94+ cell = gtk.CellRendererText()
95+ col = gtk.TreeViewColumn('Name')
96+ col.pack_start(cell, True)
97+ col.add_attribute(cell, 'text', 1)
98+ self._tree_view.append_column(col)
99+
100+ self.add(self._tree_view)
101+ self.show_all()
102+
103
104=== modified file 'tools/geisview/deviceview.py'
105--- tools/geisview/deviceview.py 2011-05-18 13:32:13 +0000
106+++ tools/geisview/deviceview.py 2011-07-01 14:44:36 +0000
107@@ -34,7 +34,7 @@
108 for device in devices:
109 it = self._tree_store.append(None, ["%s" % device])
110 self._tree_view = gtk.TreeView(self._tree_store)
111- self._tree_view.set_mode(gtk.SELECTION_SINGLE)
112+# self._tree_view.set_mode(gtk.SELECTION_SINGLE)
113 cell = gtk.CellRendererText()
114 col = gtk.TreeViewColumn('Label')
115 col.pack_start(cell, True)
116
117=== modified file 'tools/geisview/geisview'
118--- tools/geisview/geisview 2011-05-22 01:00:44 +0000
119+++ tools/geisview/geisview 2011-07-01 14:44:36 +0000
120@@ -25,6 +25,7 @@
121 import argparse
122 import geis
123 import geisview.defaults
124+import geisview.classview
125 import geisview.deviceview
126 import geisview.filter_list
127 from gettext import gettext as _
128@@ -58,6 +59,7 @@
129 geis_fd = self._geis.get_configuration(geis.GEIS_CONFIGURATION_FD)
130 glib.io_add_watch(geis_fd, glib.IO_IN, self._dispatch_geis_events)
131
132+ self._classes = {}
133 self._devices = {}
134
135 self._sub = geis.Subscription(self._geis)
136@@ -81,6 +83,9 @@
137 filter_list_dialog = geisview.filter_list.FilterList()
138 filter_list_dialog.run()
139
140+ def on_view_classes_menu_item_activate(self, widget, data=None):
141+ class_view = geisview.classview.GestureClassView(self._classes)
142+
143 def on_view_device_menu_item_activate(self, widget, data=None):
144 device_view = geisview.deviceview.DeviceView(self._devices)
145
146@@ -116,11 +121,14 @@
147 """
148 frame_label = _("frame: %i") % frame.id()
149 touch_label = _("touch indexes %s") % frame.touches()
150+ class_label = _("classes: %s") % [gc.name() for gc in
151+ filter(frame.is_class, self._classes.itervalues())]
152
153 dev = None
154
155 frame_row = self._geis_event_store.append(group_row)
156 self._geis_event_store.set(frame_row, 0, frame_label)
157+ self._geis_event_store.append(frame_row, [class_label, None, None])
158 for (k, v) in frame.attrs().iteritems():
159 row = self._geis_event_store.append(frame_row)
160 self._geis_event_store.set(row, 0, "%s: %s" % (k, v))
161@@ -173,6 +181,7 @@
162 def _do_class_added(self, event):
163 gclass = event.attrs()[geis.GEIS_EVENT_ATTRIBUTE_CLASS]
164 it = self._geis_event_store.append(None)
165+ self._classes[gclass.id()] = gclass
166 self._geis_event_store.set(it,
167 0, _("Class %s Added: %s") % (gclass.id(), gclass.name()))
168 self._detail_gesture_class(it, gclass)
169
170=== modified file 'tools/geisview/geisview.ui'
171--- tools/geisview/geisview.ui 2011-04-27 14:19:58 +0000
172+++ tools/geisview/geisview.ui 2011-07-01 14:44:36 +0000
173@@ -25,6 +25,11 @@
174 <property name="can_focus">False</property>
175 <property name="stock">gtk-missing-image</property>
176 </object>
177+ <object class="GtkImage" id="image2">
178+ <property name="visible">True</property>
179+ <property name="can_focus">False</property>
180+ <property name="stock">gtk-missing-image</property>
181+ </object>
182 <object class="GtkWindow" id="main_window">
183 <property name="can_focus">False</property>
184 <property name="default_width">480</property>
185@@ -212,6 +217,18 @@
186 <signal name="activate" handler="on_view_device_menu_item_activate" swapped="no"/>
187 </object>
188 </child>
189+ <child>
190+ <object class="GtkImageMenuItem" id="view_classes_menu_item">
191+ <property name="label" translatable="yes">Show _Classes</property>
192+ <property name="visible">True</property>
193+ <property name="can_focus">False</property>
194+ <property name="use_action_appearance">False</property>
195+ <property name="use_underline">True</property>
196+ <property name="image">image2</property>
197+ <property name="use_stock">False</property>
198+ <signal name="activate" handler="on_view_classes_menu_item_activate" swapped="no"/>
199+ </object>
200+ </child>
201 </object>
202 </child>
203 </object>

Subscribers

People subscribed via source and target branches