Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 245 → Rev 246

/branches/BR-0.3/basico/widgets/wdg_about.py
1,23 → 1,26
#!/usr/bin/python
"""
# -*- coding: utf-8 -*-
# File: about.py
# File: wdg_about.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: About Widget
"""
 
from os.path import sep as SEP
from cgi import escape
from html import escape
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
from basico.core.mod_env import APP
 
from basico.core.mod_env import ROOT, USER_DIR, APP, LPATH, GPATH, FILE
from basico.core.mod_srv import Service
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
 
 
class About(Gtk.ScrolledWindow):
"""
About class
"""
def __init__(self):
Gtk.ScrolledWindow.__init__(self)
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
/branches/BR-0.3/basico/widgets/wdg_annot.py
1,32 → 1,28
#!/usr/bin/python
"""
# -*- coding: utf-8 -*-
# File: annotation.py
# File: wdg_annot.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Annotation Widget
"""
 
import os
import json
import uuid
import glob
from os.path import sep as SEP
from cgi import escape
 
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
from basico.core.mod_env import LPATH
 
from basico.core.mod_env import ROOT, USER_DIR, APP, LPATH, GPATH, FILE
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
 
 
class AnnotationWidget(Gtk.VBox):
"""
Annotation Widget
"""
def __init__(self, app, sid='0000000000'):
Gtk.VBox.__init__(self)
self.app = app
self.log = app.log
self.sid = sid
self.get_services()
self.__setup()
35,13 → 31,13
def get_services(self):
"""Load services to be used in this class
"""
self.gui = self.app.get_service("GUI")
self.im = self.app.get_service("IM")
self.uif = self.app.get_service("UIF")
self.clts = self.app.get_service('Collections')
self.cb = self.app.get_service('Callbacks')
self.annot = self.app.get_service('Annotation')
self.utils = self.app.get_service('Utils')
self.srvgui = self.app.get_service("GUI")
self.srvicm = self.app.get_service("IM")
self.srvuif = self.app.get_service("UIF")
self.srvclt = self.app.get_service('Collections')
self.srvclb = self.app.get_service('Callbacks')
self.srvant = self.app.get_service('Annotation')
self.srvutl = self.app.get_service('Utils')
 
 
def __setup(self):
52,7 → 48,7
self.set_vexpand(True)
 
# Annotation container (body)
self.container_body = self.gui.add_widget('gtk_vbox_annotation_container', Gtk.VBox())
self.container_body = self.srvgui.add_widget('gtk_vbox_annotation_container', Gtk.VBox())
self.container_body.set_border_width(3)
self.pack_start(self.container_body, True, True, 3)
 
63,10 → 59,10
 
def __setup_header(self):
# Annotation Header
container = self.gui.get_widget('gtk_vbox_annotation_container')
container = self.srvgui.get_widget('gtk_vbox_annotation_container')
header = Gtk.VBox()
hbox = Gtk.HBox()
title = self.gui.add_widget('gtk_label_annotation_sid', Gtk.Label())
title = self.srvgui.add_widget('gtk_label_annotation_sid', Gtk.Label())
if self.sid == '0000000000':
title.set_markup('<big><b>Annotation</b></big>')
else:
76,7 → 72,7
a_lbl_aid.set_property('xalign', 1.0)
a_lbl_aid.modify_font(Pango.FontDescription('Monospace 10'))
a_lbl_aid.set_markup('<b>Annotation Id:</b>')
a_aid = self.gui.add_widget('gtk_label_aid', Gtk.Label())
a_aid = self.srvgui.add_widget('gtk_label_aid', Gtk.Label())
a_aid.set_property('xalign', 1.0)
a_aid.set_selectable(True)
a_aid.modify_font(Pango.FontDescription('Monospace 10'))
87,7 → 83,7
header.pack_start(hbox, False, False, 0)
 
# Timestamp
a_wdg_human_timestamp = self.gui.add_widget('gtk_label_human_timestamp', Gtk.Label())
a_wdg_human_timestamp = self.srvgui.add_widget('gtk_label_human_timestamp', Gtk.Label())
a_wdg_human_timestamp.modify_font(Pango.FontDescription('Monospace 10'))
a_wdg_human_timestamp.set_xalign(0.0)
header.pack_start(a_wdg_human_timestamp, True, True, 0)
103,9 → 99,9
# Hidden metadata
hhbox = Gtk.HBox()
 
a_timestamp = self.gui.add_widget('gtk_label_timestamp', Gtk.Label(self.utils.timestamp()))
a_timestamp = self.srvgui.add_widget('gtk_label_timestamp', Gtk.Label(self.srvutl.timestamp()))
a_timestamp.set_sensitive(False)
self.uif.set_widget_visibility('gtk_label_timestamp', False)
self.srvuif.set_widget_visibility('gtk_label_timestamp', False)
hhbox.pack_start(a_timestamp, False, False, 0)
vbox.pack_start(hhbox, False, False, 0)
 
119,7 → 115,7
vboxr.set_vexpand(True)
 
# Title
a_title = self.gui.add_widget('gtk_entry_annotation_title', Gtk.Entry())
a_title = self.srvgui.add_widget('gtk_entry_annotation_title', Gtk.Entry())
a_title.set_placeholder_text("Type a title here...")
a_title.modify_font(Pango.FontDescription('Monospace 10'))
vboxl.pack_start(a_title, False, False, 0)
131,14 → 127,14
scroller.set_shadow_type(Gtk.ShadowType.IN)
scroller.set_hexpand(True)
scroller.set_vexpand(True)
a_text = self.gui.add_widget('gtk_textview_annotation_text', Gtk.TextView())
a_text = self.srvgui.add_widget('gtk_textview_annotation_text', Gtk.TextView())
a_text.set_wrap_mode(Gtk.WrapMode.WORD)
a_text.modify_font(Pango.FontDescription('Monospace 10'))
a_text.set_vexpand(True)
a_text.set_left_margin (6)
a_text.set_top_margin (6)
a_text.set_right_margin (6)
a_text.set_bottom_margin (6)
a_text.set_left_margin(6)
a_text.set_top_margin(6)
a_text.set_right_margin(6)
a_text.set_bottom_margin(6)
a_textbuffer = Gtk.TextBuffer()
a_textbuffer.set_text('')
a_text.set_buffer(a_textbuffer)
153,15 → 149,15
a_type_lbl.set_xalign(1.0)
# ~ vboxr.pack_start(a_type_lbl, False, False, 0)
a_type_model = Gtk.ListStore(str)
self.gui.add_widget('annotation_type_FIXME', a_type_model.append(['FIXME']))
active = self.gui.add_widget('annotation_type_Note', a_type_model.append(['Note']))
self.gui.add_widget('annotation_type_Procedure', a_type_model.append(['Procedure']))
self.gui.add_widget('annotation_type_Snippet', a_type_model.append(['Snippet']))
self.gui.add_widget('annotation_type_Template', a_type_model.append(['Template']))
self.gui.add_widget('annotation_type_TODO', a_type_model.append(['TODO']))
self.srvgui.add_widget('annotation_type_FIXME', a_type_model.append(['FIXME']))
active = self.srvgui.add_widget('annotation_type_Note', a_type_model.append(['Note']))
self.srvgui.add_widget('annotation_type_Procedure', a_type_model.append(['Procedure']))
self.srvgui.add_widget('annotation_type_Snippet', a_type_model.append(['Snippet']))
self.srvgui.add_widget('annotation_type_Template', a_type_model.append(['Template']))
self.srvgui.add_widget('annotation_type_TODO', a_type_model.append(['TODO']))
a_type = Gtk.ComboBox.new_with_model(a_type_model)
a_type.set_active_iter(active)
self.gui.add_widget('gtk_combobox_annotation_type', a_type)
self.srvgui.add_widget('gtk_combobox_annotation_type', a_type)
renderer_type = Gtk.CellRendererText()
a_type.pack_start(renderer_type, True)
a_type.add_attribute(renderer_type, "text", 0)
174,7 → 170,7
 
 
 
# ~ calendar = self.gui.add_widget('gtk_calendar_annotation_timestamp', Gtk.Calendar())
# ~ calendar = self.srvgui.add_widget('gtk_calendar_annotation_timestamp', Gtk.Calendar())
# ~ calendar.modify_font(Pango.FontDescription('Monospace 8'))
# ~ hbox.pack_start(calendar, False, False, 0)
 
183,12 → 179,12
hbox = Gtk.HBox()
 
