Added some annotation support in selections.py, including the beginning of a
menu option to add an arbitrary annotation alongside identifiers.
This commit is contained in:
parent
953662e1fb
commit
6809c1a454
|
@ -1,5 +1,6 @@
|
|||
|
||||
import logger, dataset
|
||||
import annotations
|
||||
|
||||
import pygtk
|
||||
import gtk
|
||||
|
@ -79,6 +80,17 @@ class DimListController:
|
|||
renderer = gtk.CellRendererText()
|
||||
dim_column = gtk.TreeViewColumn('Identifiers', renderer, text=0)
|
||||
idlist.insert_column(dim_column, 0)
|
||||
idlist.connect('button-press-event', self._idlist_button_pressed)
|
||||
|
||||
## Set up identifier list context menu
|
||||
self._idlist_menu = SimpleMenu()
|
||||
self._idlist_menu.add_simple_item('Import...', self._on_idlist_import)
|
||||
self._idlist_menu.add_simple_item('Export...', self._on_idlist_export)
|
||||
|
||||
i = gtk.MenuItem('Show annotations')
|
||||
self._idlist_menu.append(i)
|
||||
i.show()
|
||||
self._idlist_menu_ann = i
|
||||
|
||||
|
||||
def get_dataset_iter(self, dataset):
|
||||
|
@ -213,3 +225,32 @@ class DimListController:
|
|||
self.add_dataset(obj)
|
||||
self.set_dimension(obj.get_dim_name(0))
|
||||
widget.emit_stop_by_name('drag-data-received')
|
||||
|
||||
def _update_annotations_menu(self):
|
||||
dim_h = annotations.get_dim_handler(self._current_dim)
|
||||
if not dim_h:
|
||||
print "No annotations etc"
|
||||
self._idlist_menu_ann.set_sensitive(False)
|
||||
else:
|
||||
annotations_menu = SimpleMenu()
|
||||
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)
|
||||
self._idlist_menu_ann.set_submenu(annotations_menu)
|
||||
|
||||
def _idlist_button_pressed(self, widget, event):
|
||||
if event.button == 3:
|
||||
self._update_annotations_menu()
|
||||
self._idlist_menu.popup(None, None, None, event.button, event.time)
|
||||
|
||||
def _popup_idlist_menu(self, *rest):
|
||||
self._update_annotations_menu()
|
||||
self._idlist_menu.popup(None, None, None, 0, 0)
|
||||
|
||||
def _on_idlist_export(self, menuitem):
|
||||
print "export stuff"
|
||||
|
||||
def _on_idlist_import(self, menuitem):
|
||||
pass
|
||||
|
||||
|
|
Reference in New Issue