Commit edd34c50 authored by Florian Müllner's avatar Florian Müllner Committed by Marge Bot

Port extensions app and portal to GTK4

With the previous preparations in place, it is time to take the plunge.

As both the app and the portal use the same small library for handling
external windows, port everything at once to avoid the hassle of building
and installing two versions of the library.

With the portal using GTK4 now, all extensions must port their preference
widgets as well.

Part-of: <!1495>
parent ba039bcc
Pipeline #246850 passed with stages
in 3 minutes and 43 seconds
......@@ -128,7 +128,7 @@ var ExtensionsService = class extends ServiceImplementation {
externalWindow = Shew.ExternalWindow.new_from_handle(parentWindow);
if (externalWindow)
externalWindow.set_parent_of(window.window);
externalWindow.set_parent_of(window.get_surface());
if (options.modal)
window.modal = options.modal.get_boolean();
......@@ -177,11 +177,11 @@ var ExtensionPrefsDialog = GObject.registerClass({
this._initActions();
this._addCustomStylesheet();
this._gesture = new Gtk.GestureMultiPress({
widget: this._expander,
this._gesture = new Gtk.GestureClick({
button: 0,
exclusive: true,
});
this._expander.add_controller(this._gesture);
this._gesture.connect('released', (gesture, nPress) => {
if (nPress === 1)
......@@ -216,9 +216,9 @@ var ExtensionPrefsDialog = GObject.registerClass({
_syncExpandedStyle() {
if (this._revealer.reveal_child)
this._expander.get_style_context().add_class('expanded');
this._expander.add_css_class('expanded');
else if (!this._revealer.child_revealed)
this._expander.get_style_context().remove_class('expanded');
this._expander.remove_css_class('expanded');
}
_setError(exc) {
......@@ -276,7 +276,7 @@ var ExtensionPrefsDialog = GObject.registerClass({
} 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);
}
......
/* 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 { Gtk } = imports.gi;
const pkg = imports.package;
......@@ -10,7 +10,7 @@ const { DBusService } = imports.dbusService;
const { ExtensionsService } = imports.extensionsService;
function main() {
Gtk.init(null);
Gtk.init();
pkg.initFormat();
const service = new DBusService(
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="ExtensionPrefsDialog" parent="GtkWindow">
<property name="default-width">600</property>
<property name="default-height">400</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerBar">
<property name="visible">True</property>
<property name="show-close-button">True</property>
</object>
<object class="GtkHeaderBar"/>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="margin-start">100</property>
<property name="margin-end">100</property>
......@@ -34,7 +25,6 @@
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Something’s gone wrong</property>
<attributes>
<attribute name="scale" value="1.44"/> <!-- x-large -->
......@@ -46,7 +36,6 @@
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">We’re very sorry, but there’s been a problem: the settings for this extension can’t be displayed. We recommend that you report the issue to the extension authors.</property>
<property name="justify">center</property>
<property name="wrap">True</property>
......@@ -54,29 +43,24 @@
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="margin-top">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="expander">
<property name="visible">True</property>
<property name="spacing">6</property>
<style>
<class name="expander"/>
</style>
<child>
<object class="GtkImage" id="expanderArrow">
<property name="visible">True</property>
<property name="icon-name">pan-end-symbolic</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Technical Details</property>
</object>
</child>
......@@ -84,15 +68,11 @@
</child>
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTextView" id="errorView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="monospace">True</property>
<property name="editable">False</property>
<property name="wrap-mode">word</property>
......@@ -104,26 +84,15 @@
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<style>
<class name="expander-toolbar"/>
</style>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">win.copy-error</property>
<style>
<class name="flat"/>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">edit-copy-symbolic</property>
</object>
</child>
<property name="has-frame">False</property>
<property name="icon-name">edit-copy-symbolic</property>
</object>
</child>
<child>
......@@ -136,13 +105,9 @@
<property name="halign">end</property>
<property name="label" translatable="yes">Homepage</property>
<property name="tooltip-text" translatable="yes">Visit extension homepage</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="no-show-all">True</property>
<property name="has-frame">False</property>
<property name="action-name">win.show-url</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="ExtensionRow" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="column-spacing">12</property>
<child>
<object class="GtkLabel" id="nameLabel">
<property name="visible">True</property>
</object>
<object class="GtkLabel" id="nameLabel"/>
</child>
<child>
<object class="GtkImage" id="errorIcon">
<property name="no-show-all">True</property>
<property name="visible">False</property>
<property name="icon-name">dialog-error-symbolic</property>
<style>
<class name="error"/>
......@@ -29,7 +24,7 @@
</child>
<child>
<object class="GtkImage" id="updatesIcon">
<property name="no-show-all">True</property>
<property name="visible">False</property>
<property name="icon-name">software-update-available-symbolic</property>
<style>
<class name="warning"/>
......@@ -38,77 +33,53 @@
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="hexpand">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="prefsButton">
<property name="no-show-all">True</property>
<property name="visible"
bind-source="prefsButton"
bind-property="sensitive"
bind-flags="sync-create"/>
<property name="can-focus">True</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="action-name">row.show-prefs</property>
<style>
<class name="circular"/>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">emblem-system-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSwitch" id="switch">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="action-name">row.enabled</property>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
</object>
<object class="GtkSeparator"/>
</child>
<child>
<child>
<object class="GtkButton" id="revealButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="has-frame">False</property>
<property name="icon-name">pan-end-symbolic</property>
<style>
<class name="details-button"/>
<class name="image-button"/>
<class name="flat"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">pan-end-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="margin-top">12</property>
<property name="row-spacing">6</property>
<property name="column-spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Description</property>
<property name="xalign">0</property>
<style>
......@@ -118,7 +89,6 @@
</child>
<child>
<object class="GtkLabel" id="descriptionLabel">
<property name="visible">True</property>
<property name="ellipsize">end</property>
<property name="max-width-chars">60</property>
<property name="xalign">0</property>
......@@ -131,27 +101,26 @@
bind-source="versionLabel"
bind-property="visible"
bind-flags="sync-create"/>
<property name="no-show-all">True</property>
<property name="label" translatable="yes">Version</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="versionLabel">
<property name="no-show-all">True</property>
<property name="visible">False</property>
<property name="xalign">0</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
......@@ -159,27 +128,26 @@
bind-source="authorLabel"
bind-property="visible"
bind-flags="sync-create"/>
<property name="no-show-all">True</property>
<property name="label" translatable="yes">Author</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="authorLabel">
<property name="no-show-all">True</property>
<property name="visible">False</property>
<property name="xalign">0</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
......@@ -187,44 +155,42 @@
bind-source="errorLabel"
bind-property="visible"
bind-flags="sync-create"/>
<property name="no-show-all">True</property>
<property name="label" translatable="yes">Error</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="errorLabel">
<property name="no-show-all">True</property>
<property name="visible">False</property>
<property name="selectable">True</property>
<property name="wrap">True</property>
<property name="max-width-chars">60</property>
<property name="xalign">0</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="label" translatable="yes">Website</property>
<property name="action-name">row.show-url</property>
<property name="valign">end</property>
<property name="margin-top">12</property>
<layout>
<property name="column">0</property>
<property name="row">4</property>
</layout>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="removeButton">
......@@ -232,7 +198,6 @@
bind-source="removeButton"
bind-property="sensitive"
bind-flags="sync-create"/>
<property name="no-show-all">True</property>
<property name="label" translatable="yes">Remove…</property>
<property name="action-name">row.uninstall</property>
<property name="hexpand">True</property>
......@@ -241,20 +206,20 @@
<style>
<class name="destructive-action"/>
</style>
<layout>
<property name="column">1</property>
<property name="row">4</property>
</layout>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
</object>
</child>
<layout>
<property name="column">0</property>
<property name="row">1</property>
<property name="column-span">8</property>
</layout>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="width">8</property>
</packing>
</child>
</object>
</child>
......
/* 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;
......@@ -65,7 +65,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);
......@@ -88,7 +88,6 @@ var ExtensionsWindow = GObject.registerClass({
InternalChildren: [
'userList',
'systemList',
'mainBox',
'mainStack',
'scrolledWindow',
'searchBar',
......@@ -106,8 +105,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));
......@@ -127,16 +124,6 @@ var ExtensionsWindow = GObject.registerClass({
});
this.add_action(action);
const accelGroup = new Gtk.AccelGroup();
this._searchButton.add_accelerator('clicked',
accelGroup, Gdk.KEY_f, Gdk.ModifierType.CONTROL_MASK, 0);
this._searchButton.add_accelerator('clicked',
accelGroup, Gdk.KEY_s, Gdk.ModifierType.CONTROL_MASK, 0);
this.add_accel_group(accelGroup);
this.connect('key-press-event',
(w, event) => this._searchBar.handle_event(event));
this._searchTerms = [];
this._searchEntry.connect('search-changed', () => {
const { text } = this._searchEntry;
......@@ -150,7 +137,6 @@ var ExtensionsWindow = GObject.registerClass({
});
this._userList.set_sort_func(this._sortList.bind(this));
this._userList.set_header_func(this._updateHeader.bind(this));
this._userList.set_filter_func(this._filterList.bind(this));
this._userList.set_placeholder(new Gtk.Label({
label: _('No Matches'),
......@@ -158,11 +144,9 @@ var ExtensionsWindow = GObject.registerClass({
margin_end: 12,
margin_top: 12,
margin_bottom: 12,
visible: true,
}));
this._systemList.set_sort_func(this._sortList.bind(this));
this._systemList.set_header_func(this._updateHeader.bind(this));
this._systemList.set_filter_func(this._filterList.bind(this));
this._systemList.set_placeholder(new Gtk.Label({
label: _('No Matches'),
......@@ -170,7 +154,6 @@ var ExtensionsWindow = GObject.registerClass({
margin_end: 12,
margin_top: 12,
margin_bottom: 12,
visible: true,
}));
this._shellProxy.connectSignal('ExtensionStateChanged',
......@@ -265,18 +248,10 @@ var ExtensionsWindow = GObject.registerClass({
t => row.keywords.some(k => k.startsWith(t)));
}
_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);
}
......@@ -296,13 +271,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();