diff --git a/po/POTFILES.in b/po/POTFILES.in index 74a521202..93ad531a3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -107,5 +107,6 @@ subprojects/extensions-tool/src/command-uninstall.c subprojects/extensions-tool/src/main.c subprojects/extensions-tool/src/templates/00-plain.desktop.in subprojects/extensions-tool/src/templates/indicator.desktop.in +subprojects/extensions-tool/src/templates/quick-settings.desktop.in # Please do not remove this file from POTFILES.in. Run "git submodule init && git submodule update" to get it. subprojects/gvc/gvc-mixer-control.c diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 0c8451d64..36fe39be5 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -2,3 +2,4 @@ data/org.gnome.Shell@wayland.service.in data/org.gnome.Shell@x11.service.in js/ui/init.js subprojects/extensions-tool/src/templates/indicator/extension.js +subprojects/extensions-tool/src/templates/quick-settings/extension.js diff --git a/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml b/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml index 0db87c3c2..4a64c6195 100644 --- a/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml +++ b/subprojects/extensions-tool/src/gnome-extensions-tool.gresource.xml @@ -7,5 +7,8 @@ templates/indicator/stylesheet.css templates/plain/extension.js templates/plain/stylesheet.css + templates/quick-settings.desktop + templates/quick-settings/extension.js + templates/quick-settings/stylesheet.css diff --git a/subprojects/extensions-tool/src/templates/meson.build b/subprojects/extensions-tool/src/templates/meson.build index d693bfadd..8c0079ecb 100644 --- a/subprojects/extensions-tool/src/templates/meson.build +++ b/subprojects/extensions-tool/src/templates/meson.build @@ -1,6 +1,7 @@ template_metas = [ '00-plain.desktop', 'indicator.desktop', + 'quick-settings.desktop', ] template_deps = [] foreach template : template_metas diff --git a/subprojects/extensions-tool/src/templates/quick-settings.desktop.in b/subprojects/extensions-tool/src/templates/quick-settings.desktop.in new file mode 100644 index 000000000..e2fc3d89e --- /dev/null +++ b/subprojects/extensions-tool/src/templates/quick-settings.desktop.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=Quick Settings Item +Comment=Add an item to quick settings +Path=quick-settings diff --git a/subprojects/extensions-tool/src/templates/quick-settings/extension.js b/subprojects/extensions-tool/src/templates/quick-settings/extension.js new file mode 100644 index 000000000..a3faf656d --- /dev/null +++ b/subprojects/extensions-tool/src/templates/quick-settings/extension.js @@ -0,0 +1,62 @@ +/* extension.js + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +import GObject from 'gi://GObject'; + +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + +import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; +import {QuickToggle, SystemIndicator} from 'resource:///org/gnome/shell/ui/quickSettings.js'; + +const ExampleToggle = GObject.registerClass( +class ExampleToggle extends QuickToggle { + constructor() { + super({ + title: _('Smile'), + iconName: 'face-smile-symbolic', + toggleMode: true, + }); + } +}); + +const ExampleIndicator = GObject.registerClass( +class ExampleIndicator extends SystemIndicator { + constructor() { + super(); + + this._indicator = this._addIndicator(); + this._indicator.iconName = 'face-smile-symbolic'; + + const toggle = new ExampleToggle(); + toggle.bind_property('checked', + this._indicator, 'visible', + GObject.BindingFlags.SYNC_CREATE); + this.quickSettingsItems.push(toggle); + } +}); + +export default class QuickSettingsExampleExtension extends Extension { + enable() { + this._indicator = new ExampleIndicator(); + Main.panel.statusArea.quickSettings.addExternalIndicator(this._indicator); + } + + disable() { + this._indicator.quickSettingsItems.forEach(item => item.destroy()); + this._indicator.destroy(); + } +} diff --git a/subprojects/extensions-tool/src/templates/quick-settings/stylesheet.css b/subprojects/extensions-tool/src/templates/quick-settings/stylesheet.css new file mode 100644 index 000000000..37b93f219 --- /dev/null +++ b/subprojects/extensions-tool/src/templates/quick-settings/stylesheet.css @@ -0,0 +1 @@ +/* Add your custom extension styling here */