Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 133 → Rev 134

/branches/BR-0.3/basico/log.py
17,6 → 17,7
log.setLevel(logging.DEBUG)
 
## Redirect log to stdout
#~ formatter = logging.Formatter("%(levelname)7s | %(asctime)s | %(message)s")
formatter = logging.Formatter("%(levelname)7s | %(lineno)3d | %(asctime)s | %(message)s")
ch = logging.StreamHandler() # Create console handler and set level to debug
ch.setLevel(logging.DEBUG) # Set logging devel
24,9 → 25,9
log.addHandler(ch) # add console handler to logger
 
#FIXME Redirect log to file
#FIXME fh = logging.FileHandler(LOG_FILE)
#FIXME fh.setFormatter(formatter)
#FIXME fh.setLevel(logging.DEBUG) # Set logging devel
#FIXME log.addHandler(fh) # add file handler to logger
fh = logging.FileHandler(LOG_FILE)
fh.setFormatter(formatter)
fh.setLevel(logging.DEBUG) # Set logging devel
log.addHandler(fh) # add file handler to logger
 
return log
/branches/BR-0.3/basico/sapnoteview.py
41,6 → 41,7
def __init__(self, app):
SAPNoteView.numOfInstances += 1
self.app = app
self.log = self.app.log
self.get_services()
self.toggled = 0
self.selected = set()
225,10 → 226,12
 
# Custom method to be implemented.
self.prepare()
 
self.show_all()
 
def debug(self, message):
self.log.debug("%15s | %s" % (self.__class__.__name__, message))
 
 
def getNumInstances(self):
self.app.debug("SAPNoteView instances: %d" % self.numOfInstances)
 
/branches/BR-0.3/basico/sapnoteviewmenu.py
26,6 → 26,11
 
 
class SAPNoteViewMenu(SAPNoteView, Service):
def __init__(self, app):
SAPNoteView.__init__(self, app)
self.app = app
 
 
def prepare(self):
self.column_rowtype.set_visible(False)
self.column_checkbox.set_visible(False)
55,10 → 60,10
visor = self.gui.get_widget('visor')
try:
row = model[treeiters][0]
row_type, sid = row.split('@')
self.debug("%s (%s)" % (row_type, sid))
matches = self.db.get_notes_by_node(row_type, sid)
visor.populate(matches)
row_type, cid = row.split('@')
self.app.debug("%s (%s)" % (row_type, cid))
matches = self.db.get_notes_by_node(row_type, cid)
visor.populate(matches, cid)
except:
visor.populate([])
 
/branches/BR-0.3/basico/sapnoteviewrow.py
37,7 → 37,6
self.sap = self.app.get_service('SAP')
self.im = self.app.get_service('IM')
self.settings = self.app.get_service('Settings')
#~ self.plugins = self.app.get_service('Plugins')
self.db = self.app.get_service('DB')
self.uif = self.app.get_service("UIF")
 
64,12 → 63,10
 
def bookmark_switch(self, *args):
if self.bookmark.get_active():
icon = self.im.get_pixbuf_icon('bookmark_on', 16, 16)
self.bookmark_image.set_from_pixbuf(icon)
self.bookmark.set_label('🖤️')
self.cb.bookmark([self.sid])
else:
icon = self.im.get_pixbuf_icon('bookmark_off', 16, 16)
self.bookmark_image.set_from_pixbuf(icon)
self.bookmark.set_label('♡')
self.cb.unbookmark([self.sid])
 
 
97,19 → 94,13
hboxup.pack_start(self.checkbox, False, False, 6)
 
# BOOKMARK BUTTON
icon = self.im.get_pixbuf_icon('bookmark_off', 16, 16)
self.bookmark_image = Gtk.Image()
self.bookmark_image.set_from_pixbuf(icon)
self.bookmark = Gtk.ToggleButton()
self.bookmark.set_relief(Gtk.ReliefStyle.NONE)
self.bookmark.set_active(sapnote['bookmark'])
if self.bookmark.get_active():
icon = self.im.get_pixbuf_icon('bookmark_on', 16, 16)
self.bookmark_image.set_from_pixbuf(icon)
self.bookmark.set_label('🖤')
else:
icon = self.im.get_pixbuf_icon('bookmark_off', 16, 16)
self.bookmark_image.set_from_pixbuf(icon)
self.bookmark.add(self.bookmark_image)
self.bookmark.set_label('♡')
self.bookmark.connect('toggled', self.bookmark_switch)
hboxup.pack_start(self.bookmark, False, False, 0)
 
