diff --git a/package-lock.json b/package-lock.json index 7aafb82..e628625 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ags", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ags", - "version": "0.1.0", + "version": "1.0.0", "license": "GPL", "dependencies": { "@girs/gvc-1.0": "^1.0.0-3.1.0", diff --git a/src/widgets/box.ts b/src/widgets/box.ts index 3062294..42473fb 100644 --- a/src/widgets/box.ts +++ b/src/widgets/box.ts @@ -25,19 +25,20 @@ export default class AgsBox extends Gtk.Box { get children() { return this.get_children(); } set children(children: Gtk.Widget[] | null) { const newChildren = children || []; - + this.get_children() - .filter((ch) => !newChildren?.includes(ch)) - .forEach((ch) => ch.destroy()); + .filter(ch => !newChildren?.includes(ch)) + .forEach(ch => ch.destroy()); // remove any children that weren't destroyed so // we can re-add everything in the correct new order this.get_children() .forEach(ch => this.remove(ch)); - - if (!children) return; - children.forEach((w) => w && this.add(w)); + if (!children) + return; + + children.forEach(w => w && this.add(w)); this.show_all(); } diff --git a/src/widgets/button.ts b/src/widgets/button.ts index 513ef0b..91cc645 100644 --- a/src/widgets/button.ts +++ b/src/widgets/button.ts @@ -80,8 +80,9 @@ export default class AgsButton extends Gtk.Button { get child() { return this.get_child(); } set child(child: Gtk.Widget) { const widget = this.get_child(); - - if (widget === child) return; + + if (widget === child) + return; if (widget) widget.destroy(); diff --git a/src/widgets/centerbox.ts b/src/widgets/centerbox.ts index b05e11f..0e3db7d 100644 --- a/src/widgets/centerbox.ts +++ b/src/widgets/centerbox.ts @@ -29,7 +29,7 @@ export default class AgsCenterBox extends AgsBox { set children(children: Gtk.Widget[] | null) { const newChildren = children || []; - newChildren.filter((ch) => !newChildren?.includes(ch)) + newChildren.filter(ch => !newChildren?.includes(ch)) .forEach(ch => ch.destroy()); if (!children) diff --git a/src/widgets/eventbox.ts b/src/widgets/eventbox.ts index a8d8672..3ccc7be 100644 --- a/src/widgets/eventbox.ts +++ b/src/widgets/eventbox.ts @@ -95,8 +95,9 @@ export default class AgsEventBox extends Gtk.EventBox { get child() { return this.get_child(); } set child(child: Gtk.Widget) { const widget = this.get_child(); - if (widget === child) return; - + if (widget === child) + return; + if (widget) widget.destroy(); diff --git a/src/widgets/menu.ts b/src/widgets/menu.ts index a598db1..ad67f75 100644 --- a/src/widgets/menu.ts +++ b/src/widgets/menu.ts @@ -80,8 +80,9 @@ export class AgsMenuItem extends Gtk.MenuItem { get child() { return this.get_child(); } set child(child: Gtk.Widget) { const widget = this.get_child(); - if (widget === child) return; - + if (widget === child) + return; + if (widget) widget.destroy(); diff --git a/src/widgets/overlay.ts b/src/widgets/overlay.ts index 621360c..ff4f49b 100644 --- a/src/widgets/overlay.ts +++ b/src/widgets/overlay.ts @@ -38,8 +38,9 @@ export default class AgsOverlay extends Gtk.Overlay { get child() { return this._child; } set child(child: Gtk.Widget) { const widget = this.get_child(); - if (widget === child) return; - + if (widget === child) + return; + if (widget) widget.destroy(); @@ -54,12 +55,12 @@ export default class AgsOverlay extends Gtk.Overlay { overlays ||= []; this.get_children().filter( ch => ch !== this._child - // && !overlays.includes(ch) - ) + && !overlays.includes(ch), + ) .forEach(ch => ch.destroy()); - // this.get_children() - // .forEach(ch => this.remove_overlay(ch)); + this.get_children() + .forEach(ch => this.remove_overlay(ch)); this._overlays = []; overlays.forEach(ch => this.add_overlay(ch)); @@ -71,7 +72,6 @@ export default class AgsOverlay extends Gtk.Overlay { } remove_overlay(widget: Gtk.Widget): void { - //why is ts complaining remove_overlay doesn't exist? - //super.remove_overlay(widget); + super.remove(widget); } } diff --git a/src/widgets/revealer.ts b/src/widgets/revealer.ts index cb83322..4dbcb1e 100644 --- a/src/widgets/revealer.ts +++ b/src/widgets/revealer.ts @@ -40,8 +40,9 @@ export default class AgsRevealer extends Gtk.Revealer { get child() { return this.get_child(); } set child(child: Gtk.Widget) { const widget = this.get_child(); - if (widget === child) return; - + if (widget === child) + return; + if (widget) widget.destroy(); diff --git a/src/widgets/scrollable.ts b/src/widgets/scrollable.ts index 29c15cb..bed4f54 100644 --- a/src/widgets/scrollable.ts +++ b/src/widgets/scrollable.ts @@ -34,8 +34,9 @@ export default class AgsScrollable extends Gtk.ScrolledWindow { get child() { return this.get_child(); } set child(child: Gtk.Widget) { const widget = this.get_child(); - if (widget === child) return; - + if (widget === child) + return; + if (widget) widget.destroy(); diff --git a/src/widgets/stack.ts b/src/widgets/stack.ts index 8087152..a36877c 100644 --- a/src/widgets/stack.ts +++ b/src/widgets/stack.ts @@ -44,15 +44,15 @@ export default class AgsStack extends Gtk.Stack { set items(items: [string, Gtk.Widget][]) { this._items .filter(([name]) => !items.find(([n]) => n === name)) - .forEach(([_, ch]) => ch.destroy()); - + .forEach(([, ch]) => ch.destroy()); + // remove any children that weren't destroyed so // we can re-add everything without trying to add // items multiple times this._items - .filter(([_, ch]) => this.get_children().includes(ch)) - .forEach(([_, ch]) => this.remove(ch)); - + .filter(([, ch]) => this.get_children().includes(ch)) + .forEach(([, ch]) => this.remove(ch)); + this._items = []; items.forEach(([name, widget]) => { widget && this.add_named(widget, name); diff --git a/src/widgets/window.ts b/src/widgets/window.ts index 54ebec4..853b71f 100644 --- a/src/widgets/window.ts +++ b/src/widgets/window.ts @@ -174,7 +174,8 @@ export default class AgsWindow extends Gtk.Window { get child() { return this.get_child(); } set child(child: Gtk.Widget) { const widget = this.get_child(); - if (widget === child) return; + if (widget === child) + return; if (widget) widget.destroy();