[pitivi] timeline: Implement a copy/paste feature
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Implement a copy/paste feature
- Date: Mon, 6 Jul 2015 09:45:30 +0000 (UTC)
commit b9a3f20946307b6b1468ccbe405ce2e7bb677128
Author: Thibault Saunier <tsaunier gnome org>
Date: Fri Jul 3 11:05:23 2015 +0200
timeline: Implement a copy/paste feature
data/ui/timelinecontainer.xml | 8 ++++++--
pitivi/timeline/timeline.py | 22 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/timelinecontainer.xml b/data/ui/timelinecontainer.xml
index 550c81d..46d93f7 100644
--- a/data/ui/timelinecontainer.xml
+++ b/data/ui/timelinecontainer.xml
@@ -6,7 +6,9 @@
<toolitem action="DeleteObj" />
<toolitem action="GroupObj" />
<toolitem action="UngroupObj" />
- <toolitem action="AlignObj" />
+ <toolitem action="Copy" />
+ <toolitem action="Paste" />
+ <!-- <toolitem action="AlignObj" /> -->
</placeholder>
</toolbar>
<accelerator action="ZoomIn" />
@@ -19,7 +21,9 @@
<accelerator action="DeleteObj" />
<accelerator action="UngroupObj" />
<accelerator action="GroupObj" />
- <accelerator action="AlignObj" />
+ <accelerator action="Copy" />
+ <accelerator action="Paste" />
+ <!-- <accelerator action="AlignObj" /> -->
<accelerator action="PlayPause" />
<accelerator action="Split" />
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 3537211..03f4d1e 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -25,6 +25,7 @@ import os
from gettext import gettext as _
from gi.repository import GES
+from gi.repository import Gio
from gi.repository import GLib
from gi.repository import Gdk
from gi.repository import Gst
@@ -1360,6 +1361,12 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
("GroupObj", "pitivi-group", _("Group"),
"<Control>G", _("Group clips"), self._groupSelected),
+ ("Copy", "copy", _("Copy"),
+ "<Control>c", _("Copy clips"), self.__copyClipsCb),
+
+ ("Paste", "paste", _("Paste"),
+ "<Control>v", _("Paste clips"), self.__pasteClipsCb),
+
# TODO: Fix the align feature.
# ("AlignObj", "pitivi-align", _("Align"),
# "<Shift><Control>A", _("Align clips based on their soundtracks"), self._alignSelected),
@@ -1389,6 +1396,9 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.playhead_actions.add_actions(playhead_actions)
self.ui_manager.insert_action_group(self.playhead_actions, -1)
+ self.selection_actions.get_action("Copy").set_gicon(Gio.Icon.new_for_string("edit-copy"))
+ self.selection_actions.get_action("Paste").set_gicon(Gio.Icon.new_for_string("edit-paste"))
+
def _setBestZoomRatio(self, allow_zoom_in=False):
"""
Set the zoom level so that the entire timeline is in view.
@@ -1520,6 +1530,18 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self._project.pipeline.commit_timeline()
self.app.action_log.commit()
+ def __copyClipsCb(self, unused_action):
+ if self.timeline.current_group:
+ self.__copiedGroup = self.timeline.current_group.copy(True)
+
+ def __pasteClipsCb(self, unused_action):
+ if self.__copiedGroup:
+ save = self.__copiedGroup.copy(True)
+ position = self._project.pipeline.getPosition()
+ self.__copiedGroup.paste(position)
+ self.__copiedGroup = save
+ self._project.pipeline.commit_timeline()
+
def _alignSelected(self, unused_action):
if not self.bTimeline:
self.error(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]