Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 361 → Rev 362

/branches/BR-0.4/basico/core/mod_win.py
439,13 → 439,13
scr.set_shadow_type(Gtk.ShadowType.NONE)
vwp = Gtk.Viewport()
vwp.set_hexpand(True)
visor = self.srvgui.add_widget('visor_sapnotes', SAPNotesVisor(self.controller))
visor.set_hexpand(True)
visor.set_vexpand(True)
vwp.add(visor)
visor_sapnotes = self.srvgui.add_widget('visor_sapnotes', SAPNotesVisor(self.controller))
visor_sapnotes.set_hexpand(True)
visor_sapnotes.set_vexpand(True)
vwp.add(visor_sapnotes)
scr.add(vwp)
box.pack_start(scr, True, True, 0)
visor.show_all()
visor_sapnotes.show_all()
box.show_all()
return box
 
461,13 → 461,13
scr.set_shadow_type(Gtk.ShadowType.NONE)
vwp = Gtk.Viewport()
vwp.set_hexpand(True)
visor = self.srvgui.add_widget('visor_annotations', AnnotationsVisor(self.controller))
visor.set_hexpand(True)
visor.set_vexpand(True)
vwp.add(visor)
visor_annotations = self.srvgui.add_widget('visor_annotations', AnnotationsVisor(self.controller))
visor_annotations.set_hexpand(True)
visor_annotations.set_vexpand(True)
vwp.add(visor_annotations)
scr.add(vwp)
box.pack_start(scr, True, True, 0)
visor.show_all()
visor_annotations.show_all()
box.show_all()
return box
 
483,13 → 483,13
scr.set_shadow_type(Gtk.ShadowType.NONE)
vwp = Gtk.Viewport()
vwp.set_hexpand(True)
visor = self.srvgui.add_widget('visor_attachments', AttachmentsVisor(self.controller))
visor.set_hexpand(True)
visor.set_vexpand(True)
vwp.add(visor)
visor_attachments = self.srvgui.add_widget('visor_attachments', AttachmentsVisor(self.controller))
visor_attachments.set_hexpand(True)
visor_attachments.set_vexpand(True)
vwp.add(visor_attachments)
scr.add(vwp)
box.pack_start(scr, True, True, 0)
visor.show_all()
visor_attachments.show_all()
box.show_all()
return box
727,10 → 727,10
 
 
def run(self):
visor_annotations = self.srvgui.get_widget('visor_annotations')
# ~ visor_annotations = self.srvgui.get_widget('visor_annotations')
viewmenu = self.srvgui.get_widget('viewmenu')
viewmenu.set_view('collection')
self.srvclb.gui_show_visor_annotations()
annotations = self.srvant.search_term('')
visor_annotations.populate_annotations(annotations)
# ~ self.srvclb.gui_show_visor_annotations()
# ~ annotations = self.srvant.search_term('')
# ~ visor_annotations.populate(annotations)
self.srvclb.gui_viewmenu_select_first_entry()
/branches/BR-0.4/basico/services/srv_callbacks.py
59,20 → 59,26
if page_num == 0:
self.srvuif.set_widget_visibility('gtk_button_menu_views', True)
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
visor = self.srvgui.get_widget('visor_sapnotes')
visible_filter = visor.get_visible_filter()
visor.update_total_sapnotes_count()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
visible_filter = visor_sapnotes.get_visible_filter()
visor_sapnotes.update_total_sapnotes_count()
paned.set_position(400)
notebook_viewmenu.set_current_page(0)
elif page_num == 1:
self.srvuif.set_widget_visibility('gtk_button_menu_views', False)
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
visor = self.srvgui.get_widget('visor_annotations')
visor.populate_annotations()
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_annotations.populate()
paned.set_position(400)
notebook_viewmenu.set_current_page(1)
elif page_num == 2:
self.srvuif.set_widget_visibility('gtk_button_menu_views', False)
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
visor_attachments = self.srvgui.get_widget('visor_attachments')
visor_attachments.populate()
paned.set_position(400)
notebook_viewmenu.set_current_page(2)
 
 
def gui_show_visor_sapnotes(self):
notebook = self.srvgui.get_widget('gtk_notebook_visor')
notebook.set_current_page(0)
94,7 → 100,7
 
if page == 0:
bag = self.srvdtb.search(term)
visor_sapnotes.populate_sapnotes(bag)
visor_sapnotes.populate(bag)
ebuffer = entry.get_buffer()
ebuffer.delete_text(0, -1)
msg = "Found %d SAP Notes for term '%s'" % (len(bag), term)
102,7 → 108,7
self.srvuif.statusbar_msg(msg)
elif page == 1:
annotations = self.srvant.search_term(term)
visor_annotations.populate_annotations(annotations)
visor_annotations.populate(annotations)
msg = "Found %d annotations for term '%s'" % (len(annotations), term)
self.log.info(msg)
self.srvuif.statusbar_msg(msg)
124,7 → 130,7
 
 
def sapnote_delete(self, button, sid):
visor = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
viewmenu = self.srvgui.get_widget('viewmenu')
 
