Commit a0cd232f authored by VIGNET Pierre's avatar VIGNET Pierre

Add transient param for all windows, and escape key press event

parent 7e103a0b
......@@ -61,7 +61,7 @@ class ChartChecker(object):
This class provide a gui interface for checking some queries
"""
def __init__(self, emvc, reporter):
def __init__(self, emvc, reporter, parent=None):
self.__emvc = emvc # edit mvc - link with charter
self.__reporter = reporter
self.__occ_form = OccurenceForm(emvc, reporter)
......@@ -76,6 +76,13 @@ class ChartChecker(object):
self.__main_window.set_position(gtk.WIN_POS_CENTER)
self.__main_window.resize(600, 300)
if parent:
# Set window above all windows
self.__main_window.set_transient_for(parent.main_window)
# Event on_escape key pressed
self.__main_window.connect('key_press_event', self.on_escape)
# register as auxiliary window
self.__emvc.win_register(self)
......@@ -97,6 +104,10 @@ class ChartChecker(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.__main_window.destroy()
class OccurenceForm(object):
......
......@@ -365,6 +365,7 @@ class SCCWindow(object):
self.choice = 0
self.textview_list = []
self.l_solutions = l_fsol
self.aux_win = [] # for clean_subwin works properly
# window creation
template = pkg_resources.resource_filename(
......@@ -381,6 +382,11 @@ class SCCWindow(object):
height = int(height * 0.30)
self.window.set_size_request(700, height)
# Set window above all windows
self.window.set_transient_for(parent.main_window)
# Event on_escape key pressed
self.window.connect('key_press_event', self.on_escape)
# button save choice
button = self.wtree.get_widget("but_sv_choice")
......@@ -400,7 +406,6 @@ class SCCWindow(object):
vbox = self.wtree.get_widget("vbox1")
vbox.remove(hbbox)
# register
parent.win_register(self.window)
self.parent = parent
......@@ -412,6 +417,8 @@ class SCCWindow(object):
def on_destroy(self, widget):
"""
when leaving the window
useless ? no sub window is created from this mother class and from
subclasses...
"""
self.clean_subwin()
self.parent.win_remove(self)
......@@ -424,6 +431,11 @@ class SCCWindow(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.window.destroy()
def display_info(self):
"""
......
......@@ -582,7 +582,7 @@ class Charter(object):
"""
def on_enter(widget, event):
"""On ESC key_press_event, destroy this window."""
"""On ESC/Return key_press_event, destroy/valid this window."""
keyval_name = gtk.gdk.keyval_name(event.keyval)
if keyval_name == 'Return':
self.ok_new_text(None, die)
......@@ -598,7 +598,6 @@ class Charter(object):
die.cancel.connect("clicked", self.cancel, die)
die.run()
def save_choice(self):
"""
choice of file for save
......@@ -847,6 +846,8 @@ class Charter(object):
"""Register a sub window
This window will be destroyed when you connect its main widget
event "destroy" to subwin_on_destroy()
used by: STATWindow, SCCWindow, BAGWindow, LegendWindow
"""
self.subwindows.add(window)
......@@ -854,6 +855,8 @@ class Charter(object):
"""Destroy a sub window
This window will be destroyed when you connect its main widget
event "destroy" to subwin_on_destroy()
used by: STATWindow, SCCWindow, BAGWindow, LegendWindow
"""
self.subwindows.remove(window)
window.destroy()
......
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