js: Simplify promisify() calls
If the finish function isn't specified, promisify will now try to use the async name without '_async'/'_begin' suffix (if any) and '_finish' appended. Everything except IBus uses a variation of that pattern, so there's quite a bit of boilerplate we get to remove… Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2174>
This commit is contained in:
parent
928f3288e9
commit
5442266f28
@ -9,7 +9,7 @@ const { ServiceImplementation } = imports.dbusService;
|
|||||||
const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
|
const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
|
||||||
const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface);
|
const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface);
|
||||||
|
|
||||||
Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
|
Gio._promisify(Gio.DBusConnection.prototype, 'call');
|
||||||
|
|
||||||
var NotificationDaemon = class extends ServiceImplementation {
|
var NotificationDaemon = class extends ServiceImplementation {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -18,14 +18,11 @@ const FprintManagerProxy = Gio.DBusProxy.makeProxyWrapper(FprintManagerIface);
|
|||||||
const FprintDeviceIface = loadInterfaceXML('net.reactivated.Fprint.Device');
|
const FprintDeviceIface = loadInterfaceXML('net.reactivated.Fprint.Device');
|
||||||
const FprintDeviceProxy = Gio.DBusProxy.makeProxyWrapper(FprintDeviceIface);
|
const FprintDeviceProxy = Gio.DBusProxy.makeProxyWrapper(FprintDeviceIface);
|
||||||
|
|
||||||
Gio._promisify(Gdm.Client.prototype,
|
Gio._promisify(Gdm.Client.prototype, 'open_reauthentication_channel');
|
||||||
'open_reauthentication_channel', 'open_reauthentication_channel_finish');
|
Gio._promisify(Gdm.Client.prototype, 'get_user_verifier');
|
||||||
Gio._promisify(Gdm.Client.prototype,
|
|
||||||
'get_user_verifier', 'get_user_verifier_finish');
|
|
||||||
Gio._promisify(Gdm.UserVerifierProxy.prototype,
|
Gio._promisify(Gdm.UserVerifierProxy.prototype,
|
||||||
'call_begin_verification_for_user', 'call_begin_verification_for_user_finish');
|
'call_begin_verification_for_user');
|
||||||
Gio._promisify(Gdm.UserVerifierProxy.prototype,
|
Gio._promisify(Gdm.UserVerifierProxy.prototype, 'call_begin_verification');
|
||||||
'call_begin_verification', 'call_begin_verification_finish');
|
|
||||||
|
|
||||||
var PASSWORD_SERVICE_NAME = 'gdm-password';
|
var PASSWORD_SERVICE_NAME = 'gdm-password';
|
||||||
var FINGERPRINT_SERVICE_NAME = 'gdm-fingerprint';
|
var FINGERPRINT_SERVICE_NAME = 'gdm-fingerprint';
|
||||||
|
@ -32,7 +32,7 @@ const HAVE_MALCONTENT = imports.package.checkSymbol(
|
|||||||
var Malcontent = null;
|
var Malcontent = null;
|
||||||
if (HAVE_MALCONTENT) {
|
if (HAVE_MALCONTENT) {
|
||||||
Malcontent = imports.gi.Malcontent;
|
Malcontent = imports.gi.Malcontent;
|
||||||
Gio._promisify(Malcontent.Manager.prototype, 'get_app_filter_async', 'get_app_filter_finish');
|
Gio._promisify(Malcontent.Manager.prototype, 'get_app_filter_async');
|
||||||
}
|
}
|
||||||
|
|
||||||
let _singleton = null;
|
let _singleton = null;
|
||||||
|
@ -7,7 +7,7 @@ const PermissionStore = imports.misc.permissionStore;
|
|||||||
|
|
||||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||||
|
|
||||||
Gio._promisify(Geoclue.Simple, 'new', 'new_finish');
|
Gio._promisify(Geoclue.Simple, 'new');
|
||||||
|
|
||||||
const WeatherIntegrationIface = loadInterfaceXML('org.gnome.Shell.WeatherIntegration');
|
const WeatherIntegrationIface = loadInterfaceXML('org.gnome.Shell.WeatherIntegration');
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ const LoginManager = imports.misc.loginManager;
|
|||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const Params = imports.misc.params;
|
const Params = imports.misc.params;
|
||||||
|
|
||||||
Gio._promisify(Gio.File.prototype, 'query_info_async', 'query_info_finish');
|
Gio._promisify(Gio.File.prototype, 'query_info_async');
|
||||||
|
|
||||||
var DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
|
var DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
|
||||||
|
|
||||||
|
@ -10,9 +10,8 @@ const MessageTray = imports.ui.messageTray;
|
|||||||
const ModalDialog = imports.ui.modalDialog;
|
const ModalDialog = imports.ui.modalDialog;
|
||||||
const ShellEntry = imports.ui.shellEntry;
|
const ShellEntry = imports.ui.shellEntry;
|
||||||
|
|
||||||
Gio._promisify(Shell.NetworkAgent.prototype, 'init_async', 'init_finish');
|
Gio._promisify(Shell.NetworkAgent.prototype, 'init_async');
|
||||||
Gio._promisify(Shell.NetworkAgent.prototype,
|
Gio._promisify(Shell.NetworkAgent.prototype, 'search_vpn_plugin');
|
||||||
'search_vpn_plugin', 'search_vpn_plugin_finish');
|
|
||||||
|
|
||||||
const VPN_UI_GROUP = 'VPN Plugin UI';
|
const VPN_UI_GROUP = 'VPN Plugin UI';
|
||||||
|
|
||||||
|
@ -8,13 +8,10 @@ var Tp = null;
|
|||||||
try {
|
try {
|
||||||
({ TelepathyGLib: Tp, TelepathyLogger: Tpl } = imports.gi);
|
({ TelepathyGLib: Tp, TelepathyLogger: Tpl } = imports.gi);
|
||||||
|
|
||||||
Gio._promisify(Tp.Channel.prototype, 'close_async', 'close_finish');
|
Gio._promisify(Tp.Channel.prototype, 'close_async');
|
||||||
Gio._promisify(Tp.TextChannel.prototype,
|
Gio._promisify(Tp.TextChannel.prototype, 'send_message_async');
|
||||||
'send_message_async', 'send_message_finish');
|
Gio._promisify(Tp.ChannelDispatchOperation.prototype, 'claim_with_async');
|
||||||
Gio._promisify(Tp.ChannelDispatchOperation.prototype,
|
Gio._promisify(Tpl.LogManager.prototype, 'get_filtered_events_async');
|
||||||
'claim_with_async', 'claim_with_finish');
|
|
||||||
Gio._promisify(Tpl.LogManager.prototype,
|
|
||||||
'get_filtered_events_async', 'get_filtered_events_finish');
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Telepathy is not available, chat integration will be disabled.');
|
log('Telepathy is not available, chat integration will be disabled.');
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,14 @@ const { Clutter, Gio, GLib, GObject, Meta, Polkit, Shell, St } = imports.gi;
|
|||||||
const Gettext = imports.gettext;
|
const Gettext = imports.gettext;
|
||||||
const System = imports.system;
|
const System = imports.system;
|
||||||
|
|
||||||
Gio._promisify(Gio.DataInputStream.prototype, 'fill_async', 'fill_finish');
|
Gio._promisify(Gio.DataInputStream.prototype, 'fill_async');
|
||||||
Gio._promisify(Gio.DataInputStream.prototype,
|
Gio._promisify(Gio.DataInputStream.prototype, 'read_line_async');
|
||||||
'read_line_async', 'read_line_finish');
|
Gio._promisify(Gio.DBus, 'get');
|
||||||
Gio._promisify(Gio.DBus, 'get', 'get_finish');
|
Gio._promisify(Gio.DBusConnection.prototype, 'call');
|
||||||
Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
|
Gio._promisify(Gio.DBusProxy, 'new');
|
||||||
Gio._promisify(Gio.DBusProxy, 'new', 'new_finish');
|
Gio._promisify(Gio.DBusProxy.prototype, 'init_async');
|
||||||
Gio._promisify(Gio.DBusProxy.prototype, 'init_async', 'init_finish');
|
Gio._promisify(Gio.DBusProxy.prototype, 'call_with_unix_fd_list');
|
||||||
Gio._promisify(Gio.DBusProxy.prototype,
|
Gio._promisify(Polkit.Permission, 'new');
|
||||||
'call_with_unix_fd_list', 'call_with_unix_fd_list_finish');
|
|
||||||
Gio._promisify(Polkit.Permission, 'new', 'new_finish');
|
|
||||||
|
|
||||||
let _localTimeZone = null;
|
let _localTimeZone = null;
|
||||||
|
|
||||||
|
@ -10,14 +10,10 @@ const FileUtils = imports.misc.fileUtils;
|
|||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const ModalDialog = imports.ui.modalDialog;
|
const ModalDialog = imports.ui.modalDialog;
|
||||||
|
|
||||||
Gio._promisify(Soup.Session.prototype,
|
Gio._promisify(Soup.Session.prototype, 'send_and_read_async');
|
||||||
'send_and_read_async', 'send_and_read_finish');
|
Gio._promisify(Gio.OutputStream.prototype, 'write_bytes_async');
|
||||||
Gio._promisify(Gio.OutputStream.prototype,
|
Gio._promisify(Gio.IOStream.prototype, 'close_async');
|
||||||
'write_bytes_async', 'write_bytes_finish');
|
Gio._promisify(Gio.Subprocess.prototype, 'wait_check_async');
|
||||||
Gio._promisify(Gio.IOStream.prototype,
|
|
||||||
'close_async', 'close_finish');
|
|
||||||
Gio._promisify(Gio.Subprocess.prototype,
|
|
||||||
'wait_check_async', 'wait_check_finish');
|
|
||||||
|
|
||||||
var REPOSITORY_URL_DOWNLOAD = 'https://extensions.gnome.org/download-extension/%s.shell-extension.zip';
|
var REPOSITORY_URL_DOWNLOAD = 'https://extensions.gnome.org/download-extension/%s.shell-extension.zip';
|
||||||
var REPOSITORY_URL_INFO = 'https://extensions.gnome.org/extension-info/';
|
var REPOSITORY_URL_INFO = 'https://extensions.gnome.org/extension-info/';
|
||||||
|
@ -100,8 +100,8 @@ let _themeResource = null;
|
|||||||
let _oskResource = null;
|
let _oskResource = null;
|
||||||
let _iconResource = null;
|
let _iconResource = null;
|
||||||
|
|
||||||
Gio._promisify(Gio.File.prototype, 'delete_async', 'delete_finish');
|
Gio._promisify(Gio.File.prototype, 'delete_async');
|
||||||
Gio._promisify(Gio.File.prototype, 'touch_async', 'touch_finish');
|
Gio._promisify(Gio.File.prototype, 'touch_async');
|
||||||
|
|
||||||
let _remoteAccessInhibited = false;
|
let _remoteAccessInhibited = false;
|
||||||
|
|
||||||
|
@ -10,17 +10,12 @@ const Main = imports.ui.main;
|
|||||||
const MessageTray = imports.ui.messageTray;
|
const MessageTray = imports.ui.messageTray;
|
||||||
const Workspace = imports.ui.workspace;
|
const Workspace = imports.ui.workspace;
|
||||||
|
|
||||||
Gio._promisify(Shell.Screenshot.prototype, 'pick_color', 'pick_color_finish');
|
Gio._promisify(Shell.Screenshot.prototype, 'pick_color');
|
||||||
Gio._promisify(Shell.Screenshot.prototype, 'screenshot', 'screenshot_finish');
|
Gio._promisify(Shell.Screenshot.prototype, 'screenshot');
|
||||||
Gio._promisify(Shell.Screenshot.prototype,
|
Gio._promisify(Shell.Screenshot.prototype, 'screenshot_window');
|
||||||
'screenshot_window', 'screenshot_window_finish');
|
Gio._promisify(Shell.Screenshot.prototype, 'screenshot_area');
|
||||||
Gio._promisify(Shell.Screenshot.prototype,
|
Gio._promisify(Shell.Screenshot.prototype, 'screenshot_stage_to_content');
|
||||||
'screenshot_area', 'screenshot_area_finish');
|
Gio._promisify(Shell.Screenshot, 'composite_to_stream');
|
||||||
Gio._promisify(Shell.Screenshot.prototype,
|
|
||||||
'screenshot_stage_to_content', 'screenshot_stage_to_content_finish');
|
|
||||||
Gio._promisify(
|
|
||||||
Shell.Screenshot,
|
|
||||||
'composite_to_stream', 'composite_to_stream_finish');
|
|
||||||
|
|
||||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||||
const { DBusSenderChecker } = imports.misc.util;
|
const { DBusSenderChecker } = imports.misc.util;
|
||||||
|
@ -15,10 +15,9 @@ const Util = imports.misc.util;
|
|||||||
|
|
||||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||||
|
|
||||||
Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
|
Gio._promisify(Gio.DBusConnection.prototype, 'call');
|
||||||
Gio._promisify(NM.Client, 'new_async', 'new_finish');
|
Gio._promisify(NM.Client, 'new_async');
|
||||||
Gio._promisify(NM.Client.prototype,
|
Gio._promisify(NM.Client.prototype, 'check_connectivity_async');
|
||||||
'check_connectivity_async', 'check_connectivity_finish');
|
|
||||||
|
|
||||||
const NMConnectionCategory = {
|
const NMConnectionCategory = {
|
||||||
INVALID: 'invalid',
|
INVALID: 'invalid',
|
||||||
|
@ -46,10 +46,8 @@ const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
|
|||||||
|
|
||||||
const WINDOW_DIMMER_EFFECT_NAME = "gnome-shell-window-dimmer";
|
const WINDOW_DIMMER_EFFECT_NAME = "gnome-shell-window-dimmer";
|
||||||
|
|
||||||
Gio._promisify(Shell,
|
Gio._promisify(Shell, 'util_start_systemd_unit');
|
||||||
'util_start_systemd_unit', 'util_start_systemd_unit_finish');
|
Gio._promisify(Shell, 'util_stop_systemd_unit');
|
||||||
Gio._promisify(Shell,
|
|
||||||
'util_stop_systemd_unit', 'util_stop_systemd_unit_finish');
|
|
||||||
|
|
||||||
var DisplayChangeDialog = GObject.registerClass(
|
var DisplayChangeDialog = GObject.registerClass(
|
||||||
class DisplayChangeDialog extends ModalDialog.ModalDialog {
|
class DisplayChangeDialog extends ModalDialog.ModalDialog {
|
||||||
|
@ -14,8 +14,8 @@ const { ExtensionState, ExtensionType } = ExtensionUtils;
|
|||||||
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
||||||
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
|
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
|
||||||
|
|
||||||
Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
|
Gio._promisify(Gio.DBusConnection.prototype, 'call');
|
||||||
Gio._promisify(Shew.WindowExporter.prototype, 'export', 'export_finish');
|
Gio._promisify(Shew.WindowExporter.prototype, 'export');
|
||||||
|
|
||||||
function loadInterfaceXML(iface) {
|
function loadInterfaceXML(iface) {
|
||||||
const uri = 'resource:///org/gnome/Extensions/dbus-interfaces/%s.xml'.format(iface);
|
const uri = 'resource:///org/gnome/Extensions/dbus-interfaces/%s.xml'.format(iface);
|
||||||
|
Loading…
Reference in New Issue
Block a user