[pitivi] Escape keyboard shortcut key to defocus the viewer's timecode entry widget and refocus the timeline
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Escape keyboard shortcut key to defocus the viewer's timecode entry widget and refocus the timeline
- Date: Thu, 2 Feb 2017 22:20:52 +0000 (UTC)
commit 1b7e0a47e1c6bf95f1554f6ddceda40c3775acb0
Author: Dan Muntean <dan_i muntean yahoo com>
Date: Thu Feb 2 22:01:40 2017 +0000
Escape keyboard shortcut key to defocus the viewer's timecode entry widget and refocus the timeline
Differential Revision: https://phabricator.freedesktop.org/D1627
pitivi/utils/widgets.py | 7 +++++++
pitivi/viewer/viewer.py | 6 ++++++
2 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index c1a538a..3c16bf8 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -302,6 +302,7 @@ class TimeWidget(TextWidget, DynamicWidget):
TextWidget.__init__(self, self.VALID_REGEX)
TextWidget.set_width_chars(self, 10)
self._framerate = None
+ self.text.connect("focus-out-event", self._focus_out_cb)
def getWidgetValue(self):
timecode = TextWidget.getWidgetValue(self)
@@ -326,11 +327,17 @@ class TimeWidget(TextWidget, DynamicWidget):
return int(nanosecs)
def setWidgetValue(self, timeNanos, send_signal=True):
+ self.default = timeNanos
timecode = time_to_string(timeNanos)
if timecode.startswith("0:"):
timecode = timecode[2:]
TextWidget.setWidgetValue(self, timecode, send_signal=send_signal)
+ def _focus_out_cb(self, widget, event):
+ """Reset the text to display the current position of the playhead."""
+ if self.default is not None:
+ self.setWidgetValue(self.default)
+
def connectActivateEvent(self, activateCb):
return self.connect("activate", activateCb)
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index 40b814d..f5f5650 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -255,6 +255,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self.timecode_entry.set_tooltip_text(
_('Enter a timecode or frame number\nand press "Enter" to go to that position'))
self.timecode_entry.connectActivateEvent(self._entryActivateCb)
+ self.timecode_entry.connect("key_press_event", self._entry_key_press_event_cb)
bbox.pack_start(self.timecode_entry, False, 10, 0)
self.undock_button = Gtk.ToolButton()
@@ -295,6 +296,11 @@ class ViewerContainer(Gtk.Box, Loggable):
self.app.project_manager.current_project.pipeline.simple_seek(nanoseconds)
self.app.gui.timeline_ui.timeline.scrollToPlayhead(align=Gtk.Align.CENTER, when_not_in_view=True)
+ def _entry_key_press_event_cb(self, widget, event):
+ """Handles the key press events in the timecode_entry widget."""
+ if event.keyval == Gdk.KEY_Escape:
+ self.app.gui.focusTimeline()
+
# Active Timeline calllbacks
def _durationChangedCb(self, unused_pipeline, duration):
if duration == 0:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]