answer = self.srvuif.warning_message_delete_sapnotes(button, 'Deleting SAP Notes', 'Are you sure?', [sid])
131,21 → 137,21
if answer is True:
self.srvdtb.delete(sid)
self.srvuif.statusbar_msg("SAP Note %s deleted" % sid, True)
visor.reload()
visor_sapnotes.reload()
else:
self.log.info("SAP Note %s not deletd", sid)
 
 
def sapnote_delete_view(self, button):
visor = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
viewmenu = self.srvgui.get_widget('viewmenu')
 
bag = visor.get_filtered_bag()
bag = visor_sapnotes.get_filtered_bag()
answer = self.srvuif.warning_message_delete_sapnotes(button, 'Deleting SAP Notes', 'Are you sure?', bag)
if answer is True:
for sid in bag:
self.srvdtb.delete(sid)
visor.reload()
visor_sapnotes.reload()
msg = "Deleted %d SAP Notes" % len(bag)
self.log.info(msg)
self.srvuif.statusbar_msg(msg, True)
153,9 → 159,10
msg = "None of the %d SAP Notes has been deleted" % len(bag)
self.log.info(msg)
self.srvuif.statusbar_msg(msg, True)
visor.reload()
visor_sapnotes.reload()
viewmenu.populate()
 
 
def gui_hide_popover(self, popover):
popover.hide()
 
249,7 → 256,7
self.srvbnr.restore_from_backup(backup, overwrite)
self.srvdtb.load_notes()
self.srvclt.load_collections()
visor_annotations.populate_annotations()
visor_annotations.populate()
self.gui_refresh_view()
self.gui_show_visor_sapnotes()
self.srvuif.statusbar_msg("Backup restored successfully", True)
373,8 → 380,8
 
 
def switch_bookmark_current_view(self, *args):
visor = self.srvgui.get_widget('visor_sapnotes')
bag = visor.get_filtered_bag()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
bag = visor_sapnotes.get_filtered_bag()
try:
for sid in bag:
metadata = self.srvdtb.get_sapnote_metadata(sid)
386,7 → 393,7
except:
self.log.error("Could not bookmark SAP Note %s" % sid)
self.log.error(self.get_traceback())
visor.populate_sapnotes(bag)
visor_sapnotes.populate(bag)
msg = "%d SAP Notes (un)bookmarked" % len(bag)
self.log.info(msg)
self.srvuif.statusbar_msg(msg, True)
393,7 → 400,7
 
 
def switch_bookmark(self, button, lsid, popover):
visor = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
try:
for sid in lsid:
metadata = self.srvdtb.get_sapnote_metadata(sid)
408,7 → 415,7
except:
self.log.error("Could not bookmark SAP Note %s" % sid)
self.log.error(self.get_traceback())
visor.populate_sapnotes()
visor_sapnotes.populate()
 
 
def sapnote_bookmark(self, lsid):
423,7 → 430,7
db = self.get_service('DB')
webdriver = self.get_service('Driver')
textview = self.srvgui.get_widget('gtk_textview_download_launchpad')
visor = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
 
bag = []
all_notes = []
489,7 → 496,7
db.build_stats()
self.log.info("Download completed.")
self.srvuif.statusbar_msg("Download completed", True)
visor.populate_sapnotes(all_notes)
visor_sapnotes.populate(all_notes)
self.gui_show_visor_sapnotes()
return result
 
536,16 → 543,16
def gui_filter_visor(self, entry):
page = self.srvgui.get_key_value('current_visor_tab')
if page == 0:
visor = self.srvgui.get_widget('visor_sapnotes')
visible_filter = visor.get_visible_filter()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
visible_filter = visor_sapnotes.get_visible_filter()
visible_filter.refilter()
visor.update_total_sapnotes_count()
visor_sapnotes.update_total_sapnotes_count()
elif page == 1:
visor = self.srvgui.get_widget('visor_annotations')
visor.populate_annotations()
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_annotations.populate()
visible_filter = visor.get_visible_filter()
visible_filter.refilter()
visor.update_total_annotations_count()
visor_annotations.update_total_annotations_count()
 
 
def gui_refresh_view(self, button=None, view=None):
602,7 → 609,7
 
 
def action_annotation_delete(self, *args):
visor = self.srvgui.get_widget('visor_annotations')
visor_annotations = self.srvgui.get_widget('visor_annotations')
widget_annotation = self.srvgui.get_widget('widget_annotation')
aid = widget_annotation.get_aid_from_widget()
 
