From 9557f67d94d0655982a687f93e3c12bbc34b883b Mon Sep 17 00:00:00 2001 From: zehkira <9485872-zehkira@users.noreply.gitlab.com> Date: Thu, 13 Nov 2025 11:37:06 +0100 Subject: [PATCH] Add playlists directory button --- source/monophony/playlists.py | 8 ++++---- source/monophony/ui/pages/home_page.py | 11 +++++++++++ source/monophony/ui/row_groups/queueable_row_group.py | 7 +++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source/monophony/playlists.py b/source/monophony/playlists.py index 467d759..310c076 100644 --- a/source/monophony/playlists.py +++ b/source/monophony/playlists.py @@ -9,18 +9,18 @@ from monophony.data import Artist, Group, Song from gi.repository import GLib -def _get_directory() -> str: +def get_directory() -> str: return os.getenv( 'XDG_CONFIG_HOME', os.path.expanduser('~/.config') ) + '/' + NAME def _get_file_path() -> str: - return _get_directory() + '/playlists.json' + return get_directory() + '/playlists.json' def _get_external_file_path() -> str: - return _get_directory() + '/external-playlists.json' + return get_directory() + '/external-playlists.json' def add(playlist: Group) -> str: @@ -183,7 +183,7 @@ def _write(playlists: list[Group] | None=None, ext_playlists: list[Group] | None ) lists_path = _get_file_path() ext_lists_path = _get_external_file_path() - os.makedirs(_get_directory(), exist_ok=True) + os.makedirs(get_directory(), exist_ok=True) if playlists is not None: serialized_playlists = {} diff --git a/source/monophony/ui/pages/home_page.py b/source/monophony/ui/pages/home_page.py index bc880f5..55eb353 100644 --- a/source/monophony/ui/pages/home_page.py +++ b/source/monophony/ui/pages/home_page.py @@ -72,6 +72,16 @@ class HomePage(Page): weakref.ref(self) ) + open_dir_button = Gtk.Button.new_from_icon_name('folder-symbolic') + open_dir_button.props.tooltip_text = _('Playlists Directory') + open_dir_button.connect( + 'clicked', + lambda _button: + Gio.AppInfo.launch_default_for_uri( + 'file://' + playlists.get_directory() + ) + ) + self._playlists_group = EditableGroupRowGroup() self._playlists_group.props.title = _('Your Playlists') self._playlists_group.props.margin_start = 12 @@ -126,6 +136,7 @@ class HomePage(Page): lambda _group, playlist, ref: HomePage._on_delete_playlist(ref(), playlist), weakref.ref(self) ) + self._playlists_group.props.header_suffix.prepend(open_dir_button) no_playlists_group = Adw.PreferencesGroup() no_playlists_group.props.title = _('Your Playlists') diff --git a/source/monophony/ui/row_groups/queueable_row_group.py b/source/monophony/ui/row_groups/queueable_row_group.py index d1aa64e..d604521 100644 --- a/source/monophony/ui/row_groups/queueable_row_group.py +++ b/source/monophony/ui/row_groups/queueable_row_group.py @@ -24,7 +24,11 @@ class QueueableRowGroup(PlayableRowGroup): weakref.ref(self) ) - self.props.header_suffix = play_button + box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) + box.props.spacing = 6 + box.append(play_button) + + self.props.header_suffix = box @GObject.Signal(name='queue-song', arg_types=(object,)) def _queue_song(self, _song: Song): @@ -42,4 +46,3 @@ class QueueableRowGroup(PlayableRowGroup): def on_play_all(self): group = Group(songs=[row_ref().song for row_ref in self._rows]) self.emit('play', group.songs[0], group) - -- GitLab