Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 401 → Rev 402

/branches/BR-0.4/basico/widgets/wdg_annot.py
161,12 → 161,12
tool = Gtk.ToolItem()
icon = self.srvicm.get_new_image_icon('basico-annotation-type-template', 18, 18)
switch = self.srvgui.add_widget('gtk_switch_annotation_template', Gtk.ToggleButton())
switch.set_tooltip_markup('<b>Toggle to mark this annotation as a template</b>')
# ~ switch.connect('state-set', callback)
label = Gtk.Label()
label.set_markup('<b>Template?</b>')
 
hbox.pack_start(icon, False, False, 3)
hbox.pack_start(label, False, False, 3)
# ~ hbox.pack_start(label, False, False, 3)
switch.add(hbox)
tool.add(switch)
self.toolbar.insert(tool, -1)
635,7 → 635,7
a_wdg_link_button = self.srvgui.get_widget('gtk_link_button_annotation_link')
a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
 
title.set_markup("<big><b>%s - %s</b></big>" % (annotation['Type'], annotation['Title']))
title.set_markup("<big><b>%s - </b>%s</big>" % (annotation['Type'], annotation['Title']))
a_wdg_aid.set_text(annotation['AID'])
icon = self.srvicm.get_new_image_icon('basico-annotation-type-%s' % annotation['Type'].lower())
self.srvgui.swap_widget(a_wdg_icon, icon)
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
13,6 → 13,7
import glob
import json
import html
from enum import IntEnum
 
import gi
gi.require_version('Gdk', '3.0')
29,7 → 30,22
from basico.widgets.wdg_cols import CollectionsMgtView
from basico.widgets.wdg_import import ImportWidget
 
class COLUMN(IntEnum):
AID = 0
ICON = 1
CHECKBOX = 2
SID = 3
TITLE = 4
COMPONENT = 5
SCOPE = 6
PRODUCT = 7
PRIORITY = 8
UPDATED = 9
TS_UPDATED = 10
CREATED = 11
TS_CREATED = 12
 
 
class AnnotationsVisor(BasicoWidget, Gtk.HBox):
def __init__(self, app):
super().__init__(app, __class__.__name__)
76,7 → 92,7
 
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)
sorted_model.set_sort_column_id(COLUMN.TS_UPDATED, Gtk.SortType.DESCENDING)
 
 
def __setup_panel(self):
314,7 → 330,7
 
# Annotation key
self.renderer_key = Gtk.CellRendererText()
self.column_key = Gtk.TreeViewColumn('Key', self.renderer_key, text=0)
self.column_key = Gtk.TreeViewColumn('Key', self.renderer_key, text=COLUMN.AID)
self.column_key.set_visible(False)
self.column_key.set_expand(False)
self.column_key.set_clickable(False)
324,20 → 340,20
# Annotation 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)
widget = get_column_header_widget('', 'basico-type')
self.column_icon.set_widget(widget)
self.column_icon = Gtk.TreeViewColumn('', self.renderer_icon, pixbuf=COLUMN.ICON)
# ~ widget = get_column_header_widget('', 'basico-type')
# ~ self.column_icon.set_widget(widget)
self.column_icon.set_visible(True)
self.column_icon.set_expand(False)
self.column_icon.set_clickable(True)
self.column_icon.set_sort_indicator(True)
self.column_icon.set_sort_column_id(7)
# ~ self.column_icon.set_sort_column_id(7)
treeview.append_column(self.column_icon)
 
# Annotation Checkbox
self.renderer_checkbox = Gtk.CellRendererToggle()
self.renderer_checkbox.connect("toggled", self.__clb_toggle_checkbox)
self.column_checkbox = Gtk.TreeViewColumn('', self.renderer_checkbox, active=2)
self.renderer_checkbox.connect("toggled", self.__clb_row_toggled)
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)
354,7 → 370,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 Id', self.renderer_sid, markup=3)
self.column_sid = Gtk.TreeViewColumn('SAP Note Id', self.renderer_sid, markup=COLUMN.SID)
widget = get_column_header_widget('SAP Note Id', 'basico-sid')
self.column_sid.set_widget(widget)
self.column_sid.set_visible(True)
362,7 → 378,7
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(0)
treeview.append_column(self.column_sid)
 
# Annotation title
369,7 → 385,7
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)
377,13 → 393,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.column_title.set_sort_column_id(COLUMN.TITLE)
treeview.append_column(self.column_title)
 
# Annotation 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(False)
391,13 → 407,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.column_component.set_sort_column_id(COLUMN.COMPONENT)
treeview.append_column(self.column_component)
 
