Verified Commit d3e17b7f authored by Todd Weaver's avatar Todd Weaver
Browse files

Adding initial keybinding listener

parent 6e6ba36b
......@@ -65,7 +65,6 @@ class ResultsBox(Gtk.Box):
super().__init__(**kwargs)
self.app_window = app_window
self.is_playing = False
# listen for motion on the player box for controls show/hide
self.event_box.add_events(Gdk.EventMask.POINTER_MOTION_MASK)
......@@ -194,7 +193,7 @@ class ResultsBox(Gtk.Box):
self.get_video_details()
def update_slider(self):
if not self.is_playing:
if not self.app_window.is_playing:
return False
else:
success, duration = self.player.query_duration(Gst.Format.TIME)
......@@ -332,7 +331,7 @@ class ResultsBox(Gtk.Box):
self.play.set_visible(False)
self.pause.set_visible(True)
self.player.set_state(Gst.State.PLAYING)
self.is_playing = True
self.app_window.is_playing = True
# hide the poster, show the video
self.player_box.show_all()
......@@ -351,7 +350,7 @@ class ResultsBox(Gtk.Box):
self.play.set_visible(True)
self.pause.set_visible(False)
self.player.set_state(Gst.State.PAUSED)
self.is_playing = False
self.app_window.is_playing = False
@Gtk.Template.Callback()
def speed_button(self, button):
......@@ -426,7 +425,7 @@ class ResultsBox(Gtk.Box):
@Gtk.Template.Callback()
def event_box_mouse_click(self, event, data):
if self.is_playing:
if self.app_window.is_playing:
self.pause_button(None)
self.event_box_mouse_action(event, data)
......
......@@ -25,7 +25,6 @@
<object class="GtkBox" id="player_box">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
......@@ -70,7 +69,7 @@
<child type="overlay">
<object class="GtkBox" id="controls_box">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-focus">False</property>
<property name="valign">end</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
......@@ -91,7 +90,6 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Save Audio</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......@@ -119,7 +117,6 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Save Video</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......@@ -162,8 +159,7 @@
<child>
<object class="GtkButton" id="play">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Play</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......@@ -188,9 +184,8 @@
</child>
<child>
<object class="GtkButton" id="pause">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="visible">False</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Pause</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......@@ -238,7 +233,6 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Adjust Speed</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......@@ -274,7 +268,6 @@
<object class="GtkButton" id="fullscreen">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Fullscreen</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......@@ -298,7 +291,6 @@
<child>
<object class="GtkButton" id="unfullscreen">
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Unfullscreen</property>
<property name="opacity">0.80</property>
<property name="halign">center</property>
......
......@@ -66,12 +66,29 @@ class StreamWindow(Handy.ApplicationWindow):
else:
self.show_error_box("Service Failure",
"No strong video server instances found yet. Try again shortly.")
def fullscreen_toggle(self, focus_child):
if self.is_fullscreen:
focus_child.get_child().unfullscreen_button(None)
else:
focus_child.get_child().fullscreen_button(None)
# @Gtk.Template.Callback()
# def keypress_listener(self, widget, ev):
# key = Gdk.keyval_name(ev.keyval)
# if key == "k":
# # do stuff
def play_pause_toggle(self, focus_child):
if self.is_playing:
self.pause_all()
else:
focus_child.get_child().play_button(None)
@Gtk.Template.Callback()
def keypress_listener(self, widget, ev):
key = Gdk.keyval_name(ev.keyval)
focus_child = self.results_list.get_focus_child()
if focus_child:
if key == "Escape":
focus_child.get_child().unfullscreen_button(None)
if key == "space":
self.play_pause_toggle(focus_child)
if key == "f":
self.fullscreen_toggle(focus_child)
@Gtk.Template.Callback()
def swallow_fullscreen_scroll_event(self, event, data):
......@@ -97,6 +114,7 @@ class StreamWindow(Handy.ApplicationWindow):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.is_playing = False
self.is_fullscreen = False
self.strong_instances = []
instances = Instances(app_window = self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment