Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 368 → Rev 369

/branches/BR-0.4/basico/core/mod_win.py
65,6 → 65,10
self.controller = uiapp.get_controller()
 
 
def get_signal(self, signal):
return self.signals[key]
 
def setup_window(self, uiapp):
Gtk.Window.__init__(self, title=APP['name'], application=uiapp)
icon = self.srvicm.get_icon('basico-component', 48, 48)
372,7 → 376,8
 
### Visor
notebook = self.srvgui.add_widget('gtk_notebook_visor', Gtk.Notebook())
notebook.connect('switch-page', self.srvclb.gui_visor_switch_page)
signal = notebook.connect('switch-page', self.srvclb.gui_visor_switch_page)
self.srvgui.add_signal('gtk_notebook_visor', 'switch-page', signal)
notebook.set_show_border(False)
notebook.set_hexpand(True)
 
/branches/BR-0.4/basico/services/srv_callbacks.py
16,6 → 16,7
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
 
from basico.core.mod_srv import Service
from basico.core.mod_env import FILE, LPATH, ATYPES, APP
55,6 → 56,7
self.srvgui.set_key_value('current_visor_tab', page_num)
notebook_viewmenu = self.srvgui.get_widget('gtk_notebook_menuview')
paned = self.srvgui.get_widget('gtk_hpaned')
self.log.debug("Visor page switched to: %d", page_num)
 
if page_num == 0:
self.srvuif.set_widget_visibility('gtk_button_menu_views', True)
358,7 → 360,8
def gui_annotation_widget_show(self, widget, sid='0000000000', action='create'):
widget_annotation = self.srvgui.get_widget('widget_annotation')
widget = self.srvgui.get_widget('gtk_label_timestamp_created')
 
vpaned = self.srvgui.get_widget('gtk_vpaned_visor')
vpaned.set_position(0)
if action == 'create':
self.gui_annotation_widget_clear()
aid = self.srvant.gen_aid(sid)
365,9 → 368,10
elif action == 'edit':
aid = sid
 
self.log.debug("AID: %s", aid)
self.log.debug("%s %s", action, aid)
widget_annotation.set_metadata_to_widget(aid, action)
 
stack_annotation = self.srvgui.get_widget('stack_annotation')
stack_annotation.set_visible_child_name('editor')
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', True)
widget.grab_focus()
 
612,10 → 616,9
visor_annotations = self.srvgui.get_widget('visor_annotations')
widget_annotation = self.srvgui.get_widget('widget_annotation')
aid = widget_annotation.get_aid_from_widget()
 
title = self.srvant.get_title(aid)
answer = self.srvuif.warning_message_delete_annotations(None, 'Deleting annotations', 'Are you sure?', [aid])
if answer is True:
title = self.srvant.get_title(aid)
self.srvant.delete(aid)
self.gui_annotation_widget_clear()
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
840,6 → 843,24
self.srvuif.statusbar_msg(msg)
 
 
def gui_jump_to_annotation(self, widget, aid):
paned = self.srvgui.get_widget('gtk_hpaned')
notebook = self.srvgui.get_widget('gtk_notebook_visor')
notebook_viewmenu = self.srvgui.get_widget('gtk_notebook_menuview')
notebook_viewmenu.set_current_page(1)
signal = self.srvgui.get_signal('gtk_notebook_visor', 'switch-page')
GObject.signal_handler_block(notebook, signal)
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_annotations.populate([aid])
self.gui_show_visor_annotations()
self.srvuif.grab_focus()
msg = "Jumping to annotation %s" % aid
self.log.info(msg)
self.srvuif.statusbar_msg(msg)
GObject.signal_handler_unblock(notebook, signal)
paned.set_position(400)
 
def gui_link_to_sapnote(self, *args):
pass
 
/branches/BR-0.4/basico/services/srv_gui.py
82,6 → 82,7
srvsap = None
widgets = {} # Widget name : Object
keys = {} # Key : Value; keys: doctype, property, values
signals = {} # Signals dictionary for all widgets (widget::signal)
 
def initialize(self):
"""
137,6 → 138,15
return self.keys
 
 
def get_keys_starting_with(self, name):
matches = []
for key in self.keys:
if key.startswith(name):
matches.append(key)
 
return matches
 
 
def get_key_value(self, key):
"""
Return current value from var cache
151,6 → 161,25
self.keys[key] = value
 
 
def add_signal(self, widget, signal, value):
"""
Add signal to signals cache
"""
signal_name = "%s::%s" % (widget, signal)
self.signals[signal_name] = value
 
 
def get_signal(self, widget, signal):
"""
Return signal from cache
"""
signal_name = "%s::%s" % (widget, signal)
try:
return self.signals[signal_name]
except KeyError:
return None
 
