[gnome] Fix version for gjsosk and gsconnect, add impatience
This commit is contained in:
61
gnome/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/gsconnect-preferences
Normal file → Executable file
61
gnome/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/gsconnect-preferences
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env gjs
|
||||
#!/usr/bin/env -S gjs -m
|
||||
|
||||
// SPDX-FileCopyrightText: GSConnect Developers https://github.com/GSConnect
|
||||
//
|
||||
@ -6,43 +6,20 @@
|
||||
|
||||
// -*- mode: js; -*-
|
||||
|
||||
'use strict';
|
||||
import Gdk from 'gi://Gdk?version=3.0';
|
||||
import 'gi://GdkPixbuf?version=2.0';
|
||||
import Gio from 'gi://Gio?version=2.0';
|
||||
import GLib from 'gi://GLib?version=2.0';
|
||||
import GObject from 'gi://GObject?version=2.0';
|
||||
import Gtk from 'gi://Gtk?version=3.0';
|
||||
|
||||
imports.gi.versions.Gdk = '3.0';
|
||||
imports.gi.versions.GdkPixbuf = '2.0';
|
||||
imports.gi.versions.Gio = '2.0';
|
||||
imports.gi.versions.GLib = '2.0';
|
||||
imports.gi.versions.GObject = '2.0';
|
||||
imports.gi.versions.Gtk = '3.0';
|
||||
import system from 'system';
|
||||
|
||||
const Gdk = imports.gi.Gdk;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const GObject = imports.gi.GObject;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
import './preferences/init.js';
|
||||
import {Window} from './preferences/service.js';
|
||||
import Config from './config.js';
|
||||
|
||||
|
||||
// Bootstrap
|
||||
function get_datadir() {
|
||||
let [, path] = /@([^:]+):\d+/.exec(new Error().stack.split('\n')[1]);
|
||||
const info = Gio.File.new_for_path(path)
|
||||
.query_info('standard::*', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
||||
path = info.get_is_symlink() ? info.get_symlink_target() : path;
|
||||
|
||||
return Gio.File.new_for_path(path).get_parent().get_path();
|
||||
}
|
||||
|
||||
imports.searchPath.unshift(get_datadir());
|
||||
imports.config.PACKAGE_DATADIR = imports.searchPath[0];
|
||||
|
||||
// Bootstrap
|
||||
const {setup, setupGettext} = imports.utils.setup;
|
||||
setup(imports.config.PACKAGE_DATADIR);
|
||||
setupGettext();
|
||||
|
||||
// Local Imports
|
||||
const Config = imports.config;
|
||||
const Settings = imports.preferences.service;
|
||||
import('gi://GioUnix?version=2.0').catch(() => {}); // Set version for optional dependency
|
||||
|
||||
|
||||
/**
|
||||
@ -65,7 +42,7 @@ const Preferences = GObject.registerClass({
|
||||
|
||||
vfunc_activate() {
|
||||
if (this._window === undefined) {
|
||||
this._window = new Settings.Window({
|
||||
this._window = new Window({
|
||||
application: this,
|
||||
});
|
||||
}
|
||||
@ -77,7 +54,7 @@ const Preferences = GObject.registerClass({
|
||||
super.vfunc_startup();
|
||||
|
||||
// Init some resources
|
||||
let provider = new Gtk.CssProvider();
|
||||
const provider = new Gtk.CssProvider();
|
||||
provider.load_from_resource(`${Config.APP_PATH}/application.css`);
|
||||
Gtk.StyleContext.add_provider_for_screen(
|
||||
Gdk.Screen.get_default(),
|
||||
@ -85,13 +62,13 @@ const Preferences = GObject.registerClass({
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
);
|
||||
|
||||
let actions = [
|
||||
const actions = [
|
||||
['refresh', null],
|
||||
['connect', GLib.VariantType.new('s')],
|
||||
];
|
||||
|
||||
for (let [name, type] of actions) {
|
||||
let action = new Gio.SimpleAction({
|
||||
for (const [name, type] of actions) {
|
||||
const action = new Gio.SimpleAction({
|
||||
name: name,
|
||||
parameter_type: type,
|
||||
});
|
||||
@ -101,7 +78,7 @@ const Preferences = GObject.registerClass({
|
||||
|
||||
vfunc_activate_action(action_name, parameter) {
|
||||
try {
|
||||
let paramArray = [];
|
||||
const paramArray = [];
|
||||
|
||||
if (parameter instanceof GLib.Variant)
|
||||
paramArray[0] = parameter;
|
||||
@ -124,4 +101,4 @@ const Preferences = GObject.registerClass({
|
||||
}
|
||||
});
|
||||
|
||||
(new Preferences()).run([imports.system.programInvocationName].concat(ARGV));
|
||||
await (new Preferences()).runAsync([system.programInvocationName].concat(ARGV));
|
||||
|
||||
Reference in New Issue
Block a user