#!/usr/bin/env python
#
# Expand Tabs
# Copyright (C) 2008 Christopher Williams
#
# Based on:
# Only One Close Button - Epiphany Extension
# Copyright (C) 2006 Stefan Stuhr
#
# Tab Close Button
# 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 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.
def on_switch_page(notebook, page, page_num):
if notebook._oocb_current > -1:
old_child = notebook.get_nth_page(notebook._oocb_current)
if old_child:
old_tab = notebook.get_tab_label(old_child)
old_tab.get_children()[-1].hide()
child = notebook.get_nth_page(page_num)
tab = notebook.get_tab_label(child)
tab.get_children()[-1].show()
notebook._oocb_current = page_num
def attach_window(window):
notebook = window.get_notebook()
notebook.connect("switch-page", on_switch_page)
notebook._expandtabs_current = 0
def detach_window(window):
notebook = window.get_notebook()
notebook.disconnect_by_func(on_switch_page)
del notebook._oocb_current
def attach_tab(window, child):
notebook = window.get_notebook()
tab = notebook.get_tab_label(child)
if len(notebook.get_children()) == 2:
first_tab = notebook.get_tab_label(notebook.get_children()[0])
first_tab.set_size_request(48, -1)
tab.get_children()[-1].hide()
tab.set_size_request(48, -1)
notebook.child_set(child, "tab-expand", True)