diff --git a/#prefs3.ui# b/#prefs3.ui# deleted file mode 100644 index dbe26cb..0000000 --- a/#prefs3.ui# +++ /dev/null @@ -1,1232 +0,0 @@ - - - - - - 100 - 1 - 10 - - - 500 - 1 - 10 - - - True - True - - - True - True - - - True - False - - - - True - False - 15 - 15 - 15 - 15 - 15 - 15 - 10 - True - - - True - False - start - <b>Max widget width</b> -<span size="small"><i>0 to disable</i></span> - True - - - 0 - 0 - - - - - True - True - end - 0 - max_widget_width - - - 0 - 0 - - - - - True - False - start - Track label - - - - - - 0 - 1 - - - - - - True - False - True - - - track-label-sep - True - True - center - - - - 0 - 0 - - - - - track-label-start - True - False - start - - - - 0 - 0 - - - - - track-label-end - True - False - end - - - - 0 - 0 - - - - - 0 - 2 - - - - - True - False - start - vertical - - - True - True - True - https://github.com/cliffniff/media-controls/issues - - - True - False - 5 - - - True - False - mail-mark-junk-symbolic - - - False - True - 0 - - - - - True - False - Report a issue - - - False - True - 1 - - - - - - - False - True - 0 - - - - - True - True - True - https://github.com/cliffniff/media-controls/blob/main/README.md - - - True - False - 5 - - - True - False - go-home-symbolic - - - False - True - 0 - - - - - True - False - Extension home page - - - False - True - 1 - - - - - - - False - True - 1 - - - - - 0 - 4 - - - - - True - False - end - True - vertical - - - True - False - 10 - 10 - - - False - True - 0 - - - - - True - True - - - - True - False - end - 10 - 10 - 10 - 10 - 10 - 10 - True - 10 - 5 - - - True - False - start - Now, the extension does not update itself every <i>x</i> seconds. It watches for changes in the media player and updates itself. - True - True - 0 - - - 1 - 6 - - - - - True - False - start - You can switch on/off individual control icons - 0 - - - 1 - 1 - - - - - -1 - 0 - True - False - start - start - You can choose which parts of the label are visible. -ex. track name, artist - True - 0 - - - 1 - 2 - - - - - True - False - start - Better player icon and name recognition - True - 0 - - - 1 - 3 - - - - - True - False - start - New track information menu which can be opened with a mouse action - True - 0 - - - 1 - 4 - - - - - True - False - start - Left double click, Right double click, Scroll up, Scroll down and Mouse hover added for mouse actions. - True - 0 - - - 1 - 5 - - - - - True - False - center - center - 16 - dialog-information-symbolic - - - 0 - 0 - - - - - True - False - center - start - 16 - pan-end - - - 0 - 1 - - - - - True - False - center - start - 16 - pan-end - - - 0 - 2 - - - - - True - False - center - start - 16 - pan-end - - - 0 - 3 - - - - - True - False - center - start - 16 - pan-end - - - 0 - 4 - - - - - True - False - center - start - 16 - pan-end - - - 0 - 5 - - - - - True - False - center - start - 16 - pan-end - - - 0 - 6 - - - - - True - False - start - center - What's new in v15? - - - - - - - 1 - 0 - - - - - - - True - False - 5 - 5 - 5 - 5 - Release Notes - - - - - - - - - False - True - 1 - - - - - 0 - 3 - - - - - - - - - - - True - False - General - - - False - - - - - True - True - - - True - False - - - - True - False - 15 - 15 - 15 - 15 - 15 - 15 - 10 - True - - - True - False - start - Colored player icon - - - 0 - 3 - - - - - True - True - end - - - 0 - 3 - - - - - Preset - True - True - False - start - True - True - - - - 0 - 6 - - - - - Custom - True - True - False - start - True - preset-radio-btn - - - - 0 - 7 - - - - - True - False - end - - - - 0 - 6 - - - - - True - False - start - 8 - 8 - <b>Seperator characters</b> - True - - - 0 - 5 - - - - - True - True - end - <...> - - - - 0 - 7 - - - - - - True - False - 10 - 10 - 10 - 10 - 8 - True - - - True - True - end - - - 0 - 0 - - - - - True - False - start - Title/Track name - - - 0 - 0 - - - - - True - True - end - - - 0 - 3 - - - - - True - True - end - - - 0 - 4 - - - - - True - False - start - Seperators - - - 0 - 4 - - - - - True - True - end - - - 0 - 1 - - - - - True - False - start - Player icon - - - 0 - 3 - - - - - True - False - start - Player controls - - - 0 - 1 - - - - - True - False - start - Sources menu - - - 0 - 5 - - - - - True - True - end - - - 0 - 5 - - - - - - True - False - 15 - 15 - 15 - 15 - 8 - True - - - True - False - start - Play/pause button - - - 0 - 0 - - - - - True - True - end - - - 0 - 0 - - - - - True - False - start - Previous track button - - - 0 - 1 - - - - - True - False - start - Next track button - - - 0 - 2 - - - - - True - True - end - - - 0 - 1 - - - - - True - True - end - - - 0 - 2 - - - - - 0 - 2 - - - - - 0 - 1 - - - - - True - False - start - <b>Show/hide elements</b> - True - - - 0 - 0 - - - - - True - False - - - 0 - 2 - - - - - True - False - - - 0 - 4 - - - - - - - - - 1 - - - - - True - False - Visibility - - - 1 - False - - - - - True - True - - - True - False - - - - True - False - 15 - 15 - 15 - 15 - 15 - 15 - 10 - True - - - True - False - start - Extension position - - - 0 - 0 - - - - - True - False - start - Extension index - - - 0 - 1 - - - - - True - True - end - 0 - extension_index - - - 0 - 1 - - - - - True - False - start - <b>Element order</b> - True - - - 0 - 2 - - - - - True - False - end - - - - 0 - 0 - - - - - - True - False - 3 - True - - - - - - - - - - - - 0 - 3 - - - - - - - - - 2 - - - - - True - False - Position - - - 2 - False - - - - - True - True - - - True - False - - - - True - False - 15 - 15 - 15 - 15 - 15 - 15 - 10 - True - - - True - False - start - <b>Mouse actions</b> - True - - - 0 - 0 - - - - - True - False - start - center - <b>Cache images</b> - True - - - 0 - 5 - - - - - True - False - start - Media Controls caches album art so they don't need to be redownloaded everytime. You can clear your cache here. - True - 0 - - - 0 - 6 - - - - - - True - False - 10 - - - Clear cache - True - True - True - start - - - - 0 - 0 - - - - - True - False - start - 0 MB - - - 1 - 0 - - - - - True - False - - - 2 - 0 - - - - - 0 - 7 - - - - - - True - False - 5 - True - - - - - - - - - - - - 0 - 1 - - - - - True - True - end - - - 0 - 5 - - - - - True - False - start - Blacklist players - - - 0 - 2 - - - - - True - False - - - 0 - 4 - - - - - True - True - - - - 0 - 3 - - - - - - - - - 3 - - - - - True - False - Other - - - 3 - False - - - - - diff --git a/main.js b/main.js deleted file mode 100644 index 97694b4..0000000 --- a/main.js +++ /dev/null @@ -1,469 +0,0 @@ -const { St, GLib, Gio, Clutter } = imports.gi; - -const ExtensionUtils = imports.misc.extensionUtils; -const Me = ExtensionUtils.getCurrentExtension(); - -const Mainloop = imports.mainloop; -const Main = imports.ui.main; - -const PanelMenu = imports.ui.panelMenu; -const PopupMenu = imports.ui.popupMenu; - -const { playerAction, updatePlayers } = Me.imports.utils; - -const { startMainloop, mainloop } = Me.imports.mainloop; - -var maxDisplayLength, - updateDelay, - showTrackName, - showPlayerIcon, - showControls, - showSeperators, - showMenu, - extensionPosition, - extensionIndex, - coloredPlayerIcon, - showAllOnHover, - sepChars, - mouseActions, - elementOrder; - -var onMaxLengthChanged, - onUpdateDelayChanged, - onShowTrackNameChanged, - onShowPlayerIconChanged, - onShowControlsChanged, - onShowMenuChanged, - onShowSeperatorsChanged, - onExtensionPositionChanged, - onExtensionIndexChanged, - onColoredPlayerIconChanged, - onShowAllOnHoverChanged, - onSepCharsChanged, - onMouseActionsChanged, - onElementOrderChanged; - -var buttonNext, - buttonPrev, - buttonToggle, - buttonLabel, - buttonPlayer, - iconNext, - iconPause, - iconPlay, - iconPrev, - iconPlayer, - labelSeperatorStart, - labelSeperatorEnd, - container, - box, - menuIcon; - -var settings, settingsMap, positions, playerIcons; - -var currentPlayer, currentMetadata, currentLabel, currentStatus; - -var loopFinished, contentRemoved, mouseHovered, sourceChanged; - -var initVars = () => { - playerIcons = ["chromium", "firefox"]; - positions = { - left: "_leftBox", - center: "_centerBox", - right: "_rightBox", - }; - - settings = ExtensionUtils.getSettings(); - loopFinished = true; - contentRemoved = true; - - currentMetadata = null; - currentPlayer = null; - currentStatus = null; - currentLabel = null; - sourceChanged = false; -}; - -var bindSignals = () => { - onMaxLengthChanged = settings.connect("changed::max-text-width", () => { - maxDisplayLength = settings.get_int("max-text-width"); - if (maxDisplayLength === 0) { - buttonLabel.set_style(`max-width: none; padding: 0px 3px;`); - } else { - buttonLabel.set_style(`max-width: ${maxDisplayLength}px; padding: 0px 3px;`); - } - }); - - onUpdateDelayChanged = settings.connect("changed::update-delay", () => { - updateDelay = settings.get_int("update-delay"); - startMainloop(); - }); - - onShowTrackNameChanged = settings.connect("changed::show-text", () => { - showTrackName = settings.get_boolean("show-text"); - removeContent(); - addContent(); - }); - - onShowPlayerIconChanged = settings.connect("changed::show-player-icon", () => { - showPlayerIcon = settings.get_boolean("show-player-icon"); - removeContent(); - addContent(); - }); - - onShowControlsChanged = settings.connect("changed::show-control-icons", () => { - showControls = settings.get_boolean("show-control-icons"); - removeContent(); - addContent(); - }); - - onShowSeperatorsChanged = settings.connect("changed::show-seperators", () => { - showSeperators = settings.get_boolean("show-seperators"); - removeContent(); - addContent(); - }); - - onShowMenuChanged = settings.connect("changed::show-sources-menu", () => { - showMenu = settings.get_boolean("show-sources-menu"); - if (!showMenu) { - if (showTrackName) { - altSourceMenu = new PanelMenu.Button(1); - } else { - } - } - removeContent(); - addContent(); - }); - - onExtensionPositionChanged = settings.connect("changed::extension-position", () => { - removeContent(); - extensionPosition = settings.get_string("extension-position"); - addContent(); - }); - - onExtensionIndexChanged = settings.connect("changed::extension-index", () => { - extensionIndex = settings.get_int("extension-index"); - removeContent(); - addContent(); - }); - - onColoredPlayerIconChanged = settings.connect("changed::colored-player-icon", () => { - coloredPlayerIcon = settings.get_boolean("colored-player-icon"); - _updatePlayerIconEffects(); - }); - - onShowAllOnHoverChanged = settings.connect("changed::show-all-on-hover", () => { - showAllOnHover = settings.get_boolean("show-all-on-hover"); - }); - - onSepCharsChanged = settings.connect("changed::seperator-chars", () => { - sepChars = settings.get_strv("seperator-chars"); - labelSeperatorStart.set_text(sepChars[0]); - labelSeperatorEnd.set_text(sepChars[1]); - }); - - onMouseActionsChanged = settings.connect("changed::mouse-actions", () => { - mouseActions = settings.get_strv("mouse-actions"); - }); - - onElementOrderChanged = settings.connect("changed::element-order", () => { - elementOrder = settings.get_strv("element-order"); - removeContent(); - addContent(); - }); -}; - -var initSettings = () => { - _initNewSettings(); - maxDisplayLength = settings.get_int("max-text-width"); - updateDelay = settings.get_int("update-delay"); - showTrackName = settings.get_boolean("show-text"); - showPlayerIcon = settings.get_boolean("show-player-icon"); - showControls = settings.get_boolean("show-control-icons"); - showSeperators = settings.get_boolean("show-seperators"); - showMenu = settings.get_boolean("show-sources-menu"); - extensionPosition = settings.get_string("extension-position"); - extensionIndex = settings.get_int("extension-index"); - coloredPlayerIcon = settings.get_boolean("colored-player-icon"); - showAllOnHover = settings.get_boolean("show-all-on-hover"); - mouseActions = settings.get_strv("mouse-actions"); - sepChars = settings.get_strv("seperator-chars"); - elementOrder = settings.get_strv("element-order"); -}; - -var initWidgets = () => { - buttonToggle = new St.Button({ style_class: "panel-button" }); - buttonNext = new St.Button({ - style_class: "panel-button", - }); - buttonPrev = new St.Button({ - style_class: "panel-button", - }); - buttonLabel = new St.Button({ - style: `max-width: ${maxDisplayLength}px; padding: 0px 3px;`, - style_class: "panel-button", - label: "No media", - }); - buttonPlayer = new St.Button({ - style_class: "panel-button", - }); - - iconPlay = new St.Icon({ - icon_name: "media-playback-start-symbolic", - style_class: "system-status-icon", - }); - iconPause = new St.Icon({ - icon_name: "media-playback-pause-symbolic", - style_class: "system-status-icon", - }); - iconNext = new St.Icon({ - icon_name: "media-skip-forward-symbolic", - style_class: "system-status-icon", - }); - iconPrev = new St.Icon({ - icon_name: "media-skip-backward-symbolic", - style_class: "system-status-icon", - }); - iconPlayer = new St.Icon({ - style_class: "system-status-icon", - }); - - labelSeperatorStart = new St.Label({ - y_align: Clutter.ActorAlign.CENTER, - style_class: "panel-button", - style: "padding: 3px", - }); - - labelSeperatorEnd = new St.Label({ - y_align: Clutter.ActorAlign.CENTER, - style_class: "panel-button", - style: "padding: 3px", - }); - - box = new St.BoxLayout(); - - container = new PanelMenu.Button(0.5); - container.set_style_class_name(null); - - container.add_child(box); - container.menu.connect("open-state-changed", (menu, open) => { - if (open) { - menuIcon.add_style_pseudo_class("active"); - try { - (() => { - updatePlayers(container, changeSource); - })(); - } catch (error) { - logError(error); - } - } else { - menuIcon.remove_style_pseudo_class("active"); - } - }); - container.menu.addMenuItem(new PopupMenu.PopupMenuItem("Players", { reactive: false })); - - menuIcon = PopupMenu.arrowIcon(St.Side.BOTTOM); - menuIcon.add_style_class_name("panel-button"); - menuIcon.set_style("padding: 3px;"); - - buttonNext.set_child(iconNext); - buttonNext.connect("button-release-event", () => { - (() => { - playerAction(currentPlayer, "next"); - })(); - }); - - buttonPrev.set_child(iconPrev); - buttonPrev.connect("button-release-event", () => { - (() => { - playerAction(currentPlayer, "previous"); - })(); - }); - - buttonToggle.set_child(iconPlay); - buttonToggle.connect("button-release-event", () => { - (() => { - playerAction(currentPlayer, "toggle_play"); - })(); - }); - - buttonPlayer.set_child(iconPlayer); - buttonPlayer.connect("button-release-event", _mouseAction); - - buttonLabel.connect("button-release-event", _mouseAction); - buttonLabel.connect("enter-event", () => { - if (showAllOnHover) { - buttonLabel.set_style("max-width: none; padding: 0px 3px;"); - } - }); - buttonLabel.connect("leave-event", () => { - if (showAllOnHover) { - buttonLabel.set_style(`max-width: ${maxDisplayLength}px; padding: 0px 3px;`); - } - }); - - labelSeperatorStart.set_text(sepChars[0]); - labelSeperatorEnd.set_text(sepChars[1]); - - _updatePlayerIconEffects(); -}; - -var disconnectSignals = () => { - settings.disconnect(onMaxLengthChanged); - settings.disconnect(onUpdateDelayChanged); - settings.disconnect(onShowControlsChanged); - settings.disconnect(onShowPlayerIconChanged); - settings.disconnect(onShowTrackNameChanged); - settings.disconnect(onShowSeperatorsChanged); - settings.disconnect(onExtensionPositionChanged); - settings.disconnect(onExtensionIndexChanged); - settings.disconnect(onShowAllOnHoverChanged); - settings.disconnect(onColoredPlayerIconChanged); - settings.disconnect(onMouseActionsChanged); - settings.disconnect(onSepCharsChanged); - settings.disconnect(onElementOrderChanged); -}; - -var destroyWidgets = () => { - buttonNext.destroy(); - buttonPrev.destroy(); - buttonToggle.destroy(); - buttonLabel.destroy(); - iconNext.destroy(); - iconPause.destroy(); - iconPlay.destroy(); - iconPrev.destroy(); - iconPlayer.destroy(); - labelSeperatorStart.destroy(); - labelSeperatorEnd.destroy(); - container.destroy(); -}; - -var nullifyVars = () => { - currentMetadata = null; - currentPlayer = null; - currentStatus = null; - currentLabel = null; - sourceChanged = false; -}; - -var addContent = () => { - if (contentRemoved) { - log("[Media-Controls] Adding content"); - // Deleting reference as safety measuremnt - delete Main.panel.statusArea["sourceMenu"]; - Main.panel.addToStatusArea("sourceMenu", container, extensionIndex, extensionPosition); - for (element of elementOrder) { - if (element === "icon" && showPlayerIcon) { - box.add(buttonPlayer); - } else if (element === "title" && showTrackName) { - if (showSeperators) { - box.add(labelSeperatorStart); - } - - box.add(buttonLabel); - - if (showSeperators) { - box.add(labelSeperatorEnd); - } - } else if (element === "controls" && showControls) { - box.add(buttonPrev); - - box.add(buttonToggle); - - box.add(buttonNext); - } else if (element === "menu" && showMenu) { - box.add(menuIcon); - } - } - - contentRemoved = false; - } -}; - -var removeContent = () => { - if (!contentRemoved) { - log("[Media-Controls] Removing content"); - box.remove_child(buttonNext); - box.remove_child(buttonToggle); - box.remove_child(buttonPrev); - box.remove_child(buttonLabel); - box.remove_child(buttonPlayer); - box.remove_child(labelSeperatorStart); - box.remove_child(labelSeperatorEnd); - box.remove_child(menuIcon); - - delete Main.panel.statusArea["sourceMenu"]; - - contentRemoved = true; - } -}; - -var updateToggleButtonIcon = () => { - if (currentStatus === "Playing") { - buttonToggle.set_child(iconPause); - } else { - buttonToggle.set_child(iconPlay); - } -}; - -const _updatePlayerIconEffects = () => { - if (coloredPlayerIcon) { - iconPlayer.clear_effects(); - iconPlayer.set_style("-st-icon-style: requested"); - iconPlayer.set_fallback_icon_name("audio-x-generic"); - } else { - iconPlayer.set_style("-st-icon-style: symbolic"); - iconPlayer.add_effect(new Clutter.DesaturateEffect()); - iconPlayer.set_fallback_icon_name("audio-x-generic-symbolic"); - } -}; - -const _mouseAction = (event) => { - let button = 1; - if (event.pseudo_class && event.pseudo_class.includes("active")) { - button = 0; - } - if (mouseActions[button] === "toggle_menu") { - container.menu.open(); - } else { - playerAction(currentPlayer, mouseActions[button]); - } -}; - -/** - * Changes the currentPlayer - * @param {string} player - */ -const _changeSource = (player) => { - log(`[Media-Controls] Changing player to ${player}`); - currentPlayer = player; - sourceChanged = true; -}; - -/** - * Replace old settings with new settings - */ -const _initNewSettings = () => { - let elOrder = settings.get_strv("element-order"); - if (elOrder.length === 3) { - settingsMap = { - "hide-text": "show-text", - "hide-player-icon": "show-player-icon", - "hide-control-icons": "show-control-icons", - "hide-seperators": "show-seperators", - }; - Object.keys(settingsMap).forEach((old) => { - let oldVal = settings.get_boolean(old); - settings.set_boolean(settingsMap[old], !oldVal); - }); - - settings.set_strv("element-order", [...elOrder, "menu"]); - - let msActions = settings.get_strv("mouse-actions"); - if (msActions.includes("toggle")) { - msActions[msActions.indexOf("toggle")] = "toggle_play"; - } - settings.set_strv("mouse-actions", msActions); - } -}; diff --git a/metadata.json b/metadata.json index 78f5095..3f22eb5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,5 +1,4 @@ { - "development": true, "description": "Show controls for the current playing media in the panel", "name": "Media Controls", "settings-schema": "org.gnome.shell.extensions.mediacontrols", @@ -9,5 +8,5 @@ ], "url": "https://github.com/cliffniff/media-controls", "uuid": "mediacontrols@cliffniff.github.com", - "version": 16 + "version": 17 } \ No newline at end of file diff --git a/player.js b/player.js index f424727..17fd28b 100644 --- a/player.js +++ b/player.js @@ -599,11 +599,11 @@ const Player = GObject.registerClass( } } catch (error) { if ( - error.toString().includes("Expected type") || - error.toString().includes("Error opening file") + !( + error.toString().includes("Expected type") || + error.toString().includes("Error opening file") + ) ) { - log("[MediaControls] Failed to retrieve icon."); - } else { logError(error); } return null; @@ -697,6 +697,9 @@ const Player = GObject.registerClass( } destroy() { + this._extension = null; + this._playerProxy = null; + this._otherProxy = null; super.destroy(); } diff --git a/prefs.js b/prefs.js index cc71076..64e82e9 100644 --- a/prefs.js +++ b/prefs.js @@ -451,8 +451,12 @@ const addToBacklistListBox = (app) => { ); deleteButton.visible = true; + deleteButton.app = app; deleteButton.connect("clicked", (widget) => { + let currentBacklistApps = settings.get_strv("backlist-apps"); + currentBacklistApps.splice(currentBacklistApps.indexOf(widget.app), 1); + settings.set_strv("backlist-apps", currentBacklistApps); widgetBacklistBox.remove(widget.get_parent().get_parent()); }); diff --git a/prefs3.ui b/prefs3.ui index dbe26cb..afc7a83 100644 --- a/prefs3.ui +++ b/prefs3.ui @@ -460,7 +460,7 @@ ex. track name, artist False start center - What's new in v15? + What's new in v17? @@ -612,8 +612,10 @@ ex. track name, artist start 8 8 - <b>Seperator characters</b> - True + Seperator characters + + + 0 @@ -856,8 +858,10 @@ ex. track name, artist True False start - <b>Show/hide elements</b> - True + how/hide elements + + + 0 @@ -967,8 +971,10 @@ ex. track name, artist True False start - <b>Element order</b> - True + Element order + + + 0 @@ -1055,8 +1061,10 @@ ex. track name, artist True False start - <b>Mouse actions</b> - True + Mouse actions + + + 0 @@ -1069,8 +1077,10 @@ ex. track name, artist False start center - <b>Cache images</b> - True + Cache images + + + 0 @@ -1178,6 +1188,9 @@ ex. track name, artist False start Blacklist players + + + 0 @@ -1198,6 +1211,8 @@ ex. track name, artist True True + list-add + GTK_INPUT_HINT_LOWERCASE | GTK_INPUT_HINT_NONE diff --git a/prefs4.ui b/prefs4.ui index 7a560b1..793da95 100644 --- a/prefs4.ui +++ b/prefs4.ui @@ -353,7 +353,7 @@ ex. track name, artist start center - What's new in v15? + What's new in v17? @@ -477,8 +477,10 @@ ex. track name, artist start 8 8 - <b>Seperator characters</b> - 1 + Seperator characters + + + 0 5 @@ -688,8 +690,10 @@ ex. track name, artist start - <b>Show/hide elements</b> - 1 + how/hide elements + + + 0 0 @@ -778,8 +782,10 @@ ex. track name, artist start - <b>Element order</b> - 1 + Element order + + + 0 2 @@ -849,8 +855,10 @@ ex. track name, artist start - <b>Mouse actions</b> - 1 + Mouse actions + + + 0 0 @@ -861,8 +869,10 @@ ex. track name, artist start center - <b>Cache images</b> - 1 + Cache images + + + 0 5 @@ -954,6 +964,9 @@ ex. track name, artist start Blacklist players + + + 0 2 @@ -971,6 +984,8 @@ ex. track name, artist 1 + list-add + GTK_INPUT_HINT_LOWERCASE | GTK_INPUT_HINT_NONE 0 diff --git a/settings.js b/settings.js index a569553..1e22137 100644 --- a/settings.js +++ b/settings.js @@ -25,6 +25,7 @@ class Settings { this.elementOrder = this._settings.get_strv("element-order"); this.trackLabel = this._settings.get_strv("track-label"); this.cacheImages = this._settings.get_boolean("cache-images"); + this.blacklistApps = this._settings.get_strv("backlist-apps"); } connectSignals() { @@ -124,6 +125,10 @@ class Settings { this._onCacheImagesChanged = this._settings.connect("changed::cache-images", () => { this.cacheImages = this._settings.get_boolean("cache-images"); }); + + this._onBacklistAppsChanged = this._settings.connect("changed::backlist-apps", () => { + this.blacklistApps = this._settings.get_strv("backlist-apps"); + }); } disconnectSignals() { @@ -145,5 +150,6 @@ class Settings { this._settings.disconnect(this._onElementOrderChanged); this._settings.disconnect(this._onTrackLabelChanged); this._settings.disconnect(this._onCacheImagesChanged); + this._settings.disconnect(this._onBacklistAppsChanged); } } diff --git a/widget.js b/widget.js index 9356cc0..1dbb7fb 100644 --- a/widget.js +++ b/widget.js @@ -1,4 +1,7 @@ -// TODO FEATURES: title/artist order/hide +/** + * Main entry point of the extension + * Contains the main class of the extension + */ const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); @@ -57,17 +60,6 @@ const MediaControls = GObject.registerClass( this.updatePlayer(); }); - // this._automaticUpdateToggle.connect("toggled", (widget, value) => { - // if (value) { - // this._isFixedPlayer = true; - // this.updatePlayer(this.player); - // } else { - // this._isFixedPlayer = false; - // this.updatePlayer(); - // } - // log(this._isFixedPlayer); - // }); - this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.menu.addMenuItem(this._automaticUpdateToggle); @@ -111,8 +103,6 @@ const MediaControls = GObject.registerClass( })(); } }); - - log("[MediaControls] Enabled"); } catch (error) { logError(error); } @@ -131,8 +121,6 @@ const MediaControls = GObject.registerClass( } addWidgets() { - log("[MediaControls] Adding widgets"); - delete Main.panel.statusArea["media_controls_extension"]; Main.panel.addToStatusArea( "media_controls_extension", @@ -173,7 +161,6 @@ const MediaControls = GObject.registerClass( } removeWidgets() { - log("[MediaControls] Removing widgets"); delete Main.panel.statusArea["media_controls_extension"]; if (this.player) { @@ -202,17 +189,26 @@ const MediaControls = GObject.registerClass( async _addPlayer(busName) { try { let playerObj = await new Player(busName, this); - let menuItem = playerObj.menuItem; - - menuItem.connect("activate", (menuItem) => { - this.toggleActivatePlayer(menuItem.busName); - }); + if ( + this.settings.blacklistApps.every( + (app) => !playerObj.name.toLowerCase().includes(app.toLowerCase()) + ) + ) { + let menuItem = playerObj.menuItem; + + menuItem.connect("activate", (menuItem) => { + this.toggleActivatePlayer(menuItem.busName); + }); - this.menu.addMenuItem(menuItem); - this._players[busName] = playerObj; + this.menu.addMenuItem(menuItem); + this._players[busName] = playerObj; - if (!playerObj._metadata["title"]) { - this.hidePlayer(busName); + if (!playerObj._metadata["title"]) { + this.hidePlayer(busName); + } + } else { + playerObj.destroy(); + playerObj = null; } } catch (error) { logError(error); @@ -232,18 +228,20 @@ const MediaControls = GObject.registerClass( delete this._players[busName]; } + /** + * Determines the currently selected player + * @param {null || Player || string} player + */ updatePlayer(player = null) { if (!this.player && this.isFixedPlayer) { this.isFixedPlayer = false; } if (!player && !this.isFixedPlayer) { - log("Automatic determine"); const validPlayers = []; for (let playerName in this._players) { let playerObj = this._players[playerName]; if (playerObj._metadata["title"] && !playerObj.hidden) { - log(playerObj.busName, playerObj._status); validPlayers.push(playerObj); if (playerObj.isPlaying) { player = playerObj; @@ -286,13 +284,8 @@ const MediaControls = GObject.registerClass( this.player.active = true; } else if (!this.player) { - log("Removing all"); this.removeWidgets(); } - - log("[MediaControls] Updated player", player ? player.busName : player); - log("No. of players", Object.values(this._players).length); - log("Fixed player", this.isFixedPlayer); } toggleActivatePlayer(busName) { @@ -341,9 +334,6 @@ const MediaControls = GObject.registerClass( } playerVanished(connection, name) { - log("Player Vanished", name); - log("No. of players", Object.values(this._players).length); - if (name === this.player.busName) { Gio.bus_unwatch_name(this.playerWatchId); this._removePlayer(this.player.busName); @@ -354,7 +344,6 @@ const MediaControls = GObject.registerClass( } else { this._removePlayer(name); } - log("No. of players", Object.values(this._players).length); } destroy() {