Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Gnome 44 #199

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
64 changes: 54 additions & 10 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,66 @@
Copyright (C) 2014-2022 hslbck <[email protected]>
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();
}
}




5 changes: 3 additions & 2 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"shell-version": ["43"],
"shell-version": ["43","44"],
"uuid": "[email protected]",
"name": "Internet Radio",
"description": "Listen to an Internet Radio Stream",
"settings-schema": "org.gnome.shell.extensions.radio",
"session-modes":["user", "unlock-dialog"],
"gettext-domain": "[email protected]",
"url": "https://github.com/hslbck/gnome-shell-extension-radio",
"version": 21
"version": 22
}
69 changes: 68 additions & 1 deletion [email protected]/prefs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright (C) 2016 - 2022 hslbck <[email protected]>
Copyright (C) 2017 Justinas Narusevicius <[email protected]>
Copyright (C) 2023 Marek Mosiewicz <[email protected]>
This file is distributed under the same license as the gnome-shell-extension-radio package.
*/

Expand All @@ -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';
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@
<summary>Title Notification</summary>
<description>Show title notifications</description>
</key>
<key name="play-after-lock" type="b">
<default>false</default>
<summary>Play after lock</summary>
<description>Play music after screen lock</description>
</key>
<key name="resume-after-unlock" type="b">
<default>false</default>
<summary>Resume after unlock</summary>
<description>Resume radio after screen unlock</description>
</key>
<key name="resume-after-network-reconnect" type="b">
<default>true</default>
<summary>Resume after network reconnect</summary>
<description>Resume radio after network problems</description>
</key>
<key name="show-title-in-panel" type="b">
<default>false</default>
<summary>Show title in panel</summary>
Expand Down