Verified Commit 05bf0f7b authored by Todd Weaver's avatar Todd Weaver
Browse files

Adding autoplay toggle and autoplay next logic

parent 4dbf9041
......@@ -26,6 +26,8 @@ from .help import Help
class Menu(Gtk.PopoverMenu):
__gtype_name__ = 'Menu'
autoplay_toggle = Gtk.Template.Child()
def __init__(self, app_window, **kwargs):
super().__init__(**kwargs)
......@@ -42,4 +44,3 @@ class Menu(Gtk.PopoverMenu):
help = Help()
help.props.transient_for = self.app_window
help.present()
......@@ -169,6 +169,7 @@ class ResultsBox(Gtk.Box):
if int(position / Gst.SECOND) >= int(duration / Gst.SECOND):
GLib.timeout_add(500, self.null_out_player)
GLib.timeout_add(600, self.app_window.autoplay_next)
try:
# block seek slider function so it doesn't loop itself
......
......@@ -14,6 +14,53 @@
<property name="margin-bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-start">6</property>
<property name="label" translatable="yes">Autoplay</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="autoplay_toggle">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="preferences_button">
<property name="visible">True</property>
......
......@@ -64,8 +64,8 @@ class StreamWindow(Handy.ApplicationWindow):
instances = Instances(app_window = self)
instances.get_strong_instances()
menu = Menu(app_window = self)
self.menu_button.set_popover(menu)
self.menu = Menu(app_window = self)
self.menu_button.set_popover(self.menu)
provider = Gtk.CssProvider()
provider.load_from_resource('/sm/puri/Stream/ui/stream.css')
......@@ -163,6 +163,15 @@ class StreamWindow(Handy.ApplicationWindow):
# def open_primary_menu(self, widget, ev):
# print("in open primary menu")
def autoplay_next(self):
if self.menu.autoplay_toggle.get_active():
focus_child = self.results_list.get_focus_child()
if focus_child:
focus_index = focus_child.get_index()
focus_next = self.results_list.get_child_at_index(focus_index + 1)
if focus_next:
self.play_pause_toggle(focus_next)
@Gtk.Template.Callback()
def keypress_listener(self, widget, ev):
focus_child = self.results_list.get_focus_child()
......
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