Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 388 → Rev 389

/branches/BR-0.4/basico/widgets/wdg_visor_sapnotes.py
29,6 → 29,7
from basico.widgets.wdg_cols import CollectionsMgtView
from basico.widgets.wdg_import import ImportWidget
from basico.core.mod_log import get_logger
from basico.widgets.wdg_menuview import MenuView
 
 
class SAPNotesVisor(BasicoWidget, Gtk.Box):
39,7 → 40,14
self.bag = []
self.icons = {}
self.icons['type'] = {}
self.setup()
panel = self.setup_panel()
visor = self.setup_visor()
paned = Gtk.HPaned()
paned.add1(panel)
paned.add2(visor)
paned.set_position(400)
paned.show_all()
self.add(paned)
self.log.debug("SAP Notes Visor initialized")
 
 
64,13 → 72,124
self.sorted_model.set_sort_column_id(11, Gtk.SortType.DESCENDING)
 
 
def setup(self):
def setup_panel(self):
## Left view - SAP Notes Menu view
box = self.srvgui.add_widget('gtk_vbox_container_menu_view', Gtk.VBox())
# ~ self.pack_start(box, False, True, 3)
# ~ separator = Gtk.Separator(orientation = Gtk.Orientation.VERTICAL)
# ~ self.pack_start(separator, False, False, 3)
box.set_property('margin-left', 0)
box.set_property('margin-right', 0)
box.set_property('margin-bottom', 0)
 
# View combobox button/popover
lhbox = Gtk.HBox()
menuviews = self.srvgui.add_widget('gtk_button_menu_views', Gtk.Button())
menuviews.set_relief(Gtk.ReliefStyle.NONE)
hbox = Gtk.HBox()
label = self.srvgui.add_widget('gtk_label_current_view', Gtk.Label())
label.set_xalign(0.0)
image = self.srvgui.add_widget('gtk_image_current_view', Gtk.Image())
hbox.pack_start(image, False, False, 3)
hbox.pack_start(label, True, True, 3)
menuviews.add(hbox)
lhbox.pack_start(menuviews, True, True, 3)
lhbox.show_all()
box.pack_start(lhbox, False, False, 3)
 
### Popover menuviews
popover = self.srvgui.add_widget('gtk_popover_button_menu_views', Gtk.Popover.new(menuviews))
menuviews.connect('clicked', self.srvclb.gui_show_popover, popover)
box_views = Gtk.Box(spacing = 0, orientation="vertical")
popover.add(box_views)
 
box_views.pack_start(self.srvuif.create_menuview_button('collection'), False, False, 0)
separator = Gtk.Separator(orientation = Gtk.Orientation.HORIZONTAL)
box_views.pack_start(separator, False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('component'), False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('description'), False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('bookmarks'), False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('category'), False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('chronologic'), False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('priority'), False, False, 0)
box_views.pack_start(self.srvuif.create_menuview_button('type'), False, False, 0)
 
### Toolbar
toolbar = Gtk.Toolbar()
toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
 
#### Filter entry tool
tool = Gtk.ToolItem.new()
 
hbox = Gtk.HBox()
viewfilter = self.srvgui.add_widget('gtk_entry_filter_view', Gtk.Entry())
completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
viewfilter.set_completion(completion)
viewfilter.connect('activate', self.srvclb.gui_viewmenu_filter)
 
icon = self.srvicm.get_pixbuf_icon('basico-refresh')
viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.PRIMARY, icon)
viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.PRIMARY, True)
viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.PRIMARY, "Refresh and collapse")
 
icon = self.srvicm.get_pixbuf_icon('basico-filter')
viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, True)
viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.SECONDARY, "Click here to expand the tree")
viewfilter.set_placeholder_text("Filter this view...")
 
def on_icon_pressed(entry, icon_pos, event):
if icon_pos == Gtk.EntryIconPosition.PRIMARY:
viewmenu = self.srvgui.get_widget('viewmenu')
viewmenu.refresh()
elif icon_pos == Gtk.EntryIconPosition.SECONDARY:
self.srvclb.expand_menuview()
 