612,7 → 619,7
self.srvant.delete(aid)
self.gui_annotation_widget_clear()
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
visor.populate_annotations()
visor_annotations.populate()
self.srvuif.statusbar_msg("Annotation <i>'%s'</i> deleted" % title, True)
else:
self.log.info("Annotation %s hasn't been deleted" % title)
638,8 → 645,8
self.srvant.create(annotation)
title = self.srvant.get_title(aid)
self.srvuif.statusbar_msg('New annotation created: %s' % title, True)
visor_annotations.populate_annotations()
visor_sapnotes.populate_sapnotes()
visor_annotations.populate()
visor_sapnotes.populate()
self.gui_annotation_widget_clear()
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
self.srvuif.grab_focus()
816,7 → 823,7
 
def gui_jump_to_sapnote(self, widget, sid):
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes.populate_sapnotes([sid])
visor_sapnotes.populate([sid])
self.gui_show_visor_sapnotes()
self.srvuif.grab_focus()
msg = "Jumping to SAP Note %s" % sid
844,8 → 851,8
 
 
def gui_sapnotes_select_all_none(self, witch, state):
visor = self.srvgui.get_widget('visor_sapnotes')
model = visor.get_model()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
model = visor_sapnotes.get_model()
 
def get_selected_sapnotes(model, path, itr):
component = model.get(itr, 5)
900,9 → 907,9
# ~ self.log.debug(annotation)
annotation["Content"] = content
self.srvant.create(annotation)
visor_attachemnts.populate_attachments()
visor_annotations.populate_annotations()
visor_sapnotes.populate_sapnotes()
visor_attachemnts.populate()
visor_annotations.populate()
visor_sapnotes.populate()
else:
self.log.warning("No files selected to attach")
 
942,8 → 949,8
annotation["Content"] = content
self.srvant.create(annotation)
self.srvant.update_timestamp(aid)
visor_attachemnts.populate_attachments()
visor_annotations.populate_annotations()
visor_attachemnts.populate()
visor_annotations.populate()
else:
self.log.warning("No files selected to attach")
981,8 → 988,8
# ~ self.log.debug(annotation)
annotation["Content"] = content
self.srvant.create(annotation)
visor_attachemnts.populate_attachments()
visor_annotations.populate_annotations()
visor_attachemnts.populate()
visor_annotations.populate()
else:
self.log.warning("No files selected to attach")
 
/branches/BR-0.4/basico/widgets/wdg_cols.py
217,14 → 217,14
self.srvdtb.set_collections(self.sid, selected, self.overwrite)
self.srvuif.statusbar_msg("Selected collection linked to SAP Note %s" % str(int(self.sid)), True)
except:
visor = self.srvgui.get_widget('visor_sapnotes')
bag = visor.get_filtered_bag()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
bag = visor_sapnotes.get_filtered_bag()
for sid in bag:
self.srvdtb.set_collections(sid, selected, self.overwrite)
self.srvuif.statusbar_msg("Selected collections linked to all SAP Note in this view", True)
visor = self.srvgui.get_widget('visor_sapnotes')
visor.populate_sapnotes()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes.populate()
viewmenu = self.srvgui.get_widget('viewmenu')
viewmenu.populate()
viewmenu.grab_focus()
/branches/BR-0.4/basico/widgets/wdg_menuview.py
236,11 → 236,11
 
 
def refresh(self):
visor = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
try:
if self.row_type is not None:
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches)
visor_sapnotes.populate(matches)
except Exception as error:
pass
 
247,7 → 247,7
 
def row_changed(self, selection):
if self.current_status is None:
visor = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
self.srvclb.gui_show_visor_sapnotes()
 
try:
261,7 → 261,7
self.set_current_collection(self.cid)
if not iter_has_child:
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches, self.cid)
visor_sapnotes.populate(matches, self.cid)
else:
matches = set()
cols = self.srvclt.get_collections_by_row_title(row_title)
268,11 → 268,11
for col in cols:
for sid in self.srvdtb.get_notes_by_node(self.row_type, col):
matches.add(sid)
visor.populate_sapnotes(list(matches))
visor_sapnotes.populate(list(matches))
else:
self.set_current_collection(None)
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches, self.cid)
visor_sapnotes.populate(matches, self.cid)
self.srvuif.statusbar_msg("View populated with %d SAP Notes" % (len(matches)))
except Exception as error:
pass
492,7 → 492,7
elif self.view == 'collection':
self.populate_by_collection(sapnotes)
elif self.view == 'annotation':
self.populate_annotations()
self.populate()
else:
self.populate_by_components(sapnotes)
 
512,8 → 512,8
matches.append(sid)
matches.sort()
 
