Merge lp:~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer into lp:~zeitgeist/zeitgeist-explorer/trunk
- zeitgeist-explorer
- Merge into trunk
Proposed by
dhananjaysathe
Status: | Merged |
---|---|
Merged at revision: | 19 |
Proposed branch: | lp:~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer |
Merge into: | lp:~zeitgeist/zeitgeist-explorer/trunk |
Diff against target: |
469 lines (+176/-76) 3 files modified
zgexplorer/eventwidgets.py (+99/-64) zgexplorer/filtermanager.py (+76/-11) zgexplorer/monitorviewer.py (+1/-1) |
To merge this branch: | bzr merge lp:~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zeitgeist Framework Team | Pending | ||
Review via email: mp+99166@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 19. By dhananjaysathe
-
Ability to add a custom filter
1) monitorviewr and perhaps top level window requires the ability to handle custom filter dict too
2) In event widgets , code generates event but a template from even is remainign , dummy semi functional functions added look through lines 270-300
3) Possible Gui tweaks (for eg > edit icon and stock icons in custom filters)Bug Fixes:
1) get_active_text workaround
2) Gio App info fixes
3) Multiple typo and bug fixes
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'zgexplorer/eventwidgets.py' |
2 | --- zgexplorer/eventwidgets.py 2012-03-23 08:07:17 +0000 |
3 | +++ zgexplorer/eventwidgets.py 2012-03-24 11:58:18 +0000 |
4 | @@ -27,32 +27,40 @@ |
5 | Interpretation, StorageState, Symbol, ResultType |
6 | from lookupdata import * |
7 | |
8 | +# workaround for Gtk ComboBoxText Widgets |
9 | +def get_active_text(combobox): |
10 | + model = combobox.get_model() |
11 | + active = combobox.get_active() |
12 | + if active < 0: |
13 | + return '' |
14 | + return model[active][0] |
15 | class TimeRangeViewer(Gtk.VBox): |
16 | - def __init__(self): |
17 | + def __init__(self,start_time=None,end_time=None): |
18 | super(TimeRangeViewer, self).__init__() |
19 | |
20 | timerange_label = Gtk.Label("Time Range",xalign=0 ,yalign=0.5) |
21 | self.pack_start(timerange_label,False,False,3) |
22 | |
23 | - self.always_radio = Gtk.RadioButton(label= "Always",margin_left= 12) |
24 | + self.always_radio = Gtk.RadioButton(label= "Always") |
25 | self.pack_start(self.always_radio,False,False,3) |
26 | self.always_radio.connect('toggled',self.update_sensitivity) |
27 | |
28 | - self.custom_radio = Gtk.RadioButton(label= "Custom",margin_left= 12) |
29 | + self.custom_radio = Gtk.RadioButton(label= "Custom") |
30 | self.custom_radio.join_group(self.always_radio) |
31 | self.pack_start(self.custom_radio,False,False,3) |
32 | |
33 | - enteries_box = Gtk.VBox(margin_left=14) |
34 | + enteries_box = Gtk.VBox() |
35 | + enteries_box.set_margin_left(14) |
36 | self.pack_start(enteries_box,False,False,3) |
37 | |
38 | - self.start_time = DatetimePicker() |
39 | - self.end_time = DatetimePicker() |
40 | + self.start_time = DatetimePicker(start_time) |
41 | + self.end_time = DatetimePicker(end_time) |
42 | self.start_time.update_sensitivity(False) |
43 | self.end_time.update_sensitivity(False) |
44 | |
45 | - enteries_box.pack_start(Gtk.Label('From :',xalign=0 ,yalign=0.5),False,False,1) |
46 | + enteries_box.pack_start(Gtk.Label('From :',xalign=0 ,yalign=0.5),False,False,0) |
47 | enteries_box.pack_start(self.start_time,False,False,1) |
48 | - enteries_box.pack_start(Gtk.Label('To :',xalign=0 ,yalign=0.5),False,False,1) |
49 | + enteries_box.pack_start(Gtk.Label('To :',xalign=0 ,yalign=0.5),False,False,0) |
50 | enteries_box.pack_start(self.end_time,False,False,1) |
51 | |
52 | def get_start_time(self): |
53 | @@ -71,14 +79,15 @@ |
54 | |
55 | |
56 | class DatetimePicker(Gtk.HBox): |
57 | - def __init__(self): |
58 | + def __init__(self,time): |
59 | super(DatetimePicker, self).__init__() |
60 | - time = datetime.now() |
61 | + if time is None: |
62 | + time = datetime.now() |
63 | |
64 | #date |
65 | date_holder = Gtk.HBox() |
66 | - self.pack_start(date_holder,False,False,6) |
67 | - date_holder.pack_start(Gtk.Label('DD|MM|YY :'),False,False,6) |
68 | + self.pack_start(date_holder,False,False,3) |
69 | + date_holder.pack_start(Gtk.Label('DD|MM|YY :'),False,False,3) |
70 | self.date_spin_day = Gtk.SpinButton(numeric=True) |
71 | self.date_spin_day.set_adjustment(Gtk.Adjustment(lower=1, |
72 | upper=32,page_size=1,step_increment=1,value=time.day)) |
73 | @@ -94,8 +103,8 @@ |
74 | |
75 | #time |
76 | time_holder = Gtk.HBox() |
77 | - self.pack_end(time_holder,False,False,6) |
78 | - time_holder.pack_start(Gtk.Label('HH:MM:SS '),False,False,6) |
79 | + self.pack_end(time_holder,False,False,3) |
80 | + time_holder.pack_start(Gtk.Label('HH:MM:SS '),False,False,3) |
81 | self.time_spin_hour = Gtk.SpinButton(numeric=True) |
82 | self.time_spin_hour.set_adjustment(Gtk.Adjustment(lower=0, |
83 | upper=24,page_size=1,step_increment=1,value=time.hour)) |
84 | @@ -112,12 +121,12 @@ |
85 | self.show_all() |
86 | |
87 | def get_datetime(self): |
88 | - return datetime(self.date_spin_year.get_valuea_as_int(), |
89 | - self.date_spin_month.get_valuea_as_int(), |
90 | - self.date_spin_day.get_valuea_as_int(), |
91 | - self.time_spin_hour.get_valuea_as_int(), |
92 | - self.time_spin_min.get_valuea_as_int(), |
93 | - self.time_spin_sec.get_valuea_as_int()) |
94 | + return datetime(self.date_spin_year.get_value_as_int(), |
95 | + self.date_spin_month.get_value_as_int(), |
96 | + self.date_spin_day.get_value_as_int(), |
97 | + self.time_spin_hour.get_value_as_int(), |
98 | + self.time_spin_min.get_value_as_int(), |
99 | + self.time_spin_sec.get_value_as_int()) |
100 | |
101 | def update_sensitivity(self,enable): |
102 | self.date_spin_year.set_sensitive(enable) |
103 | @@ -133,16 +142,11 @@ |
104 | |
105 | |
106 | class TemplateEditor(Gtk.Dialog): # NOTE: INCOMPLETE |
107 | - def __init__(self,event=None): |
108 | + def __init__(self,template=None): |
109 | super(TemplateEditor, self).__init__() |
110 | + self.set_template(template) |
111 | self.create() |
112 | - if event is None: |
113 | - self.event = Event() |
114 | - self.event.set_subjects(Subject()) |
115 | - self.edit_mode = False |
116 | - else : |
117 | - self.event = event |
118 | - self.edit_mode = True |
119 | + |
120 | |
121 | |
122 | def create(self): |
123 | @@ -152,7 +156,7 @@ |
124 | box= Gtk.VBox() |
125 | frame.add(box) |
126 | |
127 | - self.timerange = TimeRangeViewer() |
128 | + self.timerange = TimeRangeViewer(self.start_time,self.end_time) |
129 | box.pack_start(self.timerange,False,False,0) |
130 | |
131 | table = Gtk.Table(1,2,True) |
132 | @@ -186,7 +190,9 @@ |
133 | self.event_manifes_field.append_text(entry) |
134 | |
135 | actor_label = Gtk.Label("Actor :",xalign=0,yalign=0.5) |
136 | - self.actor_field = Gtk.Label("") |
137 | + self.actor_field = Gtk.Label() |
138 | + self.actor_field.set_justify(Gtk.Justification.LEFT) |
139 | + self.actor_field.set_line_wrap(True) |
140 | |
141 | actor_hbox = Gtk.HBox(margin_bottom=6) |
142 | |
143 | @@ -201,10 +207,8 @@ |
144 | actor_hbox.pack_start(self.actor_dropdown, False, False, 12) |
145 | self.actor_image = Gtk.Image() |
146 | self.actor_image.set_size_request(32, 32) |
147 | - frame = Gtk.Frame() |
148 | - frame.add(self.actor_image) |
149 | - actor_hbox.pack_start(frame, False, False, 12) |
150 | - self.actor_value = Gtk.Label() |
151 | + actor_hbox.pack_start(self.actor_image, False, False, 2) |
152 | + self.actor_value = Gtk.Label(xalign=0,yalign=0.5) |
153 | actor_hbox.pack_start(self.actor_value, False, False, 12) |
154 | |
155 | subj_label = Gtk.Label() |
156 | @@ -285,20 +289,22 @@ |
157 | |
158 | actor = self.event.get_actor() |
159 | self.actor_field.set_text(actor) |
160 | + self.actor_field.set_justify(Gtk.Justification.LEFT) |
161 | + self.actor_field.set_line_wrap(True) |
162 | if actor is not "" and actor.startswith("application://"): |
163 | actor = actor.replace("application://", "") |
164 | try: |
165 | app_info = Gio.DesktopAppInfo.new(actor) |
166 | - self.actor_dropdown.set_active(actor_dict.keys().index(app_info.get_name())) |
167 | + self.actor_dropdown.set_active(self.app_dict.keys().index(app_info.get_name())) |
168 | self.actor_value.set_text(app_info.get_display_name()) |
169 | - self.actor_image = Gtk.Image.new_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON) |
170 | + self.actor_image.set_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON) |
171 | |
172 | except TypeError: |
173 | print("Wrong actor string: %s" %(actor)) |
174 | else: |
175 | self.actor_value.set_text("") |
176 | |
177 | - sub = self.event.get_subjects() |
178 | + sub = self.event.get_subjects()[0] |
179 | |
180 | self.uri_field.set_text(sub.get_uri()) |
181 | self.curr_uri_field.set_text(sub.get_current_uri()) |
182 | @@ -315,19 +321,14 @@ |
183 | |
184 | def get_values(self): |
185 | |
186 | - ev_inter=self.event_inter_field.get_active_text() |
187 | - if ev_inter is None: |
188 | - ev_inter='' |
189 | + |
190 | + ev_inter=get_active_text(self.event_inter_field) |
191 | self.event.set_interpretation(event_interpretations[ev_inter]) |
192 | |
193 | - ev_manifes=self.event_manifes_field.get_active_text() |
194 | - if ev_manifes is None: |
195 | - ev_manifes='' |
196 | + ev_manifes=get_active_text(self.event_manifes_field) |
197 | self.event.set_manifestation(event_manifestations[ev_manifes]) |
198 | |
199 | - app=self.actor_dropdown.get_active_text() |
200 | - if app is None: |
201 | - app='' |
202 | + app=get_active_text(self.actor_dropdown) |
203 | self.event.set_actor(''.join([r"application://",self.app_dict[app]])) |
204 | |
205 | #subject |
206 | @@ -336,35 +337,65 @@ |
207 | sub.set_uri(self.uri_field.get_text().strip()) |
208 | sub.set_current_uri(self.curr_uri_field.get_text().strip()) |
209 | |
210 | - sub_inter=self.subj_inter_field.get_active_text() |
211 | - if sub_inter is None: |
212 | - sub_inter='' |
213 | + sub_inter= get_active_text(self.subj_inter_field) |
214 | sub.set_interpretation(subject_interpretations[sub_inter]) |
215 | |
216 | - sub_manifes=self.subj_manifes_field.get_active_text() |
217 | - if sub_manifes is None: |
218 | - sub_manifes='' |
219 | + sub_manifes = get_active_text(self.subj_manifes_field) |
220 | sub.set_manifestation(subject_manifestations[sub_manifes]) |
221 | |
222 | sub.set_origin(self.origin_field.get_text().strip()) |
223 | sub.set_mimetype(self.mimetype_field.get_text().strip()) |
224 | |
225 | - sub_stor=self.storage_field.get_active_text() |
226 | - if sub_stor is None: |
227 | - sub_stor='' |
228 | + sub_stor = get_active_text(self.storage_field) |
229 | sub.set_storage(storage_states[sub_stor]) |
230 | + |
231 | self.event.set_subjects(sub) |
232 | |
233 | def on_app_changed(self,widget): |
234 | - app=self.actor_dropdown.get_active_text() |
235 | - if app is None: |
236 | - app='' |
237 | - actor = self.app_dict[app] |
238 | - self.actor_field.set_text(''.join([r'application://',actor])) |
239 | - app_info = Gio.DesktopAppInfo.new(actor) |
240 | - self.actor_dropdown.set_active(actor_dict.keys().index(app_info.get_name())) |
241 | - self.actor_value.set_text(app_info.get_display_name()) |
242 | - self.actor_image = Gtk.Image.new_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON) |
243 | + app=get_active_text(self.actor_dropdown) |
244 | + try: |
245 | + actor = self.app_dict[app] |
246 | + self.actor_field.set_text(''.join([r'application://',actor])) |
247 | + self.actor_field.set_justify(Gtk.Justification.LEFT) |
248 | + self.actor_field.set_line_wrap(True) |
249 | + app_info = Gio.DesktopAppInfo.new(actor) |
250 | + self.actor_value.set_text(app_info.get_display_name()) |
251 | + self.actor_image.set_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON) |
252 | + except: |
253 | + print('DEBUG : Complete Application Info for %s not available',actor) |
254 | + self.actor_field.set_text('') |
255 | + self.actor_value.set_text('') |
256 | + self.actor_image.clear() |
257 | + |
258 | + def get_time_range(self): |
259 | + start = self.timerange.get_start_time() |
260 | + end = self.timerange.get_end_time() |
261 | + #TODO |
262 | + #return deltatime range in zeitgeist format?? |
263 | + |
264 | + def get_template(self): |
265 | + self.get_values() |
266 | + timerange = self.get_time_range() |
267 | + template = ['','',self.event,timerange,] |
268 | + template[2] = self.event |
269 | + # this ensure latest selections are taken before building the template |
270 | + #this function prepares a template from the Time range and |
271 | + # comment gui fields and self.event that has been stored |
272 | + return template |
273 | + |
274 | + def set_template(self,template): |
275 | + if template is None: |
276 | + |
277 | + self.event = Event() |
278 | + self.event.set_subjects(Subject()) |
279 | + self.start_time = None |
280 | + self.end_time = None |
281 | + self.edit_mode = False |
282 | + else : |
283 | + self.event = template[2] |
284 | + #self.start_time = |
285 | + #self.end_time = |
286 | + self.edit_mode = True |
287 | |
288 | |
289 | |
290 | @@ -474,6 +505,8 @@ |
291 | |
292 | actor = ev.get_actor() |
293 | self.actor_field.set_text(actor) |
294 | + self.actor_field.set_line_wrap(True) |
295 | + |
296 | if actor is not "" and actor.startswith("application://"): |
297 | actor = actor.replace("application://", "") |
298 | try: |
299 | @@ -491,6 +524,8 @@ |
300 | subj = ev.get_subjects()[0] |
301 | else: |
302 | subj = Subject() |
303 | + if type(subj) == str : |
304 | + subj = Subject() |
305 | |
306 | # Subject Interpretation |
307 | subj_inter = subj.get_interpretation() |
308 | |
309 | === modified file 'zgexplorer/filtermanager.py' |
310 | --- zgexplorer/filtermanager.py 2012-03-23 13:23:31 +0000 |
311 | +++ zgexplorer/filtermanager.py 2012-03-24 11:58:18 +0000 |
312 | @@ -23,7 +23,7 @@ |
313 | from gi.repository import Gtk, Pango |
314 | |
315 | from templates import BuiltInFilters |
316 | -from eventwidgets import TemplateViewer, TimeRangeViewer |
317 | +from eventwidgets import TemplateViewer, TimeRangeViewer, TemplateEditor |
318 | |
319 | class FilterManagerDialog(Gtk.Dialog): |
320 | |
321 | @@ -35,15 +35,20 @@ |
322 | self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) |
323 | self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) |
324 | self.set_size_request(600, 700) |
325 | + self.active_page_index = 0 |
326 | + self.is_predefined = True |
327 | |
328 | box = self.get_content_area() |
329 | |
330 | self.notebook = Gtk.Notebook() |
331 | + self.notebook.connect('switch-page',self.on_notebook_switch_page) |
332 | box.pack_start(self.notebook, True, True, 0) |
333 | |
334 | self.add_predefined_tab() |
335 | self.add_custom_tab() |
336 | |
337 | + self.custom_event_filters={} |
338 | + |
339 | box.show_all() |
340 | |
341 | def add_predefined_tab(self): |
342 | @@ -82,7 +87,7 @@ |
343 | self.custom_store = Gtk.ListStore(int, str) |
344 | |
345 | self.custom_view = Gtk.TreeView(model=self.custom_store) |
346 | - self.custom_view.connect("cursor-changed", self.on_custom_cursor_changed) |
347 | + self.custom_view.connect("cursor-changed", self.on_cursor_changed) |
348 | |
349 | column_pix_name = Gtk.TreeViewColumn(_('Name')) |
350 | self.custom_view.append_column(column_pix_name) |
351 | @@ -108,12 +113,17 @@ |
352 | |
353 | filter_add = Gtk.ToolButton.new(None, "Add Filter") |
354 | filter_add.set_icon_name("list-add-symbolic") |
355 | - #filter_add.connect("clicked", self.on_add_clicked) |
356 | + filter_add.connect("clicked", self.on_add_clicked) |
357 | self.toolbar.insert(filter_add, 0) |
358 | |
359 | + filter_edit = Gtk.ToolButton.new(None, "Edit Filter") |
360 | + filter_edit.set_icon_name("list-edit-symbolic") |
361 | + filter_edit.connect("clicked", self.on_edit_clicked) |
362 | + self.toolbar.insert(filter_edit, 0) |
363 | + |
364 | filter_remove = Gtk.ToolButton.new(None, "Remove Filter") |
365 | filter_remove.set_icon_name("list-remove-symbolic") |
366 | - #filter_remove.connect("clicked", self.on_remove_clicked) |
367 | + filter_remove.connect("clicked", self.on_remove_clicked) |
368 | self.toolbar.insert(filter_remove, 1) |
369 | |
370 | # See the Template values |
371 | @@ -122,7 +132,11 @@ |
372 | |
373 | |
374 | def get_selected_index(self): |
375 | - selection = self.predefined_view.get_selection() |
376 | + if self.is_predefined: |
377 | + selection = self.predefined_view.get_selection() |
378 | + else : |
379 | + selection = self.custom_view.get_selection() |
380 | + |
381 | model, _iter = selection.get_selected() |
382 | if _iter is not None: |
383 | app_index = model.get(_iter, 0) |
384 | @@ -132,16 +146,67 @@ |
385 | |
386 | def get_selected_entry(self): |
387 | index = self.get_selected_index() |
388 | - is_predefined = True |
389 | if index is not None: |
390 | - return index,self.builtin[index], is_predefined |
391 | + if self.is_predefined : |
392 | + return index,self.builtin[index], True |
393 | + else : |
394 | + return index,self.custom_event_filters[index], False |
395 | |
396 | return None |
397 | |
398 | + def on_notebook_switch_page(self, widget, page, page_num): |
399 | + self.is_predefined = not bool(page_num) |
400 | + |
401 | def on_cursor_changed(self, treeview): |
402 | index = self.get_selected_index() |
403 | if index is not None: |
404 | - self.predefined_viewer.set_values(self.builtin[index]) |
405 | - |
406 | - def on_custom_cursor_changed(self, treeview): |
407 | - pass |
408 | + if self.is_predefined : |
409 | + self.predefined_viewer.set_values(self.builtin[index]) |
410 | + else: |
411 | + self.custom_viewer.set_values(self.custom_event_filters[index]) |
412 | + |
413 | + |
414 | + def on_add_clicked(self,widget): |
415 | + template = self.run_template_add_edit_dialog() |
416 | + curr_size = len(self.custom_store) |
417 | + self.custom_store.append([curr_size, template[0]]) |
418 | + self.custom_event_filters[curr_size] = template |
419 | + |
420 | + def on_edit_clicked(self,widget): |
421 | + index,template = self.get_selected_entry() |
422 | + template = self.run_template_add_edit_dialog(template) |
423 | + self.custom_store[index] = template[0] |
424 | + self.custom_event_filters[index] = template |
425 | + |
426 | + def on_remove_clicked(self): |
427 | + index,template = self.get_selected_entry() |
428 | + for row in self.custom_store: |
429 | + if row[0] == index : |
430 | + self.custom_store.remove(row.iter) |
431 | + break |
432 | + del self.custom_event_filters[index] |
433 | + |
434 | + |
435 | + def run_template_add_edit_dialog(self,template=None): |
436 | + |
437 | + dialog = TemplateEditor(template) |
438 | + dialog.show_all() |
439 | + |
440 | + while True: |
441 | + response_id = dialog.run() |
442 | + if response_id in [Gtk.ResponseType.OK,Gtk.ResponseType.APPLY] : |
443 | + template = dialog.get_template() |
444 | + |
445 | + if response_id == Gtk.ResponseType.OK: |
446 | + dialog.hide() |
447 | + break |
448 | + |
449 | + else: |
450 | + dialog.hide() |
451 | + return None |
452 | + |
453 | + return template |
454 | + |
455 | + |
456 | + |
457 | + |
458 | |
459 | === modified file 'zgexplorer/monitorviewer.py' |
460 | --- zgexplorer/monitorviewer.py 2012-03-15 20:53:00 +0000 |
461 | +++ zgexplorer/monitorviewer.py 2012-03-24 11:58:18 +0000 |
462 | @@ -124,7 +124,7 @@ |
463 | self.show_all() |
464 | |
465 | def map(self, index, is_predefined): |
466 | - self.entry = self.builtin[index] if is_predefined else None |
467 | + self.entry = self.builtin[index] if is_predefined else self.custom_event_filters[index] |
468 | if self.entry is not None: |
469 | self.desc_entry.set_text(self.entry[1]) |
470 |