viewfilter.connect("icon-press", on_icon_pressed)
 
hbox.pack_start(viewfilter, True, True, 0)
tool.add(hbox)
tool.set_expand(True)
toolbar.insert(tool, -1)
 
box.pack_start(toolbar, False, False, 0)
 
### View treeview
box_trv = Gtk.VBox()
box_trv.set_property('margin-left', 3)
box_trv.set_property('margin-right', 3)
box_trv.set_property('margin-bottom', 0)
scr = Gtk.ScrolledWindow()
# ~ scr.set_hexpand(True)
scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scr.set_shadow_type(Gtk.ShadowType.IN)
vwp = Gtk.Viewport()
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)
box_trv.pack_start(scr, True, True, 0)
box.pack_start(box_trv, True, True, 0)
# ~ box.show_all()
# ~ box.add(viewmenu)
return box
 
 
 
def setup_visor(self):
visor = Gtk.VBox()
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)
self.pack_start(scr, True, True, 0)
visor.pack_start(scr, True, True, 0)
visor.show_all()
 
# Setup model
self.model = Gtk.ListStore(
89,7 → 208,7
)
 
# Setup columns
def get_column_header_widget(title, icon_name=None, width=24, height=24):
def get_column_header_widget(title, icon_name=None, width=28, height=28):
hbox = Gtk.HBox()
icon = self.srvicm.get_new_image_icon(icon_name, width, height)
label = Gtk.Label()
114,8 → 233,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-bookmarks')
# ~ self.column_icon.set_widget(widget)
widget = get_column_header_widget('', 'basico-sapnote')
self.column_icon.set_widget(widget)
self.column_icon.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.column_icon.set_visible(False)
self.column_icon.set_expand(False)
141,7 → 260,7
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', '')
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)
200,6 → 319,8
self.renderer_type = Gtk.CellRendererText()
self.renderer_type.set_property('background', '#e4f1f1')
self.column_type = Gtk.TreeViewColumn('Type', self.renderer_type, markup=7)
widget = get_column_header_widget('Type', 'basico-type')
self.column_type.set_widget(widget)
self.column_type.set_visible(True)
self.column_type.set_expand(False)
self.column_type.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
211,6 → 332,8
# SAP Note Priority
self.renderer_priority = Gtk.CellRendererText()
self.column_priority = Gtk.TreeViewColumn('Priority', self.renderer_priority, markup=8)
widget = get_column_header_widget('Type', 'basico-priority')
self.column_priority.set_widget(widget)
self.column_priority.set_visible(False)
self.column_priority.set_expand(True)
self.column_priority.set_clickable(True)
222,6 → 345,8
self.renderer_updated = Gtk.CellRendererText()
self.renderer_updated.set_property('background', '#FFE6D1')
self.column_updated = Gtk.TreeViewColumn('Updated On', self.renderer_updated, markup=9)
widget = get_column_header_widget('Update on', 'basico-chronologic')
self.column_updated.set_widget(widget)
self.column_updated.set_visible(True)
self.column_updated.set_expand(False)
self.column_updated.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
283,6 → 408,7
self.treeview.set_model(self.sorted_model)
 
self.show_all()
return visor
 
 
def sort_function(self, model, row1, row2, user_data):
340,7 → 466,7
self.srvclb.action_annotation_edit(aid)
else:
aid = None
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
# ~ self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
except Exception as error:
self.log.debug(error)
 
503,8 → 629,9
self.treeview.set_model(self.sorted_model)
self.update_total_sapnotes_count()
self.show_widgets()
stack = self.srvgui.get_widget('gtk_stack_main')
stack.set_visible_child_name('visor')
self.srvclb.gui_show_dashboard()
# ~ stack = self.srvgui.get_widget('gtk_stack_main')
# ~ stack.set_visible_child_name('dashboard')
# ~ self.log.debug("Visor updated")
 
def show_widgets(self):
526,7 → 653,7
if sid == 0:
return
sid = "0"*(10 - len(str(sid))) + str(sid)
toolbar = self.srvgui.get_widget('visortoolbar')
# ~ 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)