Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 360 → Rev 361

/branches/BR-0.4/basico/core/mod_win.py
47,7 → 47,7
self.srvgui.add_widget('uiapp', uiapp)
self.app = self.srvgui.get_app()
self.setup_window(uiapp)
self.setup_widgets()
self.setup_widgets()
self.run()
 
 
/branches/BR-0.4/basico/services/srv_attachment.py
80,13 → 80,16
 
 
def get_by_sid(self, sid):
ATTACHMENT_FILES = LPATH['ATTACHMENTS'] + '%s*.json' % sid
attachments = glob.glob(ATTACHMENT_FILES)
attachments.sort(reverse=True)
matches = set()
ATTACHMENT_FILES = LPATH['ATTACHMENTS'] + '*.json'
attachments = glob.glob(ATTACHMENT_FILES)
for attachment in attachments:
if sid in attachment:
matches.add(attachment)
# ~ self.log.debug("Attachments for SAP Note %s: %s", sid, matches)
return matches
 
return attachments
 
 
def get_all(self):
return glob.glob(LPATH['ATTACHMENTS'] + '*.json')
 
/branches/BR-0.4/basico/services/srv_callbacks.py
358,6 → 358,7
elif action == 'edit':
aid = sid
 
self.log.debug("AID: %s", aid)
widget_annotation.set_metadata_to_widget(aid, action)
 
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', True)
863,7 → 864,7
vpaned.set_position(0)
else:
# ~ stack_main.show_all()
vpaned.set_position(600)
vpaned.set_position(450)
 
 
def gui_attachment_add_to_sapnote(self, button, sid):
/branches/BR-0.4/basico/services/srv_gui.py
97,6 → 97,7
GObject.threads_init()
self.uiapp = UIApp(self.app)
self.log.debug("Setting up GUI")
window = self.get_window()
self.uiapp.run()
 
 
/branches/BR-0.4/basico/widgets/wdg_annot.py
414,7 → 414,7
return a_aid.get_text()
 
 
def set_metadata_to_widget(self, aid, action):
def set_metadata_to_widget(self, aid, action='edit'):
"""
C:237, 4: Missing method docstring (missing-docstring)
"""
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
381,6 → 381,9
self.sorted_model.set_sort_column_id(9, Gtk.SortType.ASCENDING)
self.treeview.set_model(self.sorted_model)
 
# Other signals
self.treeview.connect('row-activated', self.double_click)
 
self.show_all()
 
 
434,19 → 437,22
aid = model[treeiter][10]
is_valid = self.srvant.is_valid(aid)
if is_valid:
self.srvclb.action_annotation_edit(aid)
widget_annotation = self.srvgui.get_widget('widget_annotation')
widget_annotation.set_metadata_to_widget(aid)
# ~ 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:
head = "Error reading annotation's contents"
body = "<i>%s</i>\n\n" % error
body += "As a workaround, a new file will be created"
dialog = self.srvuif.message_dialog_error(head, body)
self.log.debug(error)
self.log.debug(self.get_traceback())
dialog.run()
dialog.destroy()
pass
# ~ head = "Error reading annotation's contents"
# ~ body = "<i>%s</i>\n\n" % error
# ~ body += "As a workaround, a new file will be created"
# ~ dialog = self.srvuif.message_dialog_error(head, body)
# ~ self.log.debug(error)
# ~ self.log.debug(self.get_traceback())
# ~ dialog.run()
# ~ dialog.destroy()
#FIXME: create an empty file for contents
 
 
583,6 → 589,33
self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
 
 
def double_click(self, treeview, row, col):
try:
selection = treeview.get_selection()
model, treeiter = selection.get_selected()
if treeiter is not None:
component = model[treeiter][5]
if component == 'Annotation':
aid = model[treeiter][10]
is_valid = self.srvant.is_valid(aid)
if is_valid:
fullscreen_annotation = self.srvgui.get_widget('gtk_togglebutton_maximize_annotation_widget')
fullscreen_annotation.set_active(True)
self.srvclb.action_annotation_edit(aid)
else:
aid = None
self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
except Exception as error:
head = "Error reading annotation's contents"
body = "<i>%s</i>\n\n" % error
body += "As a workaround, a new file will be created"
dialog = self.srvuif.message_dialog_error(head, body)
self.log.debug(error)
self.log.debug(self.get_traceback())
dialog.run()
dialog.destroy()
# ~ #FIXME: create an empty file for contents
 
def right_click(self, treeview, event, data=None):
if event.button == 3:
rect = Gdk.Rectangle()
601,8 → 634,13
popover.set_pointing_to(rect)
box = self.build_popover(aid, popover, component)
if box is not None:
vpaned = self.srvgui.get_widget('gtk_vpaned_visor')
visor_annotations = self.srvgui.get_widget('visor_annotations')
width, height = visor_annotations.get_size_request()
vpaned.set_position(1000)
popover.add(box)
self.srvclb.gui_show_popover(None, popover)
 
 
def build_popover(self, aid, popover, component):
/branches/BR-0.4/basico/widgets/wdg_visor_sapnotes.py
53,6 → 53,7
self.srvuif = self.get_service("UIF")
self.srvutl = self.get_service("Utils")
self.srvant = self.get_service('Annotation')
self.srvatc = self.get_service('Attachment')
 
 
def get_treeview(self):
465,6 → 466,28
annotation['Timestamp']
)
self.model.append(pid, node)
 
# Load attachments
files = self.srvatc.get_by_sid(metadata['id'])
for fname in files:
with open(fname, 'r') as ft:
attachment = json.load(ft)
icon = self.srvicm.get_pixbuf_icon('basico-attachment')
node = self.get_node( 0,
icon,
False,
'',
attachment['Title'],
'Attachment',
'',
attachment['Description'],
'',
self.srvutl.fuzzy_date_from_timestamp(attachment['Created']),
attachment['TID'],
attachment['Created']
)
self.model.append(pid, node)
self.treeview.set_model(self.sorted_model)
self.update_total_sapnotes_count()
self.show_widgets()
488,6 → 511,8
treeiter = model.get_iter(path)
component = model[treeiter][5]
sid = model[treeiter][0]
if sid == 0:
return
sid = "0"*(10 - len(str(sid))) + str(sid)
toolbar = self.srvgui.get_widget('visortoolbar')
popover = self.srvgui.add_widget('gtk_popover_visor_row', Gtk.Popover.new(treeview))