elementary / music

Music player and library designed for elementary OS
https://elementary.io
GNU General Public License v3.0
145 stars 49 forks source link

Open song or folder from Music #716

Open diogopessoa opened 2 years ago

diogopessoa commented 2 years ago

Problem

Music doesn't have an option to open song or folder directly from the app.

Proposal

Have option to open File or Folder directly from Music.

Prior Art (Optional)

No response

jeremypw commented 1 year ago

Firstly, you need to base your new branch on the main branch of Music which the current focus of development (I am assuming you know the essentials of development with git, Gtk4 and the Vala language). I am not that familiar with Music code but I would imagine a possible solution would be to place a button either in the headerbar at the top of the playlist or in an actionbar at the bottom which when pressed launches a Gtk.FileChooser (to be replaced by Gtk.FileDialog when available) suitably configured to allow selection of multiple music files (or a folder). The response can then be used to form an array of GLib.Files (FIle[]) which can be passed to the playback manager in the same way as the open function in Application.vala does. You could look at the action_open and action_open_folder methods in Code for an idea how to use FileChooserNative (although that is in Gtk3 so may need some modification).

Probably best to get approval from the UX team for this feature (perhaps mockup something) before getting too deep into the coding.

jeremypw commented 1 year ago

Not sure how you would do this without some kind of activatable widget to click on and a filechooser dialog - there are multiple possibilities for visual details. You could also implement a keyboard accelerator but would need to make it discoverable.

jeremypw commented 1 year ago

But I thought this issue was about not using Files?. Being able to open folders in Music from Files is a different issue see #709.

jeremypw commented 1 year ago

Should be able to fix #709 by amending the .desktop file to indicate that the app is capable of handling a folder uri as an opening argument. Files should then show Music in the "Open in" submenu when secondary-clicking on a folder. Then fix the playback manager so that it can handle being fed a folder - converting its contents to an array of music files.

ghost commented 1 year ago

Okay, will work on it ASAP

jeremypw commented 1 year ago

@aitor-gomila Thanks for making the effort to fix the issue you raised! If you need any help or a review let me know.

ghost commented 1 year ago

@jeremypw Thanks you too! Where is the .desktop file in the project source?

jeremypw commented 1 year ago

@aitor-gomila The desktop file is created from a template found at /data/music.desktop.in.

ghost commented 1 year ago

It's being very hard for me to find docs. I can't go to definition on GNOME Builder. How do you stat on a File(GFile) to see if it's a file or a folder?

lenemter commented 1 year ago

@aitor-gomila You can use https://valadoc.org/glib-2.0/GLib.FileUtils.test.html FileUtils.test (path, FileTest.IS_DIR)

ghost commented 1 year ago

Pushed a commit that should allow to open folders directly. The code is messy, can someone give me feedback on how to improve it? #747