139,11 → 130,8
 
# SAP NOTE INFO
# Popover button
icon = self.im.get_pixbuf_icon('info', 16, 16)
img = Gtk.Image()
img.set_from_pixbuf(icon)
button = Gtk.Button()
button.add(img)
button.set_label('ℹ️')
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_alignment (0.0, 0.0)
button.set_hexpand(False)
/branches/BR-0.3/basico/sapnoteviewvisor.py
26,12 → 26,15
 
class SAPNoteViewVisor(Gtk.Box):
def __init__(self, app):
Gtk.Box.__init__(self)
self.app = app
self.log = self.app.log
self.get_services()
self.toggled = 0
self.selected = set()
self.count = 0
Gtk.Box.__init__(self)
welcome_widget = self.get_welcome_widget()
self.add(welcome_widget)
 
 
def get_services(self):
46,130 → 49,19
self.uif = self.app.get_service("UIF")
 
 
 
def prepare(self):
self.set_hexpand(True)
self.set_property('fill', True)
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("White"))
for widget_name in ['boxVisor', 'scrVisor', 'vwpVisor']:
widget = self.gui.get_widget(widget_name)
widget.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("White"))
 
 
def get_node_sapnote(self, sid):
sapnotes = self.db.get_notes()
sapnote = sapnotes[sid]
#~ compkey = escape(sapnote['componentkey'])
#~ icon_note = self.im.get_icon('fingerprint', 32, 32)
#~ icon_fav = self.im.get_icon('bookmark', 32, 32)
#~ compkey = escape(sapnote['componentkey'])
#~ compkey = escape(sapnote['componentkey'])
#~ catname = escape(sapnote['category'])
#~ sid = "0"*(10 - len(sid)) + sid
 
return sapnote
 
 
def show_infobox(self, button, revealer):
revealed = revealer.get_reveal_child()
revealer.set_reveal_child(not revealed)
 
 
def get_row(self, sid):
sapnote = self.get_node_sapnote(sid)
 
# Container
container = Gtk.VBox()
 
# SAP Note Infobox
infobox = Gtk.Revealer()
infobox.set_reveal_child(False)
label = Gtk.Label(sid)
label.set_selectable(True)
infobox.add(label)
 
# row widget
row = Gtk.HBox()
row.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("Gold"))
row.set_hexpand(True)
 
# row items widgets
checkbox = Gtk.CheckButton()
row.pack_start(checkbox, False, False, 6)
 
def get_welcome_widget(self):
widget = Gtk.VBox()
widget.set_hexpand(True)
label = Gtk.Label()
label.set_markup('<big>❤</big>')
bookmark = Gtk.ToggleButton()
bookmark.set_relief(Gtk.ReliefStyle.NONE)
bookmark.get_style_context().add_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
bookmark.add(label)
row.pack_start(bookmark, False, False, 6)
 
lblsid = Gtk.Label()
title = escape("%s - %s" % (sid, sapnote['title']))
lblsid.set_markup("%s" % title)
lblsid.set_justify(Gtk.Justification.LEFT)
lblsid.set_xalign(0.0)
lblsid.set_selectable(True)
lblsid.set_hexpand(False)
lblsid.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
lblsid.modify_font(Pango.FontDescription('Monospace 10'))
row.pack_start(lblsid, True, True, 6)
 
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_alignment (0.0, 0.0)
button.set_hexpand(False)
button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION)
label.set_markup("<span size='60000'><b>Welcome to Basico</b></span>")
widget.pack_start(label, True, True, 6)
label = Gtk.Label()
label.set_markup('<big>❓</big>')
button.add(label)
button.connect('clicked', self.show_infobox, infobox)
row.pack_start(button, False, False, 6)
label.set_markup("<span size='100000'>🙇</span>")
widget.pack_start(label, True, True, 6)
 
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_alignment (0.0, 0.0)
button.set_hexpand(False)
button.get_style_context().add_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
label = Gtk.Label()
label.set_markup('<big>🔗</big>')
button.add(label)
button.connect('clicked', self.show_infobox, infobox)
row.pack_start(button, False, False, 6)
return widget
 
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_alignment (0.0, 0.0)
button.set_hexpand(False)
label = Gtk.Label()
label.set_markup('<big>✍</big>')
button.add(label)
button.connect('clicked', self.show_infobox, infobox)
row.pack_start(button, False, False, 6)
 
