~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to pitivi/ui/basetabs.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-04-05 15:28:16 UTC
  • mfrom: (6.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20140405152816-6lijoax4cngiz5j5
Tags: 0.93-3
* debian/control:
  + Depend on python-gi (>= 3.10), older versions do not work
    with pitivi (Closes: #732813).
  + Add missing dependency on gir1.2-clutter-gst-2.0 (Closes: #743692).
  + Add suggests on gir1.2-notify-0.7 and gir1.2-gnomedesktop-3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# PiTiVi , Non-linear video editor
2
 
#
3
 
#       ui/basetabs.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., 51 Franklin St, Fifth Floor,
20
 
# Boston, MA 02110-1301, USA.
21
 
 
22
 
import gtk
23
 
from pitivi.ui.common import SPACING
24
 
 
25
 
 
26
 
class BaseTabs(gtk.Notebook):
27
 
    def __init__(self, app, hide_hpaned=False):
28
 
        """ initialize """
29
 
        gtk.Notebook.__init__(self)
30
 
        self.set_border_width(SPACING)
31
 
 
32
 
        self.connect("create-window", self._createWindowCb)
33
 
        self._hide_hpaned = hide_hpaned
34
 
        self.app = app
35
 
        self._createUi()
36
 
 
37
 
    def _createUi(self):
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)
42
 
 
43
 
    def append_page(self, child, label):
44
 
        gtk.Notebook.append_page(self, child, label)
45
 
        self._set_child_properties(child, label)
46
 
        child.show()
47
 
        label.show()
48
 
 
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
54
 
 
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)
64
 
 
65
 
        if self._hide_hpaned:
66
 
            self._showSecondHpanedInMainWindow()
67
 
 
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")
71
 
        window = gtk.Window()
72
 
        window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_UTILITY)
73
 
 
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
80
 
        window.add(notebook)
81
 
 
82
 
        window.show_all()
83
 
        # set_uposition is deprecated but what should I use instead?
84
 
        window.set_uposition(x, y)
85
 
 
86
 
        if self._hide_hpaned:
87
 
            self._hideSecondHpanedInMainWindow()
88
 
 
89
 
        return notebook
90
 
 
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,
96
 
                                      shrink=False)
97
 
 
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)