## url entry
a_link = self.gui.add_widget('gtk_entry_annotation_link', Gtk.Entry())
a_link = self.srvgui.add_widget('gtk_entry_annotation_link', Gtk.Entry())
a_link.set_placeholder_text("Type a url here...")
hbox.pack_start(a_link, True, True, 3)
 
## url button
a_link_button = self.gui.add_widget('gtk_link_button_annotation_link', Gtk.LinkButton())
a_link_button = self.srvgui.add_widget('gtk_link_button_annotation_link', Gtk.LinkButton())
a_link_button.set_relief(Gtk.ReliefStyle.NORMAL)
a_link_button.set_label('Visit')
hbox.pack_start(a_link_button, False, False, 3)
195,18 → 191,18
 
# url type
a_link_type_model = Gtk.ListStore(str)
self.gui.add_widget('annotation_link_type_Intranet', a_link_type_model.append(['Intranet']))
self.gui.add_widget('annotation_link_type_SAP Blog', a_link_type_model.append(['SAP Blog']))
self.gui.add_widget('annotation_link_type_SAP Document', a_link_type_model.append(['SAP Document']))
self.gui.add_widget('annotation_link_type_SAP Help', a_link_type_model.append(['SAP Help']))
self.gui.add_widget('annotation_link_type_SAP Incident', a_link_type_model.append(['SAP Incident']))
self.gui.add_widget('annotation_link_type_SAP Questions and Answers', a_link_type_model.append(['SAP Questions and Answers']))
self.gui.add_widget('annotation_link_type_SAP Wiki', a_link_type_model.append(['SAP Wiki']))
self.srvgui.add_widget('annotation_link_type_Intranet', a_link_type_model.append(['Intranet']))
self.srvgui.add_widget('annotation_link_type_SAP Blog', a_link_type_model.append(['SAP Blog']))
self.srvgui.add_widget('annotation_link_type_SAP Document', a_link_type_model.append(['SAP Document']))
self.srvgui.add_widget('annotation_link_type_SAP Help', a_link_type_model.append(['SAP Help']))
self.srvgui.add_widget('annotation_link_type_SAP Incident', a_link_type_model.append(['SAP Incident']))
self.srvgui.add_widget('annotation_link_type_SAP Questions and Answers', a_link_type_model.append(['SAP Questions and Answers']))
self.srvgui.add_widget('annotation_link_type_SAP Wiki', a_link_type_model.append(['SAP Wiki']))
# ~ 'Knowledge Base Search'
active = self.gui.add_widget('annotation_link_type_Website', a_link_type_model.append(['Website']))
active = self.srvgui.add_widget('annotation_link_type_Website', a_link_type_model.append(['Website']))
a_link_type = Gtk.ComboBox.new_with_model(a_link_type_model)
a_link_type.set_active_iter(active)
self.gui.add_widget('gtk_combobox_annotation_link_type', a_link_type)
self.srvgui.add_widget('gtk_combobox_annotation_link_type', a_link_type)
renderer_text = Gtk.CellRendererText()
a_link_type.pack_start(renderer_text, True)
a_link_type.add_attribute(renderer_text, "text", 0)
222,15 → 218,15
def __setup_footer(self):
# Buttons Accept/Cancel
hbox = Gtk.HBox()
accept = self.gui.add_widget('gtk_button_accept_annotation', Gtk.Button('Accept'))
accept.connect('clicked', self.cb.action_annotation_accept, self.sid)
accept = self.srvgui.add_widget('gtk_button_accept_annotation', Gtk.Button('Accept'))
accept.connect('clicked', self.srvclb.action_annotation_accept, self.sid)
accept.set_property('always-show-image', True)
icon = self.im.get_new_image_icon('basico-check-accept', 24, 24)
icon = self.srvicm.get_new_image_icon('basico-check-accept', 24, 24)
accept.set_image(icon)
cancel = self.gui.add_widget('gtk_button_cancel_annotation', Gtk.Button('Cancel'))
cancel.connect('clicked', self.cb.action_annotation_cancel)
cancel = self.srvgui.add_widget('gtk_button_cancel_annotation', Gtk.Button('Cancel'))
cancel.connect('clicked', self.srvclb.action_annotation_cancel)
cancel.set_property('always-show-image', True)
icon = self.im.get_new_image_icon('basico-check-cancel', 24, 24)
icon = self.srvicm.get_new_image_icon('basico-check-cancel', 24, 24)
cancel.set_image(icon)
hbox.pack_start(accept, True, False, 3)
hbox.pack_start(cancel, True, False, 3)
238,19 → 234,28
 
 
def set_aid_to_widget(self, aid):
a_aid = self.gui.get_widget('gtk_label_aid')
"""
C:237, 4: Missing method docstring (missing-docstring)
"""
a_aid = self.srvgui.get_widget('gtk_label_aid')
a_aid.set_text(aid)
 
 
def get_aid_from_widget(self):
a_aid = self.gui.get_widget('gtk_label_aid')
"""
C:237, 4: Missing method docstring (missing-docstring)
"""
a_aid = self.srvgui.get_widget('gtk_label_aid')
return a_aid.get_text()
 
 
def set_metadata_to_widget(self, aid, action):
"""
C:237, 4: Missing method docstring (missing-docstring)
"""
self.set_aid_to_widget(aid)
sid = self.annot.get_sid(aid)
title = self.gui.get_widget('gtk_label_annotation_sid')
sid = self.srvant.get_sid(aid)
title = self.srvgui.get_widget('gtk_label_annotation_sid')
if sid == '0000000000':
title.set_markup('<big><b>Annotation</b></big>')
else:
259,45 → 264,47
if action == 'create':
pass
elif action == 'edit':
annotation = self.annot.get_metadata_from_file(aid)
annotation = self.srvant.get_metadata_from_file(aid)
if annotation is not None:
ANNOTATION_FILE_CONTENT = LPATH['ANNOTATIONS'] + aid + '.adoc'
timestamp = self.utils.get_datetime(annotation['timestamp'])
a_wdg_aid = self.gui.get_widget('gtk_label_aid')
a_wdg_timestamp = self.gui.get_widget('gtk_label_timestamp')
a_wdg_title = self.gui.get_widget('gtk_entry_annotation_title')
a_wdg_type = self.gui.get_widget('gtk_combobox_annotation_type')
a_wdg_human_timestamp = self.gui.get_widget('gtk_label_human_timestamp')
a_wdg_text = self.gui.get_widget('gtk_textview_annotation_text')
a_wdg_link = self.gui.get_widget('gtk_entry_annotation_link')
a_wdg_link_button = self.gui.get_widget('gtk_link_button_annotation_link')
a_wdg_link_type = self.gui.get_widget('gtk_combobox_annotation_link_type')
# ~ a_wdg_cal = self.gui.get_widget('gtk_calendar_annotation_timestamp')
a_wdg_aid = self.srvgui.get_widget('gtk_label_aid')
a_wdg_timestamp = self.srvgui.get_widget('gtk_label_timestamp')
a_wdg_title = self.srvgui.get_widget('gtk_entry_annotation_title')
a_wdg_type = self.srvgui.get_widget('gtk_combobox_annotation_type')
a_wdg_human_timestamp = self.srvgui.get_widget('gtk_label_human_timestamp')
a_wdg_text = self.srvgui.get_widget('gtk_textview_annotation_text')
a_wdg_link = self.srvgui.get_widget('gtk_entry_annotation_link')
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')
# ~ a_wdg_cal = self.srvgui.get_widget('gtk_calendar_annotation_timestamp')
 
