Save identifier list.

This commit is contained in:
Einar Ryeng 2008-02-07 18:15:39 +00:00
parent a380093afc
commit 6b78629946

View File

@ -186,6 +186,30 @@ class IdListController:
print "unknown; ", retval
dialog.destroy()
def export_annotations(self):
"""Pops up a file dialog and ask the user to select a file to save
the currently displayed annotations to.
"""
dialog = gtk.FileChooserDialog('Load annotations')
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK)
retval = dialog.run()
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
pass
elif retval == gtk.RESPONSE_OK:
filename = dialog.get_filename()
fd = open(filename, 'w')
dim = self._dimension
print >> fd, "%s\t%s" % (dim, self._annotation[dim])
for id, value in self._idstore:
print >> fd, "%s\t%s" % (id, value)
fd.close()
else:
print "unknown; ", retval
dialog.destroy()
def set_rank(self, ds):
print "Set rank."
@ -233,7 +257,7 @@ class IdListController:
self._menu.popup(None, None, None, event.button, event.time)
def _on_export_list(self, menuitem):
print "export stuff"
self.export_annotations()
def _on_import_list(self, menuitem):
self.import_annotation_file()
@ -248,15 +272,11 @@ class IdListController:
def _drag_data_received(self, widget, drag_context, x, y,
selection, info, timestamp):
print "drag_data_received"
treestore, path = selection.tree_get_row_drag_data()
i = treestore.get_iter(path)
obj = treestore.get_value(i, 2)
if isinstance(obj, dataset.Dataset):
print "is dataset"
if self._dimension in obj.get_dim_name():
print "has correct dimensions"
self.set_rank(obj)
widget.emit_stop_by_name('drag-data-received')