#!/usr/bin/env python # Copyright (C) 2005 Christian Persch # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # $Id$ def disconnect(tab): try: [ handler_id ] = tab._window_icon_details; del tab._window_icon_details; tab.disconnect(handler_id) except Exception: pass def tab_icon_cb(tab, pspec, window): window.set_icon(tab.get_icon()) def active_tab_cb(window, pspec, data): try: old_tab = window._window_icon_active_tab disconnect(old_tab) except Exception: pass try: tab = window.get_active_tab() window._window_icon_active_tab = tab tab_icon_cb(tab, None, window) handler_id = tab.connect("notify::icon", tab_icon_cb, window) tab._window_icon_details = [ handler_id ] except Exception: pass def detach_tab(window,tab): disconnect(tab) def attach_window(window): active_tab_cb(window, None, None) handler_id = window.connect("notify::active-tab", active_tab_cb, None) window._window_icon_details = [ handler_id ] def detach_window(window): [ handler_id ] = window._window_icon_details del window._window_icon_details window.disconnect(handler_id) window.set_icon(None) try: del window._window_icon_active_tab except Exception: pass