Added Import annotations option.
This commit is contained in:
parent
93a2f404d2
commit
a2195bcb4b
|
@ -232,11 +232,15 @@ class DimListController:
|
|||
print "No annotations etc"
|
||||
self._idlist_menu_ann.set_sensitive(False)
|
||||
else:
|
||||
annotations_menu = SimpleMenu()
|
||||
annotations_menu = gtk.Menu()
|
||||
self._idlist_menu_ann.set_sensitive(True)
|
||||
ann_names = annotations.get_dim_handler(self._current_dim).get_annotation_names()
|
||||
for ann in ann_names:
|
||||
annotations_menu.add_simple_item(ann, None)
|
||||
item = gtk.MenuItem(ann)
|
||||
item.connect('activate', self._on_annotation_activated, ann)
|
||||
annotations_menu.append(item)
|
||||
item.show()
|
||||
|
||||
self._idlist_menu_ann.set_submenu(annotations_menu)
|
||||
|
||||
def _idlist_button_pressed(self, widget, event):
|
||||
|
@ -248,9 +252,27 @@ class DimListController:
|
|||
self._update_annotations_menu()
|
||||
self._idlist_menu.popup(None, None, None, 0, 0)
|
||||
|
||||
def _on_annotation_activated(self, menuitem, annotation):
|
||||
print "Congratulations. You chouse %s" % annotation
|
||||
|
||||
def _on_idlist_export(self, menuitem):
|
||||
print "export stuff"
|
||||
|
||||
def _on_idlist_import(self, menuitem):
|
||||
dialog = gtk.FileChooserDialog('Load annotations')
|
||||
dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
|
||||
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK)
|
||||
dialog.set_select_multiple(True)
|
||||
retval = dialog.run()
|
||||
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
|
||||
pass
|
||||
elif retval == gtk.RESPONSE_OK:
|
||||
for filename in dialog.get_filenames():
|
||||
annotations.read_annotations_file(filename)
|
||||
else:
|
||||
print "unknown; ", retval
|
||||
dialog.destroy()
|
||||
|
||||
pass
|
||||
|
||||
|
|
Reference in New Issue