/
timeline.py
710 lines (598 loc) · 25 KB
/
timeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
# PiTiVi , Non-linear video editor
#
# pitivi/ui/timeline.py
#
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
"""
Timeline widgets for the complex view
"""
import gtk
import urllib
from pitivi.log.loggable import Loggable
import ruler
import dnd
import gst
import gobject
from gettext import gettext as _
from timelinecanvas import TimelineCanvas
from timelinecontrols import TimelineControls
from pitivi.receiver import receiver, handler
from zoominterface import Zoomable
from pitivi.ui.common import LAYER_HEIGHT_EXPANDED, LAYER_SPACING, TRACK_SPACING
from pitivi.timeline.timeline import MoveContext, SELECT
from pitivi.utils import Seeker
from pitivi.ui.filelisterrordialog import FileListErrorDialog
from pitivi.ui.curve import Curve
from pitivi.factories.operation import EffectFactory
DND_EFFECT_LIST = [[dnd.VIDEO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]],\
[dnd.AUDIO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]]]
VIDEO_EFFECT_LIST = [dnd.VIDEO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]],
AUDIO_EFFECT_LIST = [dnd.AUDIO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]],
# tooltip text for toolbar
DELETE = _("Delete Selected")
SPLIT = _("Split clip at playhead position")
KEYFRAME = _("Create a keyframe")
ZOOM_IN = _("Zoom In")
ZOOM_OUT = _("Zoom Out")
UNLINK = _("Break links between clips")
LINK = _("Link together arbitrary clips")
UNGROUP = _("Ungroup clips")
GROUP = _("Group clips")
SELECT_BEFORE = ("Select all sources before selected")
SELECT_AFTER = ("Select all after selected")
ui = '''
<ui>
<menubar name="MainMenuBar">
<menu action="View">
<placeholder name="Timeline">
<menuitem action="ZoomIn" />
<menuitem action="ZoomOut" />
</placeholder>
</menu>
<menu action="Timeline">
<placeholder name="Timeline">
<menuitem action="Split" />
<menuitem action="Keyframe" />
<separator />
<menuitem action="DeleteObj" />
<menuitem action="LinkObj" />
<menuitem action="UnlinkObj" />
<menuitem action="GroupObj" />
<menuitem action="UngroupObj" />
</placeholder>
</menu>
</menubar>
<toolbar name="TimelineToolBar">
<placeholder name="Timeline">
<separator />
<toolitem action="Split" />
<toolitem action="Keyframe" />
<separator />
<toolitem action="DeleteObj" />
<toolitem action="UnlinkObj" />
<toolitem action="LinkObj" />
<toolitem action="GroupObj" />
<toolitem action="UngroupObj" />
</placeholder>
</toolbar>
<accelerator action="DeleteObj" />
</ui>
'''
# Complex Timeline Design v2 (08 Feb 2006)
#
#
# Tree of contents (ClassName(ParentClass))
# -----------------------------------------
#
# Timeline(gtk.VBox)
# | Top container
# |
# +--ScaleRuler(gtk.Layout)
# |
# +--gtk.ScrolledWindow
# |
# +--TimelineCanvas(goocanas.Canvas)
# | |
# | +--Track(SmartGroup)
# |
# +--Status Bar ??
class InfoStub(gtk.HBox, Loggable):
"""
Box used to display information on the current state of the timeline
"""
def __init__(self):
gtk.HBox.__init__(self)
Loggable.__init__(self)
self.errors = []
self.showing = False
self._errorsmessage = _("One or more GStreamer errors has occured!")
self._makeUI()
def _makeUI(self):
self.set_spacing(6)
self.erroricon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING,
gtk.ICON_SIZE_SMALL_TOOLBAR)
self.pack_start(self.erroricon, expand=False)
self.infolabel = gtk.Label(self._errorsmessage)
self.infolabel.set_alignment(0, 0.5)
self.questionbutton = gtk.Button()
self.questionbutton.set_image(gtk.image_new_from_stock(gtk.STOCK_INFO,
gtk.ICON_SIZE_SMALL_TOOLBAR))
self.questionbutton.connect("clicked", self._questionButtonClickedCb)
self._questionshowing = False
self.pack_start(self.infolabel, expand=True, fill=True)
self.pack_start(self.questionbutton, expand=False)
def addErrors(self, *args):
self.errors.append(args)
self.show()
def _errorDialogBoxCloseCb(self, dialog):
dialog.destroy()
def _errorDialogBoxResponseCb(self, dialog, unused_response):
dialog.destroy()
def _questionButtonClickedCb(self, unused_button):
msgs = (_("Error List"),
_("The following errors have been reported:"))
# show error dialog
dbox = FileListErrorDialog(*msgs)
dbox.connect("close", self._errorDialogBoxCloseCb)
dbox.connect("response", self._errorDialogBoxResponseCb)
for reason, extra in self.errors:
dbox.addFailedFile(None, reason, extra)
dbox.show()
# reset error list
self.errors = []
self.hide()
def show(self):
self.log("showing")
self.show_all()
self.showing = True
def hide(self):
self.log("hiding")
gtk.VBox.hide(self)
self.showing = False
class Timeline(gtk.Table, Loggable, Zoomable):
# the screen width of the current unit
unit_width = 10
# specific levels of zoom, in (multiplier, unit) pairs which
# from zoomed out to zoomed in
def __init__(self, instance, ui_manager):
gtk.Table.__init__(self, rows=2, columns=1, homogeneous=False)
Loggable.__init__(self)
Zoomable.__init__(self)
self.log("Creating Timeline")
self._updateZoom = True
self.project = None
self.ui_manager = ui_manager
self.app = instance
self._temp_objects = None
self._factories = None
self._finish_drag = False
self._position = 0
self._state = gst.STATE_NULL
self._createUI()
self._prev_duration = 0
self.shrink = True
self.rate = gst.Fraction(1,1)
def _createUI(self):
self.leftSizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
self.props.row_spacing = 2
self.props.column_spacing = 2
self.hadj = gtk.Adjustment()
self.vadj = gtk.Adjustment()
# zooming slider
self._zoomAdjustment = gtk.Adjustment()
self._zoomAdjustment.set_value(Zoomable.getCurrentZoomLevel())
self._zoomAdjustment.connect("value-changed",
self._zoomAdjustmentChangedCb)
self._zoomAdjustment.props.lower = 0
self._zoomAdjustment.props.upper = Zoomable.zoom_steps
zoomslider = gtk.HScale(self._zoomAdjustment)
zoomslider.props.draw_value = False
zoomslider.set_tooltip_text(_("Zoom Timeline"))
self.attach(zoomslider, 0, 1, 0, 1, yoptions=0, xoptions=gtk.FILL)
# controls for tracks and layers
self._controls = TimelineControls()
controlwindow = gtk.Viewport(None, self.vadj)
controlwindow.add(self._controls)
controlwindow.set_size_request(-1, 1)
controlwindow.set_shadow_type(gtk.SHADOW_OUT)
self.attach(controlwindow, 0, 1, 1, 2, xoptions=0)
# timeline ruler
self.ruler = ruler.ScaleRuler(self.app, self.hadj)
self.ruler.set_size_request(0, 25)
self.ruler.set_border_width(2)
self.ruler.connect("key-press-event", self._keyPressEventCb)
self.ruler.connect("size-allocate", self._rulerSizeAllocateCb)
rulerframe = gtk.Frame()
rulerframe.set_shadow_type(gtk.SHADOW_OUT)
rulerframe.add(self.ruler)
self.attach(rulerframe, 1, 2, 0, 1, yoptions=0)
# proportional timeline
self._canvas = TimelineCanvas(self.app)
timelinewindow = gtk.ScrolledWindow(self.hadj, self.vadj)
timelinewindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
timelinewindow.add(self._canvas)
timelinewindow.set_shadow_type(gtk.SHADOW_IN)
timelinewindow.set_name("timelinewindow")
# temp fix for padding between scrollbar and scrolled window
#FIXME: should be set at an global position for easy editing?
gtk.rc_parse_string("""
style 'timelinewindow'
{
GtkScrolledWindow::scrollbar-spacing = 0
}
widget '*.timelinewindow' style 'timelinewindow'
""")
self.attach(timelinewindow, 1, 2, 1, 2)
# error infostub
self.infostub = InfoStub()
self.attach(self.infostub, 1, 2, 2, 3, yoptions=0)
self.show_all()
self.infostub.hide()
# toolbar actions
actions = (
("ZoomIn", gtk.STOCK_ZOOM_IN, None, "<Control>equal", ZOOM_IN,
self._zoomInCb),
("ZoomOut", gtk.STOCK_ZOOM_OUT, None, "<Control>minus", ZOOM_OUT,
self._zoomOutCb),
)
selection_actions = (
("DeleteObj", gtk.STOCK_DELETE, None, "Delete", DELETE,
self.deleteSelected),
("UnlinkObj", "pitivi-unlink", None, "<Shift><Control>L", UNLINK,
self.unlinkSelected),
("LinkObj", "pitivi-link", None, "<Control>L", LINK,
self.linkSelected),
("UngroupObj", "pitivi-ungroup", None, "<Shift><Control>G", UNGROUP,
self.ungroupSelected),
("GroupObj", "pitivi-group", None, "<Control>G", GROUP,
self.groupSelected),
)
playhead_actions = (
("Split", "pitivi-split", _("Split"), "S", SPLIT,
self.split),
("Keyframe", "pitivi-keyframe", _("Keyframe"), "K", KEYFRAME,
self.keyframe),
)
actiongroup = gtk.ActionGroup("timelinepermanent")
actiongroup.add_actions(actions)
actiongroup.add_actions(playhead_actions)
self.ui_manager.insert_action_group(actiongroup, 0)
actiongroup = gtk.ActionGroup("timelineselection")
actiongroup.add_actions(selection_actions)
self.link_action = actiongroup.get_action("LinkObj")
self.unlink_action = actiongroup.get_action("UnlinkObj")
self.group_action = actiongroup.get_action("GroupObj")
self.ungroup_action = actiongroup.get_action("UngroupObj")
self.delete_action = actiongroup.get_action("DeleteObj")
self.ui_manager.insert_action_group(actiongroup, -1)
self.ui_manager.add_ui_from_string(ui)
# drag and drop
self.drag_dest_set(gtk.DEST_DEFAULT_MOTION,
[dnd.FILESOURCE_TUPLE, dnd.EFFECT_TUPLE],
gtk.gdk.ACTION_COPY)
self.connect("drag-data-received", self._dragDataReceivedCb)
self.connect("drag-leave", self._dragLeaveCb)
self.connect("drag-drop", self._dragDropCb)
self.connect("drag-motion", self._dragMotionCb)
self._canvas.connect("button-press-event", self._buttonPress)
self._canvas.connect("button-release-event", self._buttonRelease)
self._canvas.connect("key-press-event", self._keyPressEventCb)
## Event callbacks
def _keyPressEventCb(self, unused_widget, event):
kv = event.keyval
self.debug("kv:%r", kv)
if kv not in [gtk.keysyms.Left, gtk.keysyms.Right]:
return False
mod = event.get_state()
try:
if mod & gtk.gdk.CONTROL_MASK:
now = self.project.pipeline.getPosition()
ltime, rtime = self.project.timeline.edges.closest(now)
if kv == gtk.keysyms.Left:
if mod & gtk.gdk.SHIFT_MASK:
self._seekRelative(-gst.SECOND)
elif mod & gtk.gdk.CONTROL_MASK:
self._seeker.seek(ltime+1)
else:
self._seekRelative(-long(self.rate * gst.SECOND))
elif kv == gtk.keysyms.Right:
if mod & gtk.gdk.SHIFT_MASK:
self._seekRelative(gst.SECOND)
elif mod & gtk.gdk.CONTROL_MASK:
self._seeker.seek(rtime+1)
else:
self._seekRelative(long(self.rate * gst.SECOND))
finally:
return True
def _seekRelative(self, time):
pipeline = self.project.pipeline
seekvalue = max(0, min(pipeline.getPosition() + time,
pipeline.getDuration()))
self._seeker.seek(seekvalue)
def _buttonPress(self, window, event):
self.shrink = False
def _buttonRelease(self, window, event):
self.shrink = True
self._timelineStartDurationChanged(self.timeline,
self.timeline.duration)
## Drag and Drop callbacks
def _dragMotionCb(self, unused, context, x, y, timestamp):
self.warning("self._factories:%r, self._temp_objects:%r",
not not self._factories,
not not self._temp_objects)
if self._factories is None:
if context.targets in DND_EFFECT_LIST:
atom = gtk.gdk.atom_intern(dnd.EFFECT_TUPLE[0])
else:
atom = gtk.gdk.atom_intern(dnd.FILESOURCE_TUPLE[0])
self.drag_get_data(context, atom, timestamp)
self.drag_highlight()
else:
if context.targets not in DND_EFFECT_LIST:
if not self._temp_objects:
self.timeline.disableUpdates()
self._add_temp_source(x,y)
focus = self._temp_objects[0]
self._move_context = MoveContext(self.timeline,
focus, set(self._temp_objects[1:]))
self._move_temp_source(self.hadj.props.value + x, y)
return True
def _dragLeaveCb(self, unused_layout, context, unused_tstamp):
if self._temp_objects:
try:
for obj in self._temp_objects:
self.timeline.removeTimelineObject(obj, deep=True)
finally:
self._temp_objects = None
self.drag_unhighlight()
self.timeline.enableUpdates()
def _dragDropCb(self, widget, context, x, y, timestamp):
if context.targets not in DND_EFFECT_LIST:
self.app.action_log.begin("add clip")
self._add_temp_source(x,y)
focus = self._temp_objects[0]
self._move_context = MoveContext(self.timeline,
focus, set(self._temp_objects[1:]))
self._move_temp_source(self.hadj.props.value + x, y)
self._move_context.finish()
self.app.action_log.commit()
context.drop_finish(True, timestamp)
self._factories = None
self._temp_objects = None
self.app.current.seeker.seek(self._position)
return True
elif context.targets in DND_EFFECT_LIST:
factory = self._factories[0]
timeline_objs = self._getTimelineObjectUnderMouse(x, y, factory.getInputStreams()[0])
if timeline_objs:
self.app.action_log.begin("add effect")
self.timeline.addEffectFactoryOnObject(factory,
timeline_objects = timeline_objs)
self.app.action_log.commit()
self._factories = None
self.app.current.seeker.seek(self._position)
context.drop_finish(True, timestamp)
self.timeline.selection.setTo(timeline_objs, SELECT)
return True
return False
def _dragDataReceivedCb(self, unused_layout, context, x, y,
selection, targetType, timestamp):
self.log("SimpleTimeline, targetType:%d, selection.data:%s" %
(targetType, selection.data))
# FIXME: let's have just one target type, call it
# TYPE_PITIVI_OBJECTFACTORY.
# TODO: handle uri targets by doign an import-add. This would look
# something like this:
# tell current project to import the uri
# wait for source-added signal, meanwhile ignore dragMotion signals
# when ready, add factories to the timeline.
if targetType not in [dnd.TYPE_PITIVI_FILESOURCE, dnd.TYPE_PITIVI_EFFECT]:
context.finish(False, False, timestamp)
return
if targetType == dnd.TYPE_PITIVI_FILESOURCE:
uris = selection.data.split("\n")
self._factories = [self.project.sources.getUri(uri) for uri in uris]
else:
self._factories = [self.app.effects.getFactoryFromName(selection.data)]
context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
return True
def _getTimelineObjectUnderMouse(self, x, y, stream):
timeline_objs = []
items_in_area = self._canvas.getItemsInArea(x, y-15, x+1, y-30)
tracks = [obj for obj in items_in_area[0]]
track_objects = [obj for obj in items_in_area[1]]
for track_object in track_objects:
if (type(stream) == type(track_object.stream)):
timeline_objs.append(track_object.timeline_object)
return timeline_objs
def _add_temp_source(self, x, y):
self._temp_objects = [self.timeline.addSourceFactory(factory)
for factory in self._factories]
def _move_temp_source(self, x, y):
x1, y1, x2, y2 = self._controls.get_allocation()
offset = 10 + (x2 - x1)
x, y = self._canvas.convert_from_pixels(x - offset, y)
priority = int((y // (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)))
delta = Zoomable.pixelToNs(x)
self._move_context.editTo(delta, priority)
## Zooming and Scrolling
def _zoomAdjustmentChangedCb(self, adjustment):
# GTK crack
self._updateZoom = False
Zoomable.setZoomLevel(int(adjustment.get_value()))
self._updateZoom = True
def zoomChanged(self):
self._canvas.props.redraw_when_scrolled = True
if self._updateZoom:
self._zoomAdjustment.set_value(self.getCurrentZoomLevel())
self.ruler.queue_resize()
self.ruler.queue_draw()
def timelinePositionChanged(self, position):
self._position = position
self.ruler.timelinePositionChanged(position)
self._canvas.timelinePositionChanged(position)
if self._state == gst.STATE_PLAYING:
self.scrollToPlayhead()
def stateChanged(self, state):
self._state = state
def scrollToPlayhead(self):
"""
Scroll the current position as close to the center of the view
as possible (as close as the timeline canvas allows).
"""
page_size = self.hadj.get_page_size()
new_pos = Zoomable.nsToPixel(self._position)
scroll_pos = self.hadj.get_value()
if (new_pos > scroll_pos + page_size) or (new_pos < scroll_pos):
self.scrollToPosition(min(new_pos - page_size / 2, self.hadj.upper - page_size - 1))
return False
def scrollToPosition(self, position):
if position > self.hadj.upper:
# we can't perform the scroll because the canvas needs to be
# updated
gobject.idle_add(self._scrollToPosition, position)
else:
self._scrollToPosition(position)
def _scrollToPosition(self, position):
self.hadj.set_value(position)
return False
def _rulerSizeAllocateCb(self, ruler, allocation):
self._canvas.props.redraw_when_scrolled = False
## Project callbacks
def _setProject(self):
if self.project:
self.timeline = self.project.timeline
self._controls.timeline = self.timeline
self._canvas.timeline = self.timeline
self._canvas.zoomChanged()
self.ruler.setProjectFrameRate(self.project.getSettings().videorate)
self.ruler.zoomChanged()
self._settingsChangedCb(self.project, None, self.project.getSettings())
self._seeker = self.project.seeker
project = receiver(_setProject)
@handler(project, "settings-changed")
def _settingsChangedCb(self, project, old, new):
rate = new.videorate
self.rate = float(1 / rate)
self.ruler.setProjectFrameRate(rate)
## Timeline callbacks
def _setTimeline(self):
if self.timeline:
self._timelineSelectionChanged(self.timeline)
self._timelineStartDurationChanged(self.timeline,
self.timeline.duration)
self._controls.timeline = self.timeline
timeline = receiver(_setTimeline)
@handler(timeline, "duration-changed")
def _timelineStartDurationChanged(self, unused_timeline, duration):
if self.shrink:
self._prev_duration = duration
self.ruler.setMaxDuration(duration + 60 * gst.SECOND)
self._canvas.setMaxDuration(duration + 60 * gst.SECOND)
self.ruler.setShadedDuration(duration)
else:
# only resize if new size is larger
if duration > self._prev_duration:
self._prev_duration = duration
self.ruler.setMaxDuration(duration)
self._canvas.setMaxDuration(duration)
#self.ruler.setShadedDuration(duration)
@handler(timeline, "selection-changed")
def _timelineSelectionChanged(self, timeline):
delete = False
link = False
unlink = False
group = False
ungroup = False
timeline_objects = {}
if timeline.selection:
delete = True
if len(timeline.selection) > 1:
link = True
group = True
start = None
duration = None
for obj in self.timeline.selection:
if obj.link:
unlink = True
if len(obj.track_objects) > 1:
ungroup = True
if start is not None and duration is not None:
if obj.start != start or obj.duration != duration:
group = False
else:
start = obj.start
duration = obj.duration
self.delete_action.set_sensitive(delete)
self.link_action.set_sensitive(link)
self.unlink_action.set_sensitive(unlink)
self.group_action.set_sensitive(group)
self.ungroup_action.set_sensitive(ungroup)
## ToolBar callbacks
def hide(self):
self.actiongroup.set_visible(False)
gtk.Vbox.hide(self)
def _zoomInCb(self, unused_action):
Zoomable.zoomIn()
def _zoomOutCb(self, unused_action):
Zoomable.zoomOut()
def deleteSelected(self, unused_action):
if self.timeline:
self.app.action_log.begin("delete clip")
self.timeline.deleteSelection()
self.app.action_log.commit()
def unlinkSelected(self, unused_action):
if self.timeline:
self.timeline.unlinkSelection()
def linkSelected(self, unused_action):
if self.timeline:
self.timeline.linkSelection()
def ungroupSelected(self, unused_action):
if self.timeline:
self.app.action_log.begin("ungroup")
self.timeline.ungroupSelection()
self.app.action_log.commit()
def groupSelected(self, unused_action):
if self.timeline:
self.timeline.groupSelection()
def split(self, action):
self.app.action_log.begin("split")
self.timeline.split(self._position)
self.app.action_log.commit()
# work-around for 603149
self.project.seeker.seek(self._position)
def keyframe(self, action):
timeline_position = self._position
selected = self.timeline.selection.getSelectedTrackObjs()
for obj in selected:
keyframe_exists = False
position_in_obj = timeline_position - obj.start
interpolators = obj.getInterpolators()
for value in interpolators:
interpolator = obj.getInterpolator(value)
keyframes = interpolator.getInteriorKeyframes()
for kf in keyframes:
if kf.getTime() == position_in_obj:
keyframe_exists = True
self.app.action_log.begin("remove volume point")
interpolator.removeKeyframe(kf)
self.app.action_log.commit()
if keyframe_exists == False:
self.app.action_log.begin("add volume point")
interpolator.newKeyframe(position_in_obj)
self.app.action_log.commit()