zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #05281
[Merge] lp:~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer into lp:zeitgeist-explorer
dhananjaysathe has proposed merging lp:~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer into lp:zeitgeist-explorer.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
For more details, see:
https://code.launchpad.net/~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer/+merge/99166
--
https://code.launchpad.net/~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer/+merge/99166
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~dhananjaysathe/zeitgeist-explorer/zeitgeist-explorer into lp:zeitgeist-explorer.
=== modified file 'zgexplorer/eventwidgets.py'
--- zgexplorer/eventwidgets.py 2012-03-23 08:07:17 +0000
+++ zgexplorer/eventwidgets.py 2012-03-24 11:58:18 +0000
@@ -27,32 +27,40 @@
Interpretation, StorageState, Symbol, ResultType
from lookupdata import *
+# workaround for Gtk ComboBoxText Widgets
+def get_active_text(combobox):
+ model = combobox.get_model()
+ active = combobox.get_active()
+ if active < 0:
+ return ''
+ return model[active][0]
class TimeRangeViewer(Gtk.VBox):
- def __init__(self):
+ def __init__(self,start_time=None,end_time=None):
super(TimeRangeViewer, self).__init__()
timerange_label = Gtk.Label("Time Range",xalign=0 ,yalign=0.5)
self.pack_start(timerange_label,False,False,3)
- self.always_radio = Gtk.RadioButton(label= "Always",margin_left= 12)
+ self.always_radio = Gtk.RadioButton(label= "Always")
self.pack_start(self.always_radio,False,False,3)
self.always_radio.connect('toggled',self.update_sensitivity)
- self.custom_radio = Gtk.RadioButton(label= "Custom",margin_left= 12)
+ self.custom_radio = Gtk.RadioButton(label= "Custom")
self.custom_radio.join_group(self.always_radio)
self.pack_start(self.custom_radio,False,False,3)
- enteries_box = Gtk.VBox(margin_left=14)
+ enteries_box = Gtk.VBox()
+ enteries_box.set_margin_left(14)
self.pack_start(enteries_box,False,False,3)
- self.start_time = DatetimePicker()
- self.end_time = DatetimePicker()
+ self.start_time = DatetimePicker(start_time)
+ self.end_time = DatetimePicker(end_time)
self.start_time.update_sensitivity(False)
self.end_time.update_sensitivity(False)
- enteries_box.pack_start(Gtk.Label('From :',xalign=0 ,yalign=0.5),False,False,1)
+ enteries_box.pack_start(Gtk.Label('From :',xalign=0 ,yalign=0.5),False,False,0)
enteries_box.pack_start(self.start_time,False,False,1)
- enteries_box.pack_start(Gtk.Label('To :',xalign=0 ,yalign=0.5),False,False,1)
+ enteries_box.pack_start(Gtk.Label('To :',xalign=0 ,yalign=0.5),False,False,0)
enteries_box.pack_start(self.end_time,False,False,1)
def get_start_time(self):
@@ -71,14 +79,15 @@
class DatetimePicker(Gtk.HBox):
- def __init__(self):
+ def __init__(self,time):
super(DatetimePicker, self).__init__()
- time = datetime.now()
+ if time is None:
+ time = datetime.now()
#date
date_holder = Gtk.HBox()
- self.pack_start(date_holder,False,False,6)
- date_holder.pack_start(Gtk.Label('DD|MM|YY :'),False,False,6)
+ self.pack_start(date_holder,False,False,3)
+ date_holder.pack_start(Gtk.Label('DD|MM|YY :'),False,False,3)
self.date_spin_day = Gtk.SpinButton(numeric=True)
self.date_spin_day.set_adjustment(Gtk.Adjustment(lower=1,
upper=32,page_size=1,step_increment=1,value=time.day))
@@ -94,8 +103,8 @@
#time
time_holder = Gtk.HBox()
- self.pack_end(time_holder,False,False,6)
- time_holder.pack_start(Gtk.Label('HH:MM:SS '),False,False,6)
+ self.pack_end(time_holder,False,False,3)
+ time_holder.pack_start(Gtk.Label('HH:MM:SS '),False,False,3)
self.time_spin_hour = Gtk.SpinButton(numeric=True)
self.time_spin_hour.set_adjustment(Gtk.Adjustment(lower=0,
upper=24,page_size=1,step_increment=1,value=time.hour))
@@ -112,12 +121,12 @@
self.show_all()
def get_datetime(self):
- return datetime(self.date_spin_year.get_valuea_as_int(),
- self.date_spin_month.get_valuea_as_int(),
- self.date_spin_day.get_valuea_as_int(),
- self.time_spin_hour.get_valuea_as_int(),
- self.time_spin_min.get_valuea_as_int(),
- self.time_spin_sec.get_valuea_as_int())
+ return datetime(self.date_spin_year.get_value_as_int(),
+ self.date_spin_month.get_value_as_int(),
+ self.date_spin_day.get_value_as_int(),
+ self.time_spin_hour.get_value_as_int(),
+ self.time_spin_min.get_value_as_int(),
+ self.time_spin_sec.get_value_as_int())
def update_sensitivity(self,enable):
self.date_spin_year.set_sensitive(enable)
@@ -133,16 +142,11 @@
class TemplateEditor(Gtk.Dialog): # NOTE: INCOMPLETE
- def __init__(self,event=None):
+ def __init__(self,template=None):
super(TemplateEditor, self).__init__()
+ self.set_template(template)
self.create()
- if event is None:
- self.event = Event()
- self.event.set_subjects(Subject())
- self.edit_mode = False
- else :
- self.event = event
- self.edit_mode = True
+
def create(self):
@@ -152,7 +156,7 @@
box= Gtk.VBox()
frame.add(box)
- self.timerange = TimeRangeViewer()
+ self.timerange = TimeRangeViewer(self.start_time,self.end_time)
box.pack_start(self.timerange,False,False,0)
table = Gtk.Table(1,2,True)
@@ -186,7 +190,9 @@
self.event_manifes_field.append_text(entry)
actor_label = Gtk.Label("Actor :",xalign=0,yalign=0.5)
- self.actor_field = Gtk.Label("")
+ self.actor_field = Gtk.Label()
+ self.actor_field.set_justify(Gtk.Justification.LEFT)
+ self.actor_field.set_line_wrap(True)
actor_hbox = Gtk.HBox(margin_bottom=6)
@@ -201,10 +207,8 @@
actor_hbox.pack_start(self.actor_dropdown, False, False, 12)
self.actor_image = Gtk.Image()
self.actor_image.set_size_request(32, 32)
- frame = Gtk.Frame()
- frame.add(self.actor_image)
- actor_hbox.pack_start(frame, False, False, 12)
- self.actor_value = Gtk.Label()
+ actor_hbox.pack_start(self.actor_image, False, False, 2)
+ self.actor_value = Gtk.Label(xalign=0,yalign=0.5)
actor_hbox.pack_start(self.actor_value, False, False, 12)
subj_label = Gtk.Label()
@@ -285,20 +289,22 @@
actor = self.event.get_actor()
self.actor_field.set_text(actor)
+ self.actor_field.set_justify(Gtk.Justification.LEFT)
+ self.actor_field.set_line_wrap(True)
if actor is not "" and actor.startswith("application://"):
actor = actor.replace("application://", "")
try:
app_info = Gio.DesktopAppInfo.new(actor)
- self.actor_dropdown.set_active(actor_dict.keys().index(app_info.get_name()))
+ self.actor_dropdown.set_active(self.app_dict.keys().index(app_info.get_name()))
self.actor_value.set_text(app_info.get_display_name())
- self.actor_image = Gtk.Image.new_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON)
+ self.actor_image.set_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON)
except TypeError:
print("Wrong actor string: %s" %(actor))
else:
self.actor_value.set_text("")
- sub = self.event.get_subjects()
+ sub = self.event.get_subjects()[0]
self.uri_field.set_text(sub.get_uri())
self.curr_uri_field.set_text(sub.get_current_uri())
@@ -315,19 +321,14 @@
def get_values(self):
- ev_inter=self.event_inter_field.get_active_text()
- if ev_inter is None:
- ev_inter=''
+
+ ev_inter=get_active_text(self.event_inter_field)
self.event.set_interpretation(event_interpretations[ev_inter])
- ev_manifes=self.event_manifes_field.get_active_text()
- if ev_manifes is None:
- ev_manifes=''
+ ev_manifes=get_active_text(self.event_manifes_field)
self.event.set_manifestation(event_manifestations[ev_manifes])
- app=self.actor_dropdown.get_active_text()
- if app is None:
- app=''
+ app=get_active_text(self.actor_dropdown)
self.event.set_actor(''.join([r"application://",self.app_dict[app]]))
#subject
@@ -336,35 +337,65 @@
sub.set_uri(self.uri_field.get_text().strip())
sub.set_current_uri(self.curr_uri_field.get_text().strip())
- sub_inter=self.subj_inter_field.get_active_text()
- if sub_inter is None:
- sub_inter=''
+ sub_inter= get_active_text(self.subj_inter_field)
sub.set_interpretation(subject_interpretations[sub_inter])
- sub_manifes=self.subj_manifes_field.get_active_text()
- if sub_manifes is None:
- sub_manifes=''
+ sub_manifes = get_active_text(self.subj_manifes_field)
sub.set_manifestation(subject_manifestations[sub_manifes])
sub.set_origin(self.origin_field.get_text().strip())
sub.set_mimetype(self.mimetype_field.get_text().strip())
- sub_stor=self.storage_field.get_active_text()
- if sub_stor is None:
- sub_stor=''
+ sub_stor = get_active_text(self.storage_field)
sub.set_storage(storage_states[sub_stor])
+
self.event.set_subjects(sub)
def on_app_changed(self,widget):
- app=self.actor_dropdown.get_active_text()
- if app is None:
- app=''
- actor = self.app_dict[app]
- self.actor_field.set_text(''.join([r'application://',actor]))
- app_info = Gio.DesktopAppInfo.new(actor)
- self.actor_dropdown.set_active(actor_dict.keys().index(app_info.get_name()))
- self.actor_value.set_text(app_info.get_display_name())
- self.actor_image = Gtk.Image.new_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON)
+ app=get_active_text(self.actor_dropdown)
+ try:
+ actor = self.app_dict[app]
+ self.actor_field.set_text(''.join([r'application://',actor]))
+ self.actor_field.set_justify(Gtk.Justification.LEFT)
+ self.actor_field.set_line_wrap(True)
+ app_info = Gio.DesktopAppInfo.new(actor)
+ self.actor_value.set_text(app_info.get_display_name())
+ self.actor_image.set_from_gicon(app_info.get_icon(), Gtk.IconSize.BUTTON)
+ except:
+ print('DEBUG : Complete Application Info for %s not available',actor)
+ self.actor_field.set_text('')
+ self.actor_value.set_text('')
+ self.actor_image.clear()
+
+ def get_time_range(self):
+ start = self.timerange.get_start_time()
+ end = self.timerange.get_end_time()
+ #TODO
+ #return deltatime range in zeitgeist format??
+
+ def get_template(self):
+ self.get_values()
+ timerange = self.get_time_range()
+ template = ['','',self.event,timerange,]
+ template[2] = self.event
+ # this ensure latest selections are taken before building the template
+ #this function prepares a template from the Time range and
+ # comment gui fields and self.event that has been stored
+ return template
+
+ def set_template(self,template):
+ if template is None:
+
+ self.event = Event()
+ self.event.set_subjects(Subject())
+ self.start_time = None
+ self.end_time = None
+ self.edit_mode = False
+ else :
+ self.event = template[2]
+ #self.start_time =
+ #self.end_time =
+ self.edit_mode = True
@@ -474,6 +505,8 @@
actor = ev.get_actor()
self.actor_field.set_text(actor)
+ self.actor_field.set_line_wrap(True)
+
if actor is not "" and actor.startswith("application://"):
actor = actor.replace("application://", "")
try:
@@ -491,6 +524,8 @@
subj = ev.get_subjects()[0]
else:
subj = Subject()
+ if type(subj) == str :
+ subj = Subject()
# Subject Interpretation
subj_inter = subj.get_interpretation()
=== modified file 'zgexplorer/filtermanager.py'
--- zgexplorer/filtermanager.py 2012-03-23 13:23:31 +0000
+++ zgexplorer/filtermanager.py 2012-03-24 11:58:18 +0000
@@ -23,7 +23,7 @@
from gi.repository import Gtk, Pango
from templates import BuiltInFilters
-from eventwidgets import TemplateViewer, TimeRangeViewer
+from eventwidgets import TemplateViewer, TimeRangeViewer, TemplateEditor
class FilterManagerDialog(Gtk.Dialog):
@@ -35,15 +35,20 @@
self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.set_size_request(600, 700)
+ self.active_page_index = 0
+ self.is_predefined = True
box = self.get_content_area()
self.notebook = Gtk.Notebook()
+ self.notebook.connect('switch-page',self.on_notebook_switch_page)
box.pack_start(self.notebook, True, True, 0)
self.add_predefined_tab()
self.add_custom_tab()
+ self.custom_event_filters={}
+
box.show_all()
def add_predefined_tab(self):
@@ -82,7 +87,7 @@
self.custom_store = Gtk.ListStore(int, str)
self.custom_view = Gtk.TreeView(model=self.custom_store)
- self.custom_view.connect("cursor-changed", self.on_custom_cursor_changed)
+ self.custom_view.connect("cursor-changed", self.on_cursor_changed)
column_pix_name = Gtk.TreeViewColumn(_('Name'))
self.custom_view.append_column(column_pix_name)
@@ -108,12 +113,17 @@
filter_add = Gtk.ToolButton.new(None, "Add Filter")
filter_add.set_icon_name("list-add-symbolic")
- #filter_add.connect("clicked", self.on_add_clicked)
+ filter_add.connect("clicked", self.on_add_clicked)
self.toolbar.insert(filter_add, 0)
+ filter_edit = Gtk.ToolButton.new(None, "Edit Filter")
+ filter_edit.set_icon_name("list-edit-symbolic")
+ filter_edit.connect("clicked", self.on_edit_clicked)
+ self.toolbar.insert(filter_edit, 0)
+
filter_remove = Gtk.ToolButton.new(None, "Remove Filter")
filter_remove.set_icon_name("list-remove-symbolic")
- #filter_remove.connect("clicked", self.on_remove_clicked)
+ filter_remove.connect("clicked", self.on_remove_clicked)
self.toolbar.insert(filter_remove, 1)
# See the Template values
@@ -122,7 +132,11 @@
def get_selected_index(self):
- selection = self.predefined_view.get_selection()
+ if self.is_predefined:
+ selection = self.predefined_view.get_selection()
+ else :
+ selection = self.custom_view.get_selection()
+
model, _iter = selection.get_selected()
if _iter is not None:
app_index = model.get(_iter, 0)
@@ -132,16 +146,67 @@
def get_selected_entry(self):
index = self.get_selected_index()
- is_predefined = True
if index is not None:
- return index,self.builtin[index], is_predefined
+ if self.is_predefined :
+ return index,self.builtin[index], True
+ else :
+ return index,self.custom_event_filters[index], False
return None
+ def on_notebook_switch_page(self, widget, page, page_num):
+ self.is_predefined = not bool(page_num)
+
def on_cursor_changed(self, treeview):
index = self.get_selected_index()
if index is not None:
- self.predefined_viewer.set_values(self.builtin[index])
-
- def on_custom_cursor_changed(self, treeview):
- pass
+ if self.is_predefined :
+ self.predefined_viewer.set_values(self.builtin[index])
+ else:
+ self.custom_viewer.set_values(self.custom_event_filters[index])
+
+
+ def on_add_clicked(self,widget):
+ template = self.run_template_add_edit_dialog()
+ curr_size = len(self.custom_store)
+ self.custom_store.append([curr_size, template[0]])
+ self.custom_event_filters[curr_size] = template
+
+ def on_edit_clicked(self,widget):
+ index,template = self.get_selected_entry()
+ template = self.run_template_add_edit_dialog(template)
+ self.custom_store[index] = template[0]
+ self.custom_event_filters[index] = template
+
+ def on_remove_clicked(self):
+ index,template = self.get_selected_entry()
+ for row in self.custom_store:
+ if row[0] == index :
+ self.custom_store.remove(row.iter)
+ break
+ del self.custom_event_filters[index]
+
+
+ def run_template_add_edit_dialog(self,template=None):
+
+ dialog = TemplateEditor(template)
+ dialog.show_all()
+
+ while True:
+ response_id = dialog.run()
+ if response_id in [Gtk.ResponseType.OK,Gtk.ResponseType.APPLY] :
+ template = dialog.get_template()
+
+ if response_id == Gtk.ResponseType.OK:
+ dialog.hide()
+ break
+
+ else:
+ dialog.hide()
+ return None
+
+ return template
+
+
+
+
=== modified file 'zgexplorer/monitorviewer.py'
--- zgexplorer/monitorviewer.py 2012-03-15 20:53:00 +0000
+++ zgexplorer/monitorviewer.py 2012-03-24 11:58:18 +0000
@@ -124,7 +124,7 @@
self.show_all()
def map(self, index, is_predefined):
- self.entry = self.builtin[index] if is_predefined else None
+ self.entry = self.builtin[index] if is_predefined else self.custom_event_filters[index]
if self.entry is not None:
self.desc_entry.set_text(self.entry[1])
Follow ups