# Annotation Scope
self.renderer_scope = Gtk.CellRendererText()
self.renderer_scope.set_property('background', '#E3F1E3')
self.column_scope = Gtk.TreeViewColumn('Scope', self.renderer_scope, markup=6)
self.column_scope = Gtk.TreeViewColumn('Scope', self.renderer_scope, markup=COLUMN.SCOPE)
widget = get_column_header_widget('Scope', 'basico-scope')
self.column_scope.set_widget(widget)
self.column_scope.set_visible(True)
405,7 → 421,7
self.column_scope.set_expand(False)
self.column_scope.set_clickable(True)
self.column_scope.set_sort_indicator(True)
self.column_scope.set_sort_column_id(6)
self.column_scope.set_sort_column_id(COLUMN.SCOPE)
treeview.append_column(self.column_scope)
 
# Annotation Product
412,7 → 428,7
self.renderer_type = Gtk.CellRendererText()
self.renderer_type.set_property('background', '#DADAFF')
# ~ self.renderer_type.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
self.column_type = Gtk.TreeViewColumn('Type', self.renderer_type, markup=7)
self.column_type = Gtk.TreeViewColumn('Type', self.renderer_type, markup=COLUMN.PRODUCT)
widget = get_column_header_widget('Product', 'basico-type')
self.column_type.set_widget(widget)
self.column_type.set_visible(True)
420,13 → 436,13
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.column_type.set_sort_column_id(COLUMN.PRODUCT)
treeview.append_column(self.column_type)
 
# Annotation Priority
self.renderer_priority = Gtk.CellRendererText()
self.renderer_priority.set_property('background', '#e4f1f1')
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('Priority', 'basico-priority')
self.column_priority.set_widget(widget)
self.column_priority.set_visible(True)
433,13 → 449,13
self.column_priority.set_expand(False)
self.column_priority.set_clickable(True)
self.column_priority.set_sort_indicator(True)
self.column_priority.set_sort_column_id(8)
self.column_priority.set_sort_column_id(COLUMN.PRIORITY)
treeview.append_column(self.column_priority)
 
# Annotation Updated On
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)
447,19 → 463,19
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(10)
self.column_updated.set_sort_column_id(COLUMN.TS_UPDATED)
self.column_updated.set_sort_order(Gtk.SortType.DESCENDING)
model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
model.set_sort_column_id(COLUMN.TS_UPDATED, Gtk.SortType.DESCENDING)
treeview.append_column(self.column_updated)
 
# Timestamp updated
self.renderer_timestamp_updated = Gtk.CellRendererText()
self.column_timestamp_updated = Gtk.TreeViewColumn('Timestamp updated', self.renderer_timestamp_updated, text=10)
self.column_timestamp_updated = Gtk.TreeViewColumn('Timestamp updated', self.renderer_timestamp_updated, text=COLUMN.TS_UPDATED)
self.column_timestamp_updated.set_visible(False)
self.column_timestamp_updated.set_expand(False)
self.column_timestamp_updated.set_clickable(False)
self.column_timestamp_updated.set_sort_indicator(True)
self.column_timestamp_updated.set_sort_column_id(10)
self.column_timestamp_updated.set_sort_column_id(COLUMN.TS_UPDATED)
self.column_timestamp_updated.set_sort_order(Gtk.SortType.ASCENDING)
treeview.append_column(self.column_timestamp_updated)
 
466,7 → 482,7
# Annotation Created On
self.renderer_created = Gtk.CellRendererText()
self.renderer_created.set_property('background', '#FFE6D1')
self.column_created = Gtk.TreeViewColumn('Created', self.renderer_created, markup=11)
self.column_created = Gtk.TreeViewColumn('Created', self.renderer_created, markup=COLUMN.CREATED)
widget = get_column_header_widget('Created', 'basico-chronologic')
self.column_created.set_widget(widget)
self.column_created.set_visible(False)
474,19 → 490,19
self.column_created.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_created.set_clickable(True)
self.column_created.set_sort_indicator(True)
self.column_created.set_sort_column_id(12)
self.column_created.set_sort_column_id(COLUMN.TS_CREATED)
self.column_created.set_sort_order(Gtk.SortType.DESCENDING)
model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
model.set_sort_column_id(COLUMN.TS_CREATED, Gtk.SortType.DESCENDING)
treeview.append_column(self.column_created)
 
