gaupol/actions/video.py¶
Source code for module gaupol.actions.video from file gaupol/actions/video.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 | # -*- coding: utf-8 -*-
# Copyright (C) 2012 Osmo Salomaa
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Video actions for :class:`gaupol.Application`."""
import aeidon
import gaupol
_ = aeidon.i18n._
class LoadVideoAction(gaupol.Action):
"""Load a video file."""
def __init__(self):
"""Initialize a :class:`LoadVideoAction` instance."""
gaupol.Action.__init__(self, "load_video")
self.set_label(_("_Load Video…"))
self.set_tooltip(_("Load a video file"))
self.accelerator = "<Control>L"
self.action_group = "main-safe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(gaupol.util.gst_available())
aeidon.util.affirm(page is not None)
class PlayPauseAction(gaupol.Action):
"""Play or pause video."""
def __init__(self):
"""Initialize a :class:`PlayPauseAction` instance."""
gaupol.Action.__init__(self, "play_pause")
self.set_icon_name("media-playback-start")
self.set_label(_("_Play/Pause"))
self.set_tooltip(_("Play or pause video"))
self.accelerator = "P"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
class PlaySelectionAction(gaupol.Action):
"""Play the selected subtitles."""
def __init__(self):
"""Initialize a :class:`PlaySelectionAction`."""
gaupol.Action.__init__(self, "play_selection")
self.set_label(_("Play _Selection"))
self.set_tooltip(_("Play the selected subtitles"))
self.accelerator = "O"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
aeidon.util.affirm(selected_rows)
class SeekBackwardAction(gaupol.Action):
"""Seek backward."""
def __init__(self):
"""Initialize a :class:`SeekBackwardAction` instance."""
gaupol.Action.__init__(self, "seek_backward")
self.set_icon_name("media-seek-backward")
self.set_label(_("Seek _Backward"))
self.set_tooltip(_("Seek backward"))
self.accelerator = "<Shift><Ctrl>Left"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
class SeekForwardAction(gaupol.Action):
"""Seek forward."""
def __init__(self):
"""Initialize a :class:`SeekForwardAction` instance."""
gaupol.Action.__init__(self, "seek_forward")
self.set_icon_name("media-seek-forward")
self.set_label(_("Seek _Forward"))
self.set_tooltip(_("Seek forward"))
self.accelerator = "<Shift><Ctrl>Right"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
class SeekNextAction(gaupol.Action):
"""Seek to the start of the next subtitle."""
def __init__(self):
"""Initialize a :class:`SeekNextAction` instance."""
gaupol.Action.__init__(self, "seek_next")
self.set_icon_name("media-skip-forward")
self.set_label(_("Seek _Next"))
self.set_tooltip(_("Seek to the start of the next subtitle"))
self.accelerator = "<Ctrl>Right"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
class SeekPreviousAction(gaupol.Action):
"""Seek to the start of the previous subtitle."""
def __init__(self):
"""Initialize a :class:`SeekPreviousAction` instance."""
gaupol.Action.__init__(self, "seek_previous")
self.set_icon_name("media-skip-backward")
self.set_label(_("Seek _Previous"))
self.set_tooltip(_("Seek to the start of the previous subtitle"))
self.accelerator = "<Ctrl>Left"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
class SeekSelectionEndAction(gaupol.Action):
"""Seek the end of selection."""
def __init__(self):
"""Initialize a :class:`SeekSelectionEnd` instance."""
gaupol.Action.__init__(self, "seek_selection_end")
self.set_label(_("See_k Selection End"))
self.set_tooltip(_("Seek the end of selection"))
self.accelerator = "<Ctrl>Down"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
aeidon.util.affirm(selected_rows)
class SeekSelectionStartAction(gaupol.Action):
"""Seek the start of selection."""
def __init__(self):
"""Initialize a :class:`SeekSelectionStart` instance."""
gaupol.Action.__init__(self, "seek_selection_start")
self.set_label(_("S_eek Selection Start"))
self.set_tooltip(_("Seek the start of selection"))
self.accelerator = "<Ctrl>Up"
self.action_group = "main-unsafe"
def _affirm_doable(self, application, page, selected_rows):
"""Raise :exc:`aeidon.AffirmationError` if action cannot be done."""
aeidon.util.affirm(application.player is not None)
aeidon.util.affirm(selected_rows)
__all__ = tuple(x for x in dir() if x.endswith("Action"))
|