a_wdg_aid.set_text(annotation['aid'])
# ~ a_wdg_timestamp.set_text(self.utils.timestamp())
# ~ a_wdg_timestamp.set_text(self.srvutl.timestamp())
a_wdg_timestamp.set_text(annotation['timestamp'])
a_wdg_title.set_text(annotation['title'])
a_wdg_type.set_active_iter(self.gui.get_widget('annotation_type_%s' % annotation['type']))
self.uif.set_textview_text(a_wdg_text, open(ANNOTATION_FILE_CONTENT).read())
a_wdg_type.set_active_iter(self.srvgui.get_widget('annotation_type_%s' % annotation['type']))
self.srvuif.set_textview_text(a_wdg_text, open(ANNOTATION_FILE_CONTENT).read())
a_wdg_link.set_text(annotation['link'])
a_wdg_link_button.set_uri(annotation['link'])
a_wdg_link_type.set_active_iter(self.gui.get_widget('annotation_link_type_%s' % annotation['link_type']))
human_timestamp = self.utils.get_human_date_from_timestamp(annotation['timestamp'])
a_wdg_link_type.set_active_iter(self.srvgui.get_widget('annotation_link_type_%s' % annotation['link_type']))
human_timestamp = self.srvutl.get_human_date_from_timestamp(annotation['timestamp'])
a_wdg_human_timestamp.set_text(human_timestamp)
# ~ a_wdg_cal.select_month(timestamp.month-1, timestamp.year)
# ~ a_wdg_cal.select_day(timestamp.day)
 
 
def get_metadata_from_widget(self, aid):
def get_metadata_from_widget(self):
"""
C:237, 4: Missing method docstring (missing-docstring)
"""
annotation = {}
a_wdg_aid = self.gui.get_widget('gtk_label_aid')
a_wdg_timestamp = self.gui.get_widget('gtk_label_timestamp')
a_wdg_title = self.gui.get_widget('gtk_entry_annotation_title')
a_wdg_type = self.gui.get_widget('gtk_combobox_annotation_type')
a_wdg_text = self.gui.get_widget('gtk_textview_annotation_text')
a_wdg_link = self.gui.get_widget('gtk_entry_annotation_link')
a_wdg_link_type = self.gui.get_widget('gtk_combobox_annotation_link_type')
a_wdg_aid = self.srvgui.get_widget('gtk_label_aid')
a_wdg_timestamp = self.srvgui.get_widget('gtk_label_timestamp')
a_wdg_title = self.srvgui.get_widget('gtk_entry_annotation_title')
a_wdg_type = self.srvgui.get_widget('gtk_combobox_annotation_type')
a_wdg_text = self.srvgui.get_widget('gtk_textview_annotation_text')
a_wdg_link = self.srvgui.get_widget('gtk_entry_annotation_link')
a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
 
annotation['aid'] = a_wdg_aid.get_text()
annotation['timestamp'] = a_wdg_timestamp.get_text()
304,9 → 311,9
annotation['title'] = a_wdg_title.get_text()
annotation['component'] = 'Annotation'
annotation['category'] = ''
annotation['type'] = self.uif.get_combobox_text(a_wdg_type, 0)
annotation['content'] = self.uif.get_textview_text(a_wdg_text)
annotation['type'] = self.srvuif.get_combobox_text(a_wdg_type, 0)
annotation['content'] = self.srvuif.get_textview_text(a_wdg_text)
annotation['link'] = a_wdg_link.get_text()
annotation['link_type'] = self.uif.get_combobox_text(a_wdg_link_type, 0)
annotation['link_type'] = self.srvuif.get_combobox_text(a_wdg_link_type, 0)
 
return annotation
/branches/BR-0.3/basico/widgets/wdg_cols.py
1,27 → 1,25
#!/usr/bin/python
"""
# -*- coding: utf-8 -*-
# File: collections.py
# File: wdg_cols.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Collections Widget
"""
 
from os.path import sep as SEP
from cgi import escape
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
 
