diff --git a/Makefile b/Makefile index 1386b4e..7d9ae7f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -NAME=floarbar +NAME=floatbar DOMAIN=tomtroeger.de .PHONY: all pack install clean @@ -27,4 +27,11 @@ install: $(NAME).zip @mv dist ~/.local/share/gnome-shell/extensions/$(NAME)@$(DOMAIN) clean: - @rm -rf dist node_modules $(NAME).zip \ No newline at end of file + @rm -rf dist node_modules $(NAME).zip + +test: + @dbus-run-session -- gnome-shell --nested --wayland + +full: + @make install + @make test \ No newline at end of file diff --git a/ambient.d.ts b/ambient.d.ts index e0792f1..df51144 100644 --- a/ambient.d.ts +++ b/ambient.d.ts @@ -2,3 +2,4 @@ import "@girs/gjs"; import "@girs/gjs/dom"; import "@girs/gnome-shell/ambient"; import "@girs/gnome-shell/extensions/global"; +import "@girs/gnome-shell/ui/"; diff --git a/extension.ts b/extension.ts index 3a43a7c..1656f20 100644 --- a/extension.ts +++ b/extension.ts @@ -1,20 +1,86 @@ import GLib from "gi://GLib"; import Gio from "gi://Gio"; import Meta from "gi://Meta"; +import St from "gi://St"; import Shell from "gi://Shell"; import * as Main from "resource:///org/gnome/shell/ui/main.js"; import { Extension } from "resource:///org/gnome/shell/extensions/extension.js"; +import { SystemIndicator, QuickMenuToggle } from "resource:///org/gnome/shell/ui/quickSettings.js"; +import GObject from "gi://GObject"; +import { Button as PanelMenuButton } from "resource:///org/gnome/shell/ui/panelMenu.js"; + +const MyIndicator = GObject.registerClass( + class MyIndicator extends SystemIndicator { + _indicator: any; + _settings?: Gio.Settings; + constructor(extensioObject: Extension) { + super(); + + this._indicator = this._addIndicator(); + this._indicator.icon_name = "selection-mode-symbolic"; + + this._settings = extensioObject.getSettings(); + this._settings!.bind("float", this._indicator, "active", Gio.SettingsBindFlags.DEFAULT); + + this.quickSettingsItems.push(this._indicator); + } + } +); + +const ExampleToggle = GObject.registerClass( + class ExampleToggle extends QuickMenuToggle { + _settings: Gio.Settings; + constructor(extensionObject: Extension) { + super({ + title: "Float", + subtitle: "Floating Window", + iconName: "selection-mode-symbolic", + toggleMode: true, + }); + + this._settings = extensionObject.getSettings(); + this._settings.bind("float", this, "checked", Gio.SettingsBindFlags.DEFAULT); + } + } +); export default class MyExtension extends Extension { - gsettings?: Gio.Settings; - animationsEnabled: boolean = true; + _button?: PanelMenuButton; + indicator?: SystemIndicator; + settings?: Gio.Settings; enable() { - this.gsettings = this.getSettings(); - this.animationsEnabled = this.gsettings!.get_value("padding-inner").deepUnpack() ?? 8; + const icon = new St.Icon({ + icon_name: "face-laugh-symbolic", + style_class: "system-status-icon", + }); + + this._button = new PanelMenuButton(0.0, this.metadata.name, false); + this._button.add_child(icon); + this.settings = this.getSettings(); + + this._button.connect("button-press-event", () => this.toggleFloat()); + this._button.connect("touch-event", () => this.toggleFloat()); + + // this._button.addChild(); + // this.indicator = new MyIndicator(this); + // this.indicator.quickSettingsItems.push(new ExampleToggle(this)); + + // Main.panel.statusArea.quickSettings.addExternalIndicator(this.indicator); + Main.panel.addToStatusArea(this.uuid, this._button); + } + + toggleFloat() { + let bool = this.getSettings().get_boolean("float"); + console.log(bool); + this.getSettings().set_boolean("float", !bool); } disable() { - this.gsettings = undefined; + this._button?.destroy(); + this._button = undefined; + // this.indicator?.quickSettingsItems.forEach((item) => item.destroy()); + // this.indicator?.destroy(); + // this.indicator = undefined; } } diff --git a/floatbar.zip b/floatbar.zip new file mode 100644 index 0000000..deca3d3 Binary files /dev/null and b/floatbar.zip differ diff --git a/prefs.ts b/prefs.ts index 9499e9f..89f130f 100644 --- a/prefs.ts +++ b/prefs.ts @@ -22,7 +22,7 @@ export default class GnomeRectanglePreferences extends ExtensionPreferences { const animationEnabled = new Adw.SwitchRow({ title: _("Enabled"), - subtitle: _("Wether to animate windows"), + subtitle: _("Floating Window"), }); animationGroup.add(animationEnabled); @@ -45,7 +45,7 @@ export default class GnomeRectanglePreferences extends ExtensionPreferences { window.add(page); - this._settings!.bind("animate", animationEnabled, "active", Gio.SettingsBindFlags.DEFAULT); + this._settings!.bind("float", animationEnabled, "active", Gio.SettingsBindFlags.DEFAULT); this._settings!.bind("padding-inner", paddingInner, "value", Gio.SettingsBindFlags.DEFAULT); } } diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled new file mode 100644 index 0000000..439a133 Binary files /dev/null and b/schemas/gschemas.compiled differ diff --git a/schemas/org.gnome.shell.extensions.floatbar.gschema.xml b/schemas/org.gnome.shell.extensions.floatbar.gschema.xml new file mode 100644 index 0000000..36d3391 --- /dev/null +++ b/schemas/org.gnome.shell.extensions.floatbar.gschema.xml @@ -0,0 +1,15 @@ + + + + + 8 + Inner padding + Padding between windows + + + true + Floating + Whether the topbar floats or not + + + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 5ca135d..fa0aadd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", + "module": "ES2022", + "moduleResolution": "Bundler", "outDir": "./dist", "sourceMap": false, "strict": true,