Codebase list gnome-shell-extension-appindicator / 9af5266
prefs: Add ability to run it as standalone app with both Gtk 3 and 4 Marco Trevisan (TreviƱo) 2 years ago
1 changed file(s) with 40 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
11
22 /* exported init, buildPrefsWidget */
33
4 const Gio = imports.gi.Gio;
5
6 try {
7 // eslint-disable-next-line no-unused-expressions
8 imports.misc.extensionUtils;
9 } catch (e) {
10 const resource = Gio.Resource.load(
11 '/usr/share/gnome-shell/org.gnome.Extensions.src.gresource');
12 resource._register();
13 imports.searchPath.push('resource:///org/gnome/Extensions/js');
14
15 const { GLib } = imports.gi;
16 const gtkVersion = GLib.getenv('FORCE_GTK_VERSION') || '4.0';
17 imports.gi.versions.Gtk = gtkVersion;
18 imports.gi.versions.Gdk = gtkVersion;
19 }
20
421 const GObject = imports.gi.GObject;
522 const Gtk = imports.gi.Gtk;
6 const Gio = imports.gi.Gio;
723
824 const ExtensionUtils = imports.misc.extensionUtils;
925 const Me = ExtensionUtils.getCurrentExtension();
10 const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
26 const Gettext = imports.gettext.domain(
27 Me ? Me.metadata['gettext-domain'] : 'AppIndicatorExtension');
1128 const _ = Gettext.gettext;
1229
1330 function init() {
1936 _init() {
2037 super._init({ row_spacing: 10 });
2138 this.margin = 24;
22 this._settings = ExtensionUtils.getSettings();
39 this._settings = Me ? ExtensionUtils.getSettings()
40 : new Gio.Settings({ schema_id: 'org.gnome.shell.extensions.appindicator' });
2341
2442 let label = null;
2543 let widget = null;
142160
143161 return widget;
144162 }
163
164 if (!Me) {
165 const { GLib } = imports.gi;
166 GLib.setenv('GSETTINGS_SCHEMA_DIR', './schemas', true);
167 Gtk.init(null);
168
169 const loop = GLib.MainLoop.new(null, false);
170 const win = new Gtk.Window();
171 if (win.set_child) {
172 win.set_child(buildPrefsWidget());
173 win.connect('close-request', () => loop.quit());
174 } else {
175 win.add(buildPrefsWidget());
176 win.connect('delete-event', () => loop.quit());
177 }
178 win.present();
179
180 loop.run();
181 }