Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 399 → Rev 400

/branches/BR-0.4/basico/core/mod_win.py
277,7 → 277,7
 
# Connect signals for visor annotations
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_annotations.connect_menuview_signals()
visor_annotations.set_menuview_signals()
visor_annotations.set_active_categories()
self.add(mainbox)
self.show_all()
/branches/BR-0.4/basico/services/srv_attachment.py
37,7 → 37,7
return "%s@T%s" % (sid, str(uuid.uuid4()))
 
 
def create(self, path, aid):
def create(self, path, aid):
sid = self.get_sid(aid)
tid = self.gen_tid(sid)
metadata = self.srvutl.get_file_metadata(path)
49,9 → 49,9
self.log.debug("\tTID: %s", tid)
self.log.debug("\tPath: %s", path)
self.log.debug("\tCreated: %s", metadata['Created'])
ATTACHMENT_FILE_METADATA = LPATH['ATTACHMENTS'] + tid + '.json'
ATTACHMENT_FILE_METADATA = LPATH['ATTACHMENTS'] + tid + '.json'
ATTACHMENT_FILE_CONTENT = LPATH['ATTACHMENTS'] + tid # No extension needed
 
# copy attachment file to attachemnts database
shutil.copy(path, ATTACHMENT_FILE_CONTENT)
 
62,8 → 62,8
self.log.info("Attachment '%s' (%s) created" % (metadata['Title'], metadata['TID']))
 
return tid
 
 
def delete(self, aid):
sid = self.get_sid(aid)
ATTACHMENT_FILE_METADATA = LPATH['ATTACHMENTS'] + aid + '.json'
82,7 → 82,7
def get_by_sid(self, sid):
matches = set()
ATTACHMENT_FILES = LPATH['ATTACHMENTS'] + '*.json'
attachments = glob.glob(ATTACHMENT_FILES)
attachments = glob.glob(ATTACHMENT_FILES)
for attachment in attachments:
if sid in attachment:
matches.add(attachment)
129,6 → 129,7
metadata = self.get_metadata_from_tid(tid)
return metadata[key]
 
 
def is_valid(self, aid):
ATTACHMENT_FILE_METADATA = LPATH['ATTACHMENTS'] + aid + '.json'
ATTACHMENT_FILE_CONTENT = LPATH['ATTACHMENTS'] + aid
/branches/BR-0.4/basico/services/srv_callbacks.py
45,7 → 45,7
 
def stack_visor_changed(self, stack, gparam):
visible_stack_name = stack.get_visible_child_name()
self.log.debug("Visor switched to: %s", visible_stack_name)
# ~ self.log.debug("Visor switched to: %s", visible_stack_name)
 
if visible_stack_name is None:
return
559,7 → 559,7
elif visible_stack_name == 'visor-annotations':
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_annotations.populate()
visible_filter = visor_annotations.get_visible_filter()
visible_filter = self.srvgui.get_widget('visor_annotation_visible_filter')
visible_filter.refilter()
visor_annotations.update_total_annotations_count()
 
687,7 → 687,7
# ~ page = self.srvgui.get_key_value('current_visor_tab')
# ~ notebook = self.srvgui.get_widget('gtk_notebook_visor')
# ~ notebook.set_current_page(page)
self.log.debug('Annotation canceled')
# ~ self.log.debug('Annotation canceled')
self.srvuif.statusbar_msg("Annotation canceled")
self.gui_show_dashboard()
self.srvuif.grab_focus()
867,22 → 867,7
def gui_link_to_sapnote(self, *args):
pass
 
def gui_switch_selection_atypes(self, switch, state):
label = self.srvgui.get_widget('gtk_label_switch_select_atypes')
switched = switch.get_active()
switch.set_state(switched)
if switched is True:
label.set_text ("All selected")
 
else:
label.set_text("None selected")
 
