From f98b88834467b0976315905d8267a5d4fa34d46a Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 24 Mar 2018 11:41:25 +0100 Subject: [PATCH] Use overlay for track list on Cover panel (implements #47) --- data/de.coderkun.mcg.gresource.xml | 1 + data/de.coderkun.mcg.gschema.xml | 10 - data/gtk.css | 10 + data/gtk.glade | 788 +++++++++++++---------------- mcg/utils.py | 8 - mcg/widgets.py | 99 +--- 6 files changed, 370 insertions(+), 546 deletions(-) diff --git a/data/de.coderkun.mcg.gresource.xml b/data/de.coderkun.mcg.gresource.xml index 02969fc..1cfd6c8 100644 --- a/data/de.coderkun.mcg.gresource.xml +++ b/data/de.coderkun.mcg.gresource.xml @@ -7,5 +7,6 @@ gtk.menu.ui mcg.svg noise-texture.png + mcg-tracklist.svg diff --git a/data/de.coderkun.mcg.gschema.xml b/data/de.coderkun.mcg.gschema.xml index 57e9896..241666a 100644 --- a/data/de.coderkun.mcg.gschema.xml +++ b/data/de.coderkun.mcg.gschema.xml @@ -1,10 +1,5 @@ - - - - - @@ -47,11 +42,6 @@ Last selected panel The index of the last selected panel. - - 'large' - Size of tracklist on cover panel - The size of the tracklist on the cover panel. - 150 diff --git a/data/gtk.css b/data/gtk.css index 7588f26..469b262 100644 --- a/data/gtk.css +++ b/data/gtk.css @@ -18,6 +18,16 @@ font-weight:bold; } +revealer.sidebar > * { + background-color:alpha(@theme_bg_color, 0.8); + box-shadow:0 0 10px @theme_bg_color; + margin-left:20px +} + +revealer.sidebar scale mark indicator { + margin-right:5px; +} + actionbar { background-color:@theme_unfocused_bg_color; } diff --git a/data/gtk.glade b/data/gtk.glade index a49fa39..8e12dab 100644 --- a/data/gtk.glade +++ b/data/gtk.glade @@ -1,91 +1,7 @@ - + - - False - - - True - False - vertical - - - True - False - vertical - - - True - False - Tracklist - - - False - True - 0 - - - - - large tracklist - True - True - False - True - True - - - - False - True - 1 - - - - - small tracklist - True - True - False - True - True - cover-toolbar-tracklist-large - - - - False - True - 2 - - - - - hide tracklist - True - True - False - True - True - cover-toolbar-tracklist-large - - - - False - True - 3 - - - - - False - True - 2 - - - - - True False @@ -364,6 +280,325 @@ + + + headerbar + True + False + True + + + True + True + Connect or disconnect + + + + + 1 + + + + + True + False + + + 2 + + + + + True + True + True + Switch between play and pause + + + + True + False + media-playback-start + + + + + 3 + + + + + True + True + False + True + Adjust the volume + none + vertical + audio-volume-muted + audio-volume-high + audio-volume-low + audio-volume-medium + + + + + + True + True + center + center + none + + + + + True + True + center + center + none + + + + + 4 + + + + + headerbar-connection + True + False + 100 + crossfade + + + True + False + Connect to MPD + + + + + + page1 + page1 + + + + + True + False + panelstack + + + page0 + page0 + 1 + + + + + 4 + + + + + True + False + + + True + False + 6 + end + + + True + True + True + Show the cover in fullscreen mode + + + + True + False + view-fullscreen-symbolic + + + + + + False + False + 0 + True + + + + + cover + + + + + True + False + 6 + end + + + + + + server + 1 + + + + + True + False + 6 + end + + + True + True + True + Select multiple albums + + + + True + False + object-select-symbolic + + + + + False + False + 0 + True + + + + + True + True + True + Clear the playlist + + + + True + False + edit-clear + + + + + False + False + 1 + True + + + + + playlist + 2 + + + + + True + False + 6 + end + + + True + True + True + Search the library + + + + True + False + system-search-symbolic + + + + + + False + False + 0 + True + + + + + True + True + True + Select multiple albums + + + + True + False + object-select-symbolic + + + + + False + False + 1 + True + + + + + True + True + True + Settings and actions + library-toolbar-popover + + + True + False + open-menu-symbolic + + + + + False + False + 2 + True + + + + + library + 3 + + + + + end + 4 + + + + True @@ -1056,10 +1291,9 @@ - + True False - True True @@ -1108,20 +1342,20 @@ - True - True - 0 + -1 - + True False + end slide-right True True + start never never @@ -1133,12 +1367,17 @@ True False + start + 5 + 5 + 5 + 5 vertical True False - 5 + 5 5 5 True @@ -1146,8 +1385,10 @@ True False + start Album True + 0 0 @@ -1158,8 +1399,10 @@ True False + start Date True + 0 0 @@ -1170,8 +1413,10 @@ True False + start Artist True + 0 0 @@ -1195,6 +1440,8 @@ True start vertical + False + 0 False @@ -1202,6 +1449,7 @@ True True + end 1 @@ -1211,12 +1459,11 @@ + - - False - True - 1 - @@ -1695,347 +1942,6 @@ - - - headerbar - True - False - True - - - True - True - Connect or disconnect - - - - - 1 - - - - - True - False - - - 2 - - - - - True - True - True - Switch between play and pause - - - - True - False - media-playback-start - - - - - 3 - - - - - True - True - False - True - Adjust the volume - none - vertical - audio-volume-muted - audio-volume-high - audio-volume-low - audio-volume-medium - - - - - - True - True - center - center - none - - - - - True - True - center - center - none - - - - - 4 - - - - - headerbar-connection - True - False - 100 - crossfade - - - True - False - Connect to MPD - - - - - - page1 - page1 - - - - - True - False - panelstack - - - page0 - page0 - 1 - - - - - 4 - - - - - True - False - - - True - False - 6 - end - - - True - True - True - Show the cover in fullscreen mode - - - - True - False - view-fullscreen-symbolic - - - - - - False - False - 0 - True - - - - - True - True - True - Settings and actions - cover-toolbar-popover - - - True - False - open-menu-symbolic - - - - - False - False - 1 - True - - - - - cover - - - - - True - False - 6 - end - - - - - - server - 1 - - - - - True - False - 6 - end - - - True - True - True - Select multiple albums - - - - True - False - object-select-symbolic - - - - - False - False - 0 - True - - - - - True - True - True - Clear the playlist - - - - True - False - edit-clear - - - - - False - False - 1 - True - - - - - playlist - 2 - - - - - True - False - 6 - end - - - True - True - True - Search the library - - - - True - False - system-search-symbolic - - - - - - False - False - 0 - True - - - - - True - True - True - Select multiple albums - - - - True - False - object-select-symbolic - - - - - False - False - 1 - True - - - - - True - True - True - Settings and actions - library-toolbar-popover - - - True - False - open-menu-symbolic - - - - - False - False - 2 - True - - - - - library - 3 - - - - - end - 5 - - - - @@ -2054,6 +1960,9 @@ http://www.suruatoel.xyz/codes/mcg mcg.svg gpl-3-0 + + + False @@ -2081,8 +1990,5 @@ - - - diff --git a/mcg/utils.py b/mcg/utils.py index 03da77c..d850edc 100644 --- a/mcg/utils.py +++ b/mcg/utils.py @@ -77,14 +77,6 @@ class Utils: -class TracklistSize: - LARGE = 0 - SMALL = 1 - HIDDEN = 2 - - - - class SortOrder: ARTIST = 0 TITLE = 1 diff --git a/mcg/widgets.py b/mcg/widgets.py index 04b5c9f..b5317fa 100644 --- a/mcg/widgets.py +++ b/mcg/widgets.py @@ -17,7 +17,6 @@ from gi.repository import Gtk, Gdk, GObject, GdkPixbuf, GLib, Gio from mcg import client from mcg.utils import SortOrder -from mcg.utils import TracklistSize from mcg.utils import Utils from mcg.zeroconf import ZeroconfProvider @@ -83,7 +82,6 @@ class Window(): SETTING_WINDOW_SIZE = 'window-size' SETTING_WINDOW_MAXIMIZED = 'window-maximized' SETTING_PANEL = 'panel' - SETTING_TRACKLIST_SIZE = 'tracklist-size' SETTING_ITEM_SIZE = 'item-size' SETTING_SORT_ORDER = 'sort-order' SETTING_SORT_TYPE = 'sort-type' @@ -133,7 +131,6 @@ class Window(): if use_keyring: self._connection_panel.set_password(keyring.get_password(ZeroconfProvider.KEYRING_SYSTEM, ZeroconfProvider.KEYRING_USERNAME)) self._connection_panel.set_image_dir(self._settings.get_string(Window.SETTING_IMAGE_DIR)) - self._panels[Window._PANEL_INDEX_COVER].set_tracklist_size(self._settings.get_enum(Window.SETTING_TRACKLIST_SIZE)) self._panels[Window._PANEL_INDEX_PLAYLIST].set_item_size(self._settings.get_int(Window.SETTING_ITEM_SIZE)) self._panels[Window._PANEL_INDEX_LIBRARY].set_item_size(self._settings.get_int(Window.SETTING_ITEM_SIZE)) self._panels[Window._PANEL_INDEX_LIBRARY].set_sort_order(self._settings.get_enum(Window.SETTING_SORT_ORDER)) @@ -147,7 +144,6 @@ class Window(): self._connection_panel.connect('connection-changed', self.on_connection_panel_connection_changed) self._panels[Window._PANEL_INDEX_SERVER].connect('change-output-device', self.on_server_panel_output_device_changed) self._panels[Window._PANEL_INDEX_COVER].connect('toggle-fullscreen', self.on_cover_panel_toggle_fullscreen) - self._panels[Window._PANEL_INDEX_COVER].connect('tracklist-size-changed', self.on_cover_panel_tracklist_size_changed) self._panels[Window._PANEL_INDEX_COVER].connect('set-song', self.on_cover_panel_set_song) self._panels[Window._PANEL_INDEX_PLAYLIST].connect('clear-playlist', self.on_playlist_panel_clear_playlist) self._panels[Window._PANEL_INDEX_PLAYLIST].connect('remove', self.on_playlist_panel_remove) @@ -167,7 +163,6 @@ class Window(): self._mcg.connect_signal(client.Client.SIGNAL_LOAD_ALBUMS, self.on_mcg_load_albums) self._mcg.connect_signal(client.Client.SIGNAL_ERROR, self.on_mcg_error) self._settings.connect('changed::'+Window.SETTING_PANEL, self.on_settings_panel_changed) - self._settings.connect('changed::'+Window.SETTING_TRACKLIST_SIZE, self.on_settings_tracklist_size_changed) self._settings.connect('changed::'+Window.SETTING_ITEM_SIZE, self.on_settings_item_size_changed) self._settings.connect('changed::'+Window.SETTING_SORT_ORDER, self.on_settings_sort_order_changed) self._settings.connect('changed::'+Window.SETTING_SORT_TYPE, self.on_settings_sort_type_changed) @@ -315,10 +310,6 @@ class Window(): self._appwindow.unfullscreen() - def on_cover_panel_tracklist_size_changed(self, widget, size): - self._settings.set_enum(Window.SETTING_TRACKLIST_SIZE, size) - - def on_cover_panel_set_song(self, widget, pos, time): self._mcg.seek(pos, time) @@ -422,11 +413,6 @@ class Window(): self._stack.set_visible_child(self._panels[panel_index].get()) - def on_settings_tracklist_size_changed(self, settings, key): - size = settings.get_enum(key) - self._panels[Window._PANEL_INDEX_COVER].set_tracklist_size(size) - - def on_settings_item_size_changed(self, settings, key): size = settings.get_int(key) self._panels[Window._PANEL_INDEX_PLAYLIST].set_item_size(size) @@ -927,7 +913,6 @@ class ServerPanel(GObject.GObject): class CoverPanel(GObject.GObject): __gsignals__ = { 'toggle-fullscreen': (GObject.SIGNAL_RUN_FIRST, None, ()), - 'tracklist-size-changed': (GObject.SIGNAL_RUN_FIRST, None, (int,)), 'set-song': (GObject.SIGNAL_RUN_FIRST, None, (int, int,)) } @@ -939,7 +924,6 @@ class CoverPanel(GObject.GObject): self._cover_pixbuf = None self._timer = None self._properties = {} - self._tracklist_size = TracklistSize.LARGE self._icon_theme = Gtk.IconTheme.get_default() self._fullscreened = False @@ -949,12 +933,6 @@ class CoverPanel(GObject.GObject): self._toolbar = builder.get_object('cover-toolbar') # Toolbar menu self._toolbar_fullscreen_button = builder.get_object('cover-toolbar-fullscreen') - self._toolbar_tracklist = builder.get_object('cover-toolbar-tracklist') - self._toolbar_tracklist_buttons = { - TracklistSize.LARGE: builder.get_object('cover-toolbar-tracklist-large'), - TracklistSize.SMALL: builder.get_object('cover-toolbar-tracklist-small'), - TracklistSize.HIDDEN: builder.get_object('cover-toolbar-tracklist-hidden') - } # Cover self._cover_stack = builder.get_object('cover-stack') self._cover_spinner = builder.get_object('cover-spinner') @@ -971,7 +949,6 @@ class CoverPanel(GObject.GObject): self._album_artist_label = builder.get_object('cover-artist') # Songs self._songs_scale = builder.get_object('cover-songs') - self._songs_scale.override_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1)) # Initial actions GObject.idle_add(self._enable_tracklist) @@ -988,7 +965,6 @@ class CoverPanel(GObject.GObject): def get_signal_handlers(self): return { 'on_cover-toolbar-fullscreen_clicked': self.on_fullscreen_clicked, - 'on_cover-toolbar-tracklist_toggled': self.on_tracklist_togged, 'on_cover-box_button_press_event': self.on_cover_box_pressed, 'on_cover-scroll_size_allocate': self.on_cover_size_allocate, 'on_cover-songs_button_press_event': self.on_songs_start_change, @@ -1000,12 +976,6 @@ class CoverPanel(GObject.GObject): self.emit('toggle-fullscreen') - def on_tracklist_togged(self, widget): - if widget.get_active(): - size = [key for key, value in self._toolbar_tracklist_buttons.items() if value is widget][0] - self._change_tracklist_size(size) - - def on_cover_box_pressed(self, widget, event): if self._current_album and event.type == Gdk.EventType._2BUTTON_PRESS: self.emit('toggle-fullscreen') @@ -1035,36 +1005,13 @@ class CoverPanel(GObject.GObject): self.emit('set-song', pos, time) - def set_tracklist_size(self, size): - if self._tracklist_size != size: - button = self._toolbar_tracklist_buttons[size] - if button and not button.get_active(): - button.set_active(True) - self._change_tracklist_size(size, False) - - - def get_tracklist_size(self): - return self._tracklist_size - - def set_album(self, album): if album: # Set labels - self._album_title_label.set_label( - GObject.markup_escape_text( - album.get_title() - ) - ) - self._album_date_label.set_markup( - GObject.markup_escape_text( - ', '.join(album.get_dates()) - ) - ) - self._album_artist_label.set_markup( - GObject.markup_escape_text( - ', '.join(album.get_albumartists()) - ) - ) + self._album_title_label.set_label(album.get_title()) + self._album_date_label.set_label(', '.join(album.get_dates())) + self._album_artist_label.set_label(', '.join(album.get_albumartists())) + # Set tracks self._set_tracks(album) @@ -1098,7 +1045,6 @@ class CoverPanel(GObject.GObject): def set_fullscreen(self, active): if active: - self._change_tracklist_size(TracklistSize.HIDDEN, False, False) self._cover_box.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1)) GObject.idle_add(self._resize_image) # Hide curser @@ -1108,7 +1054,6 @@ class CoverPanel(GObject.GObject): self._fullscreened = True else: self._fullscreened = False - self._change_tracklist_size(self._tracklist_size, False, False) self._cover_box.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0)) GObject.idle_add(self._resize_image) # Reset cursor @@ -1145,46 +1090,26 @@ class CoverPanel(GObject.GObject): cur_length = cur_length + 1 self._songs_scale.add_mark( cur_length, - Gtk.PositionType.RIGHT, + Gtk.PositionType.RIGHT, GObject.markup_escape_text( Utils.create_track_title(track) ) ) length = length + track.get_length() - self._songs_scale.add_mark(length, Gtk.PositionType.RIGHT, "{0[0]:02d}:{0[1]:02d} minutes".format(divmod(length, 60))) + self._songs_scale.add_mark( + length, + Gtk.PositionType.RIGHT, + "{0[0]:02d}:{0[1]:02d} minutes".format(divmod(length, 60)) + ) def _enable_tracklist(self): if self._current_album: # enable - self._toolbar_tracklist.set_sensitive(True) - self._change_tracklist_size(self._tracklist_size, False, False) + self._info_revealer.set_reveal_child(True) else: # disable - self._toolbar_tracklist.set_sensitive(False) - self._change_tracklist_size(TracklistSize.HIDDEN, False, False) - - - def _change_tracklist_size(self, size, notify=True, store=True): - # Set tracklist size - if not self._fullscreened: - if size == TracklistSize.LARGE: - self._panel.set_homogeneous(True) - self._info_revealer.set_reveal_child(True) - elif size == TracklistSize.SMALL: - self._panel.set_homogeneous(False) - self._info_revealer.set_reveal_child(True) - else: - self._panel.set_homogeneous(False) - self._info_revealer.set_reveal_child(False) - # Store size - if store: - self._tracklist_size = size - # Notify signals - if notify: - self.emit('tracklist-size-changed', size) - # Resize image - GObject.idle_add(self._resize_image) + self._info_revealer.set_reveal_child(False) def _playing(self):