def add_widget(self, name, obj=None):
"""
Add widget to cache
/branches/BR-0.4/basico/widgets/wdg_annot.py
589,6 → 589,11
aid = self.get_aid_from_widget()
browser = self.srvgui.get_widget('annotation_browser')
# ~ self.log.debug("Execute asciidoc for current annotation: %s", self.sid)
target = self.srvacd.generate_preview(aid)
browser.load_url(html.escape(target))
try:
target = self.srvacd.generate_preview(aid)
browser.load_url(html.escape(target))
except:
self.log.debug("Showing editor instead preview")
stack_annotation = self.srvgui.get_widget('stack_annotation')
stack_annotation.set_visible_child_name('editor')
# ~ self.log.debug("Load preview from %s", target)
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
72,6 → 72,7
for priority in ['High', 'Normal', 'Low']:
self.srvgui.set_key_value('ANNOTATIONS_PRIORITY_%s_VISIBLE' % priority.upper(), True)
 
 
def get_treeview(self):
return self.treeview
 
117,6 → 118,7
def set_visible_category(self, togglebutton, title):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_CATEGORY_%s_VISIBLE' % title.upper(), active)
self.set_bag()
self.populate()
 
 
123,6 → 125,7
def set_visible_annotation_type(self, togglebutton, atype):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_TYPE_%s_VISIBLE' % atype.upper(), active)
self.set_bag()
self.populate()
 
 
129,6 → 132,7
def set_visible_priority(self, togglebutton, title):
active = togglebutton.get_active()
self.srvgui.set_key_value('ANNOTATIONS_PRIORITY_%s_VISIBLE' % title.upper(), active)
self.set_bag()
self.populate()
 
 
515,7 → 519,7
return node
 
 
def set_bag(self, annotations):
def set_bag(self, annotations=None):
self.bag = annotations
 
 
541,8 → 545,14
self.model.clear()
 
if annotations is None:
annotations = self.srvant.get_all()
annotations = self.get_bag()
if annotations is None:
annotations = self.srvant.get_all()
self.log.debug("Displaying all annotations")
else:
self.log.debug("Displaying last query")
else:
self.log.debug("Displaying following annotations: %s", annotations)
self.set_bag(annotations)
 
dcats = {}
553,6 → 563,7
with open(fname, 'r') as fa:
try:
annotation = json.load(fa)
# ~ self.log.debug("Annotation: %s", annotation['Title'])
category = annotation['Category']
atype = annotation['Type']
cat_key = 'ANNOTATIONS_CATEGORY_%s_VISIBLE' % category.upper()
616,8 → 627,9
self.update_total_annotations_count()
self.log.debug("Visor updated")
 
 
def show_widgets(self):
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
 
 
def row_double_click(self, treeview, row, col):
634,8 → 646,8
fullscreen_annotation.set_active(True)
self.srvclb.action_annotation_edit(aid)
else:
aid = None
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
# ~ aid = None
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', True)
except Exception as error:
head = "Error reading annotation's contents"
body = "<i>%s</i>\n\n" % error
/branches/BR-0.4/basico/widgets/wdg_visor_attachments.py
64,6 → 64,7
self.srvuif = self.get_service("UIF")
self.srvutl = self.get_service("Utils")
self.srvatc = self.get_service('Attachment')
self.srvant = self.get_service('Annotation')
 
def get_treeview(self):
416,7 → 417,7
sid = str(int(sid))
if sid == '0':
sid = ''
node = self.get_node( metadata['TID'],
node = self.get_node( metadata['TID'],
self.srvicm.find_mime_type_pixbuf(metadata['Mimetype'], 36, 36),
metadata['Doctype'],
metadata['Description'],
473,6 → 474,7
 
def build_popover(self, tid, popover):
sid = self.srvatc.get_sid(tid)
aid = self.srvatc.get_metadata_value(tid, 'AID')
self.log.debug("%s -> %s", tid, sid)
 
def get_popover_button(text, icon_name):
508,6 → 510,14
button.show_all()
button.connect('clicked', self.srvclb.gui_jump_to_sapnote, sid)
box.pack_start(button, False, False, 0)
 
if self.srvant.is_valid(aid):
# Jump to Annotation
aid_file = LPATH['ANNOTATIONS'] + aid + '.json'
button = get_popover_button("Jump to <b>Annotation</b>", 'basico-jump-sapnote')
button.show_all()
button.connect('clicked', self.srvclb.gui_jump_to_annotation, aid_file)
box.pack_start(button, False, False, 0)
# Separator
separator = Gtk.Separator(orientation = Gtk.Orientation.HORIZONTAL)