for name in ATYPES:
button = self.srvgui.get_widget('gtk_button_type_%s' % name.lower())
button.set_state(switched)
button.set_active(switched)
 
 
def gui_sapnotes_select_all_none(self, witch, state):
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
model = visor_sapnotes.get_model()
/branches/BR-0.4/basico/widgets/wdg_annot.py
739,13 → 739,13
self.srvgui.set_key_value('current_paned_position', pos)
paned.set_position(0)
visible_stack_name = stack.get_visible_child_name()
self.log.debug("Annotation Stack changed to: %s", visible_stack_name)
# ~ self.log.debug("Annotation Stack changed to: %s", visible_stack_name)
self.set_visible_stack(visible_stack_name)
 
 
def preview(self):
aid = self.get_aid_from_widget()
self.log.debug("Previewing aid: %s", aid)
# ~ self.log.debug("Previewing aid: %s", aid)
if len(aid) == 0:
return
 
773,10 → 773,10
# ~ self.log.debug("%s; %s", tpath, tmtime)
if tmtime < smtime:
target = self.srvacd.generate_preview(aid)
self.log.debug("Preview generated")
# ~ self.log.debug("Preview generated")
else:
target = "file://" + tpath
self.log.debug("Using cache for preview")
# ~ self.log.debug("Using cache for preview")
browser.load_url(html.escape(target))
except Exception as error:
self.log.error(error)
/branches/BR-0.4/basico/widgets/wdg_menuview.py
248,7 → 248,7
def row_changed(self, selection):
if self.current_status is None:
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
self.log.warning("gui_show_visor_sapnotes!!!")
# ~ self.log.warning("gui_show_visor_sapnotes!!!")
 
try:
model, treeiter = selection.get_selected()
273,7 → 273,7
self.set_current_collection(None)
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor_sapnotes.populate(matches, self.cid)
self.srvuif.statusbar_msg("View populated with %d SAP Notes" % (len(matches)))
# ~ self.srvuif.statusbar_msg("View populated with %d SAP Notes" % (len(matches)))
except Exception as error:
pass
 
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
36,10 → 36,10
Gtk.HBox.__init__(self, app)
self.set_homogeneous(False)
self.bag = []
self.get_services()
self.setup_panel()
self.set_initial_panel_button_status()
self.setup_visor()
self.__get_services()
self.__setup_panel()
self.__set_initial_panel_button_status()
self.__setup_visor()
self.icons = {}
self.icons['type'] = {}
for atype in ATYPES:
47,7 → 47,7
self.log.debug("Annotation Visor initialized")
 
 
def get_services(self):
def __get_services(self):
self.srvgui = self.get_service("GUI")
self.srvclb = self.get_service('Callbacks')
self.srvsap = self.get_service('SAP')
59,7 → 59,7
self.srvant = self.get_service('Annotation')
 
 
def set_initial_panel_button_status(self):
def __set_initial_panel_button_status(self):
# Categories
self.srvgui.set_key_value('ANNOTATIONS_CATEGORY_INBOX_VISIBLE', True)
self.srvgui.set_key_value('ANNOTATIONS_CATEGORY_DRAFTS_VISIBLE', False)
74,12 → 74,12
self.srvgui.set_key_value('ANNOTATIONS_PRIORITY_%s_VISIBLE' % priority.upper(), True)
 
 
def sort_by_timestamp(self):
def __sort_by_timestamp(self):
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
sorted_model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
 
 
def setup_panel(self):
def __setup_panel(self):
vbox_main = Gtk.VBox()
self.pack_start(vbox_main, False, False, 3)
# ~ separator = Gtk.Separator(orientation = Gtk.Orientation.VERTICAL)
115,7 → 115,7
label.set_xalign(0.0)
model = Gtk.ListStore(str)
scope = Gtk.ComboBox.new_with_model(model)
signal = scope.connect('changed', self.clb_scope_changed)
signal = scope.connect('changed', self.__clb_scope_changed)
self.srvgui.add_signal('gtk_combobox_filter_scope', 'changed', signal)
self.srvgui.add_widget('gtk_combobox_filter_scope', scope)
renderer = Gtk.CellRendererText()
132,7 → 132,7
label.set_xalign(0.0)
model = Gtk.ListStore(str)
product = Gtk.ComboBox.new_with_model(model)
signal = product.connect('changed', self.product_changed)
signal = product.connect('changed', self.__clb_product_changed)
self.srvgui.add_signal('gtk_combobox_filter_product', 'changed', signal)
self.srvgui.add_widget('gtk_combobox_filter_product', product)
renderer = Gtk.CellRendererText()
197,7 → 197,7
switch = Gtk.Switch()
switch.set_active(True)
switch.set_state(True)
switch.connect('state-set', self.srvclb.gui_switch_selection_atypes)
switch.connect('state-set', self.__clb_switch_selection_atypes)
label_select = Gtk.Label()
label_select.set_markup("<b>All selected</b>")
label = self.srvgui.add_widget('gtk_label_switch_select_atypes', label_select)
221,7 → 221,7
return vbox_main
 
 
def set_visible_categories(self, togglebutton):
def __clb_set_visible_categories(self, togglebutton):
types = self.srvgui.get_widget('gtk_togglebutton_types')
revealer = self.srvgui.get_widget('gtk_revealer_annotations_categories')
 
