Skip to content

Commit

Permalink
Add action to set start from video position
Browse files Browse the repository at this point in the history
Closes #148
  • Loading branch information
otsaloma committed Mar 12, 2020
1 parent c9304b4 commit 745fe18
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Gaupol 1.7.1/1.8
================

* [x] Add action set start from video position (#148)
* [x] Add and fix English spell-check special cases
4 changes: 4 additions & 0 deletions data/ui/menubar.ui
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
</item>
</section>
</submenu>
<item>
<attribute name="label" translatable="yes">Set St_art From Video Position</attribute>
<attribute name="action">win.set-start-from-video-position</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Set En_d From Video Position</attribute>
<attribute name="action">win.set-end-from-video-position</attribute>
Expand Down
11 changes: 11 additions & 0 deletions gaupol/actions/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ def _affirm_doable(self, application, page, selected_rows):
aeidon.util.affirm(application.player.ready)
aeidon.util.affirm(len(selected_rows) == 1)

class SetStartFromVideoPositionAction(gaupol.Action):
def __init__(self):
gaupol.Action.__init__(self, "set-start-from-video-position")
self.accelerators = ["U"]
self.action_group = "unsafe"
def _affirm_doable(self, application, page, selected_rows):
aeidon.util.affirm(page is not None)
aeidon.util.affirm(application.player is not None)
aeidon.util.affirm(application.player.ready)
aeidon.util.affirm(len(selected_rows) == 1)

class SplitSubtitleAction(gaupol.Action):
def __init__(self):
gaupol.Action.__init__(self, "split-subtitle")
Expand Down
10 changes: 10 additions & 0 deletions gaupol/agents/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ def _on_set_end_from_video_position_activate(self, *args):
if pos is None: return
page.project.set_end(row, pos)

@aeidon.deco.export
def _on_set_start_from_video_position_activate(self, *args):
"""Set subtitle start from video position."""
page = self.get_current_page()
mode = aeidon.modes.SECONDS
row = page.view.get_selected_rows()[0]
pos = self.player.get_position(mode)
if pos is None: return
page.project.set_start(row, pos)

@aeidon.deco.export
def _on_split_subtitle_activate(self, *args):
"""Split the selected subtitle."""
Expand Down

0 comments on commit 745fe18

Please sign in to comment.