app = self.gui.get_app()
actions_menu = Gio.Menu()
actions_menu.append_item(self.uif.create_item('Import Basico Package', 'app.actions-import-basico', 'document-open'))
app.add_action(self.uif.create_action("actions-import-basico"))
actions_menu.append_item(self.uif.create_item('Import JSON file', 'app.actions-import-json', 'document-open'))
app.add_action(self.uif.create_action("actions-import-json"))
actions_menu.append_item(self.uif.create_item('Import SAP Notes from SAP Launchpad', 'app.actions-import-launchpad', 'download'))
app.add_action(self.uif.create_action("actions-import-launchpad"))
btnactions = Gtk.MenuButton()
btnactions.set_always_show_image(True)
btnactions.set_property("use-popover", True)
btnactions.set_menu_model(actions_menu)
row.pack_start(btnactions, False, False, 6)
 
container.pack_start(row, False, False, 0)
container.pack_start(infobox, False, False, 0)
 
#~ container.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("Red"))
 
return container
 
 
def get_toggled(self):
flowbox = self.gui.get_widget('flowbox')
mnubtnactions = self.gui.get_widget('mnuBtnActions')
200,12 → 92,7
return self.bag
 
 
def filter_by_bookmark(self, item):
row = item.get_children()[0]
return row.is_bookmark()
 
 
def populate(self, bag):
def populate(self, bag, cid=None):
self.bag = bag
mnubtnactions = self.gui.get_widget('mnuBtnActions')
mnubtnactions.set_no_show_all(False)
218,7 → 105,6
flowbox.set_selection_mode(Gtk.SelectionMode.NONE)
#~ flowbox.set_filter_func(self.filter_by_bookmark)
self.gui.add_widget('flowbox', flowbox)
 
self.hide()
icon_bookmark = self.im.get_icon('bookmark')
 
228,14 → 114,19
for sid in bag:
lbag.append(sid)
lbag.sort()
t1 = datetime.now()
 
for sid in lbag:
row = SAPNoteViewRow(self.app, sid)
flowbox.add(row)
 
t2 = datetime.now()
self.log.debug("td: %s" % str(t2 - t1))
self.gui.swap_widget(self, flowbox)
 
self.show_all()
 
#~ With freeze
#~ DEBUG | 86 | 2018-03-25 00:56:03,257 | Basico | componentkey (BC)
#~ DEBUG | 124 | 2018-03-25 00:56:03,661 | td: 0:00:00.400956
 
 
/branches/BR-0.3/basico/service.py
48,6 → 48,7
"""
self.started = True
self.app = app
self.log = self.app.log
self.section = logname
self.init_section(self.section)
 
107,7 → 108,7
self.debug("Section '%s' initialized in config file" % section)
 
def debug(self, message):
self.app.log.debug("%15s | %s" % (self.__class__.__name__, message))
self.log.debug("%15s | %s" % (self.__class__.__name__, message))
 
def get_traceback(self):
return self.app.get_traceback()
/branches/BR-0.3/basico/uiapp.py
95,7 → 95,7
aboutdialog.set_icon(icon_dlg)
aboutdialog.set_comments(longname)
aboutdialog.set_version(version)
aboutdialog.set_copyright("Copyright \xa9 2016 Tomás Vírseda García")
aboutdialog.set_copyright("Copyright \xa9 2016-2018 Tomás Vírseda García")
aboutdialog.set_license_type(applicense)
aboutdialog.set_authors(authors)
aboutdialog.set_website("http://t00mlabs.net")