231,7 → 231,7
revealer.set_reveal_child(active)
 
 
def set_visible_types(self, togglebutton):
def __clb_set_visible_types(self, togglebutton):
categories = self.srvgui.get_widget('gtk_togglebutton_categories')
revealer = self.srvgui.get_widget('gtk_revealer_annotations_types')
 
241,7 → 241,7
revealer.set_reveal_child(active)
 
 
def set_visible_priority(self, togglebutton):
def __clb_set_visible_priority(self, togglebutton):
categories = self.srvgui.get_widget('gtk_togglebutton_categories')
revealer = self.srvgui.get_widget('gtk_revealer_annotations_priority')
 
251,28 → 251,28
revealer.set_reveal_child(active)
 
 
def set_visible_category(self, togglebutton, title):
def __clb_set_visible_category(self, togglebutton, title):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_CATEGORY_%s_VISIBLE' % title.upper(), active)
self.set_bag()
self.__set_bag()
self.populate()
 
 
def set_visible_annotation_type(self, togglebutton, atype):
def __clb_set_visible_annotation_type(self, togglebutton, atype):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_TYPE_%s_VISIBLE' % atype.upper(), active)
self.set_bag()
self.__set_bag()
self.populate()
 
 
def set_visible_priority(self, togglebutton, title):
def __clb_set_visible_priority(self, togglebutton, title):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_PRIORITY_%s_VISIBLE' % title.upper(), active)
self.set_bag()
self.__set_bag()
self.populate()
 
 
def setup_visor(self):
def __setup_visor(self):
scr = Gtk.ScrolledWindow()
scr.set_hexpand(True)
scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
336,7 → 336,7
 
# Annotation Checkbox
self.renderer_checkbox = Gtk.CellRendererToggle()
self.renderer_checkbox.connect("toggled", self.toggle_checkbox)
self.renderer_checkbox.connect("toggled", self.__clb_toggle_checkbox)
self.column_checkbox = Gtk.TreeViewColumn('', self.renderer_checkbox, active=2)
widget = get_column_header_widget('', 'basico-check-accept')
self.column_checkbox.set_widget(widget)
371,7 → 371,6
self.renderer_title.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
self.column_title = Gtk.TreeViewColumn('Title', self.renderer_title, markup=4)
widget = get_column_header_widget('Title', 'basico-tag')
# ~ widget.connect('button_press_event', self.header_right_click)
self.column_title.set_widget(widget)
self.column_title.set_visible(True)
self.column_title.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
428,7 → 427,7
self.renderer_priority = Gtk.CellRendererText()
self.renderer_priority.set_property('background', '#e4f1f1')
self.column_priority = Gtk.TreeViewColumn('Priority', self.renderer_priority, markup=8)
widget = get_column_header_widget('Type', 'basico-priority')
widget = get_column_header_widget('Priority', 'basico-priority')
self.column_priority.set_widget(widget)
self.column_priority.set_visible(True)
self.column_priority.set_expand(False)
500,7 → 499,7
treeview.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
treeview.set_enable_tree_lines(True)
treeview.set_level_indentation(10)
treeview.connect('button_press_event', self.row_right_click)
treeview.connect('button_press_event', self.__clb_row_right_click)
 
