Armed with a text editor

mu's views on program and recipe! design

!/usr/bin/env python Tab Menu Close - Epiphany Extension Copyright (C) 2006 Stefan Stuhr, Michael Urman 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.

import gtk import epiphany

tab_popup_xml = '''<ui> <popup name="EphyNotebookPopup" action="NotebookPopupAction"> <separator/> <menuitem name="TabCloseENP" action="FileCloseTab"/> </popup> </ui> '''

def attach_window(window): ui_manager = window.get_ui_manager() window._tab_menu_close_id = ui_manager.add_ui_from_string(tab_popup_xml)

def detach_window(window): notebook = window.get_notebook() try: ui_id = window._tab_menu_close_id except AttributeError: pass else: ui_manager = window.get_ui_manager() ui_manager.remove_ui(ui_id) ui_manager.ensure_update() del window._tab_menu_close_id