From 598eededd21659c77257cea19bd653ef9f6b7954 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 9 Aug 2009 23:25:53 +0100 Subject: [PATCH] Implement equivalent functionality as previous iterations wrt handling the availability of the hide_window keybinding --- terminatorlib/window.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 2ed65f89..d50bafdf 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -26,6 +26,7 @@ class Window(Container, gtk.Window): title = None isfullscreen = None hidebound = None + hidefunc = None def __init__(self, configobject): """Class initialiser""" @@ -45,13 +46,16 @@ class Window(Container, gtk.Window): self.connect('destroy', self.on_destroy_event) self.connect('window-state-event', self.on_window_state_changed) - self.hidebound = False - try: - self.couldbind = bindkey.tomboy_keybinder_bind( - self.config['keybindings']['hide_window'], - self.on_hide_window) - except KeyError: + # Attempt to grab a global hotkey for hiding the window. + # If we fail, we'll never hide the window, iconifying instead. + self.hidebound = bindkey.tomboy_keybinder_bind( + self.config['keybindings']['hide_window'], + self.on_hide_window) + if not self.hidebound: dbg('Unable to bind hide_window key, another instance has it.') + self.hidefunc = self.iconify + else: + self.hidefunc = self.hide def apply_config(self): """Apply various configuration options"""