extensions-app: Turn Extension into a GObject

This makes the Extension class usable as item-type in models,
and allows us to use property bindings.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3067>
This commit is contained in:
Florian Müllner
2023-12-19 18:45:04 +01:00
committed by Marge Bot
parent f7ded3e509
commit 198c7bbd9c
2 changed files with 143 additions and 21 deletions

View File

@ -4,10 +4,17 @@ import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import {ExtensionState} from './misc/extensionUtils.js';
import {Extension} from './extensionManager.js';
export const ExtensionRow = GObject.registerClass({
GTypeName: 'ExtensionRow',
Template: 'resource:///org/gnome/Extensions/ui/extension-row.ui',
Properties: {
'extension': GObject.ParamSpec.object(
'extension', null, null,
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY,
Extension),
},
InternalChildren: [
'detailsPopover',
'descriptionLabel',
@ -19,11 +26,10 @@ export const ExtensionRow = GObject.registerClass({
'actionsBox',
],
}, class ExtensionRow extends Adw.ActionRow {
_init(extension) {
super._init();
constructor(extension) {
super({extension});
this._app = Gio.Application.get_default();
this._extension = extension;
this._actionGroup = new Gio.SimpleActionGroup();
this.insert_action_group('row', this._actionGroup);
@ -89,7 +95,11 @@ export const ExtensionRow = GObject.registerClass({
}
get extension() {
return this._extension;
return this._extension ?? null;
}
set extension(ext) {
this._extension = ext;
}
_updateState() {