Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 354 → Rev 356

/branches/BR-0.4/basico/services/srv_callbacks.py
47,6 → 47,7
self.srvant = self.get_service('Annotation')
self.srvbnr = self.get_service('BNR')
self.srvclt = self.get_service('Collections')
self.srvatc = self.get_service('Attachment')
 
 
def gui_visor_switch_page(self, notebook, page, page_num):
863,3 → 864,43
else:
# ~ stack_main.show_all()
vpaned.set_position(600)
 
 
def gui_attachment_add(self, *args):
# Get Annotation ID (AID) from widget, if any
widget_annotation = self.srvgui.get_widget('widget_annotation')
aid = widget_annotation.get_aid_from_widget()
 
# Get attachments fro filechooser dialog
attachments = self.gui_attachment_show_filechooser()
 
# Add them to Basico database
if attachments is not None:
for attachment in attachments:
# only allow files (avoid directories)
if os.path.isfile(attachment):
self.srvatc.create(attachment, aid)
else:
self.log.warning("No files selected to attach")
 
def gui_attachment_show_filechooser(self):
filenames = None
parentwin = self.srvgui.get_window()
dialog = Gtk.FileChooserDialog(title="Open file(s) ...",
parent=parentwin,
action=Gtk.FileChooserAction.OPEN,
buttons=("_Cancel",
Gtk.ResponseType.CANCEL,
"_Open", Gtk.ResponseType.ACCEPT))
dialog.set_select_multiple(True)
response = dialog.run()
if response == Gtk.ResponseType.ACCEPT:
filenames = dialog.get_filenames()
i = 0
while i < len(filenames):
filename = filenames[i]
self.log.debug("%s was selected", filename)
i += 1
dialog.destroy()
return filenames