#!/usr/bin/env python # # Copyright (C) 2005, 2006 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$ import gtk import epiphany def show_tab_close_button (window, tab, show): label = window.get_notebook().get_tab_label(tab) button = label.get_children()[1] if show: button.show() else: button.hide() def active_tab_cb(window, pspec, data): try: old_tab = window._tcb_active_tab show_tab_close_button (window, old_tab, False) except Exception: pass try: tab = window.get_active_tab() window._tcb_active_tab = tab show_tab_close_button (window, tab, True) except Exception: pass def attach_tab (window, tab): show_tab_close_button (window, tab, tab == window.get_active_tab()) def detach_tab(window,tab): show_tab_close_button (window, tab, True) def attach_window(window): active_tab_cb(window, None, None) handler_id = window.connect("notify::active-tab", active_tab_cb, None) window._tcb_details = [ handler_id ] def detach_window(window): [ handler_id ] = window._tcb_details del window._tcb_details window.disconnect(handler_id) try: del window._tcb_active_tab except Exception: pass