Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 404 → Rev 405

/branches/BR-0.4/basico/core/mod_win.py
248,6 → 248,9
 
 
def setup_widgets(self):
# Statusbar
statusbar = self.srvgui.add_widget('widget_statusbar', Statusbar(self.controller))
 
# Mainbox
mainbox = self.srvgui.add_widget('gtk_vbox_container_main', Gtk.VBox())
mainbox.set_hexpand(True)
271,8 → 274,7
paned.add2(box)
mainbox.pack_start(paned, True, True, 0)
 
# Statusbar
statusbar = self.srvgui.add_widget('widget_statusbar', Statusbar(self.controller))
 
mainbox.pack_start(statusbar, False, False, 0)
 
# Connect signals for visor annotations
/branches/BR-0.4/basico/services/srv_callbacks.py
20,7 → 20,6
 
from basico.core.mod_srv import Service
from basico.core.mod_env import FILE, LPATH, ATYPES, APP
from basico.widgets.wdg_visor_sapnotes import SAPNotesVisor
from basico.widgets.wdg_cols import CollectionsMgtView
from basico.widgets.wdg_settingsview import SettingsView
 
/branches/BR-0.4/basico/services/srv_gui.py
203,7 → 203,10
"""
try:
return self.widgets[name]
except KeyError:
except KeyError as warning:
self.log.warning(warning)
# ~ self.log.error(self.get_traceback())
raise
return None
 
 
/branches/BR-0.4/basico/widgets/wdg_menuview.py
100,7 → 100,7
self.set_enable_search(True)
self.set_hover_selection(False)
self.set_grid_lines(Gtk.TreeViewGridLines.NONE)
self.set_search_entry(self.srvgui.get_widget('stySearchInfo'))
# ~ self.set_search_entry(self.srvgui.get_widget('stySearchInfo'))
self.set_search_column(1)
#~ self.set_row_separator_func(self.row_separator_func)
 
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
613,9 → 613,11
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')
lblnotescount.modify_font(Pango.FontDescription('Monospace 12'))
total = self.srvant.get_total()
count = len(visible_filter)
lblnotescount.set_markup("<b>%d/<big>%d annotations</big></b>" % (count, total))
selected = len(self.rows_toggled())
lblnotescount.set_markup("<b><small>%d</small>/%d/<big>%d</big></b>" % (selected, count, total))
msg = 'View populated with %d annotations' % count
self.srvuif.statusbar_msg(msg)
 
705,6 → 707,7
model = sorted_model.get_model()
rpath = sorted_model.convert_path_to_child_path(Gtk.TreePath(path))
model[rpath][COLUMN.CHECKBOX] = not model[rpath][COLUMN.CHECKBOX]
self.update_total_annotations_count()
 
 
def __get_node(self, key, icon, checkbox, sid, title, component, atype, scope='', sntype='', priority='', updated='', ts_updated='', created='', ts_created=''):
991,6 → 994,7
 
model = sorted_model.get_model()
model.foreach(check_row)
self.update_total_annotations_count()
self.srvuif.grab_focus()
 
 
/branches/BR-0.4/basico/widgets/wdg_visor_sapnotes.py
12,6 → 12,7
from cgi import escape
import glob
import json
from enum import IntEnum
 
import gi
gi.require_version('Gdk', '3.0')
32,6 → 33,20
from basico.widgets.wdg_menuview import MenuView
 
 
class COLUMN(IntEnum):
KEY = 0
ICON = 1
CHECKBOX = 2
SID = 3
TITLE = 4
COMPONENT = 5
CATEGORY = 6
TYPE = 7
PRIORITY = 8
UPDATED = 9
TS_UPDATED = 10
 
 
class SAPNotesVisor(BasicoWidget, Gtk.Box):
def __init__(self, app):
super().__init__(app, __class__.__name__)
64,13 → 79,9
self.srvatc = self.get_service('Attachment')
 
 
def get_treeview(self):
return self.treeview
 
 
def sort_by_timestamp(self):
sorted_model = self.srvgui.get_widget('visor_sapnotes_sorted_model')
sorted_model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
sorted_model.set_sort_column_id(COLUMN.TS_UPDATED, Gtk.SortType.DESCENDING)
 
 
def setup_panel(self):
124,6 → 135,8
 
hbox = Gtk.HBox()
viewfilter = self.srvgui.add_widget('gtk_entry_filter_view', Gtk.Entry())
viewmenu = self.srvgui.add_widget('viewmenu', MenuView(self.app))
viewmenu.set_vexpand(True)
completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
viewfilter.set_completion(completion)
viewfilter.connect('activate', self.srvclb.gui_viewmenu_filter)
168,9 → 181,6
vwp.set_hexpand(True)
viewsbox = self.srvgui.add_widget('gtk_box_container_views', Gtk.Box())
# ~ viewsbox.set_hexpand(True)
viewmenu = self.srvgui.add_widget('viewmenu', MenuView(self.app))
# ~ viewmenu.set_hexpand(True)
viewmenu.set_vexpand(True)
viewsbox.pack_start(viewmenu, True, True, 0)
vwp.add(viewsbox)
scr.add(vwp)
187,13 → 197,13
scr = Gtk.ScrolledWindow()
scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scr.set_shadow_type(Gtk.ShadowType.IN)
self.treeview = Gtk.TreeView()
scr.add(self.treeview)
treeview = self.srvgui.add_widget('visor_sapnotes_treeview', Gtk.TreeView())
scr.add(treeview)
visor.pack_start(scr, True, True, 0)
visor.show_all()
 
# Setup model
self.model = Gtk.ListStore(
model = Gtk.ListStore(
int, # key
Pixbuf, # Icon
int, # checkbox
204,9 → 214,9
str, # type
str, # priority
str, # last update
str, # Annotation Id (extra key)
str, # Timestamp
)
self.srvgui.add_widget('gtk_model_sapnotes', model)
 
# Setup columns
def get_column_header_widget(title, icon_name=None, width=28, height=28):
223,30 → 233,32
# SAP Note key
self.renderer_key = Gtk.CellRendererText()
self.renderer_key.set_property('height', 32)
self.column_key = Gtk.TreeViewColumn('Key', self.renderer_key, text=0)
self.column_key = Gtk.TreeViewColumn('Key', self.renderer_key, text=COLUMN.KEY)
self.column_key.set_visible(False)
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)
 
# Icon
self.renderer_icon = Gtk.CellRendererPixbuf()
self.renderer_icon.set_alignment(0.0, 0.5)
self.column_icon = Gtk.TreeViewColumn('', self.renderer_icon, pixbuf=1)
self.column_icon = Gtk.TreeViewColumn('', self.renderer_icon, pixbuf=COLUMN.ICON)
# ~ widget = get_column_header_widget('', '')
# ~ self.column_icon.set_widget(widget)
self.column_icon.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_icon.set_visible(True)
self.column_icon.set_expand(False)
self.column_icon.set_clickable(False)
self.column_icon.set_sort_indicator(False)
self.treeview.append_column(self.column_icon)
self.column_icon.set_clickable(True)
self.column_icon.set_sort_indicator(True)
self.column_icon.set_sort_column_id(COLUMN.TYPE)
self.column_icon.set_sort_order(Gtk.SortType.ASCENDING)
treeview.append_column(self.column_icon)
 
# SAP Note Checkbox
self.renderer_checkbox = Gtk.CellRendererToggle()
self.renderer_checkbox.connect("toggled", self.__clb_row_toggled)
self.column_checkbox = Gtk.TreeViewColumn('', self.renderer_checkbox, active=2)
self.column_checkbox = Gtk.TreeViewColumn('', self.renderer_checkbox, active=COLUMN.CHECKBOX)
widget = get_column_header_widget('', 'basico-check-accept')
self.column_checkbox.set_widget(widget)
self.column_checkbox.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
255,7 → 267,7
self.column_checkbox.set_clickable(True)
self.column_checkbox.set_sort_indicator(False)
self.column_checkbox.set_property('spacing', 50)
self.treeview.append_column(self.column_checkbox)
treeview.append_column(self.column_checkbox)
 
# SAP Note Id
self.renderer_sid = Gtk.CellRendererText()
262,7 → 274,7
self.renderer_sid.set_property('xalign', 1.0)
self.renderer_sid.set_property('height', 36)
self.renderer_sid.set_property('background', '#F0E3E3')
self.column_sid = Gtk.TreeViewColumn('SAP Note', self.renderer_sid, markup=3)
self.column_sid = Gtk.TreeViewColumn('SAP Note', self.renderer_sid, markup=COLUMN.SID)
# ~ widget = get_column_header_widget('SAP Note', 'basico-sapnote')
# ~ self.column_sid.set_widget(widget)
self.column_sid.set_visible(True)
270,16 → 282,16
self.column_sid.set_expand(False)
self.column_sid.set_clickable(True)
self.column_sid.set_sort_indicator(True)
self.column_sid.set_sort_column_id(0)
self.column_sid.set_sort_column_id(COLUMN.SID)
self.column_sid.set_sort_order(Gtk.SortType.ASCENDING)
self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
self.treeview.append_column(self.column_sid)
# ~ model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
treeview.append_column(self.column_sid)
 
# SAP Note title
self.renderer_title = Gtk.CellRendererText()
self.renderer_title.set_property('background', '#FFFEEA')
self.renderer_title.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
self.column_title = Gtk.TreeViewColumn('Title', self.renderer_title, markup=4)
self.column_title = Gtk.TreeViewColumn('Title', self.renderer_title, markup=COLUMN.TITLE)
widget = get_column_header_widget('Title', 'basico-tag')
self.column_title.set_widget(widget)
self.column_title.set_visible(True)
287,13 → 299,13
self.column_title.set_expand(True)
self.column_title.set_clickable(True)
self.column_title.set_sort_indicator(True)
self.column_title.set_sort_column_id(4)
self.treeview.append_column(self.column_title)
self.column_title.set_sort_column_id(COLUMN.TITLE)
treeview.append_column(self.column_title)
 
# SAP Note Component
self.renderer_component = Gtk.CellRendererText()
self.renderer_component.set_property('background', '#E3E3F0')
self.column_component = Gtk.TreeViewColumn('Component', self.renderer_component, markup=5)
self.column_component = Gtk.TreeViewColumn('Component', self.renderer_component, markup=COLUMN.COMPONENT)
widget = get_column_header_widget('Component', 'basico-component')
self.column_component.set_widget(widget)
self.column_component.set_visible(True)
301,13 → 313,13
self.column_component.set_expand(False)
self.column_component.set_clickable(True)
self.column_component.set_sort_indicator(True)
self.column_component.set_sort_column_id(5)
self.treeview.append_column(self.column_component)
self.column_component.set_sort_column_id(COLUMN.COMPONENT)
treeview.append_column(self.column_component)
 
# SAP Note Category
self.renderer_category = Gtk.CellRendererText()
self.renderer_category.set_property('background', '#E3F1E3')
self.column_category = Gtk.TreeViewColumn('Category', self.renderer_category, markup=6)
self.column_category = Gtk.TreeViewColumn('Category', self.renderer_category, markup=COLUMN.CATEGORY)
widget = get_column_header_widget('Category', 'basico-category')
self.column_category.set_widget(widget)
self.column_category.set_visible(False)
315,13 → 327,13
self.column_category.set_expand(False)
self.column_category.set_clickable(True)
self.column_category.set_sort_indicator(True)
self.column_category.set_sort_column_id(6)
self.treeview.append_column(self.column_category)
self.column_category.set_sort_column_id(COLUMN.CATEGORY)
treeview.append_column(self.column_category)
 
# SAP Note Type
self.renderer_type = Gtk.CellRendererText()
self.renderer_type.set_property('background', '#e4f1f1')
self.column_type = Gtk.TreeViewColumn('Type', self.renderer_type, markup=7)
self.column_type = Gtk.TreeViewColumn('Type', self.renderer_type, markup=COLUMN.TYPE)
widget = get_column_header_widget('Type', 'basico-type')
self.column_type.set_widget(widget)
self.column_type.set_visible(True)
329,12 → 341,12
self.column_type.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_type.set_clickable(True)
self.column_type.set_sort_indicator(True)
self.column_type.set_sort_column_id(7)
self.treeview.append_column(self.column_type)
self.column_type.set_sort_column_id(COLUMN.TYPE)
treeview.append_column(self.column_type)
 
# SAP Note Priority
self.renderer_priority = Gtk.CellRendererText()
self.column_priority = Gtk.TreeViewColumn('Priority', self.renderer_priority, markup=8)
self.column_priority = Gtk.TreeViewColumn('Priority', self.renderer_priority, markup=COLUMN.PRIORITY)
widget = get_column_header_widget('Type', 'basico-priority')
self.column_priority.set_widget(widget)
self.column_priority.set_visible(False)
341,13 → 353,13
self.column_priority.set_expand(True)
self.column_priority.set_clickable(True)
self.column_priority.set_sort_indicator(True)
self.column_priority.set_sort_column_id(8)
self.treeview.append_column(self.column_priority)
self.column_priority.set_sort_column_id(COLUMN.PRIORITY)
treeview.append_column(self.column_priority)
 
# SAP Note UpdatedOn
self.renderer_updated = Gtk.CellRendererText()
self.renderer_updated.set_property('background', '#FFE6D1')
self.column_updated = Gtk.TreeViewColumn('Updated', self.renderer_updated, markup=9)
self.column_updated = Gtk.TreeViewColumn('Updated', self.renderer_updated, markup=COLUMN.UPDATED)
widget = get_column_header_widget('Updated', 'basico-chronologic')
self.column_updated.set_widget(widget)
self.column_updated.set_visible(True)
355,38 → 367,29
self.column_updated.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_updated.set_clickable(True)
self.column_updated.set_sort_indicator(True)
self.column_updated.set_sort_column_id(11)
self.treeview.append_column(self.column_updated)
self.column_updated.set_sort_column_id(COLUMN.TS_UPDATED)
treeview.append_column(self.column_updated)
 
# Annotation Id
self.renderer_annotation = Gtk.CellRendererText()
self.column_annotation = Gtk.TreeViewColumn('Annotation Id', self.renderer_annotation, markup=10)
self.column_annotation.set_visible(False)
self.column_annotation.set_expand(False)
self.column_annotation.set_clickable(False)
self.column_annotation.set_sort_indicator(False)
self.treeview.append_column(self.column_annotation)
 
# Timestamp
self.renderer_timestamp = Gtk.CellRendererText()
self.column_timestamp = Gtk.TreeViewColumn('Annotation Id', self.renderer_timestamp, text=11)
self.column_timestamp = Gtk.TreeViewColumn('Annotation Id', self.renderer_timestamp, text=COLUMN.TS_UPDATED)
self.column_timestamp.set_visible(False)
self.column_timestamp.set_expand(False)
self.column_timestamp.set_clickable(False)
self.column_timestamp.set_sort_indicator(False)
self.treeview.append_column(self.column_timestamp)
treeview.append_column(self.column_timestamp)
 
# Treeview properties
self.treeview.set_can_focus(False)
self.treeview.set_enable_tree_lines(True)
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)
self.treeview.set_enable_tree_lines(True)
self.treeview.set_level_indentation(10)
# ~ self.treeview.modify_font(Pango.FontDescription('Monospace 10'))
self.treeview.connect('button_press_event', self.right_click)
treeview.set_can_focus(False)
treeview.set_enable_tree_lines(True)
treeview.set_headers_visible(True)
treeview.set_enable_search(True)
treeview.set_hover_selection(False)
treeview.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
treeview.set_enable_tree_lines(True)
treeview.set_level_indentation(10)
# ~ treeview.modify_font(Pango.FontDescription('Monospace 10'))
treeview.connect('button_press_event', self.right_click)
 
# DOC: In order to have a Gtk.Widged with sorting and filtering
# capabilities, you have to filter the model first, and use this
394,7 → 397,7
# model to the treeview...
 
# Treeview filtering:
self.visible_filter = self.model.filter_new()
self.visible_filter = model.filter_new()
self.visible_filter.set_visible_func(self.visible_function)
# https://stackoverflow.com/questions/23355866/user-search-collapsed-rows-in-a-gtk-treeview
 
404,12 → 407,12
sorted_model.set_sort_func(0, self.sort_function, None)
 
# 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)
 
# Set model (filtered and sorted)
self.treeview.set_model(sorted_model)
treeview.set_model(sorted_model)
 
self.show_all()
return visor
436,8 → 439,8
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]
component = model.get(itr, 5)[0]
title = model.get(itr, COLUMN.TITLE)[0]
component = model.get(itr, COLUMN.COMPONENT)[0]
fields = title + ' ' + component
match = text.upper() in fields.upper()
 
449,7 → 452,7
lblnotescount = self.srvgui.get_widget('gtk_label_total_notes')
total = self.srvdtb.get_total()
count = len(self.visible_filter)
lblnotescount.set_markup("<b>%d/<big>%d SAP Notes</big></b>" % (count, total))
lblnotescount.set_markup("<b>%d/<big>%d</big></b>" % (count, total))
msg = 'View populated with %d SAP Notes' % count
self.srvuif.statusbar_msg(msg)
 
459,20 → 462,20
 
 
def row_changed(self, selection):
try:
model, treeiter = selection.get_selected()
if treeiter is not None:
component = model[treeiter][5]
if component == 'Annotation':
aid = model[treeiter][10]
is_valid = self.srvant.is_valid(aid)
if is_valid:
self.srvclb.action_annotation_edit(aid)
else:
aid = None
# ~ self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
except Exception as error:
self.log.debug(error)
pass
# ~ try:
# ~ model, treeiter = selection.get_selected()
# ~ if treeiter is not None:
# ~ component = model[treeiter][5]
# ~ if component == 'Annotation':
# ~ aid = model[treeiter][10]
# ~ is_valid = self.srvant.is_valid(aid)
# ~ if is_valid:
# ~ self.srvclb.action_annotation_edit(aid)
# ~ else:
# ~ aid = None
# ~ except Exception as error:
# ~ self.log.debug(error)
 
 
def __clb_row_toggled(self, cell, path):
479,7 → 482,7
sorted_model = self.srvgui.get_widget('visor_sapnotes_sorted_model')
model = sorted_model.get_model()
rpath = sorted_model.convert_path_to_child_path(Gtk.TreePath(path))
model[rpath][2] = not model[rpath][2]
model[rpath][COLUMN.CHECKBOX] = not model[rpath][COLUMN.CHECKBOX]
 
 
def get_node(self, key, icon, checkbox, sid, title, component, category='', sntype='', priority='', updated='', aid='', timestamp=''):
500,19 → 503,10
node.append(sntype)
node.append(priority)
node.append(updated)
node.append(aid) # Extra key for annotations id (aid)
node.append(timestamp)
return node
 
 
def get_model(self):
return self.model
 
 
def get_sorted_model(self):
return self.sorted_model
 
 
def get_bag(self):
return self.bag
 
522,6 → 516,8
 
 
def populate(self, bag=None, cid=None):
self.log.debug("Hello")
model = self.srvgui.get_widget('gtk_model_sapnotes')
sorted_model = self.srvgui.get_widget('visor_sapnotes_sorted_model')
icon_sapnote = self.srvicm.get_pixbuf_icon('basico-sapnote', 32, 32)
# ~ icon_sap_note = self.srvicm.get_pixbuf_icon('basico-sap-note', 32, 32)
536,14 → 532,12
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.clear()
self.model.clear()
 
model.clear()
if bag is None:
bag = self.bag
else:
self.bag = bag
 
 
for sid in self.bag:
metadata = self.srvdtb.get_sapnote_metadata(sid)
if metadata is not None:
575,9 → 569,9
timestamp = timestamp.replace('T', '_')
stype = escape(metadata['type'].lower())
icon_name = 'basico-%s' % stype.replace(' ', '-')
self.log.debug(icon_name)
# ~ self.log.debug(icon_name)
icon = self.srvicm.get_pixbuf_icon(icon_name, 36, 36)
self.log.debug(icon)
# ~ self.log.debug(icon)
# ~ self.log.debug(icon_name)
icon_name = None
node = self.get_node( int(metadata['id']),
590,10 → 584,9
escape(metadata['type']),
escape(metadata['priority']),
self.srvutl.fuzzy_date_from_timestamp(timestamp),
'',
timestamp
)
pid = self.model.append(node)
pid = model.append(node)
 
# Load annotations
# ~ files = self.srvant.get_by_sid(metadata['id'])
618,7 → 611,7
# ~ annotation['AID'],
# ~ annotation['Timestamp']
# ~ )
# ~ self.model.append(pid, node)
# ~ model.append(pid, node)
 
# Load attachments
# ~ files = self.srvatc.get_by_sid(metadata['id'])
639,9 → 632,9
# ~ attachment['TID'],
# ~ attachment['Created']
# ~ )
# ~ self.model.append(pid, node)
 
self.treeview.set_model(sorted_model)
# ~ model.append(pid, node)
treeview = self.srvgui.get_widget('visor_sapnotes_treeview')
treeview.set_model(sorted_model)
self.update_total_sapnotes_count()
self.show_widgets()
self.srvclb.gui_show_dashboard()
654,17 → 647,18
 
 
def right_click(self, treeview, event, data=None):
treeview = self.srvgui.get_widget('visor_sapnotes_treeview')
if event.button == 3:
rect = Gdk.Rectangle()
rect.x = x = int(event.x)
rect.y = y = int(event.y)
pthinfo = self.treeview.get_path_at_pos(x,y)
pthinfo = treeview.get_path_at_pos(x,y)
if pthinfo is not None:
path,col,cellx,celly = pthinfo
model = treeview.get_model()
treeiter = model.get_iter(path)
component = model[treeiter][5]
sid = model[treeiter][0]
component = model[treeiter][COLUMN.COMPONENT]
sid = model[treeiter][COLUMN.KEY]
if sid == 0:
return
sid = "0"*(10 - len(str(sid))) + str(sid)
802,8 → 796,7
selected = []
 
def get_selected_sapnotes(model, path, itr):
sid = model.get(itr, 0)[0]
aid = model.get(itr, 10)[0]
sid = model.get(itr, COLUMN.SID)[0]
if len(aid) == 0:
selected.append(str(sid))