visor = self.srvgui.get_widget('visor_sapnotes')
visor.populate_sapnotes(matches)
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
visor_sapnotes.populate(matches)
self.srvuif.statusbar_msg("View <i>%s</i> populated with %d SAP Notes" % (self.row_type, len(matches)))
 
 
725,8 → 725,8
 
 
def populate_annotations(self, annotations=None):
visor = self.srvgui.get_widget('visor_annotations')
visor.populate_annotations(annotations)
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_annotations.populate(annotations)
 
 
def populate_by_chronologic(self, sapnotes):
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
117,19 → 117,19
def set_visible_category(self, togglebutton, title):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_CATEGORY_%s_VISIBLE' % title.upper(), active)
self.populate_annotations()
self.populate()
 
 
def set_visible_annotation_type(self, togglebutton, atype):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_TYPE_%s_VISIBLE' % atype.upper(), active)
self.populate_annotations()
self.populate()
 
 
def set_visible_priority(self, togglebutton, title):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_PRIORITY_%s_VISIBLE' % title.upper(), active)
self.populate_annotations()
self.populate()
 
 
def setup_visor(self):
355,7 → 355,7
self.treeview.set_grid_lines(Gtk.TreeViewGridLines.NONE)
self.treeview.set_enable_tree_lines(True)
self.treeview.set_level_indentation(10)
self.treeview.connect('button_press_event', self.right_click)
self.treeview.connect('button_press_event', self.row_right_click)
 
self.treeview.modify_font(Pango.FontDescription('Monospace 9'))
382,7 → 382,7
self.treeview.set_model(self.sorted_model)
 
# Other signals
self.treeview.connect('row-activated', self.double_click)
self.treeview.connect('row-activated', self.row_double_click)
 
self.show_all()
 
496,10 → 496,10
 
def reload(self):
bag = self.get_bag()
self.populate_annotations(bag)
self.populate(bag)
 
 
def populate_annotations(self, annotations=None):
def populate(self, annotations=None):
self.column_sid.set_visible(False)
self.column_checkbox.set_visible(False)
self.column_category.set_visible(True)
583,13 → 583,13
self.treeview.set_model(self.sorted_model)
self.sort_by_timestamp()
self.update_total_annotations_count()
self.log.debug("Visor updated")
 
 
def show_widgets(self):
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
 
 
def double_click(self, treeview, row, col):
def row_double_click(self, treeview, row, col):
try:
selection = treeview.get_selection()
model, treeiter = selection.get_selected()
616,7 → 616,7
dialog.destroy()
# ~ #FIXME: create an empty file for contents
 
def right_click(self, treeview, event, data=None):
def row_right_click(self, treeview, event, data=None):
if event.button == 3:
rect = Gdk.Rectangle()
rect.x = x = int(event.x)
/branches/BR-0.4/basico/widgets/wdg_visor_attachments.py
50,7 → 50,7
for atype in ATYPES:
self.icons['type'][atype.lower()] = self.srvicm.get_pixbuf_icon('basico-attachment-type-%s' % atype.lower())
self.log.debug("Attachments Visor initialized")
self.populate_attachments()
self.populate()
 
 
def get_services(self):
387,10 → 387,10
 
def reload(self):
bag = self.get_bag()
self.populate_attachments(bag)
self.populate(bag)
 
 
def populate_attachments(self, attachments=None):
def populate(self, attachments=None):
# ~ completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
# ~ completion_model = completion.get_model()
# ~ completion_model.clear()
443,8 → 443,8
self.treeview.set_model(self.sorted_model)
self.sort_by_timestamp()
self.update_total_attachments_count()
self.log.debug("Visor updated")
 
 
def show_widgets(self):
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
 
/branches/BR-0.4/basico/widgets/wdg_visor_sapnotes.py
386,10 → 386,10
 
 
def reload(self):
self.populate_sapnotes(self.bag)
self.populate(self.bag)
 
 
def populate_sapnotes(self, bag=None, cid=None):
def populate(self, bag=None, cid=None):
icon_sapnote = self.srvicm.get_pixbuf_icon('basico-sapnote', 32, 32)
icon_bookmark = self.srvicm.get_pixbuf_icon('basico-bookmarks', 32, 32)
for atype in ATYPES:
493,8 → 493,8
self.show_widgets()
stack = self.srvgui.get_widget('gtk_stack_main')
stack.set_visible_child_name('visor')
self.log.debug("Visor updated")
 
 
def show_widgets(self):
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
 
622,8 → 622,8
 
 
def get_filtered_bag(self):
visor = self.srvgui.get_widget('visor_sapnotes')
model = visor.get_sorted_model()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
model = visor_sapnotes.get_sorted_model()
selected = []
 
def get_selected_sapnotes(model, path, itr):