2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2011-08-16 12:19:59 +00:00
|
|
|
const Gio = imports.gi.Gio;
|
|
|
|
const GLib = imports.gi.GLib;
|
2012-08-11 21:11:37 +00:00
|
|
|
const Lang = imports.lang;
|
|
|
|
const Meta = imports.gi.Meta;
|
2012-01-19 02:30:06 +00:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2011-06-30 00:09:00 +00:00
|
|
|
const Config = imports.misc.config;
|
2011-06-23 02:03:04 +00:00
|
|
|
const ExtensionSystem = imports.ui.extensionSystem;
|
2012-05-25 23:07:31 +00:00
|
|
|
const ExtensionDownloader = imports.ui.extensionDownloader;
|
2012-01-31 01:58:29 +00:00
|
|
|
const ExtensionUtils = imports.misc.extensionUtils;
|
2009-09-23 18:30:05 +00:00
|
|
|
const Main = imports.ui.main;
|
2012-12-10 15:26:31 +00:00
|
|
|
const Screenshot = imports.ui.screenshot;
|
2011-07-09 13:30:42 +00:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2013-10-24 21:51:58 +00:00
|
|
|
const GnomeShellIface = '<node> \
|
|
|
|
<interface name="org.gnome.Shell"> \
|
|
|
|
<method name="Eval"> \
|
|
|
|
<arg type="s" direction="in" name="script" /> \
|
|
|
|
<arg type="b" direction="out" name="success" /> \
|
|
|
|
<arg type="s" direction="out" name="result" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="FocusSearch"/> \
|
|
|
|
<method name="ShowOSD"> \
|
|
|
|
<arg type="a{sv}" direction="in" name="params"/> \
|
|
|
|
</method> \
|
2015-01-26 14:52:10 +00:00
|
|
|
<method name="ShowMonitorLabels"> \
|
|
|
|
<arg type="a{uv}" direction="in" name="params" /> \
|
|
|
|
</method> \
|
2017-04-06 05:18:39 +00:00
|
|
|
<method name="ShowMonitorLabels2"> \
|
|
|
|
<arg type="a{sv}" direction="in" name="params" /> \
|
|
|
|
</method> \
|
2015-01-26 14:52:10 +00:00
|
|
|
<method name="HideMonitorLabels" /> \
|
2013-10-24 21:51:58 +00:00
|
|
|
<method name="FocusApp"> \
|
|
|
|
<arg type="s" direction="in" name="id"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="ShowApplications" /> \
|
|
|
|
<method name="GrabAccelerator"> \
|
|
|
|
<arg type="s" direction="in" name="accelerator"/> \
|
|
|
|
<arg type="u" direction="in" name="flags"/> \
|
|
|
|
<arg type="u" direction="out" name="action"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="GrabAccelerators"> \
|
|
|
|
<arg type="a(su)" direction="in" name="accelerators"/> \
|
|
|
|
<arg type="au" direction="out" name="actions"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="UngrabAccelerator"> \
|
|
|
|
<arg type="u" direction="in" name="action"/> \
|
|
|
|
<arg type="b" direction="out" name="success"/> \
|
|
|
|
</method> \
|
|
|
|
<signal name="AcceleratorActivated"> \
|
|
|
|
<arg name="action" type="u" /> \
|
2014-11-12 20:21:44 +00:00
|
|
|
<arg name="parameters" type="a{sv}" /> \
|
2013-10-24 21:51:58 +00:00
|
|
|
</signal> \
|
|
|
|
<property name="Mode" type="s" access="read" /> \
|
|
|
|
<property name="OverviewActive" type="b" access="readwrite" /> \
|
|
|
|
<property name="ShellVersion" type="s" access="read" /> \
|
|
|
|
</interface> \
|
|
|
|
</node>';
|
|
|
|
|
|
|
|
const ScreenSaverIface = '<node> \
|
|
|
|
<interface name="org.gnome.ScreenSaver"> \
|
|
|
|
<method name="Lock"> \
|
|
|
|
</method> \
|
|
|
|
<method name="GetActive"> \
|
|
|
|
<arg name="active" direction="out" type="b" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="SetActive"> \
|
|
|
|
<arg name="value" direction="in" type="b" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="GetActiveTime"> \
|
|
|
|
<arg name="value" direction="out" type="u" /> \
|
|
|
|
</method> \
|
|
|
|
<signal name="ActiveChanged"> \
|
|
|
|
<arg name="new_value" type="b" /> \
|
|
|
|
</signal> \
|
2014-03-10 18:16:03 +00:00
|
|
|
<signal name="WakeUpScreen" /> \
|
2013-10-24 21:51:58 +00:00
|
|
|
</interface> \
|
|
|
|
</node>';
|
2012-06-02 23:20:31 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const GnomeShell = new Lang.Class({
|
|
|
|
Name: 'GnomeShellDBus',
|
2009-09-23 18:30:05 +00:00
|
|
|
|
|
|
|
_init: function() {
|
2011-08-16 12:19:59 +00:00
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
2012-06-27 15:47:51 +00:00
|
|
|
|
2013-02-25 13:27:31 +00:00
|
|
|
this._extensionsService = new GnomeShellExtensions();
|
2012-12-10 15:26:31 +00:00
|
|
|
this._screenshotService = new Screenshot.ScreenshotService();
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2014-01-14 22:49:47 +00:00
|
|
|
this._grabbedAccelerators = new Map();
|
|
|
|
this._grabbers = new Map();
|
2012-08-11 21:11:37 +00:00
|
|
|
|
|
|
|
global.display.connect('accelerator-activated', Lang.bind(this,
|
2013-07-25 12:17:39 +00:00
|
|
|
function(display, action, deviceid, timestamp) {
|
|
|
|
this._emitAcceleratorActivated(action, deviceid, timestamp);
|
2012-08-11 21:11:37 +00:00
|
|
|
}));
|
2013-07-13 18:58:36 +00:00
|
|
|
|
|
|
|
this._cachedOverviewVisible = false;
|
|
|
|
Main.overview.connect('showing',
|
|
|
|
Lang.bind(this, this._checkOverviewVisibleChanged));
|
|
|
|
Main.overview.connect('hidden',
|
|
|
|
Lang.bind(this, this._checkOverviewVisibleChanged));
|
2009-09-23 18:30:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Eval:
|
|
|
|
* @code: A string containing JavaScript code
|
|
|
|
*
|
|
|
|
* This function executes arbitrary code in the main
|
|
|
|
* loop, and returns a boolean success and
|
|
|
|
* JSON representation of the object as a string.
|
|
|
|
*
|
|
|
|
* If evaluation completes without throwing an exception,
|
|
|
|
* then the return value will be [true, JSON.stringify(result)].
|
|
|
|
* If evaluation fails, then the return value will be
|
|
|
|
* [false, JSON.stringify(exception)];
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Eval: function(code) {
|
2011-10-27 21:41:06 +00:00
|
|
|
if (!global.settings.get_boolean('development-tools'))
|
2013-04-26 13:17:11 +00:00
|
|
|
return [false, ''];
|
2011-10-27 21:41:06 +00:00
|
|
|
|
2009-09-23 18:30:05 +00:00
|
|
|
let returnValue;
|
|
|
|
let success;
|
|
|
|
try {
|
|
|
|
returnValue = JSON.stringify(eval(code));
|
2009-11-12 23:17:58 +00:00
|
|
|
// A hack; DBus doesn't have null/undefined
|
|
|
|
if (returnValue == undefined)
|
2010-05-13 19:46:04 +00:00
|
|
|
returnValue = '';
|
2009-09-23 18:30:05 +00:00
|
|
|
success = true;
|
|
|
|
} catch (e) {
|
2013-11-13 18:20:08 +00:00
|
|
|
returnValue = '' + e;
|
2009-09-23 18:30:05 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
return [success, returnValue];
|
|
|
|
},
|
|
|
|
|
2013-05-17 15:31:27 +00:00
|
|
|
FocusSearch: function() {
|
|
|
|
Main.overview.focusSearch();
|
|
|
|
},
|
|
|
|
|
2013-03-02 15:22:49 +00:00
|
|
|
ShowOSD: function(params) {
|
|
|
|
for (let param in params)
|
|
|
|
params[param] = params[param].deep_unpack();
|
|
|
|
|
2017-06-17 16:31:34 +00:00
|
|
|
let monitorIndex = params['monitor'] || -1;
|
|
|
|
let label = params['label'] || undefined;
|
|
|
|
let level = params['level'] || undefined;
|
2013-11-18 12:48:19 +00:00
|
|
|
|
2013-03-02 15:22:49 +00:00
|
|
|
let icon = null;
|
|
|
|
if (params['icon'])
|
|
|
|
icon = Gio.Icon.new_for_string(params['icon']);
|
|
|
|
|
2017-06-17 16:31:34 +00:00
|
|
|
Main.osdWindowManager.show(monitorIndex, icon, label, level);
|
2013-03-02 15:22:49 +00:00
|
|
|
},
|
|
|
|
|
2011-07-09 13:30:42 +00:00
|
|
|
FocusApp: function(id) {
|
2013-04-24 17:32:41 +00:00
|
|
|
this.ShowApplications();
|
|
|
|
Main.overview.viewSelector.appDisplay.selectApp(id);
|
|
|
|
},
|
2011-07-09 13:30:42 +00:00
|
|
|
|
2013-04-24 17:32:41 +00:00
|
|
|
ShowApplications: function() {
|
|
|
|
Main.overview.viewSelector.showApps();
|
2011-07-09 13:30:42 +00:00
|
|
|
},
|
|
|
|
|
2012-08-11 21:11:37 +00:00
|
|
|
GrabAcceleratorAsync: function(params, invocation) {
|
|
|
|
let [accel, flags] = params;
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let bindingAction = this._grabAcceleratorForSender(accel, flags, sender);
|
|
|
|
return invocation.return_value(GLib.Variant.new('(u)', [bindingAction]));
|
|
|
|
},
|
|
|
|
|
|
|
|
GrabAcceleratorsAsync: function(params, invocation) {
|
|
|
|
let [accels] = params;
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let bindingActions = [];
|
|
|
|
for (let i = 0; i < accels.length; i++) {
|
|
|
|
let [accel, flags] = accels[i];
|
|
|
|
bindingActions.push(this._grabAcceleratorForSender(accel, flags, sender));
|
|
|
|
}
|
|
|
|
return invocation.return_value(GLib.Variant.new('(au)', [bindingActions]));
|
|
|
|
},
|
|
|
|
|
|
|
|
UngrabAcceleratorAsync: function(params, invocation) {
|
|
|
|
let [action] = params;
|
|
|
|
let grabbedBy = this._grabbedAccelerators.get(action);
|
|
|
|
if (invocation.get_sender() != grabbedBy)
|
|
|
|
return invocation.return_value(GLib.Variant.new('(b)', [false]));
|
|
|
|
|
|
|
|
let ungrabSucceeded = global.display.ungrab_accelerator(action);
|
|
|
|
if (ungrabSucceeded)
|
|
|
|
this._grabbedAccelerators.delete(action);
|
|
|
|
return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
|
|
|
|
},
|
|
|
|
|
2013-07-25 12:17:39 +00:00
|
|
|
_emitAcceleratorActivated: function(action, deviceid, timestamp) {
|
2012-08-11 21:11:37 +00:00
|
|
|
let destination = this._grabbedAccelerators.get(action);
|
|
|
|
if (!destination)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let connection = this._dbusImpl.get_connection();
|
|
|
|
let info = this._dbusImpl.get_info();
|
2014-11-12 20:21:44 +00:00
|
|
|
let params = { 'device-id': GLib.Variant.new('u', deviceid),
|
2014-11-12 19:49:24 +00:00
|
|
|
'timestamp': GLib.Variant.new('u', timestamp),
|
|
|
|
'action-mode': GLib.Variant.new('u', Main.actionMode) };
|
2012-08-11 21:11:37 +00:00
|
|
|
connection.emit_signal(destination,
|
|
|
|
this._dbusImpl.get_object_path(),
|
|
|
|
info ? info.name : null,
|
|
|
|
'AcceleratorActivated',
|
2014-11-12 20:21:44 +00:00
|
|
|
GLib.Variant.new('(ua{sv})', [action, params]));
|
2012-08-11 21:11:37 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_grabAcceleratorForSender: function(accelerator, flags, sender) {
|
|
|
|
let bindingAction = global.display.grab_accelerator(accelerator);
|
|
|
|
if (bindingAction == Meta.KeyBindingAction.NONE)
|
|
|
|
return Meta.KeyBindingAction.NONE;
|
|
|
|
|
|
|
|
let bindingName = Meta.external_binding_name_for_action(bindingAction);
|
|
|
|
Main.wm.allowKeybinding(bindingName, flags);
|
|
|
|
|
|
|
|
this._grabbedAccelerators.set(bindingAction, sender);
|
|
|
|
|
|
|
|
if (!this._grabbers.has(sender)) {
|
|
|
|
let id = Gio.bus_watch_name(Gio.BusType.SESSION, sender, 0, null,
|
|
|
|
Lang.bind(this, this._onGrabberBusNameVanished));
|
|
|
|
this._grabbers.set(sender, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bindingAction;
|
|
|
|
},
|
|
|
|
|
|
|
|
_ungrabAccelerator: function(action) {
|
|
|
|
let ungrabSucceeded = global.display.ungrab_accelerator(action);
|
|
|
|
if (ungrabSucceeded)
|
|
|
|
this._grabbedAccelerators.delete(action);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onGrabberBusNameVanished: function(connection, name) {
|
2014-01-14 22:49:47 +00:00
|
|
|
let grabs = this._grabbedAccelerators.entries();
|
|
|
|
for (let [action, sender] of grabs) {
|
2012-08-11 21:11:37 +00:00
|
|
|
if (sender == name)
|
|
|
|
this._ungrabAccelerator(action);
|
|
|
|
}
|
|
|
|
Gio.bus_unwatch_name(this._grabbers.get(name));
|
|
|
|
this._grabbers.delete(name);
|
|
|
|
},
|
|
|
|
|
2015-01-26 14:52:10 +00:00
|
|
|
ShowMonitorLabelsAsync: function(params, invocation) {
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let [dict] = params;
|
|
|
|
Main.osdMonitorLabeler.show(sender, dict);
|
|
|
|
},
|
|
|
|
|
2017-04-06 05:18:39 +00:00
|
|
|
ShowMonitorLabels2Async: function(params, invocation) {
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let [dict] = params;
|
|
|
|
Main.osdMonitorLabeler.show2(sender, dict);
|
|
|
|
},
|
|
|
|
|
2015-01-26 14:52:10 +00:00
|
|
|
HideMonitorLabelsAsync: function(params, invocation) {
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
Main.osdMonitorLabeler.hide(sender);
|
|
|
|
},
|
|
|
|
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2012-11-29 18:17:51 +00:00
|
|
|
Mode: global.session_mode,
|
|
|
|
|
2013-07-13 18:58:36 +00:00
|
|
|
_checkOverviewVisibleChanged: function() {
|
|
|
|
if (Main.overview.visible !== this._cachedOverviewVisible) {
|
|
|
|
this._cachedOverviewVisible = Main.overview.visible;
|
|
|
|
this._dbusImpl.emit_property_changed('OverviewActive', new GLib.Variant('b', this._cachedOverviewVisible));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-06-27 15:47:51 +00:00
|
|
|
get OverviewActive() {
|
2013-07-13 18:58:36 +00:00
|
|
|
return this._cachedOverviewVisible;
|
2012-06-27 15:47:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set OverviewActive(visible) {
|
|
|
|
if (visible)
|
|
|
|
Main.overview.show();
|
|
|
|
else
|
|
|
|
Main.overview.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
ShellVersion: Config.PACKAGE_VERSION
|
|
|
|
});
|
|
|
|
|
2013-10-24 21:51:58 +00:00
|
|
|
const GnomeShellExtensionsIface = '<node> \
|
|
|
|
<interface name="org.gnome.Shell.Extensions"> \
|
|
|
|
<method name="ListExtensions"> \
|
|
|
|
<arg type="a{sa{sv}}" direction="out" name="extensions" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="GetExtensionInfo"> \
|
|
|
|
<arg type="s" direction="in" name="extension" /> \
|
|
|
|
<arg type="a{sv}" direction="out" name="info" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="GetExtensionErrors"> \
|
|
|
|
<arg type="s" direction="in" name="extension" /> \
|
|
|
|
<arg type="as" direction="out" name="errors" /> \
|
|
|
|
</method> \
|
|
|
|
<signal name="ExtensionStatusChanged"> \
|
|
|
|
<arg type="s" name="uuid"/> \
|
|
|
|
<arg type="i" name="state"/> \
|
|
|
|
<arg type="s" name="error"/> \
|
|
|
|
</signal> \
|
|
|
|
<method name="InstallRemoteExtension"> \
|
|
|
|
<arg type="s" direction="in" name="uuid"/> \
|
|
|
|
<arg type="s" direction="out" name="result"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="UninstallExtension"> \
|
|
|
|
<arg type="s" direction="in" name="uuid"/> \
|
|
|
|
<arg type="b" direction="out" name="success"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="LaunchExtensionPrefs"> \
|
|
|
|
<arg type="s" direction="in" name="uuid"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="ReloadExtension"> \
|
|
|
|
<arg type="s" direction="in" name="uuid"/> \
|
|
|
|
</method> \
|
|
|
|
<method name="CheckForUpdates"> \
|
|
|
|
</method> \
|
|
|
|
<property name="ShellVersion" type="s" access="read" /> \
|
|
|
|
</interface> \
|
|
|
|
</node>';
|
2012-06-27 15:47:51 +00:00
|
|
|
|
|
|
|
const GnomeShellExtensions = new Lang.Class({
|
|
|
|
Name: 'GnomeShellExtensionsDBus',
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
|
|
|
ExtensionSystem.connect('extension-state-changed',
|
|
|
|
Lang.bind(this, this._extensionStateChanged));
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-06-23 02:03:04 +00:00
|
|
|
ListExtensions: function() {
|
2011-11-15 21:37:57 +00:00
|
|
|
let out = {};
|
2012-01-31 01:58:29 +00:00
|
|
|
for (let uuid in ExtensionUtils.extensions) {
|
2011-08-16 12:19:59 +00:00
|
|
|
let dbusObj = this.GetExtensionInfo(uuid);
|
|
|
|
out[uuid] = dbusObj;
|
|
|
|
}
|
|
|
|
return out;
|
2011-06-23 02:03:04 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
GetExtensionInfo: function(uuid) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let extension = ExtensionUtils.extensions[uuid];
|
|
|
|
if (!extension)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
let obj = {};
|
|
|
|
Lang.copyProperties(extension.metadata, obj);
|
|
|
|
|
|
|
|
// Only serialize the properties that we actually need.
|
|
|
|
const serializedProperties = ["type", "state", "path", "error", "hasPrefs"];
|
|
|
|
|
|
|
|
serializedProperties.forEach(function(prop) {
|
|
|
|
obj[prop] = extension[prop];
|
|
|
|
});
|
|
|
|
|
2011-11-15 21:37:57 +00:00
|
|
|
let out = {};
|
2012-01-31 01:58:29 +00:00
|
|
|
for (let key in obj) {
|
|
|
|
let val = obj[key];
|
2011-08-16 12:19:59 +00:00
|
|
|
let type;
|
|
|
|
switch (typeof val) {
|
|
|
|
case 'string':
|
|
|
|
type = 's';
|
|
|
|
break;
|
|
|
|
case 'number':
|
|
|
|
type = 'd';
|
|
|
|
break;
|
2012-01-19 02:30:06 +00:00
|
|
|
case 'boolean':
|
|
|
|
type = 'b';
|
|
|
|
break;
|
2011-11-15 21:46:17 +00:00
|
|
|
default:
|
|
|
|
continue;
|
2011-08-16 12:19:59 +00:00
|
|
|
}
|
|
|
|
out[key] = GLib.Variant.new(type, val);
|
|
|
|
}
|
2012-01-31 01:58:29 +00:00
|
|
|
|
2011-08-16 12:19:59 +00:00
|
|
|
return out;
|
2011-06-23 02:03:04 +00:00
|
|
|
},
|
|
|
|
|
2011-06-23 01:41:30 +00:00
|
|
|
GetExtensionErrors: function(uuid) {
|
2012-01-31 01:58:29 +00:00
|
|
|
let extension = ExtensionUtils.extensions[uuid];
|
|
|
|
if (!extension)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
if (!extension.errors)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
return extension.errors;
|
2011-06-23 01:41:30 +00:00
|
|
|
},
|
|
|
|
|
2012-06-16 03:20:36 +00:00
|
|
|
InstallRemoteExtensionAsync: function([uuid], invocation) {
|
2012-06-27 00:46:37 +00:00
|
|
|
return ExtensionDownloader.installExtension(uuid, invocation);
|
2011-08-24 17:08:34 +00:00
|
|
|
},
|
|
|
|
|
2011-09-10 21:10:50 +00:00
|
|
|
UninstallExtension: function(uuid) {
|
2012-06-27 00:46:37 +00:00
|
|
|
return ExtensionDownloader.uninstallExtension(uuid);
|
2011-09-10 21:10:50 +00:00
|
|
|
},
|
|
|
|
|
2012-01-19 02:30:06 +00:00
|
|
|
LaunchExtensionPrefs: function(uuid) {
|
|
|
|
let appSys = Shell.AppSystem.get_default();
|
|
|
|
let app = appSys.lookup_app('gnome-shell-extension-prefs.desktop');
|
2014-02-20 19:14:21 +00:00
|
|
|
let info = app.get_app_info();
|
|
|
|
let timestamp = global.display.get_current_time_roundtrip();
|
|
|
|
info.launch_uris(['extension:///' + uuid],
|
|
|
|
global.create_app_launch_context(timestamp, -1));
|
2012-01-19 02:30:06 +00:00
|
|
|
},
|
|
|
|
|
2012-06-05 17:06:40 +00:00
|
|
|
ReloadExtension: function(uuid) {
|
2012-08-24 01:37:50 +00:00
|
|
|
let extension = ExtensionUtils.extensions[uuid];
|
|
|
|
if (!extension)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ExtensionSystem.reloadExtension(extension);
|
2012-06-05 17:06:40 +00:00
|
|
|
},
|
|
|
|
|
2012-06-27 00:47:44 +00:00
|
|
|
CheckForUpdates: function() {
|
|
|
|
ExtensionDownloader.checkForUpdates();
|
|
|
|
},
|
|
|
|
|
2011-06-28 02:21:02 +00:00
|
|
|
ShellVersion: Config.PACKAGE_VERSION,
|
|
|
|
|
|
|
|
_extensionStateChanged: function(_, newState) {
|
2011-11-12 02:45:44 +00:00
|
|
|
this._dbusImpl.emit_signal('ExtensionStatusChanged',
|
|
|
|
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
|
2011-06-28 02:21:02 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2012-06-02 23:20:31 +00:00
|
|
|
|
|
|
|
const ScreenSaverDBus = new Lang.Class({
|
|
|
|
Name: 'ScreenSaverDBus',
|
|
|
|
|
2012-07-08 15:42:15 +00:00
|
|
|
_init: function(screenShield) {
|
2012-06-02 23:20:31 +00:00
|
|
|
this.parent();
|
|
|
|
|
2012-07-08 15:42:15 +00:00
|
|
|
this._screenShield = screenShield;
|
2013-02-02 16:10:45 +00:00
|
|
|
screenShield.connect('active-changed', Lang.bind(this, function(shield) {
|
2013-01-31 17:05:46 +00:00
|
|
|
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active]));
|
2012-06-02 23:20:31 +00:00
|
|
|
}));
|
2014-03-10 18:16:03 +00:00
|
|
|
screenShield.connect('wake-up-screen', Lang.bind(this, function(shield) {
|
|
|
|
this._dbusImpl.emit_signal('WakeUpScreen', null);
|
|
|
|
}));
|
2012-06-02 23:20:31 +00:00
|
|
|
|
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
|
2012-07-08 15:42:15 +00:00
|
|
|
|
|
|
|
Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
2012-06-02 23:20:31 +00:00
|
|
|
},
|
|
|
|
|
2012-09-05 20:19:45 +00:00
|
|
|
LockAsync: function(parameters, invocation) {
|
2012-07-08 15:42:15 +00:00
|
|
|
let tmpId = this._screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
|
|
|
|
this._screenShield.disconnect(tmpId);
|
2012-09-05 20:19:45 +00:00
|
|
|
|
|
|
|
invocation.return_value(null);
|
|
|
|
}));
|
|
|
|
|
2012-07-08 15:42:15 +00:00
|
|
|
this._screenShield.lock(true);
|
2012-06-02 23:20:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
SetActive: function(active) {
|
|
|
|
if (active)
|
2013-01-27 14:45:04 +00:00
|
|
|
this._screenShield.activate(true);
|
2012-06-02 23:20:31 +00:00
|
|
|
else
|
2013-03-25 20:32:15 +00:00
|
|
|
this._screenShield.deactivate(false);
|
2012-06-02 23:20:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
GetActive: function() {
|
2013-01-27 14:45:04 +00:00
|
|
|
return this._screenShield.active;
|
2012-10-16 14:38:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
GetActiveTime: function() {
|
|
|
|
let started = this._screenShield.activationTime;
|
|
|
|
if (started > 0)
|
|
|
|
return Math.floor((GLib.get_monotonic_time() - started) / 1000000);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
},
|
2012-06-02 23:20:31 +00:00
|
|
|
});
|