From a391b6a83558b14ff333c690267143b43f960112 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 1 Jul 2024 00:30:33 +0100 Subject: [PATCH] ADD: working button to control boolean float --- Makefile | 11 ++- ambient.d.ts | 1 + extension.ts | 76 ++++++++++++++++-- floatbar.zip | Bin 0 -> 3039 bytes prefs.ts | 4 +- schemas/gschemas.compiled | Bin 0 -> 357 bytes ...nome.shell.extensions.floatbar.gschema.xml | 15 ++++ tsconfig.json | 4 +- 8 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 floatbar.zip create mode 100644 schemas/gschemas.compiled create mode 100644 schemas/org.gnome.shell.extensions.floatbar.gschema.xml 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 0000000000000000000000000000000000000000..deca3d323bd188c62cf002fe1b26037edd02a3b7 GIT binary patch literal 3039 zcmb7G3pAAL8ve%^xm9K)qe$DJGK@-*OCul29z{hw#O-}^jPSg`O0KnM^8 z%E5zn3wEV=CIA4h1ZyoI4|tRPoLrpzoKPMN8kK+-1HiuHVU#b+KTrYy3BLscz}F3D z*|M&Bt7PTJ4H0+gI$QRPG2rWWsUbjR?bHtVOK$a$^JV?1#mtpj_UJ4U|5YaKkBL@*2pq z_y$n~i^y>qY_P%&HV*J=e=@@QGmx7FaT3_Q+qUc8~rL}emCyYu(oBSMMh~{lI5LRo$Jll{qlt4AL+mKBb~Ew?7VXP zb?<3UndcMU0j>0@i(%(=+bnJ?g;?vnIaC;yGY`T-$=$<=)0=?44en$WtDKvGWPM&EK5lWm~vp&J`? zW_@43Zfpv_68~t!9cwS%c?st4b}`oX4G~BbD5uYL|jp zEH5LYdL#a6MX+*2-NYr*%6L$8rg;WbjDjmjMK>B}mS@FXJW`VG6LYd@sW)Lc;&E){ z&F&SW5XqWzn+kxrpPVp}hUYU!oGr9ugbVS^@8rX#^@59d(3z!x4N zBHMpWuL{2b!K{Fs&9}B{T6AOEn%ZzLkgb@Oh7N4O_Cqbm*5)>3S5v|B$T@ZZ%XA7f zMv58&-}mp|y4&mxOD9pA4yfSZP%4OJMg?`~n?6e9F|{zFPu@Us*8|U>rh7g*{bGWV ze>V8r405cGHz!r5$ngp74qWg`NqGKcyjO1MnBLyQDy@|8(I0n5;K#aWsyWWX0$) zH)BJz(qdW`vJa&puKv-~XcE3%pOlw$vpInya$x1-_NI#(qa?XxH1yEOFha2*anzFl z_pO()mr>hh*0{|&qW)Ddo6G61GEZdciIA2^M6FYJ?}>K=-@3}QBW9cLEmT%^h)T&eeWm!w4U_^ryK*vv|!OYAZqMiuFBAG4Q|D)-PW zrCsRgMSEF;v+fFY3q`K>FVs4g`2KhU8|%M#J?3yWM<{@Uk-*1CGm|X4~r*kB@DU zY4VvhH)D2-d-Bc6z<1LwAs5+g5K`Vx*?A;hOGP zLU?q|<19HsUGHP|{tnAq2866rUS*uFu9CUURvM`!)S3s0klBFP@LAU63UF_!Hmgvg zP@HI-L#A#nXCD4=&+QDP@5macg5vXFiHYFGgl&i-U5>q{!TuAit-7LGE_V`pIN}TU zii_ATJKrl<1SHH{5KoHg%GE51zj=~nK7y`qgW^gDN~)Dhy2SQjt!?w67x=~I(**>#@<*AFDL1^icO4gS?;1cM8> z7xv}&r|bs#mfil8+x`r>Iw}1K*)4$lo|}G#_E+xr4GjRKfMqjl!QA-ng+D|4PIt8v z{`hZ~e?a@ceev%VU+oP4rt(#5$agCL#V7tA{OVcyBR35}W?em5{|XTz_!0m_1doCs KE98rPdHWZvIpGHY literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..439a133fa0d8e12dc79fe2f90ca00afd6e8461f9 GIT binary patch literal 357 zcmZ<{ODxJv%qwAl0tp};0by$}!32Rct0)7*e;|O!`GD2L0L6t@t>y2A!z1&J&I1i|jL4yTE0s%-LGZY`F zt>XsS2{MnBp^Sk8C}{%3Ft>o%3=BSCF&iLzDeEC&kPwK?3sfHfq$7ZM_QOJckT{49 zGA98@rvkBFL1IY;$Os_N2Rc?C>{xxUWA)+AE7nJLtUd!nG01(OuqjAPNy*Gh*Uik! bODzH!0t6f&LL*Z%Ehj$_6sU|08cCV}TK7s? literal 0 HcmV?d00001 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,