treeview.modify_font(Pango.FontDescription('Monospace 9'))
 
510,18 → 509,18
# model to the treeview...
 
# Treeview filtering:
visible_filter = self.srvgui.add_widget('visor_annotation_filter', model.filter_new())
visible_filter.set_visible_func(self.visible_function)
visible_filter = self.srvgui.add_widget('visor_annotation_visible_filter', model.filter_new())
visible_filter.set_visible_func(self.__visible_function)
 
# TreeView sorting
sorted_model = Gtk.TreeModelSort(model=visible_filter)
self.srvgui.add_widget('visor_annotation_sorted_model', sorted_model)
# ~ self.sorted_model.set_sort_func(0, self.sort_function, None)
sorted_model.set_sort_func(0, self.__sort_function, None)
 
# Selection
selection = treeview.get_selection()
selection.set_mode(Gtk.SelectionMode.SINGLE)
selection.connect('changed', self.row_changed)
selection.connect('changed', self.__clb_row_changed)
 
# Set model (filtered and sorted)
sorted_model.set_sort_column_id(9, Gtk.SortType.ASCENDING)
528,12 → 527,12
treeview.set_model(sorted_model)
 
# Other signals
treeview.connect('row-activated', self.row_double_click)
treeview.connect('row-activated', self.__clb_row_double_click)
 
self.show_all()
 
 
def sort_function(self, model, row1, row2, user_data):
def __sort_function(self, model, row1, row2, user_data):
sort_column = 0
 
value1 = model.get_value(row1, sort_column)
547,11 → 546,7
return 1
 
 
def always_visible(self, model, itr, data):
return False
 
 
def visible_function(self, model, itr, data):
def __visible_function(self, model, itr, data):
entry = self.srvgui.get_widget('gtk_entry_filter_visor')
text = self.srvutl.clean_html(entry.get_text())
title = model.get(itr, 4)[0]
583,7 → 578,7
 
 
def update_total_annotations_count(self):
visible_filter = self.srvgui.get_widget('visor_annotation_filter')
visible_filter = self.srvgui.get_widget('visor_annotation_visible_filter')
statusbar = self.srvgui.get_widget('widget_statusbar')
lblnotescount = self.srvgui.get_widget('gtk_label_total_notes')
total = self.srvant.get_total()
635,17 → 630,17
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
selected = []
 
def get_selected_sapnotes(model, path, itr):
def get_toggled_rows(model, path, itr):
aid = sorted_model.get(itr, 0)[0]
checked = sorted_model.get(itr, 2)[0]
if checked:
selected.append(str(aid))
sorted_model.foreach(get_selected_sapnotes)
sorted_model.foreach(get_toggled_rows)
 
return selected
 
 
def row_changed(self, selection):
def __clb_row_changed(self, selection):
try:
model, treeiter = selection.get_selected()
if treeiter is not None:
673,7 → 668,7
#FIXME: create an empty file for contents
 
 
def toggle_checkbox(self, cell, path):
def __clb_toggle_checkbox(self, cell, path):
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
model = sorted_model.get_model()
rpath = sorted_model.convert_path_to_child_path(Gtk.TreePath(path))
680,7 → 675,7
model[rpath][2] = not model[rpath][2]
 
 
def get_node(self, key, icon, checkbox, sid, title, component, scope='', sntype='', priority='', updated='', ts_updated='', created='', ts_created=''):
def __get_node(self, key, icon, checkbox, sid, title, component, scope='', sntype='', priority='', updated='', ts_updated='', created='', ts_created=''):
# Add completion entries
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
704,7 → 699,7
return node
 
 
def set_bag(self, annotations=None):
def __set_bag(self, annotations=None):
self.bag = annotations
 
 
712,20 → 707,11
return self.bag
 
 
def reload(self):
bag = self.get_bag()
self.populate(bag)
 
 
def populate(self, annotations=None):
treeview = self.srvgui.get_widget('visor_annotation_treeview')
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
model = self.srvgui.get_widget('gtk_model_annotation')
# ~ model = sorted_model.get_model()
self.column_sid.set_visible(False)
# ~ self.column_checkbox.set_visible(True)
# ~ self.column_category.set_visible(True)
# ~ self.column_component.set_visible(False)
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.clear()
737,12 → 723,11
annotations = self.get_bag()
if annotations is None:
annotations = self.srvant.get_all()
# ~ self.log.debug("Displaying all annotations")
else:
self.log.debug("Displaying last query")
else:
self.log.debug("Displaying following annotations: %s", annotations)
self.set_bag(annotations)
self.__set_bag(annotations)
 
