#!/usr/bin/env python # # Simple Tab Close Focus - Epiphany Extension # Copyright (C) 2006 Stefan Stuhr # # 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 of the License, 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., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import gtk import epiphany def tab_parent_set_cb(tab, old_parent, notebook): if not old_parent: return num = notebook.page_num(tab) count = notebook.get_n_pages() if getattr(tab, "_other_extensions_i_didnt_have_focus", False): return if count <= 1: return elif num < count - 1: notebook.set_current_page(num + 1) else: notebook.set_current_page(num - 1) def attach_tab(window, tab): notebook = window.get_notebook() tab._stf_tab_parent_set_sig = tab.connect("parent-set", tab_parent_set_cb, notebook) def detach_tab(window, tab): if hasattr(tab, "_stf_tab_parent_set_sig"): tab.disconnect(tab._stf_tab_parent_set_sig) delattr(tab, "_stf_tab_parent_set_sig")