~ubuntu-branches/ubuntu/karmic/pitivi/karmic

« back to all changes in this revision

Viewing changes to pitivi/ui/timelinecanvas.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2009-08-13 19:33:06 UTC
  • mfrom: (1.2.2 upstream) (3.2.6 karmic)
  • Revision ID: james.westby@ubuntu.com-20090813193306-3mlq3s2tlh5dbesr
Tags: 0.13.2-1
New upstream release, 'Jailbreak (out of deadlock city)'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import gtk
23
23
import goocanvas
 
24
from gettext import gettext as _
24
25
 
25
26
from pitivi.log.loggable import Loggable
26
27
from pitivi.receiver import receiver, handler
30
31
from pitivi.ui.zoominterface import Zoomable
31
32
from pitivi.settings import GlobalSettings
32
33
from pitivi.ui.prefs import PreferencesDialog
33
 
from pitivi.ui.common import TRACK_SPACING, unpack_cairo_pattern
34
 
import gtk
 
34
from pitivi.ui.common import TRACK_SPACING, unpack_cairo_pattern, \
 
35
        LAYER_HEIGHT_EXPANDED, LAYER_SPACING
35
36
 
36
37
# cursors to be used for resizing objects
37
38
ARROW = gtk.gdk.Cursor(gtk.gdk.ARROW)
45
46
    notify = True)
46
47
 
47
48
PreferencesDialog.addNumericPreference('edgeSnapDeadband',
48
 
    section = "Behavior",
49
 
    label = "Snap Distance (pixels)",
50
 
    description = "Threshold distance (in pixels) used for all snapping"
51
 
        "operations",
 
49
    section = _("Behavior"),
 
50
    label = _("Snap Distance (pixels)"),
 
51
    description = _("Threshold distance (in pixels) used for all snapping "
 
52
        "operations"),
52
53
    lower = 0)
53
54
 
54
55
class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
96
97
        root.connect("motion-notify-event", self._selectionDrag)
97
98
        root.connect("button-press-event", self._selectionStart)
98
99
        root.connect("button-release-event", self._selectionEnd)
 
100
        height = (LAYER_HEIGHT_EXPANDED + TRACK_SPACING + LAYER_SPACING) * 2
 
101
        # add some padding for the horizontal scrollbar
 
102
        height += 21
 
103
        self.set_size_request(-1, height)
99
104
 
100
105
    def from_event(self, event):
101
106
        return Point(*self.convert_from_pixels(event.x, event.y))
235
240
        if items:
236
241
            for item in items:
237
242
                if isinstance(item, TrackObject):
238
 
                    item.element.split(self.pixelToNs(x))
 
243
                    self.app.action_log.begin("split object")
 
244
                    item.element.split(self._snapToPlayhead(self.pixelToNs(x)))
 
245
                    self.app.action_log.commit()
239
246
 
240
247
        return True
241
248
 
242
249
    def _razorClickedCb(self, unused_canvas, unused_event):
243
250
        return True
244
251
 
 
252
    def _snapToPlayhead(self, time):
 
253
        thresh = self.pixelToNs(self.settings.edgeSnapDeadband)
 
254
        if abs(time - self._position) <= thresh:
 
255
            return self._position
 
256
        return time
 
257
 
245
258
    max_duration = 0
246
259
 
247
260
    def setMaxDuration(self, duration):