Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

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):
self.sn_viewer.refresh([])
class LegendWindow(object):
"""
Widget to display the legend
"""
def __init__(self, parent=None):
self.win = gtk.Window()
self.win.set_title("CADBIOM-Chart Legend")
self.win.set_position(gtk.WIN_POS_CENTER)
self.win.connect("destroy", self.on_destroy)
self.win.connect('key_press_event', self.on_escape)
image = gtk.Image()
template = pkg_resources.resource_filename(
__name__,
......@@ -352,6 +351,13 @@ class LegendWindow(object):
if self.win:
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):
"""
Widget for model importing
......@@ -373,8 +379,13 @@ class ImportPIDParam(object):
hei = int(hei * 0.20)
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('key_press_event', self.on_escape)
self.main_window.set_position(gtk.WIN_POS_CENTER)
......@@ -473,6 +484,12 @@ class ImportPIDParam(object):
"""
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):
"""
......@@ -520,8 +537,9 @@ class ImportBioPAXParams(object):
self.main_window.set_modal(True)
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('key_press_event', self.on_escape)
# Init interface
# Triplestore
......@@ -673,3 +691,9 @@ class ImportBioPAXParams(object):
for parents
"""
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):
"""
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):
"""
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)
def export_to_lang(self, widget):
......@@ -681,7 +683,7 @@ class Charter(object):
"""
Doc
"""
self.legend = LegendWindow(self.current_edit_mvc)
self.legend = LegendWindow(self)
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