[deskbar-applet/gnome-2-26] Fixed bug that caused that the window to show up again when intending to close it by pressing the ke
- From: Sebastian Polsterl <sebp src gnome org>
- To: svn-commits-list gnome org
- Subject: [deskbar-applet/gnome-2-26] Fixed bug that caused that the window to show up again when intending to close it by pressing the ke
- Date: Sun, 17 May 2009 15:33:30 -0400 (EDT)
commit 245dc5628a1afb809804bbac588ba3a7279fe01d
Author: Sebastian Pölsterl <sebp k-d-w org>
Date: Sun May 17 21:30:42 2009 +0200
Fixed bug that caused that the window to show up again when intending to close it by pressing the keybinding
---
deskbar/ui/CuemiacWindowController.py | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/deskbar/ui/CuemiacWindowController.py b/deskbar/ui/CuemiacWindowController.py
index 8338ecb..7baeea4 100644
--- a/deskbar/ui/CuemiacWindowController.py
+++ b/deskbar/ui/CuemiacWindowController.py
@@ -1,3 +1,4 @@
+import glib
import gtk
import gtk.gdk
import logging
@@ -20,14 +21,15 @@ class CuemiacWindowController(deskbar.interfaces.Controller):
self._model.connect("keybinding-activated", self.on_keybinding_activated)
self._model.connect("initialized", self.on_core_initialized)
self._clipboard = gtk.clipboard_get (selection="PRIMARY")
+ self._focus_out = False
def on_keybinding_activated(self, core, time, paste=True):
"""
Toggle view if keybinding has been activated
"""
- if self._view.get_toplevel().get_property("visible"):
- self.on_quit()
- else:
+ # Check if we saw a focus-out-event recently
+ # focus-out-event takes care of closing the window
+ if not self._focus_out:
if self._model.get_use_selection() and paste:
text = self._clipboard.wait_for_text()
if text != None:
@@ -44,9 +46,25 @@ class CuemiacWindowController(deskbar.interfaces.Controller):
self._model.set_window_x(x)
self._model.set_window_y(y)
+ if len(args) == 2:
+ event = args[1]
+ if hasattr(event, 'type'):
+ if event.type == gtk.gdk.FOCUS_CHANGE:
+ # If the keybinding is pressed to close the window
+ # we receive a focus-out-event first. Now we close
+ # the window and the keybinding handler thinks it
+ # should show the window.
+ # Settings this flag will tell us
+ # that we saw a focus-out-event recently
+ self._focus_out = True
+ glib.timeout_add(250, self._reset_focus_out)
+
window.hide()
return True
+
+ def _reset_focus_out(self):
+ self._focus_out = False
def on_show_about(self, sender):
show_about(self._view.get_toplevel())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]