Commit ac7123fd authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Handle Escape key pressed event in some windows to close them

parent b56e0b32
...@@ -311,17 +311,16 @@ class SearchFrontier(SearchManager): ...@@ -311,17 +311,16 @@ class SearchFrontier(SearchManager):
self.sn_viewer.refresh([]) self.sn_viewer.refresh([])
class LegendWindow(object): class LegendWindow(object):
""" """
Widget to display the legend Widget to display the legend
""" """
def __init__(self, parent=None): def __init__(self, parent=None):
self.win = gtk.Window() self.win = gtk.Window()
self.win.set_title("CADBIOM-Chart Legend") self.win.set_title("CADBIOM-Chart Legend")
self.win.set_position(gtk.WIN_POS_CENTER) self.win.set_position(gtk.WIN_POS_CENTER)
self.win.connect("destroy", self.on_destroy) self.win.connect("destroy", self.on_destroy)
self.win.connect('key_press_event', self.on_escape)
image = gtk.Image() image = gtk.Image()
template = pkg_resources.resource_filename( template = pkg_resources.resource_filename(
__name__, __name__,
...@@ -352,6 +351,13 @@ class LegendWindow(object): ...@@ -352,6 +351,13 @@ class LegendWindow(object):
if self.win: if self.win:
self.win.destroy() self.win.destroy()
def on_escape(self, widget, event):
"""On ESC key_press_event, destroy this window."""
if gtk.gdk.keyval_name(event.keyval) == "Escape":
self.destroy()
return False
class ImportPIDParam(object): class ImportPIDParam(object):
""" """
Widget for model importing Widget for model importing
...@@ -373,8 +379,13 @@ class ImportPIDParam(object): ...@@ -373,8 +379,13 @@ class ImportPIDParam(object):
hei = int(hei * 0.20) hei = int(hei * 0.20)
self.main_window.set_size_request(350, hei) self.main_window.set_size_request(350, hei)
if (self.main_window): # Set modal mode for the window (above all windows & block inputs)
self.main_window.set_modal(True)
self.main_window.set_transient_for(parent)
if self.main_window:
self.main_window.connect("destroy", self.on_destroy) self.main_window.connect("destroy", self.on_destroy)
self.main_window.connect('key_press_event', self.on_escape)
self.main_window.set_position(gtk.WIN_POS_CENTER) self.main_window.set_position(gtk.WIN_POS_CENTER)
...@@ -473,6 +484,12 @@ class ImportPIDParam(object): ...@@ -473,6 +484,12 @@ class ImportPIDParam(object):
""" """
self.on_destroy(None) self.on_destroy(None)
def on_escape(self, widget, event):
"""On ESC key_press_event, destroy this window."""
if gtk.gdk.keyval_name(event.keyval) == "Escape":
self.destroy()
return False
class ImportBioPAXParams(object): class ImportBioPAXParams(object):
""" """
...@@ -520,8 +537,9 @@ class ImportBioPAXParams(object): ...@@ -520,8 +537,9 @@ class ImportBioPAXParams(object):
self.main_window.set_modal(True) self.main_window.set_modal(True)
self.main_window.set_transient_for(parent) self.main_window.set_transient_for(parent)
if (self.main_window): if self.main_window:
self.main_window.connect("destroy", self.on_destroy) self.main_window.connect("destroy", self.on_destroy)
self.main_window.connect('key_press_event', self.on_escape)
# Init interface # Init interface
# Triplestore # Triplestore
...@@ -673,3 +691,9 @@ class ImportBioPAXParams(object): ...@@ -673,3 +691,9 @@ class ImportBioPAXParams(object):
for parents for parents
""" """
self.on_destroy(None) self.on_destroy(None)
def on_escape(self, widget, event):
"""On ESC key_press_event, destroy this window."""
if gtk.gdk.keyval_name(event.keyval) == "Escape":
self.destroy()
return False
...@@ -639,12 +639,14 @@ class Charter(object): ...@@ -639,12 +639,14 @@ class Charter(object):
""" """
open a window to search xml file coming from PID database open a window to search xml file coming from PID database
""" """
ImportPIDParam(self) # Pass the parent window to set modal mode on the child
ImportPIDParam(self, self.main_window)
def choose_BioPAX_file(self, widget): def choose_BioPAX_file(self, widget):
""" """
open a window to import BioPAX data from a triplestore open a window to import BioPAX data from a triplestore
""" """
# Pass the parent window to set modal mode on the child
ImportBioPAXParams(self, self.main_window) ImportBioPAXParams(self, self.main_window)
def export_to_lang(self, widget): def export_to_lang(self, widget):
...@@ -681,7 +683,7 @@ class Charter(object): ...@@ -681,7 +683,7 @@ class Charter(object):
""" """
Doc Doc
""" """
self.legend = LegendWindow(self.current_edit_mvc) self.legend = LegendWindow(self)
def export_picture(self, widget): def export_picture(self, widget):
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment