Skip to content

Commit

Permalink
Allow shifting positions of all open projects
Browse files Browse the repository at this point in the history
Closes #66
  • Loading branch information
otsaloma committed Aug 16, 2020
1 parent 76e0ef5 commit 10ebac1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Gaupol 1.9
==========

* [x] Add framerates 30, 50, 59.94 and 60 fps (#164)
* [x] Allow shifting positions of all open projects (#66)
* [x] Fix the order of audio tracks in the menu (#129, qnga)
17 changes: 17 additions & 0 deletions data/ui/position-shift-dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="all_radio">
<property name="label" translatable="yes">Shift all _open projects</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">selected_radio</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
Expand Down
7 changes: 6 additions & 1 deletion gaupol/dialogs/position_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PositionShiftDialog(gaupol.BuilderDialog):
"""Base class for dialogs for shifting positions."""

_widgets = [
"all_radio",
"amount_spin",
"current_radio",
"preview_button",
Expand Down Expand Up @@ -61,6 +62,8 @@ def _get_target(self):
return gaupol.targets.SELECTED_TO_END
if self._current_radio.get_active():
return gaupol.targets.CURRENT
if self._all_radio.get_active():
return gaupol.targets.ALL
raise ValueError("Invalid target radio state")

def _init_dialog(self, parent):
Expand All @@ -77,6 +80,7 @@ def _init_values(self):
self._selected_radio.set_active(target == gaupol.targets.SELECTED)
self._to_end_radio.set_active(target == gaupol.targets.SELECTED_TO_END)
self._current_radio.set_active(target == gaupol.targets.CURRENT)
self._all_radio.set_active(target == gaupol.targets.ALL)
page = self.application.get_current_page()
rows = page.view.get_selected_rows()
if not rows and target in (
Expand Down Expand Up @@ -120,9 +124,10 @@ def _shift_positions(self):
"""Shift positions in subtitles."""
gaupol.util.set_cursor_busy(self)
target = self._get_target()
rows = self.application.get_target_rows(target)
amount = self._get_amount()
for page in self.application.get_target_pages(target):
self.application.set_current_page(page)
rows = self.application.get_target_rows(target)
page.project.shift_positions(rows, amount)
gaupol.util.set_cursor_normal(self)

Expand Down

0 comments on commit 10ebac1

Please sign in to comment.