~ubuntu-branches/ubuntu/lucid/pitivi/lucid

« back to all changes in this revision

Viewing changes to pitivi/ui/projecttabs.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2009-05-27 14:22:49 UTC
  • mfrom: (1.2.1 upstream) (3.1.13 experimental)
  • Revision ID: james.westby@ubuntu.com-20090527142249-tj0qnkc37320ylml
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# PiTiVi , Non-linear video editor
 
2
#
 
3
#       ui/projecttabs.py
 
4
#
 
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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., 59 Temple Place - Suite 330,
 
20
# Boston, MA 02111-1307, USA.
 
21
 
 
22
"""
 
23
Source and effects list widgets
 
24
"""
 
25
 
 
26
import gtk
 
27
from gettext import gettext as _
 
28
from sourcelist import SourceList
 
29
from audiofxlist import AudioFxList
 
30
from videofxlist import VideoFxList
 
31
from propertyeditor import PropertyEditor
 
32
 
 
33
class DetachLabel(gtk.HBox):
 
34
 
 
35
    def __init__(self, parent, child, label, *args, **kwargs):
 
36
        gtk.HBox.__init__(self, *args, **kwargs)
 
37
 
 
38
        self.label = gtk.Label(label)
 
39
        self.child = child
 
40
        self.button = gtk.Button()
 
41
        image = gtk.Image()
 
42
        image.set_from_stock(gtk.STOCK_LEAVE_FULLSCREEN,
 
43
            gtk.ICON_SIZE_SMALL_TOOLBAR)
 
44
        self.button.set_image(image)
 
45
        self.button.connect("clicked", self._windowize)
 
46
        self.pack_start(self.button, False, False)
 
47
        self.pack_start(self.label)
 
48
        self.show_all()
 
49
 
 
50
    def select(self):
 
51
        self.button.set_sensitive(True)
 
52
 
 
53
    def deselect(self):
 
54
        self.button.set_sensitive(False)
 
55
 
 
56
    def _windowize(self, unused_button):
 
57
        self.parent.windowizeComponent(self.child, self)
 
58
 
 
59
class ProjectTabs(gtk.Notebook):
 
60
    """
 
61
    Widget for the various source factories (files, effects, live,...)
 
62
    """
 
63
 
 
64
    __DEFAULT_COMPONENTS__ = (
 
65
        (SourceList, _("Clip Library")),
 
66
        # (AudioFxList, _("Audio Effects")),
 
67
        # (VideoFxList, _("Video Effects")),
 
68
        # FIXME : Property editor disabled for 0.11.3 release, re-enable after
 
69
        # (PropertyEditor, _("Properties")),
 
70
    )
 
71
 
 
72
    def __init__(self, instance, uiman):
 
73
        """ initialize """
 
74
        gtk.Notebook.__init__(self)
 
75
        self.app = instance
 
76
        self.uiman = uiman
 
77
        self._full_list = []
 
78
        self.connect("switch-page", self._switchPage)
 
79
        self._createUi()
 
80
 
 
81
    def _createUi(self):
 
82
        """ set up the gui """
 
83
        self.set_tab_pos(gtk.POS_TOP)
 
84
        for component, label in self.__DEFAULT_COMPONENTS__:
 
85
            self.addComponent(component(self.app, self.uiman), label)
 
86
 
 
87
    def addComponent(self, component, label):
 
88
        self.append_page(component, DetachLabel(self, component, label))
 
89
        self._full_list.append(component)
 
90
 
 
91
    def windowizeComponent(self, component, label):
 
92
        self.remove_page(self.page_num(component))
 
93
        window = gtk.Window()
 
94
        window.add(component)
 
95
        window.show_all()
 
96
        window.connect("destroy", self._replaceComponent, component, label)
 
97
        window.resize(200, 200)
 
98
        if not self.get_n_pages():
 
99
            self.hide()
 
100
 
 
101
    def _replaceComponent(self, window, component, label):
 
102
        window.remove(component)
 
103
        self.set_current_page(self.insert_page(component, label,
 
104
            self._full_list.index(component)))
 
105
        self.show()
 
106
 
 
107
    def _switchPage(self, unused_widget, unused_page, num):
 
108
        for child in (self.get_nth_page(i) for i in xrange(self.get_n_pages())):
 
109
            self.get_tab_label(child).deselect()
 
110
        cur = self.get_tab_label(self.get_nth_page(num))
 
111
        cur.select()