# Timestamp
self.renderer_timestamp_created = Gtk.CellRendererText()
self.column_timestamp_created = Gtk.TreeViewColumn('Timestamp created', self.renderer_timestamp_created, text=12)
self.column_timestamp_created = Gtk.TreeViewColumn('Timestamp created', self.renderer_timestamp_created, text=COLUMN.TS_CREATED)
self.column_timestamp_created.set_visible(False)
self.column_timestamp_created.set_expand(False)
self.column_timestamp_created.set_clickable(False)
self.column_timestamp_created.set_sort_indicator(True)
self.column_timestamp_created.set_sort_column_id(12)
self.column_timestamp_created.set_sort_column_id(COLUMN.TS_CREATED)
self.column_timestamp_created.set_sort_order(Gtk.SortType.ASCENDING)
treeview.append_column(self.column_timestamp_created)
 
515,7 → 531,7
# TreeView sorting
sorted_model = Gtk.TreeModelSort(model=visible_filter)
self.srvgui.add_widget('visor_annotation_sorted_model', sorted_model)
sorted_model.set_sort_func(0, self.__sort_function, None)
sorted_model.set_sort_func(COLUMN.AID, self.__sort_function, None)
 
# Selection
selection = treeview.get_selection()
523,7 → 539,7
selection.connect('changed', self.__clb_row_changed)
 
# Set model (filtered and sorted)
sorted_model.set_sort_column_id(9, Gtk.SortType.ASCENDING)
sorted_model.set_sort_column_id(COLUMN.TS_UPDATED, Gtk.SortType.ASCENDING)
treeview.set_model(sorted_model)
 
# Other signals
549,9 → 565,9
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]
scope = model.get(itr, 6)[0]
product = model.get(itr, 7)[0]
title = model.get(itr, COLUMN.TITLE)[0]
scope = model.get(itr, COLUMN.SCOPE)[0]
product = model.get(itr, COLUMN.PRODUCT)[0]
match = text.upper() in title.upper()
 
cmb_scope = self.srvgui.get_widget('gtk_combobox_filter_scope')
631,8 → 647,8
selected = []
 
def get_toggled_rows(model, path, itr):
aid = sorted_model.get(itr, 0)[0]
checked = sorted_model.get(itr, 2)[0]
aid = sorted_model.get(itr, COLUMN.AID)[0]
checked = sorted_model.get(itr, COLUMN.CHECKBOX)[0]
if checked:
selected.append(str(aid))
sorted_model.foreach(get_toggled_rows)
644,9 → 660,9
try:
model, treeiter = selection.get_selected()
if treeiter is not None:
component = model[treeiter][5]
component = model[treeiter][COLUMN.COMPONENT]
if component == 'Annotation':
aid = model[treeiter][0]
aid = model[treeiter][COLUMN.AID]
is_valid = self.srvant.is_valid(aid)
if is_valid:
widget_annotation = self.srvgui.get_widget('widget_annotation')
668,11 → 684,11
#FIXME: create an empty file for contents
 
 
def __clb_toggle_checkbox(self, cell, path):
def __clb_row_toggled(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))
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, scope='', sntype='', priority='', updated='', ts_updated='', created='', ts_created=''):
829,9 → 845,9
selection = treeview.get_selection()
model, treeiter = selection.get_selected()
if treeiter is not None:
component = model[treeiter][5]
component = model[treeiter][COLUMN.COMPONENT]
if component == 'Annotation':
aid = model[treeiter][0]
aid = model[treeiter][COLUMN.AID]
is_valid = self.srvant.is_valid(aid)
if is_valid:
self.srvclb.action_annotation_preview(aid)
850,8 → 866,8
path,col,cellx,celly = pthinfo
model = treeview.get_model()
treeiter = model.get_iter(path)
component = model[treeiter][5]
aid = model[treeiter][0]
component = model[treeiter][COLUMN.COMPONENT]
aid = model[treeiter][COLUMN.AID]
popover = self.srvgui.add_widget('gtk_popover_visor_row', Gtk.Popover.new(treeview))
popover.set_pointing_to(rect)
box = self.__build_popover(aid, popover, component)
950,10 → 966,10
sorted_model = self.srvgui.get_widget('visor_annotation_sorted_model')
def check_row(model, path, itr):
if checked is not None:
model[path][2] = checked
model[path][COLUMN.CHECKBOX] = checked
else:
state = model[path][2]
model[path][2] = not state
state = model[path][COLUMN.CHECKBOX]
model[path][COLUMN.CHECKBOX] = not state
 
model = sorted_model.get_model()
model.foreach(check_row)
992,7 → 1008,7
scopes = set()
 
def get_values(model, path, itr):
scope = sorted_model.get(itr, 6)[0]
scope = sorted_model.get(itr, COLUMN.SCOPE)[0]
scopes.add(scope)
sorted_model.foreach(get_values)
 
