change window title to current playing video
This commit is contained in:
parent
638985c822
commit
85176956ab
@ -7,10 +7,13 @@ import gi
|
|||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
|
|
||||||
|
WINDOW_TITLE = "Gtk Mediathek Player"
|
||||||
|
|
||||||
class MainApp(Gtk.Window):
|
class MainApp(Gtk.Window):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Gtk.Window.__init__(self, title="Gtk Mediathek Player")
|
Gtk.Window.__init__(self, title=WINDOW_TITLE)
|
||||||
|
|
||||||
|
self._current_mediathek_item = None
|
||||||
|
|
||||||
self.set_default_icon_name("gtkmediathekplayer")
|
self.set_default_icon_name("gtkmediathekplayer")
|
||||||
|
|
||||||
@ -36,9 +39,12 @@ class MainApp(Gtk.Window):
|
|||||||
self._main_container.add(self._main_stack)
|
self._main_container.add(self._main_stack)
|
||||||
|
|
||||||
self._headerbar = self._create_headerbar(True)
|
self._headerbar = self._create_headerbar(True)
|
||||||
|
|
||||||
|
# TODO: standardize widget creation methods
|
||||||
|
self._fullscreen_bar = self._create_headerbar(False)
|
||||||
|
self._fullscreen_bar.set_title(WINDOW_TITLE)
|
||||||
self._create_fullscreen_bar()
|
self._create_fullscreen_bar()
|
||||||
|
|
||||||
# self._main_container.add_overlay(self._create_fullscreen_bar())
|
|
||||||
self._main_container.add_overlay(self._revealer)
|
self._main_container.add_overlay(self._revealer)
|
||||||
self.add(self._main_container)
|
self.add(self._main_container)
|
||||||
|
|
||||||
@ -126,7 +132,7 @@ class MainApp(Gtk.Window):
|
|||||||
|
|
||||||
def _create_fullscreen_bar(self):
|
def _create_fullscreen_bar(self):
|
||||||
self._revealer = Gtk.Revealer()
|
self._revealer = Gtk.Revealer()
|
||||||
self._revealer.add(self._create_headerbar(False))
|
self._revealer.add(self._fullscreen_bar)
|
||||||
self._revealer.set_valign(Gtk.Align.START)
|
self._revealer.set_valign(Gtk.Align.START)
|
||||||
self._revealer.set_vexpand(False)
|
self._revealer.set_vexpand(False)
|
||||||
self._revealer.set_transition_type(
|
self._revealer.set_transition_type(
|
||||||
@ -150,18 +156,36 @@ class MainApp(Gtk.Window):
|
|||||||
self._main_stack.set_visible_child_name(name)
|
self._main_stack.set_visible_child_name(name)
|
||||||
if name != "player":
|
if name != "player":
|
||||||
self._player_widget.pause()
|
self._player_widget.pause()
|
||||||
|
self.set_title(WINDOW_TITLE)
|
||||||
|
self._fullscreen_bar.set_title(WINDOW_TITLE)
|
||||||
else:
|
else:
|
||||||
if active_pane != "player":
|
if active_pane != "player":
|
||||||
if self._player_widget.is_paused():
|
if self._player_widget.is_paused():
|
||||||
self._player_widget.play()
|
self._player_widget.play()
|
||||||
|
|
||||||
|
if self._current_mediathek_item is not None:
|
||||||
|
title = self._current_mediathek_item.get_title()
|
||||||
|
if title is not None:
|
||||||
|
self.set_title(title)
|
||||||
|
|
||||||
def get_active_pane(self):
|
def get_active_pane(self):
|
||||||
return self._main_stack.get_visible_child_name()
|
return self._main_stack.get_visible_child_name()
|
||||||
|
|
||||||
def start_player(self, uri: str):
|
def start_player(self,
|
||||||
|
uri: str,
|
||||||
|
mediathek_item:mr.MediathekViewWebAnswer = None):
|
||||||
if self.get_active_pane() != "player":
|
if self.get_active_pane() != "player":
|
||||||
self.set_active_pane("player")
|
self.set_active_pane("player")
|
||||||
|
|
||||||
|
self._current_mediathek_item = mediathek_item
|
||||||
|
|
||||||
|
if mediathek_item is not None:
|
||||||
|
title = mediathek_item.get_title()
|
||||||
|
if title is not None:
|
||||||
|
self.set_title(title)
|
||||||
|
self._fullscreen_bar.set_title(title)
|
||||||
|
#self._headerbar.set_title(title)
|
||||||
|
|
||||||
self._player_widget.stop()
|
self._player_widget.stop()
|
||||||
self._player_widget.play_from_uri(uri)
|
self._player_widget.play_from_uri(uri)
|
||||||
self._player_widget.play()
|
self._player_widget.play()
|
||||||
|
@ -52,7 +52,8 @@ class PlayerWidget(Gtk.Overlay):
|
|||||||
position_string = tools.seconds_to_timestring(int(position))
|
position_string = tools.seconds_to_timestring(int(position))
|
||||||
duration_string = tools.seconds_to_timestring(int(self._duration))
|
duration_string = tools.seconds_to_timestring(int(self._duration))
|
||||||
|
|
||||||
self._duration_text.set_markup(f"{position_string}/{duration_string}")
|
self._duration_text.set_markup(
|
||||||
|
f"{position_string}/{duration_string}")
|
||||||
|
|
||||||
self._is_update = False
|
self._is_update = False
|
||||||
|
|
||||||
@ -115,7 +116,8 @@ class PlayerWidget(Gtk.Overlay):
|
|||||||
# TODO: replace this deprecated (honestly, i find it disturbing that there is no container or css template)
|
# TODO: replace this deprecated (honestly, i find it disturbing that there is no container or css template)
|
||||||
# already there to do this, such that you are forced to create a custom css
|
# already there to do this, such that you are forced to create a custom css
|
||||||
# snippet and override the default gtk scheme)
|
# snippet and override the default gtk scheme)
|
||||||
box.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(.0,.0,.0,.8))
|
box.override_background_color(
|
||||||
|
Gtk.StateType.NORMAL, Gdk.RGBA(.0, .0, .0, .8))
|
||||||
|
|
||||||
self._controls.add(box)
|
self._controls.add(box)
|
||||||
|
|
||||||
@ -126,8 +128,6 @@ class PlayerWidget(Gtk.Overlay):
|
|||||||
style_context = self._controls.get_style_context()
|
style_context = self._controls.get_style_context()
|
||||||
style_context.add_class(Gtk.STYLE_CLASS_OSD)
|
style_context.add_class(Gtk.STYLE_CLASS_OSD)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self._play_pause_button.connect("clicked", self.toogle_play)
|
self._play_pause_button.connect("clicked", self.toogle_play)
|
||||||
|
|
||||||
def play_from_uri(self, uri: str):
|
def play_from_uri(self, uri: str):
|
||||||
|
Loading…
Reference in New Issue
Block a user