##
## new-empty-tab.py
## Login : <ctaf@CTAF-FIX.CTAFLAND>
## Started on  Thu Jun 28 19:20:24 2007 GESTES Cedric
## $Id$
##
## Copyright (C) 2007 GESTES Cedric
## 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##

import epiphany

import gtk


#dir(window) to enumerate all method of window

def _add_blank_tab_cb(action, window):
    shell = epiphany.ephy_shell_get_default()
    tab = shell.new_tab(window, window.get_active_child(), "", 2048)
    window.set_active_child(tab)
    window.activate_location()


_ui_str = """
<ui>
<popup name="FileMenu">
	<separator />
	<menuitem name="FileNewTabMenu" action="FileNewTab"/>
</popup>
</ui>
"""

_actions = [('FileNewTab', 'tab-new', '_New Blank Tab',
	     '<control>T', None, _add_blank_tab_cb)]



def attach_window(window):
	ui_manager = window.get_ui_manager()
	group = gtk.ActionGroup('FileNewTab')
	group.add_actions(_actions, window)
	ui_manager.insert_action_group(group, 0)
	ui_id = ui_manager.add_ui_from_string(_ui_str)
	window._blank_new_tab = (group, ui_id)


def detach_window(window):
	group, ui_id = window._blank_new_tab
	del window._blank_new_tab
	ui_manager = window.get_ui_manager()
	ui_manager.remove_ui(ui_id)
	ui_manager.remove_action_group(group)
	ui_manager.ensure_update()