1019,7 → 1035,7
products = set()
 
def get_values(model, path, itr):
product = sorted_model.get(itr, 7)[0]
product = sorted_model.get(itr, COLUMN.PRODUCT)[0]
products.add(product)
sorted_model.foreach(get_values)
 
/branches/BR-0.4/basico/widgets/wdg_visor_sapnotes.py
69,7 → 69,8
 
 
def sort_by_timestamp(self):
self.sorted_model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
sorted_model = self.srvgui.get_widget('visor_sapnotes_sorted_model')
sorted_model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
 
 
def setup_panel(self):
233,8 → 234,8
self.renderer_icon = Gtk.CellRendererPixbuf()
self.renderer_icon.set_alignment(0.0, 0.5)
self.column_icon = Gtk.TreeViewColumn('', self.renderer_icon, pixbuf=1)
widget = get_column_header_widget('', 'basico-sapnote')
self.column_icon.set_widget(widget)
# ~ 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)
244,8 → 245,10
 
# SAP Note Checkbox
self.renderer_checkbox = Gtk.CellRendererToggle()
self.renderer_checkbox.connect("toggled", self.toggle_checkbox)
self.renderer_checkbox.connect("toggled", self.__clb_row_toggled)
self.column_checkbox = Gtk.TreeViewColumn('', self.renderer_checkbox, active=2)
widget = get_column_header_widget('', 'basico-check-accept')
self.column_checkbox.set_widget(widget)
self.column_checkbox.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_checkbox.set_visible(True)
self.column_checkbox.set_expand(False)
260,8 → 263,8
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)
widget = get_column_header_widget('SAP Note', 'basico-sapnote')
self.column_sid.set_widget(widget)
# ~ widget = get_column_header_widget('SAP Note', 'basico-sapnote')
# ~ self.column_sid.set_widget(widget)
self.column_sid.set_visible(True)
self.column_sid.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_sid.set_expand(False)
396,8 → 399,9
# https://stackoverflow.com/questions/23355866/user-search-collapsed-rows-in-a-gtk-treeview
 
# TreeView sorting
self.sorted_model = Gtk.TreeModelSort(model=self.visible_filter)
self.sorted_model.set_sort_func(0, self.sort_function, None)
sorted_model = Gtk.TreeModelSort(model=self.visible_filter)
self.srvgui.add_widget('visor_sapnotes_sorted_model', sorted_model)
sorted_model.set_sort_func(0, self.sort_function, None)
 
# Selection
self.selection = self.treeview.get_selection()
405,7 → 409,7
self.selection.connect('changed', self.row_changed)
 
# Set model (filtered and sorted)
self.treeview.set_model(self.sorted_model)
self.treeview.set_model(sorted_model)
 
self.show_all()
return visor
471,9 → 475,11
self.log.debug(error)
 
 
def toggle_checkbox(self, cell, path):
path = self.sorted_model.convert_path_to_child_path(Gtk.TreePath(path))
self.model[path][2] = not self.model[path][2]
def __clb_row_toggled(self, cell, path):
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]
 
 
def get_node(self, key, icon, checkbox, sid, title, component, category='', sntype='', priority='', updated='', aid='', timestamp=''):
516,6 → 522,7
 
 
def populate(self, bag=None, cid=None):
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)
# ~ icon_sap_note_standard = self.srvicm.get_pixbuf_icon('basico-sap-note', 32, 32)
523,9 → 530,9
for atype in ATYPES:
self.icons['type'][atype.lower()] = self.srvicm.get_pixbuf_icon('basico-annotation-type-%s' % atype.lower())
self.column_sid.set_visible(True)
self.column_checkbox.set_visible(False)
self.column_category.set_visible(False)
self.column_component.set_visible(True)
# ~ self.column_checkbox.set_visible(False)
# ~ self.column_category.set_visible(False)
# ~ self.column_component.set_visible(True)
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.clear()
634,7 → 641,7
# ~ )
# ~ self.model.append(pid, node)
 
self.treeview.set_model(self.sorted_model)
self.treeview.set_model(sorted_model)
self.update_total_sapnotes_count()
self.show_widgets()
self.srvclb.gui_show_dashboard()
790,8 → 797,8
 
 
def get_filtered_bag(self):
sorted_model = self.srvgui.get_widget('visor_sapnotes_sorted_model')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
model = visor_sapnotes.get_sorted_model()
selected = []
 
def get_selected_sapnotes(model, path, itr):
800,5 → 807,5
if len(aid) == 0:
selected.append(str(sid))
 
model.foreach(get_selected_sapnotes)
sorted_model.foreach(get_selected_sapnotes)
return selected