Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 254 → Rev 255

/branches/BR-0.3/basico/basico.py
1,5 → 1,5
"""
#!/usr/bin/python3
#!/usr/bin/python 3
# -*- coding: utf-8 -*-
# File: basico.py
# Author: Tomás Vírseda
/branches/BR-0.3/basico/core/mod_win.py
51,6 → 51,7
self.srvuif = self.controller.get_service("UIF")
self.srvicm = self.controller.get_service('IM')
self.srvclb = self.controller.get_service('Callbacks')
self.srvant = self.controller.get_service('Annotation')
 
 
def setup_controller(self, uiapp):
386,19 → 387,25
 
### Visor
notebook = self.srvgui.add_widget('gtk_notebook_visor', Gtk.Notebook())
notebook.connect('switch-page', self.srvclb.gui_visor_switch_page)
notebook.set_show_border(False)
notebook.set_hexpand(True)
 
visor_sapnotes = self.setup_tab_sapnote_visor()
notebook.append_page(visor_sapnotes, Gtk.Label('SAP Notes'))
 
visor_sapnotes_page = self.setup_tab_sapnote_visor()
visor_sapnotes_page.set_hexpand(True)
tab_widget = self.srvuif.create_notebook_tab_label('basico-sapnote', '<b>SAP Notes</b>')
notebook.append_page(visor_sapnotes_page, tab_widget)
 
visor_annotations_page = self.setup_tab_annotations_visor()
notebook.append_page(
visor_annotations_page,
Gtk.Image.new_from_icon_name(
"help-about",
Gtk.IconSize.MENU
)
)
self.controller.debug(visor_sapnotes == visor_annotations_page)
tab_widget = self.srvuif.create_notebook_tab_label('basico-annotation', '<b>Annotations</b>')
notebook.append_page(visor_annotations_page, tab_widget)
 
notebook.child_set_property(visor_sapnotes_page, "tab-expand", True)
notebook.child_set_property(visor_sapnotes_page, "tab-fill", False)
notebook.child_set_property(visor_annotations_page, "tab-expand", True)
notebook.child_set_property(visor_annotations_page, "tab-fill", False)
 
box.pack_start(notebook, True, True, 0)
 
return box
417,6 → 424,7
scr = Gtk.ScrolledWindow()
scr.set_hexpand(True)
scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scr.set_shadow_type(Gtk.ShadowType.NONE)
vwp = Gtk.Viewport()
vwp.set_hexpand(True)
visor = self.srvgui.add_widget('visor_sapnotes', SAPNotesVisor(self.controller))
444,6 → 452,7
scr = Gtk.ScrolledWindow()
scr.set_hexpand(True)
scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scr.set_shadow_type(Gtk.ShadowType.NONE)
vwp = Gtk.Viewport()
vwp.set_hexpand(True)
visor = self.srvgui.add_widget('visor_annotations', AnnotationsVisor(self.controller))
487,7 → 496,9
 
 
def run(self):
visor_annotations = self.srvgui.get_widget('visor_annotations')
viewmenu = self.srvgui.get_widget('viewmenu')
viewmenu.set_view('annotation')
viewmenu.set_view('collection')
self.srvclb.gui_show_dashboard()
# ~ self.srvclb.gui_show_about()
annotations = self.srvant.search_term('')
visor_annotations.populate_annotations(annotations)
/branches/BR-0.3/basico/services/srv_cb.py
45,18 → 45,24
self.srvbnr = self.get_service('BNR')
 
 
def gui_visor_switch_page(self, notebook, page, page_num):
# 0|1 -> SAP Notes Visor | Annotations Visor
self.srvgui.set_key_value('current_visor_tab', page_num)
 
 
 
def action_search(self, entry):
visor = self.srvgui.get_widget('visor_sapnotes')
viewmenu = self.srvgui.get_widget('viewmenu')
view = viewmenu.get_view()
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
visor_annotations = self.srvgui.get_widget('visor_annotations')
term = entry.get_text()
page = self.srvgui.get_key_value('current_visor_tab')
 
if view != 'annotation':
if page == 0:
bag = self.srvdtb.search(term)
visor.populate_sapnotes(bag)
else:
visor_sapnotes.populate_sapnotes(bag)
elif page == 1:
annotations = self.srvant.search_term(term)
visor.populate_annotations(annotations)
visor_annotations.populate_annotations(annotations)
 
ebuffer = entry.get_buffer()
ebuffer.delete_text(0, -1)
346,7 → 352,21
 
 
def gui_filter_visor(self, entry):
visor = self.srvgui.get_widget('visor_sapnotes')
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()
visible_filter.refilter()
visor.update_total_sapnotes_count(len(visible_filter))
elif page == 1:
visor = self.srvgui.get_widget('visor_annotations')
visible_filter = visor.get_visible_filter()
visible_filter.refilter()
# ~ visor.update_total_sapnotes_count(len(visible_filter))
 
 
def gui_filter_visor_annotations(self, entry):
visor = self.srvgui.get_widget('visor_annotations')
self.debug(visor)
visible_filter = visor.get_visible_filter()
visible_filter.refilter()
439,8 → 459,8
 
self.gui_annotation_widget_clear()
# ~ visor.populate_annotations()
viewmenu.set_view('annotation')
viewmenu.populate()
# ~ viewmenu.set_view('annotation')
# ~ viewmenu.populate()
 
 
def action_annotation_cancel(self, *args):
/branches/BR-0.3/basico/services/srv_cols.py
55,6 → 55,13
def get_all(self):
return self.clts
 
def get_collections_by_row_title(self, row_title):
cids = []
for cid in self.clts:
col_name = self.get_name_by_cid(cid)
if row_title in col_name:
cids.append(cid)
return cids
 
def get_collections_name(self):
names = []
/branches/BR-0.3/basico/services/srv_gui.py
123,7 → 123,11
widget.show_all()
 
 
def get_key(self, key):
def get_keys(self):
return self.keys
 
 
def get_key_value(self, key):
"""
Return current value from var cache
"""
130,7 → 134,7
return self.keys[key]
 
 
def set_key(self, key, value):
def set_key_value(self, key, value):
"""
Set current value for var cache
"""
/branches/BR-0.3/basico/services/srv_uif.py
68,7 → 68,18
 
return button
 
def create_notebook_tab_label(self, iconname, title):
hbox = Gtk.HBox()
icon = self.srvicm.get_new_image_icon(iconname)
label = Gtk.Label()
label.set_markup(title)
hbox.pack_start(icon, False, False, 3)
hbox.pack_start(label, False, False, 0)
hbox.show_all()
 
return hbox
 
 
def create_button(self, icon_name=None, icon_width=32, icon_heigth=32, title=''):
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
/branches/BR-0.3/basico/widgets/wdg_cols.py
9,6 → 9,7
 
import gi
from gi.repository import Gtk
from gi.repository import GObject
 
gi.require_version('Gtk', '3.0')
 
25,7 → 26,6
self.current_cid = None
self.get_services()
self.setup()
self.setup_treeview()
self.update()
 
 
70,8 → 70,9
# Entry Widget / Delete entry button
hbox = Gtk.HBox()
self.entry = self.srvgui.add_widget('gtk_entry_collection_new', Gtk.Entry())
self.entry.connect('changed', self.on_entry_changed)
self.entry.connect('activate', self.update)
self.entry.connect('changed', self.filter)
# ~ self.entry.connect('changed', self.filter)
delete = self.srvuif.create_button('basico-delete', 24, 24, '')
delete.connect('clicked', self.delete)
hbox.pack_start(self.entry, True, True, 6)
83,7 → 84,8
scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scr.set_shadow_type(Gtk.ShadowType.IN)
viewport = Gtk.Viewport()
self.treeview = Gtk.TreeView()
# ~ self.treeview = Gtk.TreeView()
self.treeview = self.setup_treeview()
viewport.add(self.treeview)
scr.add(viewport)
self.pack_start(scr, True, True, 6)
106,6 → 108,7
Missing method docstring (missing-docstring)
"""
# Setup model
treeview = Gtk.TreeView()
self.model = Gtk.ListStore(
str, # key
int, # checkbox
120,7 → 123,7
self.column_key.set_expand(False)
self.column_key.set_clickable(False)
self.column_key.set_sort_indicator(False)
self.treeview.append_column(self.column_key)
treeview.append_column(self.column_key)
 
# Collection Checkbox
self.renderer_checkbox = Gtk.CellRendererToggle()
134,10 → 137,12
self.column_checkbox.set_expand(False)
self.column_checkbox.set_clickable(True)
self.column_checkbox.set_sort_indicator(False)
self.treeview.append_column(self.column_checkbox)
treeview.append_column(self.column_checkbox)
 
# Collection title
self.renderer_title = Gtk.CellRendererText()
self.renderer_title.connect('edited', self.edit_title)
self.renderer_title.set_property("editable", True)
self.column_title = Gtk.TreeViewColumn('Collection', self.renderer_title, markup=2)
self.column_title.set_visible(True)
self.column_title.set_expand(True)
144,34 → 149,37
self.column_title.set_clickable(True)
self.column_title.set_sort_indicator(True)
self.model.set_sort_column_id(2, Gtk.SortType.ASCENDING)
self.treeview.append_column(self.column_title)
treeview.append_column(self.column_title)
 
# TreeView common
# ~ self.sorted_model = Gtk.TreeModelSort(model=self.model)
# ~ self.sorted_model.set_sort_column_id(2, Gtk.SortType.ASCENDING)
# ~ self.treeview.set_model(self.sorted_model)
self.sorted_model = Gtk.TreeModelSort(model=self.model)
self.sorted_model.set_sort_column_id(2, Gtk.SortType.ASCENDING)
treeview.set_model(self.sorted_model)
 
self.treeview.set_can_focus(False)
self.treeview.set_headers_visible(True)
self.treeview.set_enable_search(True)
self.treeview.set_hover_selection(False)
self.treeview.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
treeview.set_can_focus(False)
treeview.set_headers_visible(True)
treeview.set_enable_search(True)
treeview.set_hover_selection(False)
treeview.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
# ~ self.treeview.modify_font(Pango.FontDescription('Monospace 10'))
 
# Selection
self.selection = self.treeview.get_selection()
self.selection = treeview.get_selection()
self.selection.set_mode(Gtk.SelectionMode.SINGLE)
self.selection.connect('changed', self.row_changed)
self.trv_signal_changed = self.selection.connect('changed', self.row_changed)
 
# Filter
self.visible_filter = self.model.filter_new()
self.visible_filter.set_visible_func(self.visible_function)
# ~ self.visible_filter = self.model.filter_new()
# ~ self.visible_filter.set_visible_func(self.visible_function)
# ~ self.treeview.set_model(self.visible_filter)
 
self.treeview.set_model(self.visible_filter)
treeview.set_model(self.sorted_model)
 
self.show_all()
 
return treeview
 
 
def toggle_checkbox(self, cell, path):
"""
Missing method docstring (missing-docstring)
253,9 → 261,9
# ~ self.debug("Deleting collection with id: %s" % self.current_cid)
deleted = self.srvclt.delete(self.current_cid)
if deleted:
self.update()
viewmenu = self.srvgui.get_widget('viewmenu')
viewmenu.populate()
viewmenu.grab_focus()
else:
if self.current_cid is not None:
colname = self.srvclt.get_name_by_cid(self.current_cid)
279,3 → 287,35
title = model.get(itr, 2)[0]
match = text.upper() in title.upper()
return match
 
 
def on_entry_changed(self, *args):
entry = self.srvgui.get_widget('gtk_entry_collection_new')
filter = entry.get_text()
selection = self.treeview.get_selection()
 
 
def gui_iterate_over_data(model, path, itr):
title = self.sorted_model.get(itr, 2)[0]
if len(filter) > 0:
if filter.upper() in title.upper():
self.treeview.scroll_to_cell(path, self.column_title, True, 0.0, 0.0)
self.treeview.set_cursor_on_cell(path, self.column_title, self.renderer_title, False)
else:
return
 
GObject.signal_handler_block(self.selection, self.trv_signal_changed)
self.sorted_model.foreach(gui_iterate_over_data)
GObject.signal_handler_unblock(self.selection, self.trv_signal_changed)
 
 
def edit_title(self, widget, path, target):
model = self.treeview.get_model()
treeiter = model.get_iter(path)
cid = model[treeiter][0]
iter_has_child = model.iter_has_child(treeiter)
 
if not iter_has_child:
if len(target) > 0:
self.srvclt.rename(cid, target)
self.update()
/branches/BR-0.3/basico/widgets/wdg_menuview.py
103,8 → 103,8
 
# Component key
self.renderer_compkey = Gtk.CellRendererText()
self.renderer_compkey.set_property("editable", True)
self.renderer_compkey.connect('edited', self.edit_title)
# ~ self.renderer_compkey.set_property("editable", True)
# ~ self.renderer_compkey.connect('edited', self.edit_title)
# ~ self.renderer_compkey.set_editable(True)
#~ self.renderer_compkey.set_property('background', 'Lemon Chiffon')
self.column_component = Gtk.TreeViewColumn('SAP Notes', self.renderer_compkey, markup=3)
370,9 → 370,8
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches)
except Exception as error:
# ~ pass
self.app.debug(error)
self.app.print_traceback()
pass
# ~ raise
 
 
def row_changed(self, selection):
383,34 → 382,29
try:
model, treeiter = selection.get_selected()
row = model[treeiter][0]
row_title = model[treeiter][3]
self.row_type, self.cid = row.split('@')
self.app.debug("%s - %s" % (self.row_type, self.cid))
iter_has_child = model.iter_has_child(treeiter)
 
if self.row_type == 'collection':
if not iter_has_child:
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
self.app.debug(matches)
visor.populate_sapnotes(matches, self.cid)
else:
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
self.app.debug(matches)
matches = set()
cols = self.srvclt.get_collections_by_row_title(row_title)
for col in cols:
for sid in self.srvdtb.get_notes_by_node(self.row_type, col):
matches.add(sid)
if len(matches) > 0:
visor.populate_sapnotes(matches)
visor.populate_sapnotes(list(matches))
else:
visor.populate_sapnotes([])
else:
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
self.app.debug(matches)
visor.populate_sapnotes(matches, self.cid)
except AttributeError as error:
self.app.print_traceback()
except TypeError:
self.app.print_traceback()
except Exception as error:
self.app.debug(error)
# ~ pass
self.app.print_traceback()
except:
raise
 
 
def right_click(self, treeview, event, data=None):
705,7 → 699,10
ppid = treepids[key]
except:
title = key
node = self.get_node_collection(tid, title)
if title == compkey:
node = self.get_node_collection(tid, title)
else:
node = self.get_node_collection('', title)
ppid = self.model.append(ppid, node)
treepids[key] = ppid
 
776,15 → 773,15
treepids[key_day] = self.model.append(treepids[key_month], node)
 
 
def edit_title(self, widget, path, target):
model = self.get_model()
treeiter = model.get_iter(path)
row = model[treeiter][0]
rowtype, cid = row.split('@')
iter_has_child = model.iter_has_child(treeiter)
# ~ def edit_title(self, widget, path, target):
# ~ model = self.get_model()
# ~ treeiter = model.get_iter(path)
# ~ row = model[treeiter][0]
# ~ rowtype, cid = row.split('@')
# ~ iter_has_child = model.iter_has_child(treeiter)
 
if rowtype == 'collection':
if not iter_has_child:
if len(target) > 0:
self.srvclt.rename(cid, target)
self.populate()
# ~ if rowtype == 'collection':
# ~ if not iter_has_child:
# ~ if len(target) > 0:
# ~ self.srvclt.rename(cid, target)
# ~ self.populate()
/branches/BR-0.3/basico/widgets/wdg_visor_annotations.py
61,7 → 61,7
self.treeview = Gtk.TreeView()
viewport.add(self.treeview)
scr.add(viewport)
self.pack_start(scr, True, True, 6)
self.pack_start(scr, True, True, 0)
 
# Setup model
self.model = Gtk.TreeStore(
386,7 → 386,7
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.clear()
self.app.debug("VISOR:: %s" % bag)
# ~ self.app.debug("VISOR:: %s" % bag)
# ~ self.srvclb.gui_show_dashboard()
 
if bag is None:
470,7 → 470,7
self.column_category.set_visible(True)
self.column_component.set_visible(False)
# ~ self.srvclb.gui_show_dashboard()
self.app.debug("VISOR_ANNOTATIONS_1:: %s" % annotations)
# ~ self.app.debug("VISOR_ANNOTATIONS_1:: %s" % annotations)
 
self.model.clear()
 
477,7 → 477,7
if annotations is None:
annotations = self.srvant.get_all()
 
self.app.debug("VISOR_ANNOTATIONS_2:: %s" % annotations)
# ~ self.app.debug("VISOR_ANNOTATIONS_2:: %s" % annotations)
 
snpids = {}
 
498,7 → 498,7
annotation['aid'],
annotation['timestamp']
)
self.app.debug(node)
# ~ self.app.debug(node)
self.model.append(None, node)
self.treeview.set_model(self.sorted_model)
self.sort_by_timestamp()
/branches/BR-0.3/basico/widgets/wdg_visor_sapnotes.py
61,7 → 61,7
self.treeview = Gtk.TreeView()
viewport.add(self.treeview)
scr.add(viewport)
self.pack_start(scr, True, True, 6)
self.pack_start(scr, True, True, 0)
 
# Setup model
self.model = Gtk.TreeStore(
305,7 → 305,7
rtype = model.get(itr, 7)[0]
string = ' '.join(['SAP Note %s' % sid, title, component, category, rtype])
match = text.upper() in string.upper()
self.app.debug("%s in %s? %s" % (text, string, match))
# ~ self.app.debug("%s in %s? %s" % (text, string, match))
 
return match
 
338,7 → 338,7
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
except Exception as error:
self.debug(error)
self.print_traceback()
# ~ self.print_traceback()
 
 
def toggle_checkbox(self, cell, path):
386,7 → 386,7
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.clear()
self.app.debug("VISOR_SAPNOTES:: %s" % bag)
# ~ self.app.debug("VISOR_SAPNOTES:: %s" % bag)
# ~ self.srvclb.gui_show_dashboard()
 
if bag is None:
470,7 → 470,7
self.column_category.set_visible(True)
self.column_component.set_visible(False)
# ~ self.srvclb.gui_show_dashboard()
self.app.debug("ANNOTATIONS:: %s" % annotations)
# ~ self.app.debug("ANNOTATIONS:: %s" % annotations)
 
self.model.clear()
 
/branches/BR-0.3/basico/widgets/wdg_visor_toolbar.py
56,10 → 56,10
popover.add(box)
 
 
box.pack_start(self.srvuif.create_menuview_button('annotation'), False, False, 0)
# ~ box.pack_start(self.srvuif.create_menuview_button('annotation'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('collection'), False, False, 0)
separator = Gtk.Separator(orientation = Gtk.Orientation.HORIZONTAL)
box.pack_start(separator, False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('collection'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('component'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('description'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('bookmarks'), False, False, 0)