from basico.core.mod_env import ROOT, USER_DIR, APP, LPATH, GPATH, FILE
gi.require_version('Gtk', '3.0')
 
 
class CollectionsMgtView(Gtk.VBox):
"""
Missing class docstring (missing-docstring)
"""
def __init__(self, app, sid, popover):
Gtk.VBox.__init__(self)
self.app = app
self.log = app.log
self.error = self.app.error
self.sid = sid
self.popover = popover
self.current_cid = None
32,15 → 30,20
 
 
def get_services(self):
"""Load services to be used in this class
"""
self.gui = self.app.get_service("GUI")
self.im = self.app.get_service("IM")
self.uif = self.app.get_service("UIF")
self.clts = self.app.get_service('Collections')
Load services to be used in this class
"""
self.srvgui = self.app.get_service("GUI")
self.srvicm = self.app.get_service("IM")
self.srvuif = self.app.get_service("UIF")
self.srvclt = self.app.get_service('Collections')
self.srvdtb = self.app.get_service('DB')
 
 
def setup(self):
"""
Missing method docstring (missing-docstring)
"""
# Setup Widget properties
self.set_size_request(400, 680)
self.set_property('margin', 3)
50,7 → 53,7
# CollectionMgt Header
header = Gtk.VBox()
hbox = Gtk.HBox()
icon = self.im.get_new_image_icon('basico-collection')
icon = self.srvicm.get_new_image_icon('basico-collection')
title = Gtk.Label()
if self.sid != '0000000000':
title.set_markup('<big><b>Collections for SAP Note %s</b></big>' % str(int(self.sid)))
66,10 → 69,10
 
# Entry Widget / Delete entry button
hbox = Gtk.HBox()
self.entry = self.gui.add_widget('gtk_entry_collection_new', Gtk.Entry())
self.entry = self.srvgui.add_widget('gtk_entry_collection_new', Gtk.Entry())
self.entry.connect('activate', self.update)
self.entry.connect('changed', self.filter)
delete = self.uif.create_button('basico-delete', 24, 24, '')
delete = self.srvuif.create_button('basico-delete', 24, 24, '')
delete.connect('clicked', self.delete)
hbox.pack_start(self.entry, True, True, 6)
hbox.pack_start(delete, False, False, 0)
91,7 → 94,7
 
## Buttons
footer = Gtk.HBox()
accept = self.uif.create_button('basico-check-ok', 24, 24, '<b>Apply changes</b>')
accept = self.srvuif.create_button('basico-check-ok', 24, 24, '<b>Apply changes</b>')
accept.connect('clicked', self.accept)
footer.pack_start(accept, True, False, 0)
self.pack_start(footer, False, False, 3)
98,6 → 101,9
 
 
def setup_treeview(self):
"""
Missing method docstring (missing-docstring)
"""
# Setup model
self.model = Gtk.ListStore(
str, # key
132,7 → 138,6
self.column_title.set_visible(True)
self.column_title.set_expand(True)
self.column_title.set_clickable(True)
self.column_title
self.column_title.set_sort_indicator(True)
self.model.set_sort_column_id(2, Gtk.SortType.ASCENDING)
self.treeview.append_column(self.column_title)
164,13 → 169,22
 
 
def toggle_checkbox(self, cell, path):
"""
Missing method docstring (missing-docstring)
"""
self.model[path][1] = not self.model[path][1]
 
 
def accept(self, button):
db = self.app.get_service('DB')
"""
Missing method docstring (missing-docstring)
"""
selected = []
 
def get_linked_collections(model, path, itr):
"""
Missing method docstring (missing-docstring)
"""
cid = model.get(itr, 0)[0]
linked = model.get(itr, 1)[0]
if linked:
178,19 → 192,22
 
self.model.foreach(get_linked_collections)
if self.sid != '0000000000':
db.set_collections(self.sid, selected)
self.srvdtb.set_collections(self.sid, selected)
else:
visor = self.gui.get_widget('visor')
visor = self.srvgui.get_widget('visor')
bag = visor.get_bag()
for sid in bag:
db.set_collections(sid, selected)
self.srvdtb.set_collections(sid, selected)
 
self.popover.hide()
 
 
def row_changed(self, selection):
"""
Missing method docstring (missing-docstring)
"""
model, treeiter = selection.get_selected() #_rows()
visor = self.gui.get_widget('visor')
 
try:
self.current_cid = model[treeiter][0]
title = model[treeiter][2]
203,15 → 220,17
 
 
def update(self, entry=None):
db = self.app.get_service('DB')
linked = db.get_collections(self.sid)
"""
Missing method docstring (missing-docstring)
"""
linked = self.srvdtb.get_collections(self.sid)
 
if entry is not None and isinstance(entry, Gtk.Entry):
name = entry.get_text()
self.clts.create(name)
self.srvclt.create(name)
 
self.model.clear()
collections = self.clts.get_all()
collections = self.srvclt.get_all()
for cid in collections:
name = collections[cid]
if cid in linked:
222,25 → 241,33
 
 
def delete(self, button):
"""
Missing method docstring (missing-docstring)
"""
self.debug("Deleting collection with id: %s" % self.current_cid)
deleted = self.clts.delete(self.current_cid)
deleted = self.srvclt.delete(self.current_cid)
if deleted:
viewmenu = self.gui.get_widget('viewmenu')
viewmenu = self.srvgui.get_widget('viewmenu')
viewmenu.refresh()
viewmenu.grab_focus()
else:
colname = self.clts.get_name_by_cid(self.current_cid)
colname = self.srvclt.get_name_by_cid(self.current_cid)
title = "Collection '%s' not deleted" % colname
message = "Make sure there are not SAP Notes linked to this collection"
self.uif.dialog_info(title, message)
self.srvuif.dialog_info(title, message)
 
def filter(self, *args):
self.debug("Filtering")
"""
Missing method docstring (missing-docstring)
"""
self.visible_filter.refilter()
 
 
def visible_function(self, model, itr, data):
entry = self.gui.get_widget('gtk_entry_collection_new')
"""
Missing method docstring (missing-docstring)
"""
entry = self.srvgui.get_widget('gtk_entry_collection_new')
text = entry.get_text()
title = model.get(itr, 2)[0]
match = text.upper() in title.upper()
/branches/BR-0.3/basico/widgets/wdg_import.py
28,15 → 28,15
def get_services(self):
"""Load services to be used in this class
"""
self.gui = self.app.get_service("GUI")
self.cb = self.app.get_service('Callbacks')
self.im = self.app.get_service('IM')
self.srvgui = self.app.get_service("GUI")
self.srvclb = self.app.get_service('Callbacks')
self.srvicm = self.app.get_service('IM')
 
def setup(self):
# Import Header
header = Gtk.VBox()
hbox = Gtk.HBox()
icon = self.im.get_new_image_icon('basico-add')
icon = self.srvicm.get_new_image_icon('basico-add')
title = Gtk.Label()
title.set_markup('<big><b>Import SAP Notes from Launchpad</b></big>')
title.set_xalign(0.0)
62,7 → 62,7
custom_scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
custom_scroller.set_shadow_type(Gtk.ShadowType.IN)
custom_scroller.set_vexpand(True)
custom_text_view = self.gui.add_widget('gtk_textview_download_launchpad', Gtk.TextView())
custom_text_view = self.srvgui.add_widget('gtk_textview_download_launchpad', Gtk.TextView())
custom_text_view.set_vexpand(True)
custom_text_buffer = Gtk.TextBuffer()
custom_text_buffer.set_text('')
75,7 → 75,7
label.set_justify(Gtk.Justification.LEFT)
vbox.pack_end(label, False, False, 0)
custom_button = Gtk.Button("Download")
custom_button.connect('clicked', self.cb.sapnote_import_from_launchpad)
custom_button.connect('clicked', self.srvclb.sapnote_import_from_launchpad)
vbox.pack_end(custom_button, False, False, 3)
self.pack_start(vbox, True, True, 0)
self.show_all()
/branches/BR-0.3/basico/widgets/wdg_logviewer.py
30,7 → 30,7
def get_services(self):
"""Load services to be used in this class
"""
self.gui = self.app.get_service("GUI")
self.srvgui = self.app.get_service("GUI")
 
 
def setup(self):
38,7 → 38,7
self.set_shadow_type(Gtk.ShadowType.IN)
self.set_hexpand(True)
self.set_vexpand(True)
self.logviewer = self.gui.add_widget('gtk_textview_logviewer', Gtk.TextView())
self.logviewer = self.srvgui.add_widget('gtk_textview_logviewer', Gtk.TextView())
self.logviewer.modify_font(Pango.FontDescription('Monospace 10'))
buffer_logviewer = self.logviewer.get_buffer()
self.add(self.logviewer)
46,7 → 46,7
 
 
def update(self):
logviewer = self.gui.get_widget('gtk_textview_logviewer')
logviewer = self.srvgui.get_widget('gtk_textview_logviewer')
buffer_logviewer = logviewer.get_buffer()
log = open(FILE['LOG'], 'r').read()
buffer_logviewer.set_text(log)
/branches/BR-0.3/basico/widgets/wdg_menuview.py
1,27 → 1,23
#!/usr/bin/python
"""
# -*- coding: utf-8 -*-
# File: sapnoteviewmenu.py
# File: wdg_menuview.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: SAPNoteViewMenu Widget
"""
 
from enum import IntEnum
import traceback as tb
from cgi import escape
from collections import OrderedDict
 
import gi
gi.require_version('Gdk', '3.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gdk
from gi.repository import Gio
from gi.repository import Gtk
from gi.repository import Pango
from gi.repository.GdkPixbuf import Pixbuf
from gi.repository import Pango
from datetime import datetime
from dateutil import parser as dateparser
 
from basico.widgets.wdg_cols import CollectionsMgtView
 
 
48,7 → 44,7
self.toggled = 0
self.selected = set()
self.count = 0
self.completion = self.gui.add_widget('gtk_entrycompletion_viewmenu', Gtk.EntryCompletion())
self.completion = self.srvgui.add_widget('gtk_entrycompletion_viewmenu', Gtk.EntryCompletion())
self.completion.set_match_func(self.completion_match_func)
self.completion_model = Gtk.ListStore(str)
self.completion.set_model(self.completion_model)
120,7 → 116,6
self.column_component.set_sort_order(Gtk.SortType.ASCENDING)
self.column_component.set_expand(True)
self.append_column(self.column_component)
expander_column = self.column_component
 
# Category
self.renderer_cat = Gtk.CellRendererText()
213,45 → 208,35
self.set_enable_search(True)
self.set_hover_selection(False)
self.set_grid_lines(Gtk.TreeViewGridLines.NONE)
self.set_search_entry(self.gui.get_widget('stySearchInfo'))
self.set_search_entry(self.srvgui.get_widget('stySearchInfo'))
self.set_search_column(3)
#~ self.set_row_separator_func(self.row_separator_func)
 
# Selection
self.selection = self.get_selection()
#~ self.selection.set_select_function(self.select_function)
self.selection.set_mode(Gtk.SelectionMode.SINGLE)
 
# Font
font_desc = Pango.FontDescription('Monospace 10')
if font_desc:
self.modify_font(font_desc)
 
# Go live
# FIXME: right click not working
#~ self.connect('button_press_event', self.right_click)
#~ self.connect('row-activated', self.double_click)
#~ self.connect('cursor-changed', self.row_changed)
#~ self.sig_selection_changed = self.selection.connect('changed', self.row_changed) #self.selection_changed)
 
# Custom method to be implemented.
self.prepare()
self.show_all()
 
 
def get_services(self):
self.gui = self.app.get_service("GUI")
self.cb = self.app.get_service('Callbacks')
self.sap = self.app.get_service('SAP')
self.im = self.app.get_service('IM')
self.settings = self.app.get_service('Settings')
self.db = self.app.get_service('DB')
self.annot = self.app.get_service('Annotation')
self.uif = self.app.get_service('UIF')
self.srvgui = self.app.get_service("GUI")
self.srvclb = self.app.get_service('Callbacks')
self.srvsap = self.app.get_service('SAP')
self.srvicm = self.app.get_service('IM')
self.srvstg = self.app.get_service('Settings')
self.srvdtb = self.app.get_service('DB')
self.srvant = self.app.get_service('Annotation')
self.srvuif = self.app.get_service('UIF')
 
 
def get_node(self, key, checkbox, icon, component, cat='', sntype='', sid='', title='', priority='', lang='', rel=''):
completion = self.gui.get_widget('gtk_entrycompletion_viewmenu')
completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
completion_model = completion.get_model()
completion_model.append([component])
 
301,7 → 286,7
 
 
def get_node_type(self, sntype):
icon = self.im.get_icon('basico-type', 32, 32)
icon = self.srvicm.get_icon('basico-type', 32, 32)
if len(sntype) == 0:
title = "SAP Note type not found"
else:
319,17 → 304,17
 
 
def get_node_component(self, compkey, comptxt):
icon = self.im.get_icon('basico-component', 32, 32)
node = []
count = len(self.db.get_notes_by_node("componentkey", compkey))
component = "%s" % (compkey)
return self.get_node('componentkey@%s' % compkey, 0, icon, component)
icon = self.srvicm.get_icon('basico-component', 32, 32)
# ~ node = []
# ~ count = len(self.srvdtb.get_notes_by_node("componentkey", compkey))
# ~ component = "%s" % (compkey)
return self.get_node('componentkey@%s' % compkey, 0, icon, compkey)
 
 
def get_node_component_desc(self, compkey, comptxt):
icon = self.im.get_icon('basico-description', 32, 32)
icon = self.srvicm.get_icon('basico-description', 32, 32)
node = []
count = len(self.db.get_notes_by_node("componentkey", compkey))
count = len(self.srvdtb.get_notes_by_node("componentkey", compkey))
if len(comptxt) == 0:
component = "%s" % (compkey)
else:
337,13 → 322,9
return self.get_node('componentkey@%s' % compkey, 0, icon, component)
 
 
def edit_title(self, widget, path, text):
self.debug("Hi there!")
self.model[path][1] = text
 
def completion_match_func(self, completion, key, iter):
def completion_match_func(self, completion, key, treeiter):
model = completion.get_model()
text = model.get_value(iter, 0)
text = model.get_value(treeiter, 0)
if key.upper() in text.upper():
return True
return False
382,21 → 363,22
self.connect('button_press_event', self.right_click)
 
def refresh(self):
visor = self.gui.get_widget('visor')
visor = self.srvgui.get_widget('visor')
try:
self.set_view(self.view)
if self.row_type is not None:
matches = self.db.get_notes_by_node(self.row_type, self.cid)
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches)
except Exception as error:
self.debug(error)
self.print_traceback()
pass
# ~ self.debug(error)
# ~ self.print_traceback()
 
 
def row_changed(self, selection):
if self.current_status is None:
visor = self.gui.get_widget('visor')
# ~ self.uif.set_widget_visibility('widget_annotation', False)
visor = self.srvgui.get_widget('visor')
# ~ self.srvuif.set_widget_visibility('widget_annotation', False)
 
try:
model, treeiter = selection.get_selected()
407,16 → 389,16
 
if self.row_type == 'collection':
if not iter_has_child:
matches = self.db.get_notes_by_node(self.row_type, self.cid)
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches, self.cid)
else:
matches = self.db.get_notes_by_node(self.row_type, self.cid)
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
if len(matches) > 0:
visor.populate_sapnotes(matches)
else:
visor.populate_sapnotes([])
else:
matches = self.db.get_notes_by_node(self.row_type, self.cid)
matches = self.srvdtb.get_notes_by_node(self.row_type, self.cid)
visor.populate_sapnotes(matches, self.cid)
except AttributeError as error:
pass
423,7 → 405,8
except TypeError:
pass
except Exception as error:
self.debug(error)
# ~ self.debug(error)
pass
# ~ self.print_traceback()
 
 
432,29 → 415,29
rect = Gdk.Rectangle()
rect.x = x = int(event.x)
rect.y = y = int(event.y)
pthinfo = 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
path, col, cellx, celly = pthinfo
model = treeview.get_model()
treeiter = model.get_iter(path)
rid = model[treeiter][0]
rtype = rid[:rid.find('@')]
if rtype == 'collection':
popcollections = self.gui.add_widget('gtk_popover_button_manage_collections_single_note', Gtk.Popover.new(treeview))
popcollections = self.srvgui.add_widget('gtk_popover_button_manage_collections_single_note', Gtk.Popover.new(treeview))
popcollections.set_position(Gtk.PositionType.RIGHT)
popcollections.set_pointing_to(rect)
popcollections.add(CollectionsMgtView(self.app, '0000000000', popcollections))
self.cb.gui_show_popover(None, popcollections)
self.srvclb.gui_show_popover(None, popcollections)
 
 
def set_view(self, view=None):
statusbar = self.gui.get_widget('widget_statusbar')
statusbar = self.srvgui.get_widget('widget_statusbar')
# FIXME: Get last view visited from config
if view is None:
view ='chronologic'
view = 'chronologic'
 
iconview = self.gui.get_widget('gtk_image_current_view')
icon = self.im.get_pixbuf_icon('basico-%s' % view, 24, 24)
iconview = self.srvgui.get_widget('gtk_image_current_view')
icon = self.srvicm.get_pixbuf_icon('basico-%s' % view, 24, 24)
iconview.set_from_pixbuf(icon)
iconview.show_all()
self.view = view
461,7 → 444,7
# ~ self.debug("Set current view to: %s" % view)
 
# Change label
viewlabel = self.gui.get_widget('gtk_label_current_view')
viewlabel = self.srvgui.get_widget('gtk_label_current_view')
name = "<b>%s</b>" % view.capitalize()
viewlabel.set_markup(name)
viewlabel.set_xalign(0.0)
489,14 → 472,14
self.column_priority.set_expand(False)
self.column_cat.set_visible(False)
self.column_sid.set_expand(False)
tgbshowmenu = self.gui.get_widget('gtk_toogletoolbutton_menu_view')
tgbshowmenu = self.srvgui.get_widget('gtk_toogletoolbutton_menu_view')
tgbshowmenu.set_active(True)
completion = self.gui.get_widget('gtk_entrycompletion_viewmenu')
completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
completion_model = completion.get_model()
completion_model.clear()
 
if len(sapnotes) == 0:
sapnotes = self.db.get_notes()
sapnotes = self.srvdtb.get_notes()
 
if self.view == 'component':
self.populate_by_components(sapnotes)
525,28 → 508,28
else:
self.populate_by_components(sapnotes)
 
viewfilter = self.gui.get_widget('gtk_entry_filter_view')
completion = self.gui.get_widget('gtk_entrycompletion_viewmenu')
viewfilter = self.srvgui.get_widget('gtk_entry_filter_view')
completion = self.srvgui.get_widget('gtk_entrycompletion_viewmenu')
completion.set_model(completion_model)
viewfilter.set_completion(completion)
# ~ self.debug("View '%s' populated" % (self.view))
self.cb.gui_show_dashboard()
self.srvclb.gui_show_dashboard()
self.current_status = None
 
 
def populate_by_bookmarks(self):
matches = []
sapnotes = self.db.get_notes()
sapnotes = self.srvdtb.get_notes()
for sid in sapnotes:
if sapnotes[sid]['bookmark']:
matches.append(sid)
matches.sort()
 
visor = self.gui.get_widget('visor')
self.cb.gui_toggle_menu_view(False)
visor = self.srvgui.get_widget('visor')
self.srvclb.gui_toggle_menu_view(False)
visor.populate_sapnotes(matches)
statusbar = self.gui.get_widget('widget_statusbar')
self.info('View %s populated with %d SAP Notes' % (self.view.capitalize(), len(matches)))
statusbar = self.srvgui.get_widget('widget_statusbar')
# ~ self.debug('View %s populated with %d SAP Notes' % (self.view.capitalize(), len(matches)))
 
 
def populate_by_components(self, sapnotes, only_bookmarks=False):
705,8 → 688,8
scomp = set()
dcomp = {}
self.model.clear()
self.clts = self.app.get_service('Collections')
collections = self.clts.get_all()
self.srvclt = self.app.get_service('Collections')
collections = self.srvclt.get_all()
od = OrderedDict(sorted(collections.items(), key=lambda t: t[1]))
 
for tid in od:
725,8 → 708,8
 
 
def populate_annotations(self, annotations=None):
visor = self.gui.get_widget('visor')
self.cb.gui_toggle_menu_view(False)
visor = self.srvgui.get_widget('visor')
self.srvclb.gui_toggle_menu_view(False)
visor.populate_annotations(annotations)
 
 
746,9 → 729,9
year = "%d" % downloaded.year
month = "%02d" % downloaded.month
day = "%02d" % downloaded.day
key_year = year
key_month = year + month
key_day = year + month + day
key_year = year
key_month = year + month
key_day = year + month + day
years.add(key_year)
months.add(key_month)
days.add(key_day)
800,5 → 783,5
if rowtype == 'collection':
if not iter_has_child:
if len(target) > 0:
self.clts.rename(cid, target)
self.srvclt.rename(cid, target)
self.populate()
/branches/BR-0.3/basico/widgets/wdg_settingsview.py
30,12 → 30,12
def get_services(self):
"""Load services to be used in this class
"""
self.gui = self.app.get_service("GUI")
self.bnr = self.app.get_service('BNR')
self.utils = self.app.get_service('Utils')
self.annot = self.app.get_service('Annotation')
self.db = self.app.get_service('DB')
self.bnr = self.app.get_service('BNR')
self.srvgui = self.app.get_service("GUI")
self.srvbnr = self.app.get_service('BNR')
self.srvutl = self.app.get_service('Utils')
self.srvant = self.app.get_service('Annotation')
self.srvdtb = self.app.get_service('DB')
self.srvbnr = self.app.get_service('BNR')
 
 
def setup(self):
107,8 → 107,8
def update(self):
from cgi import escape
self.model.clear()
self.settings = self.app.get_service('Settings')
config = self.settings.load()
self.srvstg = self.app.get_service('Settings')
config = self.srvstg.load()
sdict = {}
 
# ENVIRONMENT NODE
161,7 → 161,7
root = self.model.append(None, ['root', '<big><b>Runtime Objects</b></big>', ''])
 
wdgdict = {}
widgets = self.gui.get_widgets()
widgets = self.srvgui.get_widgets()
for name in widgets:
objname = escape(str(widgets[name]))
pobj = gobject = objname[4:objname.find(' ')]
185,12 → 185,12
 
# BACKUPS NODE
root = self.model.append(None, ['root', '<big><b>Backups Overview</b></big>', ''])
backups = self.bnr.get_all_backups()
backups = self.srvbnr.get_all_backups()
for backup in backups:
try:
timestamp = os.path.basename(backup)[7:-4]
fuzzydate = self.utils.fuzzy_date_from_timestamp(timestamp)
sapnotes, annotations = self.bnr.test(backup)
fuzzydate = self.srvutl.fuzzy_date_from_timestamp(timestamp)
sapnotes, annotations = self.srvbnr.test(backup)
message = "Database backed up %s. It contains %d SAP Notes and %d annotations." % (fuzzydate, sapnotes, annotations)
self.model.append(root, [backup, os.path.basename(backup), message])
except:
200,9 → 200,9
 
# STATS NODE
root = self.model.append(None, ['root', '<big><b>Stats Overview</b></big>', ''])
s_count = self.db.get_total()
a_count = self.annot.get_total()
stats = self.db.get_stats()
s_count = self.srvdtb.get_total()
a_count = self.srvant.get_total()
stats = self.srvdtb.get_stats()
sapnotes_node = self.model.append(root, ['', 'SAP Notes', "%6d" % s_count])
components_node = self.model.append(sapnotes_node, ['', 'Components', ''])
for component in stats['maincomp']:
/branches/BR-0.3/basico/widgets/wdg_statusbar.py
25,7 → 25,7
vbox = Gtk.VBox()
viewport = Gtk.Viewport()
viewport.set_shadow_type(Gtk.ShadowType.NONE)
self.statusbar = self.gui.add_widget('gtk_label_statusbar', Gtk.Label())
self.statusbar = self.srvgui.add_widget('gtk_label_statusbar', Gtk.Label())
self.statusbar.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
self.statusbar.set_property('selectable', True)
self.statusbar.set_property('margin-left', 6)
40,7 → 40,7
 
 
def get_services(self):
self.gui = self.app.get_service("GUI")
self.srvgui = self.app.get_service("GUI")
 
 
def message(self, message):
/branches/BR-0.3/basico/widgets/wdg_visor.py
37,9 → 37,9
self.tool_bar.set_property('margin-bottom', 0)
 
# Toggle Views button
tool = self.gui.add_widget('gtk_toogletoolbutton_menu_view', Gtk.ToggleToolButton.new())
tool = self.srvgui.add_widget('gtk_toogletoolbutton_menu_view', Gtk.ToggleToolButton.new())
tool.set_icon_name('gtk-select-color')
tool.connect('toggled', self.cb.gui_toggle_menu_view)
tool.connect('toggled', self.srvclb.gui_toggle_menu_view)
tool.set_active(False)
tool.set_hexpand(False)
self.tool_bar.insert(tool, -1)
47,11 → 47,11
# View combobox button/popover
tool = Gtk.ToolItem.new()
lhbox = Gtk.HBox()
menuviews = self.gui.add_widget('gtk_button_menu_views', Gtk.Button())
menuviews = self.srvgui.add_widget('gtk_button_menu_views', Gtk.Button())
hbox = Gtk.HBox()
label = self.gui.add_widget('gtk_label_current_view', Gtk.Label())
label = self.srvgui.add_widget('gtk_label_current_view', Gtk.Label())
label.set_xalign(0.0)
image = self.gui.add_widget('gtk_image_current_view', Gtk.Image())
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)
62,35 → 62,35
self.tool_bar.insert(tool, -1)
 
### Popover menuviews
popover = self.gui.add_widget('gtk_popover_button_menu_views', Gtk.Popover.new(menuviews))
menuviews.connect('clicked', self.cb.gui_show_popover, popover)
popover = self.srvgui.add_widget('gtk_popover_button_menu_views', Gtk.Popover.new(menuviews))
menuviews.connect('clicked', self.srvclb.gui_show_popover, popover)
box = Gtk.Box(spacing = 0, orientation="vertical")
popover.add(box)
 
 
box.pack_start(self.uif.create_menuview_button('annotation'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('annotation'), False, False, 0)
separator = Gtk.Separator(orientation = Gtk.Orientation.HORIZONTAL)
box.pack_start(separator, False, False, 0)
box.pack_start(self.uif.create_menuview_button('collection'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('component'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('description'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('bookmarks'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('category'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('chronologic'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('priority'), False, False, 0)
box.pack_start(self.uif.create_menuview_button('type'), 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)
box.pack_start(self.srvuif.create_menuview_button('category'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('chronologic'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('priority'), False, False, 0)
box.pack_start(self.srvuif.create_menuview_button('type'), False, False, 0)
 
# Import button
tool = Gtk.ToolButton()
tool.set_icon_name('basico-add')
popover = self.gui.add_widget('gtk_popover_toolbutton_import', Gtk.Popover.new(tool))
tool.connect('clicked', self.cb.gui_show_popover, popover)
popover = self.srvgui.add_widget('gtk_popover_toolbutton_import', Gtk.Popover.new(tool))
tool.connect('clicked', self.srvclb.gui_show_popover, popover)
self.tool_bar.insert(tool, -1)
 
## Popover body
box = Gtk.VBox(spacing = 0, orientation="vertical")
box.set_property('margin', 3)
widget_import = self.gui.add_widget('widget_import', ImportWidget(self.app))
widget_import = self.srvgui.add_widget('widget_import', ImportWidget(self.app))
box.pack_start(widget_import, True, True, 6)
popover.add(box)
 
97,15 → 97,15
# Annotation button
tool = Gtk.ToolButton()
tool.set_icon_name('basico-annotation')
popover = self.gui.add_widget('gtk_popover_annotation', Gtk.Popover.new(tool))
# ~ tool.connect('clicked', self.cb.gui_show_popover, popover)
tool.connect('clicked', self.cb.gui_annotation_widget_show)
popover = self.srvgui.add_widget('gtk_popover_annotation', Gtk.Popover.new(tool))
# ~ tool.connect('clicked', self.srvclb.gui_show_popover, popover)
tool.connect('clicked', self.srvclb.gui_annotation_widget_show)
self.tool_bar.insert(tool, -1)
 
## Popover body
# ~ box = Gtk.VBox(spacing = 0, orientation="vertical")
# ~ box.set_property('margin', 3)
# ~ widget_import = self.gui.add_widget('widget_annotation', AnnotationWidget(self.app))
# ~ widget_import = self.srvgui.add_widget('widget_annotation', AnnotationWidget(self.app))
# ~ box.pack_start(widget_import, True, True, 6)
# ~ popover.add(box)
 
113,7 → 113,7
# Filter entry
 
## Completion
self.completion = self.gui.add_widget('gtk_entrycompletion_visor', Gtk.EntryCompletion())
self.completion = self.srvgui.add_widget('gtk_entrycompletion_visor', Gtk.EntryCompletion())
self.completion.set_match_func(self.completion_match_func)
self.completion_model = Gtk.ListStore(str)
self.completion.set_model(self.completion_model)
124,15 → 124,15
hbox = Gtk.HBox()
entry = Gtk.Entry()
entry.set_completion(self.completion)
entry.connect('activate', self.cb.gui_filter_visor)
self.gui.add_widget('gtk_entry_filter_visor', entry)
entry.connect('activate', self.srvclb.gui_filter_visor)
self.srvgui.add_widget('gtk_entry_filter_visor', entry)
 
icon = self.im.get_pixbuf_icon('basico-find')
icon = self.srvicm.get_pixbuf_icon('basico-find')
entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.PRIMARY, icon)
entry.set_icon_sensitive(Gtk.EntryIconPosition.PRIMARY, True)
entry.set_icon_tooltip_markup (Gtk.EntryIconPosition.PRIMARY, "Search in the whole database")
 
icon = self.im.get_pixbuf_icon('basico-filter')
icon = self.srvicm.get_pixbuf_icon('basico-filter')
entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
entry.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, True)
entry.set_icon_tooltip_markup (Gtk.EntryIconPosition.SECONDARY, "Click here to filter results")
140,11 → 140,11
 
def on_icon_pressed(entry, icon_pos, event):
if icon_pos == Gtk.EntryIconPosition.PRIMARY:
self.cb.action_search(entry)
self.srvclb.action_search(entry)
elif icon_pos == Gtk.EntryIconPosition.SECONDARY:
self.cb.gui_filter_visor(entry)
self.srvclb.gui_filter_visor(entry)
 
entry.connect('changed', self.cb.gui_filter_visor)
entry.connect('changed', self.srvclb.gui_filter_visor)
entry.connect("icon-press", on_icon_pressed)
hbox.pack_start(entry, True, True, 0)
tool.add(hbox)
160,15 → 160,15
# Button Total SAP Notes
tool = Gtk.ToolItem()
tool.set_expand(False)
button = self.gui.add_widget('gtk_button_total_notes', Gtk.Button())
button = self.srvgui.add_widget('gtk_button_total_notes', Gtk.Button())
button.set_relief(Gtk.ReliefStyle.NONE)
 
popover = self.gui.add_widget('gtk_popover_button_total_notes', Gtk.Popover.new(button))
label = self.gui.add_widget('gtk_label_total_notes', Gtk.Label())
popover = self.srvgui.add_widget('gtk_popover_button_total_notes', Gtk.Popover.new(button))
label = self.srvgui.add_widget('gtk_label_total_notes', Gtk.Label())
hbox = Gtk.HBox()
hbox.pack_start(label, False, False, 0)
button.add(hbox)
button.connect('clicked', self.cb.gui_show_popover, popover)
button.connect('clicked', self.srvclb.gui_show_popover, popover)
tool.add(button)
self.tool_bar.insert(tool, -1)
 
179,12 → 179,12
# Fullscreen toggle button
tool = Gtk.ToolItem()
tool.set_expand(False)
icon = self.im.get_new_image_icon('basico-fullscreen', 24, 24)
box = self.gui.add_widget('gtk_box_container_icon_fullscreen', Gtk.Box())
icon = self.srvicm.get_new_image_icon('basico-fullscreen', 24, 24)
box = self.srvgui.add_widget('gtk_box_container_icon_fullscreen', Gtk.Box())
box.pack_start(icon, False, False, 0)
button = Gtk.ToggleButton()
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect('toggled', self.cb.gui_toggle_fullscreen)
button.connect('toggled', self.srvclb.gui_toggle_fullscreen)
button.add(box)
tool.add(button)
self.tool_bar.insert(tool, -1)
196,13 → 196,13
 
 
def get_services(self):
self.gui = self.app.get_service("GUI")
self.cb = self.app.get_service('Callbacks')
self.sap = self.app.get_service('SAP')
self.im = self.app.get_service('IM')
self.settings = self.app.get_service('Settings')
self.db = self.app.get_service('DB')
self.uif = self.app.get_service("UIF")
self.srvgui = self.app.get_service("GUI")
self.srvclb = self.app.get_service('Callbacks')
self.srvsap = self.app.get_service('SAP')
self.srvicm = self.app.get_service('IM')
self.srvstg = self.app.get_service('Settings')
self.srvdtb = self.app.get_service('DB')
self.srvuif = self.app.get_service("UIF")
 
 
def completion_match_func(self, completion, key, iter):
222,7 → 222,7
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
hbox = Gtk.HBox()
icon = self.im.get_new_image_icon(icon_name, 24, 24)
icon = self.srvicm.get_new_image_icon(icon_name, 24, 24)
lbltext = Gtk.Label()
lbltext.set_xalign(0.0)
lbltext.set_markup('%s' % text)
233,7 → 233,7
 
# Popover button "Bookmark"
button = get_popover_button("(Un)bookmark SAP Notes", 'basico-bookmarks')
button.connect('clicked', self.cb.switch_bookmark_current_set, popover)
button.connect('clicked', self.srvclb.switch_bookmark_current_set, popover)
box.pack_start(button, False, False, 0)
 
# Separator
243,9 → 243,9
# Popover button Collection Management
button = get_popover_button("Manage collections", 'basico-collection')
box.pack_start(button, False, False, 0)
self.popcollections = self.gui.add_widget('gtk_popover_button_manage_collections_selected_notes', Gtk.Popover.new(button))
self.popcollections = self.srvgui.add_widget('gtk_popover_button_manage_collections_selected_notes', Gtk.Popover.new(button))
self.popcollections.set_position(Gtk.PositionType.RIGHT)
button.connect('clicked', self.cb.gui_show_popover, self.popcollections)
button.connect('clicked', self.srvclb.gui_show_popover, self.popcollections)
self.popcollections.add(CollectionsMgtView(self.app, sid, self.popcollections))
 
# Separator
255,7 → 255,7
 
# Popover button "Delete SAP Notes"
button = get_popover_button("Delete SAP Notes", 'basico-delete')
button.connect('clicked', self.cb.sapnote_delete, sid)
button.connect('clicked', self.srvclb.sapnote_delete, sid)
box.pack_start(button, False, False, 0)
 
return box
270,15 → 270,15
 
 
def get_services(self):
self.gui = self.app.get_service("GUI")
self.cb = self.app.get_service('Callbacks')
self.sap = self.app.get_service('SAP')
self.im = self.app.get_service('IM')
self.settings = self.app.get_service('Settings')
self.db = self.app.get_service('DB')
self.uif = self.app.get_service("UIF")
self.utils = self.app.get_service("Utils")
self.annot = self.app.get_service('Annotation')
self.srvgui = self.app.get_service("GUI")
self.srvclb = self.app.get_service('Callbacks')
self.srvsap = self.app.get_service('SAP')
self.srvicm = self.app.get_service('IM')
self.srvstg = self.app.get_service('Settings')
self.srvdtb = self.app.get_service('DB')
self.srvuif = self.app.get_service("UIF")
self.srvutl = self.app.get_service("Utils")
self.srvant = self.app.get_service('Annotation')
 
def get_treeview(self):
return self.treeview
317,7 → 317,7
# Setup columns
def get_column_header_widget(title, icon_name=None, width=24, height=24):
hbox = Gtk.HBox()
icon = self.im.get_new_image_icon(icon_name, width, height)
icon = self.srvicm.get_new_image_icon(icon_name, width, height)
label = Gtk.Label()
label.set_markup("<b>%s</b>" % title)
label.modify_font(Pango.FontDescription('Monospace 10'))
529,7 → 529,7
return False
 
def visible_function(self, model, itr, data):
entry = self.gui.get_widget('gtk_entry_filter_visor')
entry = self.srvgui.get_widget('gtk_entry_filter_visor')
text = entry.get_text()
sid = str(model.get(itr, 3)[0])
if sid.startswith('<'):
546,9 → 546,9
 
 
def update_total_sapnotes_count(self, count=0):
statusbar = self.gui.get_widget('widget_statusbar')
lblnotescount = self.gui.get_widget('gtk_label_total_notes')
total = self.db.get_total()
statusbar = self.srvgui.get_widget('widget_statusbar')
lblnotescount = self.srvgui.get_widget('gtk_label_total_notes')
total = self.srvdtb.get_total()
 
lblnotescount.set_markup("<b>%d/<big>%d</big></b>" % (count, total))
# ~ self.info('View populated with %d SAP Notes' % count)
565,12 → 565,12
component = model[treeiter][5]
if component == 'Annotation':
aid = model[treeiter][10]
is_valid = self.annot.is_valid(aid)
is_valid = self.srvant.is_valid(aid)
if is_valid:
self.cb.action_annotation_edit(aid)
self.srvclb.action_annotation_edit(aid)
else:
aid = None
self.uif.set_widget_visibility('gtk_vbox_container_annotations', False)
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
except Exception as error:
self.debug(error)
self.print_traceback()
583,7 → 583,7
 
def get_node(self, key, icon, checkbox, sid, title, component, category='', sntype='', priority='', updated='', aid='', timestamp=''):
# Add completion entries
completion = self.gui.get_widget('gtk_entrycompletion_visor')
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.append([title])
 
608,21 → 608,21
 
 
def populate_sapnotes(self, bag=None, cid=None):
icon_annotation = self.im.get_pixbuf_icon('basico-annotation', 32, 32)
icon_content = self.im.get_pixbuf_icon('basico-logviewer', 32, 32)
icon_link = self.im.get_pixbuf_icon('basico-browser', 32, 32)
icon_empty = self.im.get_pixbuf_icon('basico-empty', 32, 32)
icon_sapnote = self.im.get_pixbuf_icon('basico-sapnote', 32, 32)
icon_bookmark = self.im.get_pixbuf_icon('basico-bookmarks', 32, 32)
icon_annotation = self.srvicm.get_pixbuf_icon('basico-annotation', 32, 32)
icon_content = self.srvicm.get_pixbuf_icon('basico-logviewer', 32, 32)
icon_link = self.srvicm.get_pixbuf_icon('basico-browser', 32, 32)
icon_empty = self.srvicm.get_pixbuf_icon('basico-empty', 32, 32)
icon_sapnote = self.srvicm.get_pixbuf_icon('basico-sapnote', 32, 32)
icon_bookmark = self.srvicm.get_pixbuf_icon('basico-bookmarks', 32, 32)
self.column_sid.set_visible(True)
self.column_checkbox.set_visible(False)
self.column_category.set_visible(False)
self.column_component.set_visible(True)
completion = self.gui.get_widget('gtk_entrycompletion_visor')
completion = self.srvgui.get_widget('gtk_entrycompletion_visor')
completion_model = completion.get_model()
completion_model.clear()
 
# ~ self.cb.gui_show_dashboard()
# ~ self.srvclb.gui_show_dashboard()
 
if bag is None:
bag = self.bag
633,7 → 633,7
self.model.clear()
 
for sid in self.bag:
metadata = self.db.get_sapnote_metadata(sid)
metadata = self.srvdtb.get_sapnote_metadata(sid)
if metadata is not None:
bookmark = metadata['bookmark']
title = escape(metadata['title'])
659,7 → 659,7
escape(metadata['category']),
escape(metadata['type']),
escape(metadata['priority']),
self.utils.fuzzy_date_from_timestamp(timestamp),
self.srvutl.fuzzy_date_from_timestamp(timestamp),
'',
timestamp
)
666,7 → 666,7
pid = self.model.append(None, node)
 
# Load annotations
files = self.annot.get_by_sid(metadata['id'])
files = self.srvant.get_by_sid(metadata['id'])
for fname in files:
with open(fname, 'r') as fa:
annotation = json.load(fa)
680,7 → 680,7
'',
annotation['type'],
'',
self.utils.fuzzy_date_from_timestamp(annotation['timestamp']),
self.srvutl.fuzzy_date_from_timestamp(annotation['timestamp']),
annotation['aid'],
annotation['timestamp']
)
688,28 → 688,28
self.treeview.set_model(self.sorted_model)
self.update_total_sapnotes_count(len(self.model))
self.show_widgets()
stack = self.gui.get_widget('gtk_stack_main')
stack = self.srvgui.get_widget('gtk_stack_main')
stack.set_visible_child_name('visor')
# ~ self.annot.get_all()
# ~ self.srvant.get_all()
 
 
def populate_annotations(self, annotations=None):
icon_annotation = self.im.get_pixbuf_icon('basico-annotation', 32, 32)
icon_content = self.im.get_pixbuf_icon('basico-logviewer', 32, 32)
icon_link = self.im.get_pixbuf_icon('basico-browser', 32, 32)
icon_empty = self.im.get_pixbuf_icon('basico-empty', 32, 32)
icon_bookmark = self.im.get_pixbuf_icon('basico-bookmarks', 32, 32)
icon_sapnote = self.im.get_pixbuf_icon('basico-sapnote', 32, 32)
icon_annotation = self.srvicm.get_pixbuf_icon('basico-annotation', 32, 32)
icon_content = self.srvicm.get_pixbuf_icon('basico-logviewer', 32, 32)
icon_link = self.srvicm.get_pixbuf_icon('basico-browser', 32, 32)
icon_empty = self.srvicm.get_pixbuf_icon('basico-empty', 32, 32)
icon_bookmark = self.srvicm.get_pixbuf_icon('basico-bookmarks', 32, 32)
icon_sapnote = self.srvicm.get_pixbuf_icon('basico-sapnote', 32, 32)
self.column_sid.set_visible(False)
self.column_checkbox.set_visible(True)
self.column_category.set_visible(True)
self.column_component.set_visible(False)
# ~ self.cb.gui_show_dashboard()
# ~ self.srvclb.gui_show_dashboard()
 
self.model.clear()
 
if annotations is None:
annotations = self.annot.get_all()
annotations = self.srvant.get_all()
 
snpids = {}
 
716,7 → 716,7
for fname in annotations:
with open(fname, 'r') as fa:
annotation = json.load(fa)
sid = self.annot.get_sid(annotation['aid'])
sid = self.srvant.get_sid(annotation['aid'])
node = self.get_node( 0,
icon_annotation,
False,
726,7 → 726,7
'',
annotation['type'],
'',
self.utils.fuzzy_date_from_timestamp(annotation['timestamp']),
self.srvutl.fuzzy_date_from_timestamp(annotation['timestamp']),
annotation['aid'],
annotation['timestamp']
)
736,12 → 736,12
self.treeview.expand_all()
self.update_total_sapnotes_count(len(self.model))
self.show_widgets()
stack = self.gui.get_widget('gtk_stack_main')
stack = self.srvgui.get_widget('gtk_stack_main')
stack.set_visible_child_name('visor')
 
 
def show_widgets(self):
self.uif.set_widget_visibility('gtk_button_total_notes', True)
self.srvuif.set_widget_visibility('gtk_button_total_notes', True)
 
 
def right_click(self, treeview, event, data=None):
757,13 → 757,13
component = model[treeiter][5]
sid = model[treeiter][0]
sid = "0"*(10 - len(str(sid))) + str(sid)
toolbar = self.gui.get_widget('visortoolbar')
popover = self.gui.add_widget('gtk_popover_visor_row', Gtk.Popover.new(treeview))
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)
box = self.build_popover(sid, popover, component)
popover.add(box)
self.cb.gui_show_popover(None, popover)
self.srvclb.gui_show_popover(None, popover)
 
 
def build_popover(self, sid, popover, component):
773,7 → 773,7
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
hbox = Gtk.HBox()
icon = self.im.get_new_image_icon(icon_name, 24, 24)
icon = self.srvicm.get_new_image_icon(icon_name, 24, 24)
lbltext = Gtk.Label()
lbltext.set_xalign(0.0)
lbltext.set_markup('%s' % text)
786,13 → 786,13
# Popover button "Delete annotation"
button = get_popover_button("Delete annotation", 'basico-delete')
button.show_all()
button.connect('clicked', self.cb.action_annotation_delete)
button.connect('clicked', self.srvclb.action_annotation_delete)
box.pack_start(button, False, False, 0)
 
# Popover button "Duplicate annotation"
button = get_popover_button("Duplicate annotation", 'basico-duplicate')
button.show_all()
button.connect('clicked', self.cb.action_annotation_duplicate)
button.connect('clicked', self.srvclb.action_annotation_duplicate)
box.pack_start(button, False, False, 0)
 
else:
799,17 → 799,17
# Popover button "Add an annotation"
button = get_popover_button("Add an annotation", 'basico-annotation')
button.show_all()
button.connect('clicked', self.cb.gui_annotation_widget_show, sid, 'create')
button.connect('clicked', self.srvclb.gui_annotation_widget_show, sid, 'create')
box.pack_start(button, False, False, 0)
 
# Popover button "Open SAP Note"
button = get_popover_button("See SAP Note", 'basico-browse')
button.connect('clicked', self.cb.sapnote_browse, sid)
button.connect('clicked', self.srvclb.sapnote_browse, sid)
box.pack_start(button, False, False, 0)
 
# Popover button "Bookmark"
button = get_popover_button("(Un)bookmark SAP Note", 'basico-bookmarks')
button.connect('clicked', self.cb.switch_bookmark, [sid], popover)
button.connect('clicked', self.srvclb.switch_bookmark, [sid], popover)
box.pack_start(button, False, False, 0)
 
# Separator
819,9 → 819,9
# Popover button Collection Management
button = get_popover_button("Manage collections", 'basico-collection')
box.pack_start(button, False, False, 0)
self.popcollections = self.gui.add_widget('gtk_popover_button_manage_collections_single_note', Gtk.Popover.new(button))
self.popcollections = self.srvgui.add_widget('gtk_popover_button_manage_collections_single_note', Gtk.Popover.new(button))
self.popcollections.set_position(Gtk.PositionType.RIGHT)
button.connect('clicked', self.cb.gui_show_popover, self.popcollections)
button.connect('clicked', self.srvclb.gui_show_popover, self.popcollections)
self.popcollections.add(CollectionsMgtView(self.app, sid, self.popcollections))
 
# Separator
831,7 → 831,7
 
# Popover button "Delete SAP Note"
button = get_popover_button("Delete SAP Note", 'basico-delete')
button.connect('clicked', self.cb.sapnote_delete, sid)
button.connect('clicked', self.srvclb.sapnote_delete, sid)
box.pack_start(button, False, False, 0)
 
return box