dcats = {}
snpids = {}
799,7 → 784,7
except:
annotation['Priority'] = 'Normal'
 
node = self.get_node( annotation['AID'],
node = self.__get_node( annotation['AID'],
icon,
False,
str(int(sid)),
814,13 → 799,6
annotation['Created']
)
nodes.append(node)
# ~ if scope_filter == 'All' or scope_filter == '':
# ~ nodes.append(node)
# ~ bag.add(fname)
# ~ else:
# ~ if scope_filter == scope:
# ~ bag.add(fname)
 
except Exception as error:
self.log.error(error)
self.log.error(self.get_traceback())
827,8 → 805,6
except Exception as error:
# Whenever an annotation is deleted, after reloading
# the view, it fails. Then, skip it
# ~ self.log.error("Annotation: %s", fname)
# ~ self.log.error(error)
pass
 
for node in nodes:
835,25 → 811,20
model.append(None, node)
 
treeview.set_model(sorted_model)
self.sort_by_timestamp()
# ~ self.set_bag(bag)
self.update_panel_values()
self.__sort_by_timestamp()
self.__update_panel_values()
self.update_total_annotations_count()
 
 
def show_widgets(self):
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
 
 
def clb_preview(self, button, aid):
def __clb_preview(self, button, aid):
self.srvclb.action_annotation_preview(aid)
 
 
def clb_edit(self, button, aid):
def __clb_edit(self, button, aid):
self.srvclb.action_annotation_edit(aid)
 
 
def row_double_click(self, treeview, row, col):
def __clb_row_double_click(self, treeview, row, col):
try:
selection = treeview.get_selection()
model, treeiter = selection.get_selected()
863,29 → 834,12
aid = model[treeiter][0]
is_valid = self.srvant.is_valid(aid)
if is_valid:
# ~ fullscreen_annotation = self.srvgui.get_widget('gtk_togglebutton_maximize_annotation_widget')
# ~ fullscreen_annotation.set_active(True)
self.srvclb.action_annotation_preview(aid)
else:
pass
# ~ aid = None
# ~ self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', True)
except Exception as error:
self.log.error(error)
# ~ head = "Error reading annotation's contents"
# ~ body = "<i>%s</i>\n\n" % error
# ~ body += "As a workaround, a new file will be created"
# ~ dialog = self.srvuif.message_dialog_error(head, body)
# ~ self.log.debug(error)
# ~ self.log.debug(self.get_traceback())
# ~ dialog.run()
# ~ dialog.destroy()
# ~ #FIXME: create an empty file for contents
 
def header_right_click(self, *args):
self.log.debug(args)
 
def row_right_click(self, treeview, event, data=None):
def __clb_row_right_click(self, treeview, event, data=None):
treeview = self.srvgui.get_widget('visor_annotation_treeview')
if event.button == 3:
rect = Gdk.Rectangle()
898,22 → 852,18
treeiter = model.get_iter(path)
component = model[treeiter][5]
aid = model[treeiter][0]
# ~ toolbar = self.srvgui.get_widget('visortoolbar')
popover = self.srvgui.add_widget('gtk_popover_visor_row', Gtk.Popover.new(treeview))
# ~ popover.set_position(Gtk.PositionType.TOP)
popover.set_pointing_to(rect)
box = self.build_popover(aid, popover, component)
box = self.__build_popover(aid, popover, component)
if box is not None:
# ~ vpaned = self.srvgui.get_widget('gtk_vpaned_visor')
visor_annotations = self.srvgui.get_widget('visor_annotations')
width, height = visor_annotations.get_size_request()
# ~ vpaned.set_position(1000)
popover.add(box)
self.srvclb.gui_show_popover(None, popover)
 
 
 
def build_popover(self, aid, popover, component):
def __build_popover(self, aid, popover, component):
sid = self.srvant.get_sid(aid)
 
def get_popover_button(text, icon_name):
936,17 → 886,17
hbox_sel = Gtk.HBox()
button = get_popover_button("", 'basico-check-all')
button.set_tooltip_markup("Select all")
button.connect('clicked', self.select_all, True)
button.connect('clicked', self.__clb_select_all, True)
hbox_sel.pack_start(button, True, False, 0)
 
button = get_popover_button("", 'basico-check-none')
button.set_tooltip_markup("Select none")
button.connect('clicked', self.select_all, False)
button.connect('clicked', self.__clb_select_all, False)
hbox_sel.pack_start(button, True, False, 0)
 
button = get_popover_button("", 'basico-check-invert')
button.set_tooltip_markup("Invert selection")
button.connect('clicked', self.select_all, None)
button.connect('clicked', self.__clb_select_all, None)
hbox_sel.pack_start(button, True, False, 0)
 
box.pack_start(hbox_sel, False, False, 0)
980,12 → 930,12
 
button = get_popover_button("<b>Preview</b> annotation", 'basico-preview')
button.show_all()
button.connect('clicked', self.clb_preview, aid)
button.connect('clicked', self.__clb_preview, aid)
box.pack_start(button, False, False, 0)
 
button = get_popover_button("<b>Edit</b> annotation", 'basico-edit')
button.show_all()
button.connect('clicked', self.clb_edit, aid)
button.connect('clicked', self.__clb_edit, aid)
box.pack_start(button, False, False, 0)
 
button = get_popover_button("<b>Duplicate</b> annotation", 'basico-copy-paste')
996,10 → 946,9
return box
 
 
def select_all(self, button, checked):
def __clb_select_all(self, button, checked):
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
def check_row(model, path, itr):
# ~ model[path][2] = not model[path][2]
if checked is not None:
model[path][2] = checked
else:
1011,22 → 960,22
self.srvuif.grab_focus()
 
 
def connect_menuview_signals(self):
def set_menuview_signals(self):
# Categories
button = self.srvgui.get_widget('gtk_togglebutton_categories')
button.connect('toggled', self.set_visible_categories)
button.connect('toggled', self.__clb_set_visible_categories)
 
for name in ['inbox', 'drafts', 'archived']:
button = self.srvgui.get_widget('gtk_button_category_%s' % name)
button.connect('toggled', self.set_visible_category, name)
button.connect('toggled', self.__clb_set_visible_category, name)
 
# Types
button = self.srvgui.get_widget('gtk_togglebutton_types')
button.connect('toggled', self.set_visible_types)
button.connect('toggled', self.__clb_set_visible_types)
 
for name in ATYPES:
button = self.srvgui.get_widget('gtk_button_type_%s' % name.lower())
button.connect('toggled', self.set_visible_annotation_type, name)
button.connect('toggled', self.__clb_set_visible_annotation_type, name)
 
 
def set_active_categories(self):
1034,57 → 983,11
category.set_active(True)
 
 
# ~ def update_panel_values(self):
# ~ scopes = set()
# ~ products = set()
def __update_panel_values(self):
self.__update_scopes()
self.__update_products()
 
# ~ def get_values(model, path, itr):
# ~ scope = self.sorted_model.get(itr, 6)[0]
# ~ product = self.sorted_model.get(itr, 7)[0]
# ~ scopes.add(scope)
# ~ products.add(product)
# ~ self.sorted_model.foreach(get_values)
 
# ~ # Update scope combo
# ~ cmb_scope = self.srvgui.get_widget('gtk_combobox_filter_scope')
# ~ signal = self.srvgui.get_signal('gtk_combobox_filter_scope', 'changed')
# ~ GObject.signal_handler_block(cmb_scope, signal)
# ~ model = cmb_scope.get_model()
# ~ model.clear()
# ~ first = model.append(['<big><b>Scope</b></big>'])
# ~ model.append(['All'])
# ~ model.append(['None'])
# ~ cmb_scope.set_active_iter(first)
# ~ lscopes = list(scopes)
# ~ lscopes.sort()
# ~ for item in lscopes:
# ~ if len(item) > 0:
# ~ model.append([item])
# ~ GObject.signal_handler_unblock(cmb_scope, signal)
 
# ~ # Update product combo
# ~ cmb_product = self.srvgui.get_widget('gtk_combobox_filter_product')
# ~ signal = self.srvgui.get_signal('gtk_combobox_filter_product', 'changed')
# ~ GObject.signal_handler_block(cmb_product, signal)
# ~ model = cmb_product.get_model()
# ~ model.clear()
# ~ first = model.append(['<big><b>Product</b></big>'])
# ~ model.append(['All'])
# ~ model.append(['None'])
# ~ cmb_product.set_active_iter(first)
# ~ lproducts = list(products)
# ~ lproducts.sort()
# ~ for item in lproducts:
# ~ if len(item) > 0:
# ~ model.append([item])
# ~ GObject.signal_handler_unblock(cmb_product, signal)
 
 
def update_panel_values(self):
self.update_scopes()
self.update_products()
 
def update_scopes(self):
def __update_scopes(self):
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
scopes = set()
 
1111,7 → 1014,7
GObject.signal_handler_unblock(cmb_scope, signal)
 
 
def update_products(self):
def __update_products(self):
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
products = set()
 
1138,17 → 1041,31
GObject.signal_handler_unblock(cmb_product, signal)
 
 
def clb_scope_changed(self, *args):
visible_filter = self.srvgui.get_widget('visor_annotation_filter')
def __clb_scope_changed(self, *args):
visible_filter = self.srvgui.get_widget('visor_annotation_visible_filter')
visible_filter.refilter()
self.update_total_annotations_count()
self.update_products()
 
 
def product_changed(self, *args):
visible_filter = self.srvgui.get_widget('visor_annotation_filter')
def __clb_product_changed(self, *args):
visible_filter = self.srvgui.get_widget('visor_annotation_visible_filter')
visible_filter.refilter()
self.update_total_annotations_count()
self.update_scopes()
 
 
def __clb_switch_selection_atypes(self, switch, state):
label = self.srvgui.get_widget('gtk_label_switch_select_atypes')
switched = switch.get_active()
switch.set_state(switched)
if switched is True:
label.set_text ("All selected")
 
else:
label.set_text("None selected")
 
for name in ATYPES:
button = self.srvgui.get_widget('gtk_button_type_%s' % name.lower())
button.set_state(switched)
button.set_active(switched)
/branches/BR-0.4/basico/widgets/wdg_visor_toolbar.py
295,7 → 295,7
 
def combobox_templates(self, *args):
tpl_aids = self.srvant.get_annotations_by_type('Template')
self.log.debug(tpl_aids)
# ~ self.log.debug(tpl_aids)
 
model = Gtk.ListStore(Pixbuf, str, str)
icon = self.srvicm.get_pixbuf_icon('basico-annotation-type-template', 32)
304,7 → 304,7
atype = self.srvant.get_metadata_value(aid, 'Type')
icon = self.srvicm.get_pixbuf_icon('basico-annotation-type-%s' % atype.lower(), 32)
title = self.srvant.get_title(aid)
self.log.debug("AID(%s) - Title(%s)", aid, title)
# ~ self.log.debug("AID(%s) - Title(%s)", aid, title)
model.append([icon, aid, title])
 
templates = Gtk.ComboBox.new_with_model(model)