1
# PiTiVi , Non-linear video editor
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU Lesser General Public
9
# License as published by the Free Software Foundation; either
10
# version 2.1 of the License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public
18
# License along with this program; if not, write to the
19
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20
# Boston, MA 02110-1301, USA.
23
from pitivi.ui.common import SPACING
26
class BaseTabs(gtk.Notebook):
27
def __init__(self, app, hide_hpaned=False):
29
gtk.Notebook.__init__(self)
30
self.set_border_width(SPACING)
32
self.connect("create-window", self._createWindowCb)
33
self._hide_hpaned = hide_hpaned
38
""" set up the gui """
39
settings = self.get_settings()
40
settings.props.gtk_dnd_drag_threshold = 1
41
self.set_tab_pos(gtk.POS_TOP)
43
def append_page(self, child, label):
44
gtk.Notebook.append_page(self, child, label)
45
self._set_child_properties(child, label)
49
def _set_child_properties(self, child, label):
50
self.child_set_property(child, "detachable", True)
51
self.child_set_property(child, "tab-expand", False)
52
self.child_set_property(child, "tab-fill", True)
53
label.props.xalign = 0.0
55
def _detachedComponentWindowDestroyCb(self, window, child,
56
original_position, label):
57
notebook = window.child
58
position = notebook.child_get_property(child, "position")
59
notebook.remove_page(position)
60
label = gtk.Label(label)
61
self.insert_page(child, label, original_position)
62
self._set_child_properties(child, label)
63
self.child_set_property(child, "detachable", True)
66
self._showSecondHpanedInMainWindow()
68
def _createWindowCb(self, from_notebook, child, x, y):
69
original_position = self.child_get_property(child, "position")
70
label = self.child_get_property(child, "tab-label")
72
window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_UTILITY)
74
window.set_title(label)
75
window.set_default_size(600, 400)
76
window.connect("destroy", self._detachedComponentWindowDestroyCb,
77
child, original_position, label)
78
notebook = gtk.Notebook()
79
notebook.props.show_tabs = False
83
# set_uposition is deprecated but what should I use instead?
84
window.set_uposition(x, y)
87
self._hideSecondHpanedInMainWindow()
91
def _hideSecondHpanedInMainWindow(self):
92
self.app.gui.mainhpaned.remove(self.app.gui.secondhpaned)
93
self.app.gui.secondhpaned.remove(self.app.gui.projecttabs)
94
self.app.gui.secondhpaned.remove(self.app.gui.propertiestabs)
95
self.app.gui.mainhpaned.pack1(self.app.gui.projecttabs, resize=True,
98
def _showSecondHpanedInMainWindow(self):
99
self.app.gui.mainhpaned.remove(self.app.gui.projecttabs)
100
self.app.gui.secondhpaned.pack1(self.app.gui.projecttabs,
101
resize=True, shrink=False)
102
self.app.gui.secondhpaned.pack2(self.app.gui.propertiestabs,
103
resize=True, shrink=False)
104
self.app.gui.mainhpaned.pack1(self.app.gui.secondhpaned,
105
resize=True, shrink=False)