wip: Port extensions app/portal to GTK4
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* exported main */
|
||||
imports.gi.versions.Gdk = '3.0';
|
||||
imports.gi.versions.Gtk = '3.0';
|
||||
imports.gi.versions.Gdk = '4.0';
|
||||
imports.gi.versions.Gtk = '4.0';
|
||||
|
||||
const Gettext = imports.gettext;
|
||||
const Package = imports.package;
|
||||
@@ -63,7 +63,7 @@ class Application extends Gtk.Application {
|
||||
} catch (e) {
|
||||
logError(e, 'Failed to add application style');
|
||||
}
|
||||
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
|
||||
Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(),
|
||||
provider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
@@ -80,7 +80,6 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
InternalChildren: [
|
||||
'userList',
|
||||
'systemList',
|
||||
'mainBox',
|
||||
'mainStack',
|
||||
'scrolledWindow',
|
||||
'updatesBar',
|
||||
@@ -95,8 +94,6 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
this._exporter = new Shew.WindowExporter({ window: this });
|
||||
this._exportedHandle = '';
|
||||
|
||||
this._mainBox.set_focus_vadjustment(this._scrolledWindow.vadjustment);
|
||||
|
||||
let action;
|
||||
action = new Gio.SimpleAction({ name: 'show-about' });
|
||||
action.connect('activate', this._showAbout.bind(this));
|
||||
@@ -117,10 +114,7 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
this.add_action(action);
|
||||
|
||||
this._userList.set_sort_func(this._sortList.bind(this));
|
||||
this._userList.set_header_func(this._updateHeader.bind(this));
|
||||
|
||||
this._systemList.set_sort_func(this._sortList.bind(this));
|
||||
this._systemList.set_header_func(this._updateHeader.bind(this));
|
||||
|
||||
this._shellProxy.connectSignal('ExtensionStateChanged',
|
||||
this._onExtensionStateChanged.bind(this));
|
||||
@@ -209,18 +203,10 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
return row1.name.localeCompare(row2.name);
|
||||
}
|
||||
|
||||
_updateHeader(row, before) {
|
||||
if (!before || row.get_header())
|
||||
return;
|
||||
|
||||
let sep = new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
|
||||
row.set_header(sep);
|
||||
}
|
||||
|
||||
_findExtensionRow(uuid) {
|
||||
return [
|
||||
...this._userList.get_children(),
|
||||
...this._systemList.get_children(),
|
||||
...this._userList,
|
||||
...this._systemList,
|
||||
].find(c => c.uuid === uuid);
|
||||
}
|
||||
|
||||
@@ -240,13 +226,13 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
// and reset the variable to null so that we create a new row
|
||||
// below and add it to the appropriate list
|
||||
if (row && row.type !== extension.type) {
|
||||
row.destroy();
|
||||
row.get_parent().remove(row);
|
||||
row = null;
|
||||
}
|
||||
|
||||
if (row) {
|
||||
if (extension.state === ExtensionState.UNINSTALLED)
|
||||
row.destroy();
|
||||
row.get_parent().remove(row);
|
||||
} else {
|
||||
this._addExtensionRow(extension);
|
||||
}
|
||||
@@ -276,12 +262,11 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
|
||||
_addExtensionRow(extension) {
|
||||
let row = new ExtensionRow(extension);
|
||||
row.show_all();
|
||||
|
||||
if (row.type === ExtensionType.PER_USER)
|
||||
this._userList.add(row);
|
||||
this._userList.insert(row, -1);
|
||||
else
|
||||
this._systemList.add(row);
|
||||
this._systemList.insert(row, -1);
|
||||
}
|
||||
|
||||
_queueUpdatesCheck() {
|
||||
@@ -298,8 +283,8 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
}
|
||||
|
||||
_syncListVisibility() {
|
||||
this._userList.visible = this._userList.get_children().length > 0;
|
||||
this._systemList.visible = this._systemList.get_children().length > 0;
|
||||
this._userList.visible = this._userList.get_first_child() !== null;
|
||||
this._systemList.visible = this._systemList.get_first_child() !== null;
|
||||
|
||||
if (this._userList.visible || this._systemList.visible)
|
||||
this._mainStack.visible_child_name = 'main';
|
||||
@@ -308,13 +293,13 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
}
|
||||
|
||||
_checkUpdates() {
|
||||
let nUpdates = this._userList.get_children().filter(c => c.hasUpdate).length;
|
||||
let nUpdates = [...this._userList].filter(c => c.hasUpdate).length;
|
||||
|
||||
this._updatesLabel.label = Gettext.ngettext(
|
||||
'%d extension will be updated on next login.',
|
||||
'%d extensions will be updated on next login.',
|
||||
nUpdates).format(nUpdates);
|
||||
this._updatesBar.visible = nUpdates > 0;
|
||||
this._updatesBar.revealed = nUpdates > 0;
|
||||
}
|
||||
|
||||
_extensionsLoaded() {
|
||||
@@ -354,7 +339,7 @@ var ExtensionRow = GObject.registerClass({
|
||||
name: 'show-prefs',
|
||||
enabled: this.hasPrefs,
|
||||
});
|
||||
action.connect('activate', () => this.get_toplevel().openPrefs(this.uuid));
|
||||
action.connect('activate', () => this.get_root().openPrefs(this.uuid));
|
||||
this._actionGroup.add_action(action);
|
||||
|
||||
action = new Gio.SimpleAction({
|
||||
@@ -371,7 +356,7 @@ var ExtensionRow = GObject.registerClass({
|
||||
name: 'uninstall',
|
||||
enabled: this.type === ExtensionType.PER_USER,
|
||||
});
|
||||
action.connect('activate', () => this.get_toplevel().uninstall(this.uuid));
|
||||
action.connect('activate', () => this.get_root().uninstall(this.uuid));
|
||||
this._actionGroup.add_action(action);
|
||||
|
||||
action = new Gio.SimpleAction({
|
||||
|
Reference in New Issue
Block a user