Verified Commit 356d421c authored by Tijder's avatar Tijder

Add windowed fullscreen closes #42

parent 0f8505d1
Pipeline #200790 passed with stage
in 8 minutes and 23 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<!-- interface-css-provider-path plex.css -->
......@@ -46,7 +46,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="_fullscreen_button">
<object class="GtkButton" id="_close_button">
<property name="width_request">50</property>
<property name="height_request">50</property>
<property name="visible">True</property>
......@@ -56,33 +56,65 @@
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-fullscreen-symbolic</property>
<property name="icon_name">media-playback-stop-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="_close_button">
<property name="width_request">50</property>
<property name="height_request">50</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage">
<object class="GtkButton" id="_fullscreen_button">
<property name="width_request">50</property>
<property name="height_request">50</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-playback-stop-symbolic</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-fullscreen-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="_fullscreen_windowed_button">
<property name="width_request">50</property>
<property name="height_request">50</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">video-display-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">2</property>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
......
......@@ -28,6 +28,7 @@ class MediaBox(GObject.Object):
__gsignals__ = {
'fullscreen-clicked': (GObject.SignalFlags.RUN_FIRST, None, ()),
'fullscreen-windowed-clicked': (GObject.SignalFlags.RUN_FIRST, None, ()),
'active': (GObject.SignalFlags.RUN_FIRST, None, (bool,)),
}
......@@ -39,6 +40,7 @@ class MediaBox(GObject.Object):
_skip_forward_button = None
_play_image = None
_fullscreen_button = None
_fullscreen_windowed_button = None
_media_settings = None
_music_popover_menu = None
......@@ -110,6 +112,7 @@ class MediaBox(GObject.Object):
self._boxes.append(box)
box.set_visible(True)
self.__set_fullscreen_button(box._fullscreen_button)
self.__set_fullscreen_windowed_button(box._fullscreen_windowed_button)
self.__set_close_button(box._close_button)
self.__set_title_label(box._title_label)
self.__set_subtitle_label(box._subtitle_label)
......@@ -134,6 +137,14 @@ class MediaBox(GObject.Object):
self.set_reveal_child(False)
def hide_windowed_button(self):
if self._fullscreen_windowed_button != None:
self._fullscreen_windowed_button.hide()
def show_windowed_button(self):
if self._fullscreen_windowed_button != None:
self._fullscreen_windowed_button.show()
def __set_playque_button(self, button):
self._playqueue_button = button
self._playqueue_popover = PlayqueuePopover(self._plex, self._player)
......@@ -182,6 +193,10 @@ class MediaBox(GObject.Object):
self._fullscreen_button = button
self._fullscreen_button.connect("clicked", self.__on_fullscreen_button_clicked)
def __set_fullscreen_windowed_button(self, button):
self._fullscreen_windowed_button = button
self._fullscreen_windowed_button.connect("clicked", self.__on_fullscreen_windowed_button_clicked)
def __set_scale_bar(self, bar):
self._scale_bar = bar
......@@ -216,6 +231,9 @@ class MediaBox(GObject.Object):
def __on_fullscreen_button_clicked(self, button):
self.emit('fullscreen-clicked')
def __on_fullscreen_windowed_button_clicked(self, button):
self.emit('fullscreen-windowed-clicked')
def __on_prev_button_clicked(self, button):
thread = threading.Thread(target=self._player.prev)
thread.daemon = True
......
......@@ -24,6 +24,7 @@ class MediaBoxVideoTop(Gtk.Revealer):
_close_button = GtkTemplate.Child()
_fullscreen_button = GtkTemplate.Child()
_fullscreen_windowed_button = GtkTemplate.Child()
_title_label = GtkTemplate.Child()
_subtitle_label = GtkTemplate.Child()
......
......@@ -16,6 +16,7 @@ class PlayerView(Gtk.Box):
__gsignals__ = {
'fullscreen': (GObject.SignalFlags.RUN_FIRST, None, (bool,)),
'windowed': (GObject.SignalFlags.RUN_FIRST, None, (bool,)),
'view-show-wanted': (GObject.SignalFlags.RUN_FIRST, None, (str,)),
'view-album-wanted': (GObject.SignalFlags.RUN_FIRST, None, (str,)),
'view-artist-wanted': (GObject.SignalFlags.RUN_FIRST, None, (str,))
......@@ -51,6 +52,7 @@ class PlayerView(Gtk.Box):
_progress = 0
_paused = True
_fullscreen = False
_windowed = False
_playing = False
_cover_width = 200
......@@ -92,11 +94,23 @@ class PlayerView(Gtk.Box):
self._controlls_top.set_visible(True)
self._controlls_bottom.set_visible(True)
self._media_box.connect("fullscreen-clicked", self.__on_fullscreen_button_clicked)
self._media_box.connect("fullscreen-windowed-clicked", self.__on_fullscreen_windowed_button_clicked)
self._media_box.connect("active", self.__on_media_box_active)
def __on_fullscreen_button_clicked(self, button):
self.__fullscreen()
def __on_fullscreen_windowed_button_clicked(self, button):
self.__toggle_windowed()
def __toggle_windowed(self):
if self._windowed:
self.__add_extra_widgets()
else:
self.__remove_extra_widgets()
self.emit('windowed', self._windowed)
self._windowed = not self._windowed
def __on_media_box_active(self, mediabox, active):
if active:
self.__stop_controlls_timout()
......@@ -114,6 +128,10 @@ class PlayerView(Gtk.Box):
def set_fullscreen_state(self):
self._fullscreen = True
self._media_box.hide_windowed_button()
self.__remove_extra_widgets()
def __remove_extra_widgets(self):
self._box.hide()
self._event.set_vexpand(True)
self._event.set_size_request(-1, -1)
......@@ -122,6 +140,11 @@ class PlayerView(Gtk.Box):
def set_unfullscreen_state(self):
self._fullscreen = False
self._media_box.show_windowed_button()
self._windowed = False
self.__add_extra_widgets()
def __add_extra_widgets(self):
self.__set_correct_event_size(self._old_screensize)
self._box.show()
self._event.set_vexpand(False)
......@@ -132,6 +155,8 @@ class PlayerView(Gtk.Box):
def __on_playqueue_ended(self, player):
if self._fullscreen == True:
GLib.idle_add(self.__fullscreen)
elif self._windowed == True:
GLib.idle_add(self.__toggle_windowed)
def __on_play_button_clicked(self, button):
self._player.play_pause()
......
......@@ -151,6 +151,7 @@ class PlexWindow(Gtk.ApplicationWindow):
self._player_view = PlayerView(self)
self._player_view.connect("fullscreen", self.__fullscreen)
self._player_view.connect("windowed", self.__windowed)
self._player_view.connect("view-show-wanted", self.__on_go_to_show_clicked)
self._player_view.connect("view-album-wanted", self.__on_go_to_album_clicked)
self._player_view.connect("view-artist-wanted", self.__on_go_to_artist_clicked)
......@@ -540,23 +541,35 @@ class PlexWindow(Gtk.ApplicationWindow):
else:
self.unfullscreen()
def __windowed(self, widged, booleon):
if booleon:
self.__add_extra_widgets()
else:
self.__remove_extra_widgets()
def __remove_extra_widgets(self):
#self._media_box.set_visible(False)
self.sidebar.hide()
self.separator.hide()
self.get_style_context().add_class("black_background")
self._main_scrolled_window.get_style_context().add_class("black_background")
def __add_extra_widgets(self):
#self._media_box.set_visible(True)
self.sidebar.show()
self.separator.show()
self.get_style_context().remove_class("black_background")
self._main_scrolled_window.get_style_context().remove_class("black_background")
def __on_window_state_event(self, widget, event):
if (event.changed_mask == Gdk.WindowState.FULLSCREEN):
if (Gdk.WindowState.FULLSCREEN & int(event.new_window_state)): # Is fullscreen
self.header.set_visible_child_name("content")
#self._media_box.set_visible(False)
self.sidebar.hide()
self.separator.hide()
self._player_view.set_fullscreen_state()
self.get_style_context().add_class("black_background")
self._main_scrolled_window.get_style_context().add_class("black_background")
self.__remove_extra_widgets()
else: # Is not fullscreen
#self._media_box.set_visible(True)
self.sidebar.show()
self.separator.show()
self._player_view.set_unfullscreen_state()
self.get_style_context().remove_class("black_background")
self._main_scrolled_window.get_style_context().remove_class("black_background")
self.__add_extra_widgets()
def __on_show_download_button(self, menu):
......
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