From 245f9cd3b0943a08837c0942bdf3454170919417 Mon Sep 17 00:00:00 2001 From: Marek Mosiewicz Date: Wed, 22 Mar 2023 22:20:55 +0100 Subject: [PATCH 1/3] Update metadata to Gnome 44 --- radio@hslbck.gmail.com/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio@hslbck.gmail.com/metadata.json b/radio@hslbck.gmail.com/metadata.json index b0ad2a0..8ffadff 100644 --- a/radio@hslbck.gmail.com/metadata.json +++ b/radio@hslbck.gmail.com/metadata.json @@ -1,5 +1,5 @@ { - "shell-version": ["43"], + "shell-version": ["43","44"], "uuid": "radio@hslbck.gmail.com", "name": "Internet Radio", "description": "Listen to an Internet Radio Stream", From d2ac42525e4d0ba05498c8be959f157415dc30cf Mon Sep 17 00:00:00 2001 From: Marek Mosiewicz Date: Wed, 22 Mar 2023 22:23:50 +0100 Subject: [PATCH 2/3] Update README to reflect support for Gnome 44 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb3ab3d..a9075a6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A GNOME Shell extension for listening to internet radio streams. ### Features -* Supports GNOME Shell 43 - for older versions see [releases] +* Supports GNOME Shell 43 and 44 - for older versions see [releases] * Manage internet radio streams * Middle click to start/stop last played station * Cyrillic tag support - see [charset conversion] From de37397bc88759e205364158890fc3e123e0cbc3 Mon Sep 17 00:00:00 2001 From: Marek Mosiewicz Date: Tue, 2 May 2023 20:41:14 +0200 Subject: [PATCH 3/3] Possibility to change lock behaviour Added option to play/stop after screen lock Added option to resume after unlock if radio was playing. For some reason this does not work --- radio@hslbck.gmail.com/extension.js | 64 ++++++++++++++--- radio@hslbck.gmail.com/metadata.json | 3 +- radio@hslbck.gmail.com/prefs.js | 69 ++++++++++++++++++- ...g.gnome.shell.extensions.radio.gschema.xml | 15 ++++ 4 files changed, 139 insertions(+), 12 deletions(-) diff --git a/radio@hslbck.gmail.com/extension.js b/radio@hslbck.gmail.com/extension.js index 4ef48cf..b65785f 100644 --- a/radio@hslbck.gmail.com/extension.js +++ b/radio@hslbck.gmail.com/extension.js @@ -2,22 +2,66 @@ Copyright (C) 2014-2022 hslbck This file is distributed under the same license as the gnome-shell-extension-radio package. */ - +const Main = imports.ui.main; const ExtensionUtils = imports.misc.extensionUtils; -const Extension = ExtensionUtils.getCurrentExtension(); -const RadioMenu = Extension.imports.radioMenu; +const Me = ExtensionUtils.getCurrentExtension(); +const RadioMenu = Me.imports.radioMenu; +const Prefs = Me.imports.prefs; // init with translation support -function init() { - ExtensionUtils.initTranslations(); +function init(meta) { + ExtensionUtils.initTranslations(); + return new Extension(); } -// build and add the extension -function enable() { +class Extension { + constructor() { + this._sessionId = null; + this._radioIsOn = false; + } + + _onSessionModeEvent(session) { + if (session.currentMode === 'user' || session.parentMode === 'user') { + if(Prefs._settings.get_boolean(Prefs.SETTING_PLAY_AFTER_LOCK) === false){ + //radio was removed so add it again + this.show(); + //radio was playing and resume is set + if(Prefs._settings.get_boolean(Prefs.SETTING_RESUME_AFTER_UNLOCK) === true + && this._radioIsOn === true){ + RadioMenu._onPlayButtonClicked(); + } + } + } else if (session.currentMode === 'unlock-dialog') { + if(Prefs._settings.get_boolean(Prefs.SETTING_PLAY_AFTER_LOCK) === false){ + this._radioIsOn = RadioMenu.isPlaying + this.hide(); + } + } + } + + // build and add the extension + enable() { + //register session events + if(this._sessionId == null){ + this._sessionId = Main.sessionMode.connect('updated', + this._onSessionModeEvent.bind(this)); + } + this.show(); + } + + // stop playing and destroy extension content + disable() { + this.hide(); + } + show(){ RadioMenu.addToPanel(); -} + } -// stop playing and destroy extension content -function disable() { + hide(){ RadioMenu.removeFromPanel(); + } } + + + + diff --git a/radio@hslbck.gmail.com/metadata.json b/radio@hslbck.gmail.com/metadata.json index 8ffadff..5a7b035 100644 --- a/radio@hslbck.gmail.com/metadata.json +++ b/radio@hslbck.gmail.com/metadata.json @@ -4,7 +4,8 @@ "name": "Internet Radio", "description": "Listen to an Internet Radio Stream", "settings-schema": "org.gnome.shell.extensions.radio", + "session-modes":["user", "unlock-dialog"], "gettext-domain": "radio@hslbck.gmail.com", "url": "https://github.com/hslbck/gnome-shell-extension-radio", - "version": 21 + "version": 22 } diff --git a/radio@hslbck.gmail.com/prefs.js b/radio@hslbck.gmail.com/prefs.js index d3f2962..9c0d4af 100644 --- a/radio@hslbck.gmail.com/prefs.js +++ b/radio@hslbck.gmail.com/prefs.js @@ -1,6 +1,7 @@ /* Copyright (C) 2016 - 2022 hslbck Copyright (C) 2017 Justinas Narusevicius + Copyright (C) 2023 Marek Mosiewicz This file is distributed under the same license as the gnome-shell-extension-radio package. */ @@ -20,6 +21,9 @@ const Convert = Extension.imports.convertCharset; const SETTING_USE_MEDIA_KEYS = 'use-media-keys'; const SETTING_TITLE_NOTIFICATION = 'title-notification'; +const SETTING_PLAY_AFTER_LOCK = 'play-after-lock'; +const SETTING_RESUME_AFTER_UNLOCK = 'resume-after-unlock'; +const SETTING_RESUME_AFTER_NETWORK_RECONNECT = 'resume-after-network-reconnect'; const SETTING_SHOW_TITLE_IN_PANEL = 'show-title-in-panel'; const SETTING_SHOW_VOLUME_ADJUSTMENT_SLIDER = 'show-volume-adjustment-slider'; const SETTING_ENABLE_SEARCH_PROVIDER = 'enable-search-provider'; @@ -600,11 +604,74 @@ var GeneralPane = GObject.registerClass( this._addTitleNotificationsSwitch(); this._addShowTitleInPanelSwitch(); this._addEnableMediaKeysSwitch(); - this._addShowVolumeAdjustmentSliderSwitch(); + this._addPlayAfterScreenLock(); + this._addResumeAfterScreenUnLock(); + this._addResumeAfterNetworkReconnect(); + this._addShowVolumeAdjustmentSliderSwitch(); this._addEnableSearchProviderSwitch(); this.attach(this._widgets.box, 0, 0, 1, 1); } + _addPlayAfterScreenLock() { + let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL }); + let label = new Gtk.Label({ + label: _("Play music after screen lock"), + "xalign": 0, + "hexpand": true + }); + this._widgets.playAfterScreenLockSwitch = new Gtk.Switch({ active: this._settings.get_boolean(SETTING_PLAY_AFTER_LOCK) }); + + hbox.prepend(label); + hbox.append(this._widgets.playAfterScreenLockSwitch); + + this._widgets.box.append(hbox); + + this._widgets.playAfterScreenLockSwitch.connect('notify::active', (button) => { + this._settings.set_boolean(SETTING_PLAY_AFTER_LOCK, button.get_active()); + this._widgets.resumeAfterScreenUnLockSwitch.set_sensitive(this._settings.get_boolean(SETTING_PLAY_AFTER_LOCK) === false); + }); + } + _addResumeAfterScreenUnLock() { + let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL }); + let label = new Gtk.Label({ + label: _("Resume music after screen unlock"), + "xalign": 0, + "hexpand": true + }); + this._widgets.resumeAfterScreenUnLockSwitch = new Gtk.Switch({ active: this._settings.get_boolean(SETTING_RESUME_AFTER_UNLOCK) }); + + this._widgets.resumeAfterScreenUnLockSwitch.set_sensitive(this._settings.get_boolean(SETTING_PLAY_AFTER_LOCK) === false); + + hbox.prepend(label); + hbox.append(this._widgets.resumeAfterScreenUnLockSwitch); + + this._widgets.box.append(hbox); + + this._widgets.resumeAfterScreenUnLockSwitch.connect('notify::active', (button) => { + this._settings.set_boolean(SETTING_RESUME_AFTER_UNLOCK, button.get_active()); + }); + } + _addResumeAfterNetworkReconnect() { + //TODO add implementation + /** + let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL }); + let label = new Gtk.Label({ + label: _("Reconnect station after network failure"), + "xalign": 0, + "hexpand": true + }); + this._widgets.resumeAfterNetworkReconnectSwitch = new Gtk.Switch({ active: this._settings.get_boolean(SETTING_RESUME_AFTER_NETWORK_RECONNECT) }); + + hbox.prepend(label); + hbox.append(this._widgets.resumeAfterNetworkReconnectSwitch); + + this._widgets.box.append(hbox); + + this._widgets.resumeAfterNetworkReconnectSwitch.connect('notify::active', (button) => { + this._settings.set_boolean(SETTING_RESUME_AFTER_NETWORK_RECONNECT, button.get_active()); + }); + */ + } _addTitleNotificationsSwitch() { let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL }); diff --git a/radio@hslbck.gmail.com/schemas/org.gnome.shell.extensions.radio.gschema.xml b/radio@hslbck.gmail.com/schemas/org.gnome.shell.extensions.radio.gschema.xml index 5597f0d..76651bb 100644 --- a/radio@hslbck.gmail.com/schemas/org.gnome.shell.extensions.radio.gschema.xml +++ b/radio@hslbck.gmail.com/schemas/org.gnome.shell.extensions.radio.gschema.xml @@ -11,6 +11,21 @@ Title Notification Show title notifications + + false + Play after lock + Play music after screen lock + + + false + Resume after unlock + Resume radio after screen unlock + + + true + Resume after network reconnect + Resume radio after network problems + false Show title in panel