Enforce nomodal to try to put focus back

The widget with the focus could disappear when setting back the focus so it
tries to put the focus to one of its parents.
This commit is contained in:
Cédric Krier committed 2012-04-15 17:02:09 +02:00
1 parent 6b6527f172
commit 5a9954fa88
1 file changed
+9 -3
+9 -3
View File
@@ -12,7 +12,11 @@ class NoModal(object):
self.parent = common.get_toplevel_window()
self.sensible_widget = common.get_sensible_widget(self.parent)
self.page = None
self.parent_focus = self.parent.get_focus()
self.parent_focus = []
focus = self.parent.get_focus()
while focus:
self.parent_focus.append(focus)
focus = focus.get_parent()
def register(self):
main = Main.get_main()
@@ -29,5 +33,7 @@ class NoModal(object):
return
self.parent.present()
self.sensible_widget.props.sensitive = True
if self.parent_focus:
self.parent_focus.grab_focus()
for focus in self.parent_focus:
if focus and focus.is_ancestor(self.parent):
focus.grab_focus()
break