music icon indicating copy to clipboard operation
music copied to clipboard

Open song or folder from Music

Open diogopessoa opened this issue 2 years ago • 12 comments

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

diogopessoa avatar Jun 17 '22 16:06 diogopessoa

+1

I think it is essential for a music player to have a library function, at the current state, it is only useful to play a few files.

TwinTusks avatar Aug 26 '22 01:08 TwinTusks

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 avatar Mar 27 '23 11:03 jeremypw

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 avatar Mar 27 '23 12:03 jeremypw

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 avatar Mar 27 '23 12:03 jeremypw

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.

jeremypw avatar Mar 27 '23 16:03 jeremypw

Okay, will work on it ASAP

ghost avatar Mar 27 '23 17:03 ghost

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

jeremypw avatar Mar 28 '23 11:03 jeremypw

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

ghost avatar Mar 29 '23 18:03 ghost

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

jeremypw avatar Mar 29 '23 19:03 jeremypw

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?

ghost avatar Apr 01 '23 13:04 ghost

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

lenemter avatar Apr 01 '23 13:04 lenemter

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

ghost avatar Apr 02 '23 09:04 ghost