[gnome-music/wip/jfelder/open-audio-files: 6/6] application: Handle files opening
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/open-audio-files: 6/6] application: Handle files opening
- Date: Sat, 8 Jan 2022 13:52:08 +0000 (UTC)
commit 386e6a0dde493c72ab06a5f220cd0e27cbfd8908
Author: Jean Felder <jfelder src gnome org>
Date: Fri Dec 3 16:36:40 2021 +0100
application: Handle files opening
This allows to display a FilesView populated with the audio files
received from command line. In that event, the FilesView is displayed
instead of the AlbumsView.
Closes: https://gitlab.gnome.org/GNOME/gnome-music/-/issues/268
data/org.gnome.Music.desktop.in.in | 3 ++-
gnomemusic/application.py | 7 ++++++-
gnomemusic/window.py | 6 +++++-
3 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.Music.desktop.in.in b/data/org.gnome.Music.desktop.in.in
index 62dfd398b..601ebe9ee 100644
--- a/data/org.gnome.Music.desktop.in.in
+++ b/data/org.gnome.Music.desktop.in.in
@@ -4,10 +4,11 @@ GenericName=Music Player
Comment=Play and organize your music collection
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=@icon@
-Exec=gnome-music
+Exec=gnome-music %U
Terminal=false
Type=Application
Categories=GNOME;GTK;AudioVideo;Player;Audio;
# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list
MUST also end with a semicolon!
Keywords=Music;Player;
StartupNotify=true
+MimeType=application/ogg;application/x-ogg;application/x-ogm-audio;audio/aac;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/vnd.rn-realaudio;audio/vorbis;audio/x-flac;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-oggflac;audio/x-pn-realaudio;audio/x-scpls;audio/x-speex;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;x-content/audio-player;audio/x-aac;audio/m4a;audio/x-m4a;audio/mp3;audio/ac3;audio/flac;application/xspf+xml;audio/x-opus+ogg;application/vnd.apple.mpegurl
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index c92a6aa1e..e9ba6ded4 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -31,6 +31,7 @@
# delete this exception statement from your version.
from gettext import gettext as _
+from typing import List
from gi.repository import Gtk, Gio, GLib, Gdk, GObject
@@ -55,7 +56,7 @@ class Application(Gtk.Application):
def __init__(self, application_id):
super().__init__(
application_id=application_id,
- flags=Gio.ApplicationFlags.FLAGS_NONE)
+ flags=Gio.ApplicationFlags.HANDLES_OPEN)
self.props.resource_base_path = "/org/gnome/Music"
GLib.set_application_name(_("Music"))
GLib.set_prgname(application_id)
@@ -218,6 +219,10 @@ class Application(Gtk.Application):
about.props.transient_for = self._window
about.present()
+ def do_open(self, files: List[Gio.File], n_files: int, hint: str) -> None:
+ self.props.coregrilo.load_files(files)
+ self.do_activate()
+
def do_startup(self):
Gtk.Application.do_startup(self)
self._set_actions()
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 5bee676a6..0bb50e617 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -259,7 +259,11 @@ class Window(Handy.ApplicationWindow):
# The "visible-child" notification ensures that the AlbumView
# appears as selected by the stack switcher on launch.
- self._stack.props.visible_child = self.views[View.ALBUM]
+ if self.views[View.FILES].props.visible:
+ self._stack.props.visible_child = self.views[View.FILES]
+ else:
+ self._stack.props.visible_child = self.views[View.ALBUM]
+
self._stack.notify("visible-child")
self._stack.props.transition_type = Gtk.StackTransitionType.CROSSFADE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]