Compare commits

...

10 Commits

Author SHA1 Message Date
3fd70e37bd Application Menu: add support for showing GApplication actions
Use the new GApplication support in ShellApp to create the application
menu. Supports plain (no state), boolean and double actions.
Includes a test application (as no other application uses GApplication
for actions)

https://bugzilla.gnome.org/show_bug.cgi?id=621203
2011-11-25 15:06:17 -05:00
5580cfaf63 ShellApp: port to new GDBusActionGroup and GMenuProxy API
GDBusActionGroup and GMenuProxy are new objects in GIO 2.32 that
help with accessing menus and actions of remote applications.
This patch makes it possible for the shell to associate an
application with a dbus name and from that a GMenu, that will
be shown as the application menu.

https://bugzilla.gnome.org/show_bug.cgi?id=621203
2011-11-25 15:06:17 -05:00
17c46c2452 Port everything to class framework
The last patch in the sequence. Every place that was previously
setting prototype has been ported to Lang.Class, to make code more
concise and allow for better toString().

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
0996174b3d Port GDM and Caribou to GDBus
During the mass port to GDBus, this classes were left out (probably
because they didn't exist at the time). Now it's time to update
them.

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
d6b6f814d3 Port all classes with inheritance to class framework
All classes that have at least one other derived class (and thus
benefit from the framework) have been now ported. These includes
NMDevice, SearchProvider, AltTab.SwitcherList, and some other
stuff around.

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
987099ea55 Port ModalDialog to the class framework
Similar to the previous commits, time to port shell modal dialogs
to the class framework.

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
b356aa8e3b Port message tray sources and notifications to class framework
Third step in the class framework port, now it's the turn of
MessageTray.Source and MessageTray.Notification, as well as
the various implementations around the shell.

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
566bdb50c2 Port PanelMenu to new class framework
Second patch in the class framework, now it's the turn of
PanelMenu (buttons, menus and status indicators).

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
2b57603271 Port PopupMenu to new Lang.Class framework
The Lang module in gjs has recently gained a small yet powerful
Class framework, that should help improve the readability of code
when using complex inheritance.
This commit starts porting shell code, by rewriting all classes in
popupMenu.js (and all derived classes) to Lang.Class.

https://bugzilla.gnome.org/show_bug.cgi?id=664436
2011-11-24 09:50:04 +01:00
c3528f5b6b lookingGlass: Fix global key press handler
No idea why connecting a key-press-event to a non-reactive actor
used to work, but some Clutter update broke it. Obvious fix is
to make the actor reactive.

https://bugzilla.gnome.org/show_bug.cgi?id=664582
2011-11-22 22:33:05 +01:00
70 changed files with 1765 additions and 1522 deletions

View File

@ -21,11 +21,9 @@
const Lang = imports.lang; const Lang = imports.lang;
const Signals = imports.signals; const Signals = imports.signals;
function Task() { const Task = new Lang.Class({
this._init.apply(this, arguments); Name: 'Task',
}
Task.prototype = {
_init: function(scope, handler) { _init: function(scope, handler) {
if (scope) if (scope)
this.scope = scope; this.scope = scope;
@ -41,22 +39,17 @@ Task.prototype = {
return null; return null;
}, },
}; });
Signals.addSignalMethods(Task.prototype); Signals.addSignalMethods(Task.prototype);
function Hold() { const Hold = new Lang.Class({
this._init.apply(this, arguments); Name: 'Hold',
} Extends: Task,
Hold.prototype = {
__proto__: Task.prototype,
_init: function() { _init: function() {
Task.prototype._init.call(this, this.parent(this, function () {
this, return this;
function () { });
return this;
});
this._acquisitions = 1; this._acquisitions = 1;
}, },
@ -88,18 +81,15 @@ Hold.prototype = {
isAcquired: function() { isAcquired: function() {
return this._acquisitions > 0; return this._acquisitions > 0;
} }
} });
Signals.addSignalMethods(Hold.prototype); Signals.addSignalMethods(Hold.prototype);
function Batch() { const Batch = new Lang.Class({
this._init.apply(this, arguments); Name: 'Batch',
} Extends: Task,
Batch.prototype = {
__proto__: Task.prototype,
_init: function(scope, tasks) { _init: function(scope, tasks) {
Task.prototype._init.call(this); this.parent();
this.tasks = []; this.tasks = [];
@ -166,20 +156,12 @@ Batch.prototype = {
cancel: function() { cancel: function() {
this.tasks = this.tasks.splice(0, this._currentTaskIndex + 1); this.tasks = this.tasks.splice(0, this._currentTaskIndex + 1);
} }
});
};
Signals.addSignalMethods(Batch.prototype); Signals.addSignalMethods(Batch.prototype);
function ConcurrentBatch() { const ConcurrentBatch = new Lang.Class({
this._init.apply(this, arguments); Name: 'ConcurrentBatch',
} Extends: Batch,
ConcurrentBatch.prototype = {
__proto__: Batch.prototype,
_init: function(scope, tasks) {
Batch.prototype._init.call(this, scope, tasks);
},
process: function() { process: function() {
let hold = this.runTask(); let hold = this.runTask();
@ -193,19 +175,12 @@ ConcurrentBatch.prototype = {
// concurrently. // concurrently.
this.nextTask(); this.nextTask();
} }
}; });
Signals.addSignalMethods(ConcurrentBatch.prototype); Signals.addSignalMethods(ConcurrentBatch.prototype);
function ConsecutiveBatch() { const ConsecutiveBatch = new Lang.Class({
this._init.apply(this, arguments); Name: 'ConsecutiveBatch',
} Extends: Batch,
ConsecutiveBatch.prototype = {
__proto__: Batch.prototype,
_init: function(scope, tasks) {
Batch.prototype._init.call(this, scope, tasks);
},
process: function() { process: function() {
let hold = this.runTask(); let hold = this.runTask();
@ -224,5 +199,5 @@ ConsecutiveBatch.prototype = {
this.nextTask(); this.nextTask();
} }
} }
}; });
Signals.addSignalMethods(ConsecutiveBatch.prototype); Signals.addSignalMethods(ConsecutiveBatch.prototype);

View File

@ -1,32 +1,22 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const DBus = imports.dbus; const Gio = imports.gi.Gio;
const ConsoleKitManagerIface = { const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
name: 'org.freedesktop.ConsoleKit.Manager', <method name='CanRestart'>
methods: [{ name: 'CanRestart', <arg type='b' direction='out'/>
inSignature: '', </method>
outSignature: 'b' }, <method name='CanStop'>
{ name: 'CanStop', <arg type='b' direction='out'/>
inSignature: '', </method>
outSignature: 'b' }, <method name='Restart' />
{ name: 'Restart', <method name='Stop' />
inSignature: '', </interface>;
outSignature: '' },
{ name: 'Stop', const ConsoleKitProxy = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
inSignature: '',
outSignature: '' }]
};
function ConsoleKitManager() { function ConsoleKitManager() {
this._init(); return new ConsoleKitProxy(Gio.DBus.system,
'org.freedesktop.ConsoleKit',
'/org/freedesktop/ConsoleKit/Manager');
}; };
ConsoleKitManager.prototype = {
_init: function() {
DBus.system.proxifyObject(this,
'org.freedesktop.ConsoleKit',
'/org/freedesktop/ConsoleKit/Manager');
}
};
DBus.proxifyPrototype(ConsoleKitManager.prototype, ConsoleKitManagerIface);

View File

@ -1,26 +1,20 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const DBus = imports.dbus; const Gio = imports.gi.Gio;
const Lang = imports.lang; const Lang = imports.lang;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const FprintManagerIface = { const FprintManagerIface = <interface name='net.reactivated.Fprint.Manager'>
name: 'net.reactivated.Fprint.Manager', <method name='GetDefaultDevice'>
methods: [{ name: 'GetDefaultDevice', <arg type='o' direction='out' />
inSignature: '', </method>
outSignature: 'o' }] </interface>;
};
const FprintManagerProxy = Gio.DBusProxy.makeProxyWrapper(FprintManagerIface);
function FprintManager() { function FprintManager() {
this._init(); return new FprintManagerProxy(Gio.DBus.system,
'net.reactivated.Fprint',
'/net/reactivated/Fprint/Manager');
}; };
FprintManager.prototype = {
_init: function() {
DBus.system.proxifyObject(this,
'net.reactivated.Fprint',
'/net/reactivated/Fprint/Manager');
}
};
DBus.proxifyPrototype(FprintManager.prototype, FprintManagerIface);

View File

@ -33,7 +33,6 @@ const St = imports.gi.St;
const GdmGreeter = imports.gi.GdmGreeter; const GdmGreeter = imports.gi.GdmGreeter;
const Batch = imports.gdm.batch; const Batch = imports.gdm.batch;
const DBus = imports.dbus;
const Fprint = imports.gdm.fingerprint; const Fprint = imports.gdm.fingerprint;
const Lightbox = imports.ui.lightbox; const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main; const Main = imports.ui.main;
@ -141,11 +140,9 @@ function _smoothlyResizeActor(actor, width, height) {
return hold; return hold;
} }
function UserListItem(user, reason) { const UserListItem = new Lang.Class({
this._init(user, reason); Name: 'UserListItem',
}
UserListItem.prototype = {
_init: function(user) { _init: function(user) {
this.user = user; this.user = user;
this._userChangedId = this.user.connect('changed', this._userChangedId = this.user.connect('changed',
@ -274,15 +271,12 @@ UserListItem.prototype = {
}); });
return hold; return hold;
} }
});
};
Signals.addSignalMethods(UserListItem.prototype); Signals.addSignalMethods(UserListItem.prototype);
function UserList() { const UserList = new Lang.Class({
this._init.apply(this, arguments); Name: 'UserList',
}
UserList.prototype = {
_init: function() { _init: function() {
this.actor = new St.ScrollView({ style_class: 'login-dialog-user-list-view'}); this.actor = new St.ScrollView({ style_class: 'login-dialog-user-list-view'});
this.actor.set_policy(Gtk.PolicyType.NEVER, this.actor.set_policy(Gtk.PolicyType.NEVER,
@ -538,14 +532,12 @@ UserList.prototype = {
item.actor.destroy(); item.actor.destroy();
delete this._items[userName]; delete this._items[userName];
} }
}; });
Signals.addSignalMethods(UserList.prototype); Signals.addSignalMethods(UserList.prototype);
function SessionListItem(id, name) { const SessionListItem = new Lang.Class({
this._init(id, name); Name: 'SessionListItem',
}
SessionListItem.prototype = {
_init: function(id, name) { _init: function(id, name) {
this.id = id; this.id = id;
@ -600,14 +592,12 @@ SessionListItem.prototype = {
_onClicked: function() { _onClicked: function() {
this.emit('activate'); this.emit('activate');
} }
}; });
Signals.addSignalMethods(SessionListItem.prototype); Signals.addSignalMethods(SessionListItem.prototype);
function SessionList() { const SessionList = new Lang.Class({
this._init(); Name: 'SessionList',
}
SessionList.prototype = {
_init: function() { _init: function() {
this.actor = new St.Bin(); this.actor = new St.Bin();
@ -738,24 +728,15 @@ SessionList.prototype = {
})); }));
} }
} }
}; });
Signals.addSignalMethods(SessionList.prototype); Signals.addSignalMethods(SessionList.prototype);
function LoginDialog() { const LoginDialog = new Lang.Class({
if (_loginDialog == null) { Name: 'LoginDialog',
this._init(); Extends: ModalDialog.ModalDialog,
_loginDialog = this;
}
return _loginDialog;
}
LoginDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function() { _init: function() {
ModalDialog.ModalDialog.prototype._init.call(this, { shellReactive: true, this.parent({ shellReactive: true, styleClass: 'login-dialog' });
styleClass: 'login-dialog' });
this.connect('destroy', this.connect('destroy',
Lang.bind(this, this._onDestroy)); Lang.bind(this, this._onDestroy));
this.connect('opened', this.connect('opened',
@ -908,7 +889,7 @@ LoginDialog.prototype = {
if (!this._settings.get_boolean(_FINGERPRINT_AUTHENTICATION_KEY)) if (!this._settings.get_boolean(_FINGERPRINT_AUTHENTICATION_KEY))
return; return;
this._fprintManager.GetDefaultDeviceRemote(DBus.CALL_FLAG_START, Lang.bind(this, this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, Lang.bind(this,
function(device, error) { function(device, error) {
if (!error && device) if (!error && device)
this._haveFingerprintReader = true; this._haveFingerprintReader = true;
@ -1399,8 +1380,8 @@ LoginDialog.prototype = {
}, },
close: function() { close: function() {
ModalDialog.ModalDialog.prototype.close.call(this); this.parent();
Main.ctrlAltTabManager.removeGroup(this._group); Main.ctrlAltTabManager.removeGroup(this._group);
} }
}; });

View File

@ -25,15 +25,12 @@ const ConsoleKit = imports.gdm.consoleKit;
const PanelMenu = imports.ui.panelMenu; const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu; const PopupMenu = imports.ui.popupMenu;
function PowerMenuButton() { const PowerMenuButton = new Lang.Class({
this._init(); Name: 'PowerMenuButton',
} Extends: PanelMenu.SystemStatusButton,
PowerMenuButton.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'system-shutdown', null); this.parent('system-shutdown', null);
this._consoleKitManager = new ConsoleKit.ConsoleKitManager(); this._consoleKitManager = new ConsoleKit.ConsoleKitManager();
this._upClient = new UPowerGlib.Client(); this._upClient = new UPowerGlib.Client();
@ -143,4 +140,4 @@ PowerMenuButton.prototype = {
if (this._haveShutdown) if (this._haveShutdown)
this._consoleKitManager.StopRemote(); this._consoleKitManager.StopRemote();
} }
}; });

View File

@ -8,11 +8,9 @@ const Search = imports.ui.search;
const THUMBNAIL_ICON_MARGIN = 2; const THUMBNAIL_ICON_MARGIN = 2;
function DocInfo(recentInfo) { const DocInfo = new Lang.Class({
this._init(recentInfo); Name: 'DocInfo',
}
DocInfo.prototype = {
_init : function(recentInfo) { _init : function(recentInfo) {
this.recentInfo = recentInfo; this.recentInfo = recentInfo;
// We actually used get_modified() instead of get_visited() // We actually used get_modified() instead of get_visited()
@ -49,7 +47,7 @@ DocInfo.prototype = {
} }
return mtype; return mtype;
} }
}; });
var docManagerInstance = null; var docManagerInstance = null;
@ -62,11 +60,9 @@ function getDocManager() {
/** /**
* DocManager wraps the DocSystem, primarily to expose DocInfo objects. * DocManager wraps the DocSystem, primarily to expose DocInfo objects.
*/ */
function DocManager() { const DocManager = new Lang.Class({
this._init(); Name: 'DocManager',
}
DocManager.prototype = {
_init: function() { _init: function() {
this._docSystem = Shell.DocSystem.get_default(); this._docSystem = Shell.DocSystem.get_default();
this._infosByTimestamp = []; this._infosByTimestamp = [];
@ -135,6 +131,6 @@ DocManager.prototype = {
return this._infosByUri[url]; return this._infosByUri[url];
})), terms); })), terms);
} }
}; });
Signals.addSignalMethods(DocManager.prototype); Signals.addSignalMethods(DocManager.prototype);

View File

@ -7,11 +7,9 @@ const Params = imports.misc.params;
const DEFAULT_LIMIT = 512; const DEFAULT_LIMIT = 512;
function HistoryManager(params) { const HistoryManager = new Lang.Class({
this._init(params); Name: 'HistoryManager',
}
HistoryManager.prototype = {
_init: function(params) { _init: function(params) {
params = Params.parse(params, { gsettingsKey: null, params = Params.parse(params, { gsettingsKey: null,
limit: DEFAULT_LIMIT, limit: DEFAULT_LIMIT,
@ -111,5 +109,5 @@ HistoryManager.prototype = {
if (this._key) if (this._key)
global.settings.set_strv(this._key, this._history); global.settings.set_strv(this._key, this._history);
} }
}; });
Signals.addSignalMethods(HistoryManager.prototype); Signals.addSignalMethods(HistoryManager.prototype);

View File

@ -54,11 +54,9 @@ function _getProvidersTable() {
return _providersTable = providers; return _providersTable = providers;
} }
function ModemGsm() { const ModemGsm = new Lang.Class({
this._init.apply(this, arguments); Name: 'ModemGsm',
}
ModemGsm.prototype = {
_init: function(path) { _init: function(path) {
this._proxy = new ModemGsmNetworkProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path); this._proxy = new ModemGsmNetworkProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
@ -156,14 +154,12 @@ ModemGsm.prototype = {
return name3 || name2 || null; return name3 || name2 || null;
} }
} });
Signals.addSignalMethods(ModemGsm.prototype); Signals.addSignalMethods(ModemGsm.prototype);
function ModemCdma() { const ModemCdma = new Lang.Class({
this._init.apply(this, arguments); Name: 'ModemCdma',
}
ModemCdma.prototype = {
_init: function(path) { _init: function(path) {
this._proxy = new ModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path); this._proxy = new ModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
@ -231,5 +227,5 @@ ModemCdma.prototype = {
return null; return null;
} }
}; });
Signals.addSignalMethods(ModemCdma.prototype); Signals.addSignalMethods(ModemCdma.prototype);

View File

@ -43,11 +43,9 @@ function primaryModifier(mask) {
return primary; return primary;
} }
function AltTabPopup() { const AltTabPopup = new Lang.Class({
this._init(); Name: 'AltTabPopup',
}
AltTabPopup.prototype = {
_init : function() { _init : function() {
this.actor = new Shell.GenericContainer({ name: 'altTabPopup', this.actor = new Shell.GenericContainer({ name: 'altTabPopup',
reactive: true, reactive: true,
@ -540,13 +538,11 @@ AltTabPopup.prototype = {
onComplete: Lang.bind(this, function () { this.thumbnailsVisible = true; }) onComplete: Lang.bind(this, function () { this.thumbnailsVisible = true; })
}); });
} }
}; });
function SwitcherList(squareItems) { const SwitcherList = new Lang.Class({
this._init(squareItems); Name: 'SwitcherList',
}
SwitcherList.prototype = {
_init : function(squareItems) { _init : function(squareItems) {
this.actor = new Shell.GenericContainer({ style_class: 'switcher-list' }); this.actor = new Shell.GenericContainer({ style_class: 'switcher-list' });
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
@ -851,15 +847,13 @@ SwitcherList.prototype = {
// Clip the area for scrolling // Clip the area for scrolling
this._clipBin.set_clip(0, -topPadding, (this.actor.allocation.x2 - this.actor.allocation.x1) - leftPadding - rightPadding, this.actor.height + bottomPadding); this._clipBin.set_clip(0, -topPadding, (this.actor.allocation.x2 - this.actor.allocation.x1) - leftPadding - rightPadding, this.actor.height + bottomPadding);
} }
}; });
Signals.addSignalMethods(SwitcherList.prototype); Signals.addSignalMethods(SwitcherList.prototype);
function AppIcon(app) { const AppIcon = new Lang.Class({
this._init(app); Name: 'AppIcon',
}
AppIcon.prototype = {
_init: function(app) { _init: function(app) {
this.app = app; this.app = app;
this.actor = new St.BoxLayout({ style_class: 'alt-tab-app', this.actor = new St.BoxLayout({ style_class: 'alt-tab-app',
@ -877,17 +871,14 @@ AppIcon.prototype = {
this._iconBin.set_size(size, size); this._iconBin.set_size(size, size);
this._iconBin.child = this.icon; this._iconBin.child = this.icon;
} }
}; });
function AppSwitcher() { const AppSwitcher = new Lang.Class({
this._init.apply(this, arguments); Name: 'AppSwitcher',
} Extends: SwitcherList,
AppSwitcher.prototype = {
__proto__ : SwitcherList.prototype,
_init : function(localApps, otherApps, altTabPopup) { _init : function(localApps, otherApps, altTabPopup) {
SwitcherList.prototype._init.call(this, true); this.parent(true);
// Construct the AppIcons, add to the popup // Construct the AppIcons, add to the popup
let activeWorkspace = global.screen.get_active_workspace(); let activeWorkspace = global.screen.get_active_workspace();
@ -966,7 +957,7 @@ AppSwitcher.prototype = {
_allocate: function (actor, box, flags) { _allocate: function (actor, box, flags) {
// Allocate the main list items // Allocate the main list items
SwitcherList.prototype._allocate.call(this, actor, box, flags); this.parent(actor, box, flags);
let arrowHeight = Math.floor(this.actor.get_theme_node().get_padding(St.Side.BOTTOM) / 3); let arrowHeight = Math.floor(this.actor.get_theme_node().get_padding(St.Side.BOTTOM) / 3);
let arrowWidth = arrowHeight * 2; let arrowWidth = arrowHeight * 2;
@ -1021,7 +1012,7 @@ AppSwitcher.prototype = {
this._arrows[this._curApp].remove_style_pseudo_class('highlighted'); this._arrows[this._curApp].remove_style_pseudo_class('highlighted');
} }
SwitcherList.prototype.highlight.call(this, n, justOutline); this.parent(n, justOutline);
this._curApp = n; this._curApp = n;
if (this._curApp != -1) { if (this._curApp != -1) {
@ -1045,17 +1036,14 @@ AppSwitcher.prototype = {
if (appIcon.cachedWindows.length == 1) if (appIcon.cachedWindows.length == 1)
arrow.hide(); arrow.hide();
} }
}; });
function ThumbnailList(windows) { const ThumbnailList = new Lang.Class({
this._init(windows); Name: 'ThumbnailList',
} Extends: SwitcherList,
ThumbnailList.prototype = {
__proto__ : SwitcherList.prototype,
_init : function(windows) { _init : function(windows) {
SwitcherList.prototype._init.call(this); this.parent(false);
let activeWorkspace = global.screen.get_active_workspace(); let activeWorkspace = global.screen.get_active_workspace();
@ -1133,7 +1121,7 @@ ThumbnailList.prototype = {
// Make sure we only do this once // Make sure we only do this once
this._thumbnailBins = new Array(); this._thumbnailBins = new Array();
} }
}; });
function _drawArrow(area, side) { function _drawArrow(area, side) {
let themeNode = area.get_theme_node(); let themeNode = area.get_theme_node();

View File

@ -26,11 +26,9 @@ const MAX_APPLICATION_WORK_MILLIS = 75;
const MENU_POPUP_TIMEOUT = 600; const MENU_POPUP_TIMEOUT = 600;
const SCROLL_TIME = 0.1; const SCROLL_TIME = 0.1;
function AlphabeticalView() { const AlphabeticalView = new Lang.Class({
this._init(); Name: 'AlphabeticalView',
}
AlphabeticalView.prototype = {
_init: function() { _init: function() {
this._grid = new IconGrid.IconGrid({ xAlign: St.Align.START }); this._grid = new IconGrid.IconGrid({ xAlign: St.Align.START });
this._appSystem = Shell.AppSystem.get_default(); this._appSystem = Shell.AppSystem.get_default();
@ -130,13 +128,11 @@ AlphabeticalView.prototype = {
this._addApp(app); this._addApp(app);
} }
} }
}; });
function ViewByCategories() { const ViewByCategories = new Lang.Class({
this._init(); Name: 'ViewByCategories',
}
ViewByCategories.prototype = {
_init: function() { _init: function() {
this._appSystem = Shell.AppSystem.get_default(); this._appSystem = Shell.AppSystem.get_default();
this.actor = new St.BoxLayout({ style_class: 'all-app' }); this.actor = new St.BoxLayout({ style_class: 'all-app' });
@ -281,16 +277,14 @@ ViewByCategories.prototype = {
this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
} }
} }
}; });
/* This class represents a display containing a collection of application items. /* This class represents a display containing a collection of application items.
* The applications are sorted based on their name. * The applications are sorted based on their name.
*/ */
function AllAppDisplay() { const AllAppDisplay = new Lang.Class({
this._init(); Name: 'AllAppDisplay',
}
AllAppDisplay.prototype = {
_init: function() { _init: function() {
this._appSystem = Shell.AppSystem.get_default(); this._appSystem = Shell.AppSystem.get_default();
this._appSystem.connect('installed-changed', Lang.bind(this, function() { this._appSystem.connect('installed-changed', Lang.bind(this, function() {
@ -306,17 +300,15 @@ AllAppDisplay.prototype = {
_redisplay: function() { _redisplay: function() {
this._appView.refresh(); this._appView.refresh();
} }
}; });
function AppSearchProvider() { const AppSearchProvider = new Lang.Class({
this._init(); Name: 'AppSearchProvider',
} Extends: Search.SearchProvider,
AppSearchProvider.prototype = {
__proto__: Search.SearchProvider.prototype,
_init: function() { _init: function() {
Search.SearchProvider.prototype._init.call(this, _("APPLICATIONS")); this.parent(_("APPLICATIONS"));
this._appSys = Shell.AppSystem.get_default(); this._appSys = Shell.AppSystem.get_default();
}, },
@ -364,17 +356,15 @@ AppSearchProvider.prototype = {
let icon = new AppWellIcon(app); let icon = new AppWellIcon(app);
return icon.actor; return icon.actor;
} }
}; });
function SettingsSearchProvider() { const SettingsSearchProvider = new Lang.Class({
this._init(); Name: 'SettingsSearchProvider',
} Extends: Search.SearchProvider,
SettingsSearchProvider.prototype = {
__proto__: Search.SearchProvider.prototype,
_init: function() { _init: function() {
Search.SearchProvider.prototype._init.call(this, _("SETTINGS")); this.parent(_("SETTINGS"));
this._appSys = Shell.AppSystem.get_default(); this._appSys = Shell.AppSystem.get_default();
this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop'); this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop');
}, },
@ -412,35 +402,28 @@ SettingsSearchProvider.prototype = {
let icon = new AppWellIcon(app); let icon = new AppWellIcon(app);
return icon.actor; return icon.actor;
} }
}; });
function AppIcon(app, params) { const AppIcon = new Lang.Class({
this._init(app, params); Name: 'AppIcon',
} Extends: IconGrid.BaseIcon,
AppIcon.prototype = {
__proto__: IconGrid.BaseIcon.prototype,
_init : function(app, params) { _init : function(app, params) {
this.app = app; this.app = app;
let label = this.app.get_name(); let label = this.app.get_name();
IconGrid.BaseIcon.prototype._init.call(this, this.parent(label, params);
label,
params);
}, },
createIcon: function(iconSize) { createIcon: function(iconSize) {
return this.app.create_icon_texture(iconSize); return this.app.create_icon_texture(iconSize);
} }
}; });
function AppWellIcon(app, iconParams, onActivateOverride) { const AppWellIcon = new Lang.Class({
this._init(app, iconParams, onActivateOverride); Name: 'AppWellIcon',
}
AppWellIcon.prototype = {
_init : function(app, iconParams, onActivateOverride) { _init : function(app, iconParams, onActivateOverride) {
this.app = app; this.app = app;
this.actor = new St.Button({ style_class: 'app-well-app', this.actor = new St.Button({ style_class: 'app-well-app',
@ -620,22 +603,19 @@ AppWellIcon.prototype = {
getDragActorSource: function() { getDragActorSource: function() {
return this.icon.icon; return this.icon.icon;
} }
}; });
Signals.addSignalMethods(AppWellIcon.prototype); Signals.addSignalMethods(AppWellIcon.prototype);
function AppIconMenu(source) { const AppIconMenu = new Lang.Class({
this._init(source); Name: 'AppIconMenu',
} Extends: PopupMenu.PopupMenu,
AppIconMenu.prototype = {
__proto__: PopupMenu.PopupMenu.prototype,
_init: function(source) { _init: function(source) {
let side = St.Side.LEFT; let side = St.Side.LEFT;
if (St.Widget.get_default_direction() == St.TextDirection.RTL) if (St.Widget.get_default_direction() == St.TextDirection.RTL)
side = St.Side.RIGHT; side = St.Side.RIGHT;
PopupMenu.PopupMenu.prototype._init.call(this, source.actor, 0.5, side); this.parent(source.actor, 0.5, side);
// We want to keep the item hovered while the menu is up // We want to keep the item hovered while the menu is up
this.blockSourceEvents = true; this.blockSourceEvents = true;
@ -723,5 +703,5 @@ AppIconMenu.prototype = {
} }
this.close(); this.close();
} }
}; });
Signals.addSignalMethods(AppIconMenu.prototype); Signals.addSignalMethods(AppIconMenu.prototype);

View File

@ -6,11 +6,9 @@ const Signals = imports.signals;
const Main = imports.ui.main; const Main = imports.ui.main;
function AppFavorites() { const AppFavorites = new Lang.Class({
this._init(); Name: 'AppFavorites',
}
AppFavorites.prototype = {
FAVORITE_APPS_KEY: 'favorite-apps', FAVORITE_APPS_KEY: 'favorite-apps',
_init: function() { _init: function() {
@ -122,7 +120,7 @@ AppFavorites.prototype = {
this._addFavorite(appId, pos); this._addFavorite(appId, pos);
})); }));
} }
}; });
Signals.addSignalMethods(AppFavorites.prototype); Signals.addSignalMethods(AppFavorites.prototype);
var appFavoritesInstance = null; var appFavoritesInstance = null;

View File

@ -64,11 +64,9 @@ function ConsoleKitManager() {
return self; return self;
} }
function AutomountManager() { const AutomountManager = new Lang.Class({
this._init(); Name: 'AutomountManager',
}
AutomountManager.prototype = {
_init: function() { _init: function() {
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA }); this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
this._volumeQueue = []; this._volumeQueue = [];
@ -268,4 +266,4 @@ AutomountManager.prototype = {
return false; return false;
}); });
} }
} });

View File

@ -75,11 +75,9 @@ function HotplugSniffer() {
'/org/gnome/Shell/HotplugSniffer'); '/org/gnome/Shell/HotplugSniffer');
} }
function ContentTypeDiscoverer(callback) { const ContentTypeDiscoverer = new Lang.Class({
this._init(callback); Name: 'ContentTypeDiscoverer',
}
ContentTypeDiscoverer.prototype = {
_init: function(callback) { _init: function(callback) {
this._callback = callback; this._callback = callback;
}, },
@ -136,13 +134,11 @@ ContentTypeDiscoverer.prototype = {
this._callback(mount, apps, contentTypes); this._callback(mount, apps, contentTypes);
} }
} });
function AutorunManager() { const AutorunManager = new Lang.Class({
this._init(); Name: 'AutorunManager',
}
AutorunManager.prototype = {
_init: function() { _init: function() {
this._volumeMonitor = Gio.VolumeMonitor.get(); this._volumeMonitor = Gio.VolumeMonitor.get();
@ -259,17 +255,14 @@ AutorunManager.prototype = {
+ ': ' + e.toString()); + ': ' + e.toString());
} }
}, },
} });
function AutorunResidentSource() { const AutorunResidentSource = new Lang.Class({
this._init(); Name: 'AutorunResidentSource',
} Extends: MessageTray.Source,
AutorunResidentSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function() { _init: function() {
MessageTray.Source.prototype._init.call(this, _("Removable Devices")); this.parent(_("Removable Devices"));
this._mounts = []; this._mounts = [];
@ -324,19 +317,14 @@ AutorunResidentSource.prototype = {
icon_type: St.IconType.FULLCOLOR, icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE }); icon_size: this.ICON_SIZE });
} }
} });
function AutorunResidentNotification(source) { const AutorunResidentNotification = new Lang.Class({
this._init(source); Name: 'AutorunResidentNotification',
} Extends: MessageTray.Notification,
AutorunResidentNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source) { _init: function(source) {
MessageTray.Notification.prototype._init.call(this, source, this.parent(source, source.title, null, { customContent: true });
source.title, null,
{ customContent: true });
// set the notification as resident // set the notification as resident
this.setResident(true); this.setResident(true);
@ -410,13 +398,11 @@ AutorunResidentNotification.prototype = {
return item; return item;
}, },
} });
function AutorunTransientDispatcher() { const AutorunTransientDispatcher = new Lang.Class({
this._init(); Name: 'AutorunTransientDispatcher',
}
AutorunTransientDispatcher.prototype = {
_init: function() { _init: function() {
this._sources = []; this._sources = [];
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA }); this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
@ -507,17 +493,14 @@ AutorunTransientDispatcher.prototype = {
// destroy the notification source // destroy the notification source
source.destroy(); source.destroy();
} }
} });
function AutorunTransientSource(mount, apps) { const AutorunTransientSource = new Lang.Class({
this._init(mount, apps); Name: 'AutorunTransientSource',
} Extends: MessageTray.Source,
AutorunTransientSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(mount, apps) { _init: function(mount, apps) {
MessageTray.Source.prototype._init.call(this, mount.get_name()); this.parent(mount.get_name());
this.mount = mount; this.mount = mount;
this.apps = apps; this.apps = apps;
@ -534,19 +517,14 @@ AutorunTransientSource.prototype = {
return new St.Icon({ gicon: this.mount.get_icon(), return new St.Icon({ gicon: this.mount.get_icon(),
icon_size: this.ICON_SIZE }); icon_size: this.ICON_SIZE });
} }
} });
function AutorunTransientNotification(source) { const AutorunTransientNotification = new Lang.Class({
this._init(source); Name: 'AutorunTransientNotification',
} Extends: MessageTray.Notification,
AutorunTransientNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source) { _init: function(source) {
MessageTray.Notification.prototype._init.call(this, source, this.parent(source, source.title, null, { customContent: true });
source.title, null,
{ customContent: true });
this._box = new St.BoxLayout({ style_class: 'hotplug-transient-box', this._box = new St.BoxLayout({ style_class: 'hotplug-transient-box',
vertical: true }); vertical: true });
@ -621,5 +599,5 @@ AutorunTransientNotification.prototype = {
return button; return button;
} }
} });

View File

@ -21,11 +21,9 @@ const POPUP_ANIMATION_TIME = 0.15;
* placed. The arrow position may be controlled via setArrowOrigin(). * placed. The arrow position may be controlled via setArrowOrigin().
* *
*/ */
function BoxPointer(side, binProperties) { const BoxPointer = new Lang.Class({
this._init(side, binProperties); Name: 'BoxPointer',
}
BoxPointer.prototype = {
_init: function(arrowSide, binProperties) { _init: function(arrowSide, binProperties) {
this._arrowSide = arrowSide; this._arrowSide = arrowSide;
this._arrowOrigin = 0; this._arrowOrigin = 0;
@ -452,4 +450,4 @@ BoxPointer.prototype = {
get opacity() { get opacity() {
return this.actor.opacity; return this.actor.opacity;
} }
}; });

View File

@ -155,28 +155,24 @@ function _getEventDayAbbreviation(dayNumber) {
// Abstraction for an appointment/event in a calendar // Abstraction for an appointment/event in a calendar
function CalendarEvent(date, end, summary, allDay) { const CalendarEvent = new Lang.Class({
this._init(date, end, summary, allDay); Name: 'CalendarEvent',
}
CalendarEvent.prototype = {
_init: function(date, end, summary, allDay) { _init: function(date, end, summary, allDay) {
this.date = date; this.date = date;
this.end = end; this.end = end;
this.summary = summary; this.summary = summary;
this.allDay = allDay; this.allDay = allDay;
} }
}; });
// Interface for appointments/events - e.g. the contents of a calendar // Interface for appointments/events - e.g. the contents of a calendar
// //
// First, an implementation with no events // First, an implementation with no events
function EmptyEventSource() { const EmptyEventSource = new Lang.Class({
this._init(); Name: 'EmptyEventSource',
}
EmptyEventSource.prototype = {
_init: function() { _init: function() {
}, },
@ -191,7 +187,7 @@ EmptyEventSource.prototype = {
hasEvents: function(day) { hasEvents: function(day) {
return false; return false;
} }
}; });
Signals.addSignalMethods(EmptyEventSource.prototype); Signals.addSignalMethods(EmptyEventSource.prototype);
const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer"> const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer">
@ -219,11 +215,6 @@ function CalendarServer() {
return self; return self;
} }
// an implementation that reads data from a session bus service
function DBusEventSource() {
this._init();
}
function _datesEqual(a, b) { function _datesEqual(a, b) {
if (a < b) if (a < b)
return false; return false;
@ -242,8 +233,10 @@ function _dateIntervalsOverlap(a0, a1, b0, b1)
return true; return true;
} }
// an implementation that reads data from a session bus service
const DBusEventSource = new Lang.Class({
Name: 'DBusEventSource',
DBusEventSource.prototype = {
_init: function() { _init: function() {
this._resetCache(); this._resetCache();
@ -344,17 +337,15 @@ DBusEventSource.prototype = {
return true; return true;
} }
}; });
Signals.addSignalMethods(DBusEventSource.prototype); Signals.addSignalMethods(DBusEventSource.prototype);
// Calendar: // Calendar:
// @eventSource: is an object implementing the EventSource API, e.g. the // @eventSource: is an object implementing the EventSource API, e.g. the
// requestRange(), getEvents(), hasEvents() methods and the ::changed signal. // requestRange(), getEvents(), hasEvents() methods and the ::changed signal.
function Calendar(eventSource) { const Calendar = new Lang.Class({
this._init(eventSource); Name: 'Calendar',
}
Calendar.prototype = {
_init: function(eventSource) { _init: function(eventSource) {
if (eventSource) { if (eventSource) {
this._eventSource = eventSource; this._eventSource = eventSource;
@ -620,15 +611,13 @@ Calendar.prototype = {
if (this._eventSource) if (this._eventSource)
this._eventSource.requestRange(beginDate, iter, forceReload); this._eventSource.requestRange(beginDate, iter, forceReload);
} }
}; });
Signals.addSignalMethods(Calendar.prototype); Signals.addSignalMethods(Calendar.prototype);
function EventsList(eventSource) { const EventsList = new Lang.Class({
this._init(eventSource); Name: 'EventsList',
}
EventsList.prototype = {
_init: function(eventSource) { _init: function(eventSource) {
this.actor = new St.BoxLayout({ vertical: true, style_class: 'events-header-vbox'}); this.actor = new St.BoxLayout({ vertical: true, style_class: 'events-header-vbox'});
this._date = new Date(); this._date = new Date();
@ -759,4 +748,4 @@ EventsList.prototype = {
this._showOtherDay(this._date); this._showOtherDay(this._date);
} }
} }
}; });

View File

@ -20,11 +20,9 @@ function launchContact(id) {
/* This class represents a shown contact search result in the overview */ /* This class represents a shown contact search result in the overview */
function Contact(id) { const Contact = new Lang.Class({
this._init(id); Name: 'Contact',
}
Contact.prototype = {
_init: function(id) { _init: function(id) {
this._contactSys = Shell.ContactSystem.get_default(); this._contactSys = Shell.ContactSystem.get_default();
this.individual = this._contactSys.get_individual(id); this.individual = this._contactSys.get_individual(id);
@ -131,19 +129,16 @@ Contact.prototype = {
return tc.load_icon_name(null, 'avatar-default', St.IconType.FULLCOLOR, size); return tc.load_icon_name(null, 'avatar-default', St.IconType.FULLCOLOR, size);
} }
}, },
}; });
/* Searches for and returns contacts */ /* Searches for and returns contacts */
function ContactSearchProvider() { const ContactSearchProvider = new Lang.Class({
this._init(); Name: 'ContactSearchProvider',
} Extends: Search.SearchProvider,
ContactSearchProvider.prototype = {
__proto__: Search.SearchProvider.prototype,
_init: function() { _init: function() {
Search.SearchProvider.prototype._init.call(this, _("CONTACTS")); this.parent(_("CONTACTS"));
this._contactSys = Shell.ContactSystem.get_default(); this._contactSys = Shell.ContactSystem.get_default();
}, },
@ -182,4 +177,4 @@ ContactSearchProvider.prototype = {
activateResult: function(id, params) { activateResult: function(id, params) {
launchContact(id); launchContact(id);
} }
}; });

View File

@ -22,11 +22,9 @@ const SortGroup = {
BOTTOM: 2 BOTTOM: 2
}; };
function CtrlAltTabManager() { const CtrlAltTabManager = new Lang.Class({
this._init(); Name: 'CtrlAltTabManager',
}
CtrlAltTabManager.prototype = {
_init: function() { _init: function() {
this._items = []; this._items = [];
this._focusManager = St.FocusManager.get_for_stage(global.stage); this._focusManager = St.FocusManager.get_for_stage(global.stage);
@ -134,17 +132,15 @@ CtrlAltTabManager.prototype = {
})); }));
} }
} }
}; });
function mod(a, b) { function mod(a, b) {
return (a + b) % b; return (a + b) % b;
} }
function CtrlAltTabPopup() { const CtrlAltTabPopup = new Lang.Class({
this._init(); Name: 'CtrlAltTabPopup',
}
CtrlAltTabPopup.prototype = {
_init : function() { _init : function() {
this.actor = new Shell.GenericContainer({ name: 'ctrlAltTabPopup', this.actor = new Shell.GenericContainer({ name: 'ctrlAltTabPopup',
reactive: true }); reactive: true });
@ -303,17 +299,14 @@ CtrlAltTabPopup.prototype = {
this._selection = num; this._selection = num;
this._switcher.highlight(num); this._switcher.highlight(num);
} }
}; });
function CtrlAltTabSwitcher(items) { const CtrlAltTabSwitcher = new Lang.Class({
this._init(items); Name: 'CtrlAltTabSwitcher',
} Extends: AltTab.SwitcherList,
CtrlAltTabSwitcher.prototype = {
__proto__ : AltTab.SwitcherList.prototype,
_init : function(items) { _init : function(items) {
AltTab.SwitcherList.prototype._init.call(this, true); this.parent(true);
for (let i = 0; i < items.length; i++) for (let i = 0; i < items.length; i++)
this._addIcon(items[i]); this._addIcon(items[i]);
@ -336,4 +329,4 @@ CtrlAltTabSwitcher.prototype = {
this.addItem(box, text); this.addItem(box, text);
} }
}; });

View File

@ -19,11 +19,9 @@ const DASH_ANIMATION_TIME = 0.2;
// A container like StBin, but taking the child's scale into account // A container like StBin, but taking the child's scale into account
// when requesting a size // when requesting a size
function DashItemContainer() { const DashItemContainer = new Lang.Class({
this._init(); Name: 'DashItemContainer',
}
DashItemContainer.prototype = {
_init: function() { _init: function() {
this.actor = new Shell.GenericContainer({ style_class: 'dash-item-container' }); this.actor = new Shell.GenericContainer({ style_class: 'dash-item-container' });
this.actor.connect('get-preferred-width', this.actor.connect('get-preferred-width',
@ -157,17 +155,14 @@ DashItemContainer.prototype = {
get childOpacity() { get childOpacity() {
return this._childOpacity; return this._childOpacity;
} }
}; });
function RemoveFavoriteIcon() { const RemoveFavoriteIcon = new Lang.Class({
this._init(); Name: 'RemoveFavoriteIcon',
} Extends: DashItemContainer,
RemoveFavoriteIcon.prototype = {
__proto__: DashItemContainer.prototype,
_init: function() { _init: function() {
DashItemContainer.prototype._init.call(this); this.parent();
this._iconBin = new St.Bin({ style_class: 'remove-favorite' }); this._iconBin = new St.Bin({ style_class: 'remove-favorite' });
this._iconActor = null; this._iconActor = null;
@ -219,28 +214,21 @@ RemoveFavoriteIcon.prototype = {
return true; return true;
} }
}; });
const DragPlaceholderItem = new Lang.Class({
function DragPlaceholderItem() { Name: 'DragPlaceholderItem',
this._init(); Extends: DashItemContainer,
}
DragPlaceholderItem.prototype = {
__proto__: DashItemContainer.prototype,
_init: function() { _init: function() {
DashItemContainer.prototype._init.call(this); this.parent();
this.setChild(new St.Bin({ style_class: 'placeholder' })); this.setChild(new St.Bin({ style_class: 'placeholder' }));
} }
}; });
const Dash = new Lang.Class({
Name: 'Dash',
function Dash() {
this._init();
}
Dash.prototype = {
_init : function() { _init : function() {
this._maxHeight = -1; this._maxHeight = -1;
this.iconSize = 64; this.iconSize = 64;
@ -762,6 +750,6 @@ Dash.prototype = {
return true; return true;
} }
}; });
Signals.addSignalMethods(Dash.prototype); Signals.addSignalMethods(Dash.prototype);

View File

@ -40,12 +40,9 @@ function _onVertSepRepaint (area)
cr.stroke(); cr.stroke();
}; };
function DateMenuButton() { const DateMenuButton = new Lang.Class({
this._init.apply(this, arguments); Name: 'DateMenuButton',
} Extends: PanelMenu.Button,
DateMenuButton.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function(params) { _init: function(params) {
params = Params.parse(params, { showEvents: true }); params = Params.parse(params, { showEvents: true });
@ -57,7 +54,7 @@ DateMenuButton.prototype = {
let menuAlignment = 0.25; let menuAlignment = 0.25;
if (St.Widget.get_default_direction() == St.TextDirection.RTL) if (St.Widget.get_default_direction() == St.TextDirection.RTL)
menuAlignment = 1.0 - menuAlignment; menuAlignment = 1.0 - menuAlignment;
PanelMenu.Button.prototype._init.call(this, menuAlignment); this.parent(menuAlignment);
this._clock = new St.Label(); this._clock = new St.Label();
this.actor.add_actor(this._clock); this.actor.add_actor(this._clock);
@ -239,4 +236,4 @@ DateMenuButton.prototype = {
} }
} }
} }
}; });

View File

@ -69,11 +69,9 @@ function removeDragMonitor(monitor) {
} }
} }
function _Draggable(actor, params) { const _Draggable = new Lang.Class({
this._init(actor, params); Name: 'Draggable',
}
_Draggable.prototype = {
_init : function(actor, params) { _init : function(actor, params) {
params = Params.parse(params, { manualMode: false, params = Params.parse(params, { manualMode: false,
restoreOnSuccess: false, restoreOnSuccess: false,
@ -596,7 +594,7 @@ _Draggable.prototype = {
this._dragActor = undefined; this._dragActor = undefined;
currentDraggable = null; currentDraggable = null;
} }
}; });
Signals.addSignalMethods(_Draggable.prototype); Signals.addSignalMethods(_Draggable.prototype);

View File

@ -1,19 +1,16 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const DocInfo = imports.misc.docInfo; const DocInfo = imports.misc.docInfo;
const Lang = imports.lang;
const Params = imports.misc.params; const Params = imports.misc.params;
const Search = imports.ui.search; const Search = imports.ui.search;
const DocSearchProvider = new Lang.Class({
function DocSearchProvider() { Name: 'DocSearchProvider',
this._init(); Extends: Search.SearchProvider,
}
DocSearchProvider.prototype = {
__proto__: Search.SearchProvider.prototype,
_init: function(name) { _init: function(name) {
Search.SearchProvider.prototype._init.call(this, _("RECENT ITEMS")); this.parent(_("RECENT ITEMS"));
this._docManager = DocInfo.getDocManager(); this._docManager = DocInfo.getDocManager();
}, },
@ -44,4 +41,4 @@ DocSearchProvider.prototype = {
getSubsearchResultSet: function(previousResults, terms) { getSubsearchResultSet: function(previousResults, terms) {
return this._docManager.subsearch(previousResults, terms); return this._docManager.subsearch(previousResults, terms);
} }
}; });

View File

@ -142,11 +142,9 @@ function findAppFromInhibitor(inhibitor) {
return app; return app;
} }
function ListItem(app, reason) { const ListItem = new Lang.Class({
this._init(app, reason); Name: 'ListItem',
}
ListItem.prototype = {
_init: function(app, reason) { _init: function(app, reason) {
this._app = app; this._app = app;
this._reason = reason; this._reason = reason;
@ -192,7 +190,7 @@ ListItem.prototype = {
this.emit('activate'); this.emit('activate');
this._app.activate(); this._app.activate();
} }
}; });
Signals.addSignalMethods(ListItem.prototype); Signals.addSignalMethods(ListItem.prototype);
// The logout timer only shows updates every 10 seconds // The logout timer only shows updates every 10 seconds
@ -230,27 +228,19 @@ function _setLabelText(label, text) {
} }
} }
function EndSessionDialog() {
if (_endSessionDialog == null) {
this._init();
_endSessionDialog = this;
}
return _endSessionDialog;
}
function init() { function init() {
// This always returns the same singleton object // This always returns the same singleton object
// By instantiating it initially, we register the // By instantiating it initially, we register the
// bus object, etc. // bus object, etc.
let dialog = new EndSessionDialog(); _endSessionDialog = new EndSessionDialog();
} }
EndSessionDialog.prototype = { const EndSessionDialog = new Lang.Class({
__proto__: ModalDialog.ModalDialog.prototype, Name: 'EndSessionDialog',
Extends: ModalDialog.ModalDialog,
_init: function() { _init: function() {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'end-session-dialog' }); this.parent({ styleClass: 'end-session-dialog' });
this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name()); this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
@ -441,7 +431,7 @@ EndSessionDialog.prototype = {
}, },
close: function() { close: function() {
ModalDialog.ModalDialog.prototype.close.call(this); this.parent();
this._dbusImpl.emit_signal('Closed', null); this._dbusImpl.emit_signal('Closed', null);
}, },
@ -543,4 +533,4 @@ EndSessionDialog.prototype = {
this.disconnect(signalId); this.disconnect(signalId);
})); }));
} }
}; });

View File

@ -502,15 +502,12 @@ function loadExtensions() {
_loadExtensionsIn(userExtensionsDir, ExtensionType.PER_USER); _loadExtensionsIn(userExtensionsDir, ExtensionType.PER_USER);
} }
function InstallExtensionDialog(uuid, version_tag, name) { const InstallExtensionDialog = new Lang.Class({
this._init(uuid, version_tag, name); Name: 'InstallExtensionDialog',
} Extends: ModalDialog.ModalDialog,
InstallExtensionDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(uuid, version_tag, name) { _init: function(uuid, version_tag, name) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'extension-dialog' }); this.parent({ styleClass: 'extension-dialog' });
this._uuid = uuid; this._uuid = uuid;
this._version_tag = version_tag; this._version_tag = version_tag;
@ -570,4 +567,4 @@ InstallExtensionDialog.prototype = {
this.close(global.get_current_time()); this.close(global.get_current_time());
} }
}; });

View File

@ -10,11 +10,9 @@ const Params = imports.misc.params;
const ICON_SIZE = 48; const ICON_SIZE = 48;
function BaseIcon(label, createIcon) { const BaseIcon = new Lang.Class({
this._init(label, createIcon); Name: 'BaseIcon',
}
BaseIcon.prototype = {
_init : function(label, params) { _init : function(label, params) {
params = Params.parse(params, { createIcon: null, params = Params.parse(params, { createIcon: null,
setSizeManually: false, setSizeManually: false,
@ -149,13 +147,11 @@ BaseIcon.prototype = {
this._createIconTexture(size); this._createIconTexture(size);
} }
}; });
function IconGrid(params) { const IconGrid = new Lang.Class({
this._init(params); Name: 'IconGrid',
}
IconGrid.prototype = {
_init: function(params) { _init: function(params) {
params = Params.parse(params, { rowLimit: null, params = Params.parse(params, { rowLimit: null,
columnLimit: null, columnLimit: null,
@ -324,4 +320,4 @@ IconGrid.prototype = {
visibleItemsCount: function() { visibleItemsCount: function() {
return this._grid.get_children().length - this._grid.get_n_skip_paint(); return this._grid.get_children().length - this._grid.get_n_skip_paint();
} }
}; });

View File

@ -39,34 +39,31 @@ const PRETTY_KEYS = {
'Alt_L': 'Alt' 'Alt_L': 'Alt'
}; };
const CaribouKeyboardIface = { const CaribouKeyboardIface = <interface name='org.gnome.Caribou.Keyboard'>
name: 'org.gnome.Caribou.Keyboard', <method name='Show'>
methods: [ { name: 'Show', <arg type='u' direction='in' />
inSignature: 'u', </method>
outSignature: '' <method name='Hide'>
}, <arg type='u' direction='in' />
{ name: 'Hide', </method>
inSignature: 'u', <method name='SetCursorLocation'>
outSignature: '' <arg type='i' direction='in' />
}, <arg type='i' direction='in' />
{ name: 'SetCursorLocation', <arg type='i' direction='in' />
inSignature: 'iiii', <arg type='i' direction='in' />
outSignature: '' </method>
}, <method name='SetEntryLocation'>
{ name: 'SetEntryLocation', <arg type='i' direction='in' />
inSignature: 'iiii', <arg type='i' direction='in' />
outSignature: '' <arg type='i' direction='in' />
} ], <arg type='i' direction='in' />
properties: [ { name: 'Name', </method>
signature: 's', <property name='Name' access='read' type='s' />
access: 'read' } ] </interface>;
};
function Key() { const Key = new Lang.Class({
this._init.apply(this, arguments); Name: 'Key',
}
Key.prototype = {
_init : function(key) { _init : function(key) {
this._key = key; this._key = key;
@ -192,15 +189,15 @@ Key.prototype = {
this._boxPointer.hide(true); this._boxPointer.hide(true);
} }
} }
}; });
function Keyboard() { const Keyboard = new Lang.Class({
this._init.apply(this, arguments); // HACK: we can't set Name, because it collides with Name dbus property
} // Name: 'Keyboard',
Keyboard.prototype = {
_init: function () { _init: function () {
DBus.session.exportObject('/org/gnome/Caribou/Keyboard', this); this._impl = Gio.DBusExportedObject.wrapJSObject(CaribouKeyboardIface, this);
this._impl.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
this.actor = null; this.actor = null;
@ -532,19 +529,15 @@ Keyboard.prototype = {
get Name() { get Name() {
return 'gnome-shell'; return 'gnome-shell';
} }
}; });
DBus.conformExport(Keyboard.prototype, CaribouKeyboardIface);
function KeyboardSource() { const KeyboardSource = new Lang.Class({
this._init.apply(this, arguments); Name: 'KeyboardSource',
} Extends: MessageTray.Source,
KeyboardSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(keyboard) { _init: function(keyboard) {
this.parent(_("Keyboard"));
this._keyboard = keyboard; this._keyboard = keyboard;
MessageTray.Source.prototype._init.call(this, _("Keyboard"));
this._setSummaryIcon(this.createNotificationIcon()); this._setSummaryIcon(this.createNotificationIcon());
}, },
@ -555,7 +548,7 @@ KeyboardSource.prototype = {
icon_size: this.ICON_SIZE }); icon_size: this.ICON_SIZE });
}, },
handleSummaryClick: function() { handleSummaryClick: function() {
let event = Clutter.get_current_event(); let event = Clutter.get_current_event();
if (event.type() != Clutter.EventType.BUTTON_RELEASE) if (event.type() != Clutter.EventType.BUTTON_RELEASE)
return false; return false;
@ -567,4 +560,4 @@ KeyboardSource.prototype = {
open: function() { open: function() {
this._keyboard.show(); this._keyboard.show();
} }
}; });

View File

@ -17,11 +17,9 @@ const HOT_CORNER_ACTIVATION_TIMEOUT = 0.5;
const STARTUP_ANIMATION_TIME = 0.2; const STARTUP_ANIMATION_TIME = 0.2;
const KEYBOARD_ANIMATION_TIME = 0.5; const KEYBOARD_ANIMATION_TIME = 0.5;
function LayoutManager() { const LayoutManager = new Lang.Class({
this._init.apply(this, arguments); Name: 'LayoutManager',
}
LayoutManager.prototype = {
_init: function () { _init: function () {
this._rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL); this._rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
this.monitors = []; this.monitors = [];
@ -374,7 +372,7 @@ LayoutManager.prototype = {
findMonitorForActor: function(actor) { findMonitorForActor: function(actor) {
return this._chrome.findMonitorForActor(actor); return this._chrome.findMonitorForActor(actor);
} }
}; });
Signals.addSignalMethods(LayoutManager.prototype); Signals.addSignalMethods(LayoutManager.prototype);
@ -382,11 +380,9 @@ Signals.addSignalMethods(LayoutManager.prototype);
// //
// This class manages a "hot corner" that can toggle switching to // This class manages a "hot corner" that can toggle switching to
// overview. // overview.
function HotCorner() { const HotCorner = new Lang.Class({
this._init(); Name: 'HotCorner',
}
HotCorner.prototype = {
_init : function() { _init : function() {
// We use this flag to mark the case where the user has entered the // We use this flag to mark the case where the user has entered the
// hot corner and has not left both the hot corner and a surrounding // hot corner and has not left both the hot corner and a surrounding
@ -548,7 +544,7 @@ HotCorner.prototype = {
return true; return true;
return false; return false;
} }
}; });
// This manages the shell "chrome"; the UI that's visible in the // This manages the shell "chrome"; the UI that's visible in the
@ -561,11 +557,9 @@ const defaultParams = {
affectsInputRegion: true affectsInputRegion: true
}; };
function Chrome() { const Chrome = new Lang.Class({
this._init.apply(this, arguments); Name: 'Chrome',
}
Chrome.prototype = {
_init: function(layoutManager) { _init: function(layoutManager) {
this._layoutManager = layoutManager; this._layoutManager = layoutManager;
@ -981,4 +975,4 @@ Chrome.prototype = {
return false; return false;
} }
}; });

View File

@ -30,11 +30,9 @@ const Tweener = imports.ui.tweener;
* @container and will track any changes in its size. You can override * @container and will track any changes in its size. You can override
* this by passing an explicit width and height in @params. * this by passing an explicit width and height in @params.
*/ */
function Lightbox(container, params) { const Lightbox = new Lang.Class({
this._init(container, params); Name: 'Lightbox',
}
Lightbox.prototype = {
_init : function(container, params) { _init : function(container, params) {
params = Params.parse(params, { inhibitEvents: false, params = Params.parse(params, { inhibitEvents: false,
width: null, width: null,
@ -196,4 +194,4 @@ Lightbox.prototype = {
this.highlight(null); this.highlight(null);
} }
}; });

View File

@ -4,11 +4,9 @@ const Lang = imports.lang;
const Signals = imports.signals; const Signals = imports.signals;
const St = imports.gi.St; const St = imports.gi.St;
function Link(props) { const Link = new Lang.Class({
this._init(props); Name: 'Link',
}
Link.prototype = {
_init : function(props) { _init : function(props) {
let realProps = { reactive: true, let realProps = { reactive: true,
track_hover: true, track_hover: true,
@ -19,6 +17,5 @@ Link.prototype = {
this.actor = new St.Button(realProps); this.actor = new St.Button(realProps);
} }
}; });
Signals.addSignalMethods(Link.prototype); Signals.addSignalMethods(Link.prototype);

View File

@ -55,11 +55,9 @@ function _getAutoCompleteGlobalKeywords() {
return keywords.concat(windowProperties).concat(headerProperties); return keywords.concat(windowProperties).concat(headerProperties);
} }
function AutoComplete(entry) { const AutoComplete = new Lang.Class({
this._init(entry); Name: 'AutoComplete',
}
AutoComplete.prototype = {
_init: function(entry) { _init: function(entry) {
this._entry = entry; this._entry = entry;
this._entry.connect('key-press-event', Lang.bind(this, this._entryKeyPressEvent)); this._entry.connect('key-press-event', Lang.bind(this, this._entryKeyPressEvent));
@ -118,15 +116,13 @@ AutoComplete.prototype = {
this._entry.clutter_text.insert_text(additionalCompletionText, cursorPos); this._entry.clutter_text.insert_text(additionalCompletionText, cursorPos);
} }
}; });
Signals.addSignalMethods(AutoComplete.prototype); Signals.addSignalMethods(AutoComplete.prototype);
function Notebook() { const Notebook = new Lang.Class({
this._init(); Name: 'Notebook',
}
Notebook.prototype = {
_init: function() { _init: function() {
this.actor = new St.BoxLayout({ vertical: true }); this.actor = new St.BoxLayout({ vertical: true });
@ -250,7 +246,7 @@ Notebook.prototype = {
this.selectIndex(prevIndex); this.selectIndex(prevIndex);
} }
}; });
Signals.addSignalMethods(Notebook.prototype); Signals.addSignalMethods(Notebook.prototype);
function objectToString(o) { function objectToString(o) {
@ -262,12 +258,9 @@ function objectToString(o) {
} }
} }
function ObjLink(o, title) { const ObjLink = new Lang.Class({
this._init(o, title); Name: 'ObjLink',
} Extends: Link.Link,
ObjLink.prototype = {
__proto__: Link.Link,
_init: function(o, title) { _init: function(o, title) {
let text; let text;
@ -277,7 +270,8 @@ ObjLink.prototype = {
text = objectToString(o); text = objectToString(o);
text = GLib.markup_escape_text(text, -1); text = GLib.markup_escape_text(text, -1);
this._obj = o; this._obj = o;
Link.Link.prototype._init.call(this, { label: text });
this.parent({ label: text });
this.actor.get_child().single_line_mode = true; this.actor.get_child().single_line_mode = true;
this.actor.connect('clicked', Lang.bind(this, this._onClicked)); this.actor.connect('clicked', Lang.bind(this, this._onClicked));
}, },
@ -285,13 +279,11 @@ ObjLink.prototype = {
_onClicked: function (link) { _onClicked: function (link) {
Main.lookingGlass.inspectObject(this._obj, this.actor); Main.lookingGlass.inspectObject(this._obj, this.actor);
} }
}; });
function Result(command, o, index) { const Result = new Lang.Class({
this._init(command, o, index); Name: 'Result',
}
Result.prototype = {
_init : function(command, o, index) { _init : function(command, o, index) {
this.index = index; this.index = index;
this.o = o; this.o = o;
@ -313,13 +305,11 @@ Result.prototype = {
padBin.add_actor(line); padBin.add_actor(line);
this.actor.add(padBin); this.actor.add(padBin);
} }
}; });
function WindowList() { const WindowList = new Lang.Class({
this._init(); Name: 'WindowList',
}
WindowList.prototype = {
_init : function () { _init : function () {
this.actor = new St.BoxLayout({ name: 'Windows', vertical: true, style: 'spacing: 8px' }); this.actor = new St.BoxLayout({ name: 'Windows', vertical: true, style: 'spacing: 8px' });
let tracker = Shell.WindowTracker.get_default(); let tracker = Shell.WindowTracker.get_default();
@ -360,14 +350,12 @@ WindowList.prototype = {
} }
} }
} }
}; });
Signals.addSignalMethods(WindowList.prototype); Signals.addSignalMethods(WindowList.prototype);
function ObjInspector() { const ObjInspector = new Lang.Class({
this._init(); Name: 'ObjInspector',
}
ObjInspector.prototype = {
_init : function () { _init : function () {
this._obj = null; this._obj = null;
this._previousObj = null; this._previousObj = null;
@ -467,7 +455,7 @@ ObjInspector.prototype = {
_onBack: function() { _onBack: function() {
this.selectObject(this._previousObj, true); this.selectObject(this._previousObj, true);
} }
}; });
function addBorderPaintHook(actor) { function addBorderPaintHook(actor) {
let signalId = actor.connect_after('paint', let signalId = actor.connect_after('paint',
@ -493,11 +481,9 @@ function addBorderPaintHook(actor) {
return signalId; return signalId;
} }
function Inspector() { const Inspector = new Lang.Class({
this._init(); Name: 'Inspector',
}
Inspector.prototype = {
_init: function() { _init: function() {
let container = new Shell.GenericContainer({ width: 0, let container = new Shell.GenericContainer({ width: 0,
height: 0 }); height: 0 });
@ -636,15 +622,13 @@ Inspector.prototype = {
this._borderPaintId = addBorderPaintHook(this._target); this._borderPaintId = addBorderPaintHook(this._target);
} }
} }
}; });
Signals.addSignalMethods(Inspector.prototype); Signals.addSignalMethods(Inspector.prototype);
function ErrorLog() { const ErrorLog = new Lang.Class({
this._init(); Name: 'ErrorLog',
}
ErrorLog.prototype = {
_init: function() { _init: function() {
this.actor = new St.BoxLayout(); this.actor = new St.BoxLayout();
this.text = new St.Label(); this.text = new St.Label();
@ -679,13 +663,11 @@ ErrorLog.prototype = {
} }
this.text.text = text; this.text.text = text;
} }
}; });
function Memory() { const Memory = new Lang.Class({
this._init(); Name: 'Memory',
}
Memory.prototype = {
_init: function() { _init: function() {
this.actor = new St.BoxLayout({ vertical: true }); this.actor = new St.BoxLayout({ vertical: true });
this._glibc_uordblks = new St.Label(); this._glibc_uordblks = new St.Label();
@ -730,13 +712,11 @@ Memory.prototype = {
this._gjs_closure.text = 'gjs_closure: ' + memInfo.gjs_closure; this._gjs_closure.text = 'gjs_closure: ' + memInfo.gjs_closure;
this._last_gc_seconds_ago.text = 'last_gc_seconds_ago: ' + memInfo.last_gc_seconds_ago; this._last_gc_seconds_ago.text = 'last_gc_seconds_ago: ' + memInfo.last_gc_seconds_ago;
} }
}; });
function Extensions() { const Extensions = new Lang.Class({
this._init(); Name: 'Extensions',
}
Extensions.prototype = {
_init: function() { _init: function() {
this.actor = new St.BoxLayout({ vertical: true, this.actor = new St.BoxLayout({ vertical: true,
name: 'lookingGlassExtensions' }); name: 'lookingGlassExtensions' });
@ -866,13 +846,11 @@ Extensions.prototype = {
return box; return box;
} }
}; });
function LookingGlass() { const LookingGlass = new Lang.Class({
this._init(); Name: 'LookingGlass',
}
LookingGlass.prototype = {
_init : function() { _init : function() {
this._borderPaintTarget = null; this._borderPaintTarget = null;
this._borderPaintId = 0; this._borderPaintId = 0;
@ -889,7 +867,8 @@ LookingGlass.prototype = {
this.actor = new St.BoxLayout({ name: 'LookingGlassDialog', this.actor = new St.BoxLayout({ name: 'LookingGlassDialog',
style_class: 'lg-dialog', style_class: 'lg-dialog',
vertical: true, vertical: true,
visible: false }); visible: false,
reactive: true });
this.actor.connect('key-press-event', Lang.bind(this, this._globalKeyPressEvent)); this.actor.connect('key-press-event', Lang.bind(this, this._globalKeyPressEvent));
this._interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' }); this._interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
@ -1228,5 +1207,5 @@ LookingGlass.prototype = {
}) })
}); });
} }
}; });
Signals.addSignalMethods(LookingGlass.prototype); Signals.addSignalMethods(LookingGlass.prototype);

View File

@ -36,11 +36,9 @@ const CROSS_HAIRS_CLIP_KEY = 'cross-hairs-clip';
let magDBusService = null; let magDBusService = null;
function Magnifier() { const Magnifier = new Lang.Class({
this._init(); Name: 'Magnifier',
}
Magnifier.prototype = {
_init: function() { _init: function() {
// Magnifier is a manager of ZoomRegions. // Magnifier is a manager of ZoomRegions.
this._zoomRegions = []; this._zoomRegions = [];
@ -543,14 +541,12 @@ Magnifier.prototype = {
); );
} }
} }
}; });
Signals.addSignalMethods(Magnifier.prototype); Signals.addSignalMethods(Magnifier.prototype);
function ZoomRegion(magnifier, mouseSourceActor) { const ZoomRegion = new Lang.Class({
this._init(magnifier, mouseSourceActor); Name: 'ZoomRegion',
}
ZoomRegion.prototype = {
_init: function(magnifier, mouseSourceActor) { _init: function(magnifier, mouseSourceActor) {
this._magnifier = magnifier; this._magnifier = magnifier;
@ -1150,13 +1146,11 @@ ZoomRegion.prototype = {
yMagMouse - groupHeight / 2); yMagMouse - groupHeight / 2);
} }
} }
}; });
function Crosshairs() { const Crosshairs = new Lang.Class({
this._init(); Name: 'Crosshairs',
}
Crosshairs.prototype = {
_init: function() { _init: function() {
// Set the group containing the crosshairs to three times the desktop // Set the group containing the crosshairs to three times the desktop
@ -1412,4 +1406,4 @@ Crosshairs.prototype = {
this._vertTopHair.set_position((groupWidth - thickness) / 2, top); this._vertTopHair.set_position((groupWidth - thickness) / 2, top);
this._vertBottomHair.set_position((groupWidth - thickness) / 2, bottom); this._vertBottomHair.set_position((groupWidth - thickness) / 2, bottom);
} }
}; });

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Main = imports.ui.main; const Main = imports.ui.main;
const MAG_SERVICE_NAME = 'org.gnome.Magnifier'; const MAG_SERVICE_NAME = 'org.gnome.Magnifier';
@ -95,11 +96,9 @@ const ZoomRegionIface = <interface name={ZOOM_SERVICE_NAME}>
// '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc. // '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc.
let _zoomRegionInstanceCount = 0; let _zoomRegionInstanceCount = 0;
function ShellMagnifier() { const ShellMagnifier = new Lang.Class({
this._init(); Name: 'ShellMagnifier',
}
ShellMagnifier.prototype = {
_init: function() { _init: function() {
this._zoomers = {}; this._zoomers = {};
@ -325,7 +324,7 @@ ShellMagnifier.prototype = {
// Drop the leading '#'. // Drop the leading '#'.
return parseInt(colorString.slice(1), 16); return parseInt(colorString.slice(1), 16);
} }
}; });
/** /**
* ShellMagnifierZoomRegion: * ShellMagnifierZoomRegion:
@ -333,11 +332,9 @@ ShellMagnifier.prototype = {
* @zoomerObjectPath: String that is the path to a DBus ZoomRegion. * @zoomerObjectPath: String that is the path to a DBus ZoomRegion.
* @zoomRegion: The actual zoom region associated with the object path. * @zoomRegion: The actual zoom region associated with the object path.
*/ */
function ShellMagnifierZoomRegion(zoomerObjectPath, zoomRegion) { const ShellMagnifierZoomRegion = new Lang.Class({
this._init(zoomerObjectPath, zoomRegion); Name: 'ShellMagnifierZoomRegion',
}
ShellMagnifierZoomRegion.prototype = {
_init: function(zoomerObjectPath, zoomRegion) { _init: function(zoomerObjectPath, zoomRegion) {
this._zoomRegion = zoomRegion; this._zoomRegion = zoomRegion;
@ -422,4 +419,4 @@ ShellMagnifierZoomRegion.prototype = {
destroy: function() { destroy: function() {
this._dbusImpl.unexport(); this._dbusImpl.unexport();
} }
}; });

View File

@ -83,11 +83,9 @@ function _fixMarkup(text, allowMarkup) {
return GLib.markup_escape_text(text, -1); return GLib.markup_escape_text(text, -1);
} }
function URLHighlighter(text, lineWrap, allowMarkup) { const URLHighlighter = new Lang.Class({
this._init(text, lineWrap, allowMarkup); Name: 'URLHighlighter',
}
URLHighlighter.prototype = {
_init: function(text, lineWrap, allowMarkup) { _init: function(text, lineWrap, allowMarkup) {
if (!text) if (!text)
text = ''; text = '';
@ -211,13 +209,11 @@ URLHighlighter.prototype = {
} }
return -1; return -1;
} }
}; });
function FocusGrabber() { const FocusGrabber = new Lang.Class({
this._init(); Name: 'FocusGrabber',
}
FocusGrabber.prototype = {
_init: function() { _init: function() {
this.actor = null; this.actor = null;
@ -351,7 +347,7 @@ FocusGrabber.prototype = {
this._togglingFocusGrabMode = false; this._togglingFocusGrabMode = false;
} }
} }
} });
Signals.addSignalMethods(FocusGrabber.prototype); Signals.addSignalMethods(FocusGrabber.prototype);
// Notification: // Notification:
@ -408,11 +404,9 @@ Signals.addSignalMethods(FocusGrabber.prototype);
// the content and the action area of the notification will be cleared. // the content and the action area of the notification will be cleared.
// The content area is also always cleared if 'customContent' is false // The content area is also always cleared if 'customContent' is false
// because it might contain the @banner that didn't fit in the banner mode. // because it might contain the @banner that didn't fit in the banner mode.
function Notification(source, title, banner, params) { const Notification = new Lang.Class({
this._init(source, title, banner, params); Name: 'Notification',
}
Notification.prototype = {
IMAGE_SIZE: 125, IMAGE_SIZE: 125,
_init: function(source, title, banner, params) { _init: function(source, title, banner, params) {
@ -953,14 +947,12 @@ Notification.prototype = {
this.actor.destroy(); this.actor.destroy();
this.actor._delegate = null; this.actor._delegate = null;
} }
}; });
Signals.addSignalMethods(Notification.prototype); Signals.addSignalMethods(Notification.prototype);
function Source(title) { const Source = new Lang.Class({
this._init(title); Name: 'MessageTraySource',
}
Source.prototype = {
ICON_SIZE: 24, ICON_SIZE: 24,
_init: function(title) { _init: function(title) {
@ -1142,14 +1134,12 @@ Source.prototype = {
_lastNotificationRemoved: function() { _lastNotificationRemoved: function() {
this.destroy(); this.destroy();
} }
}; });
Signals.addSignalMethods(Source.prototype); Signals.addSignalMethods(Source.prototype);
function SummaryItem(source) { const SummaryItem = new Lang.Class({
this._init(source); Name: 'SummaryItem',
}
SummaryItem.prototype = {
_init: function(source) { _init: function(source) {
this.source = source; this.source = source;
this.source.connect('notification-added', Lang.bind(this, this._notificationAddedToSource)); this.source.connect('notification-added', Lang.bind(this, this._notificationAddedToSource));
@ -1340,14 +1330,12 @@ SummaryItem.prototype = {
if (this.notificationStack.get_children().length > 0) if (this.notificationStack.get_children().length > 0)
this.notificationStack.get_children()[0]._delegate.setIconVisible(true); this.notificationStack.get_children()[0]._delegate.setIconVisible(true);
} }
}; });
Signals.addSignalMethods(SummaryItem.prototype); Signals.addSignalMethods(SummaryItem.prototype);
function MessageTray() { const MessageTray = new Lang.Class({
this._init(); Name: 'MessageTray',
}
MessageTray.prototype = {
_init: function() { _init: function() {
this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) { this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
this._onStatusChanged(proxy.status); this._onStatusChanged(proxy.status);
@ -2426,17 +2414,14 @@ MessageTray.prototype = {
if (this._clickedSummaryItem) if (this._clickedSummaryItem)
this._updateState(); this._updateState();
} }
}; });
function SystemNotificationSource() { const SystemNotificationSource = new Lang.Class({
this._init(); Name: 'SystemNotificationSource',
} Extends: Source,
SystemNotificationSource.prototype = {
__proto__: Source.prototype,
_init: function() { _init: function() {
Source.prototype._init.call(this, _("System Information")); this.parent(_("System Information"));
this._setSummaryIcon(this.createNotificationIcon()); this._setSummaryIcon(this.createNotificationIcon());
}, },
@ -2450,4 +2435,4 @@ SystemNotificationSource.prototype = {
open: function() { open: function() {
this.destroy(); this.destroy();
} }
}; });

View File

@ -29,11 +29,9 @@ const State = {
FADED_OUT: 4 FADED_OUT: 4
}; };
function ModalDialog() { const ModalDialog = new Lang.Class({
this._init(); Name: 'ModalDialog',
}
ModalDialog.prototype = {
_init: function(params) { _init: function(params) {
params = Params.parse(params, { shellReactive: false, params = Params.parse(params, { shellReactive: false,
styleClass: null }); styleClass: null });
@ -303,5 +301,5 @@ ModalDialog.prototype = {
}) })
}); });
} }
}; });
Signals.addSignalMethods(ModalDialog.prototype); Signals.addSignalMethods(ModalDialog.prototype);

View File

@ -32,15 +32,12 @@ const ModalDialog = imports.ui.modalDialog;
const PopupMenu = imports.ui.popupMenu; const PopupMenu = imports.ui.popupMenu;
const ShellEntry = imports.ui.shellEntry; const ShellEntry = imports.ui.shellEntry;
function NetworkSecretDialog() { const NetworkSecretDialog = new Lang.Class({
this._init.apply(this, arguments); Name: 'NetworkSecretDialog',
} Extends: ModalDialog.ModalDialog,
NetworkSecretDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(agent, requestId, connection, settingName, hints) { _init: function(agent, requestId, connection, settingName, hints) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'polkit-dialog' }); this.parent({ styleClass: 'polkit-dialog' });
this._agent = agent; this._agent = agent;
this._requestId = requestId; this._requestId = requestId;
@ -358,13 +355,11 @@ NetworkSecretDialog.prototype = {
return content; return content;
} }
}; });
function NetworkAgent() { const NetworkAgent = new Lang.Class({
this._init.apply(this, arguments); Name: 'NetworkAgent',
}
NetworkAgent.prototype = {
_init: function() { _init: function() {
this._native = new Shell.NetworkAgent({ auto_register: true, this._native = new Shell.NetworkAgent({ auto_register: true,
identifier: 'org.gnome.Shell.NetworkAgent' }); identifier: 'org.gnome.Shell.NetworkAgent' });
@ -387,4 +382,4 @@ NetworkAgent.prototype = {
this._dialogs[requestId].close(global.get_current_time()); this._dialogs[requestId].close(global.get_current_time());
this._dialogs[requestId].destroy(); this._dialogs[requestId].destroy();
} }
}; });

View File

@ -87,11 +87,9 @@ const rewriteRules = {
] ]
}; };
function NotificationDaemon() { const NotificationDaemon = new Lang.Class({
this._init(); Name: 'NotificationDaemon',
}
NotificationDaemon.prototype = {
_init: function() { _init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(NotificationDaemonIface, this); this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(NotificationDaemonIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications'); this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications');
@ -474,17 +472,14 @@ NotificationDaemon.prototype = {
if (source) if (source)
source.destroy(); source.destroy();
} }
}; });
function Source(title, pid, sender) { const Source = new Lang.Class({
this._init(title, pid, sender); Name: 'NotificationDaemonSource',
} Extends: MessageTray.Source,
Source.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(title, pid, sender) { _init: function(title, pid, sender) {
MessageTray.Source.prototype._init.call(this, title); this.parent(title);
this._pid = pid; this._pid = pid;
if (sender) if (sender)
@ -606,6 +601,6 @@ Source.prototype = {
this._nameWatcherId = 0; this._nameWatcherId = 0;
} }
MessageTray.Source.prototype.destroy.call(this); this.parent();
} }
}; });

View File

@ -46,11 +46,9 @@ const SwipeScrollResult = {
CLICK: 2 CLICK: 2
}; };
function ShellInfo() { const ShellInfo = new Lang.Class({
this._init(); Name: 'ShellInfo',
}
ShellInfo.prototype = {
_init: function() { _init: function() {
this._source = null; this._source = null;
this._undoCallback = null; this._undoCallback = null;
@ -95,13 +93,11 @@ ShellInfo.prototype = {
this._source.notify(notification); this._source.notify(notification);
} }
}; });
function Overview() { const Overview = new Lang.Class({
this._init.apply(this, arguments); Name: 'Overview',
}
Overview.prototype = {
_init : function(params) { _init : function(params) {
params = Params.parse(params, { isDummy: false }); params = Params.parse(params, { isDummy: false });
@ -811,5 +807,5 @@ Overview.prototype = {
this._needsFakePointerEvent = false; this._needsFakePointerEvent = false;
} }
} }
}; });
Signals.addSignalMethods(Overview.prototype); Signals.addSignalMethods(Overview.prototype);

View File

@ -3,6 +3,7 @@
const Cairo = imports.cairo; const Cairo = imports.cairo;
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Pango = imports.gi.Pango; const Pango = imports.gi.Pango;
@ -98,11 +99,9 @@ function _unpremultiply(color) {
}; };
function AnimatedIcon(name, size) { const AnimatedIcon = new Lang.Class({
this._init(name, size); Name: 'AnimatedIcon',
}
AnimatedIcon.prototype = {
_init: function(name, size) { _init: function(name, size) {
this.actor = new St.Bin({ visible: false }); this.actor = new St.Bin({ visible: false });
this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
@ -139,13 +138,11 @@ AnimatedIcon.prototype = {
if (this._timeoutId) if (this._timeoutId)
Mainloop.source_remove(this._timeoutId); Mainloop.source_remove(this._timeoutId);
} }
}; });
function TextShadower() { const TextShadower = new Lang.Class({
this._init(); Name: 'TextShadower',
}
TextShadower.prototype = {
_init: function() { _init: function() {
this.actor = new Shell.GenericContainer(); this.actor = new Shell.GenericContainer();
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
@ -225,7 +222,7 @@ TextShadower.prototype = {
child.allocate(childBox, flags); child.allocate(childBox, flags);
} }
} }
}; });
/** /**
* AppMenuButton: * AppMenuButton:
@ -235,17 +232,16 @@ TextShadower.prototype = {
* this menu also handles startup notification for it. So when we * this menu also handles startup notification for it. So when we
* have an active startup notification, we switch modes to display that. * have an active startup notification, we switch modes to display that.
*/ */
function AppMenuButton() { const AppMenuButton = new Lang.Class({
this._init(); Name: 'AppMenuButton',
} Extends: PanelMenu.Button,
AppMenuButton.prototype = { _init: function(menuManager) {
__proto__: PanelMenu.Button.prototype, this.parent(0.0, true);
_init: function() {
PanelMenu.Button.prototype._init.call(this, 0.0);
this._startingApps = []; this._startingApps = [];
this._menuManager = menuManager;
this._targetApp = null; this._targetApp = null;
let bin = new St.Bin({ name: 'appMenu' }); let bin = new St.Bin({ name: 'appMenu' });
@ -271,10 +267,6 @@ AppMenuButton.prototype = {
this._iconBottomClip = 0; this._iconBottomClip = 0;
this._quitMenu = new PopupMenu.PopupMenuItem('');
this.menu.addMenuItem(this._quitMenu);
this._quitMenu.connect('activate', Lang.bind(this, this._onQuit));
this._visible = !Main.overview.visible; this._visible = !Main.overview.visible;
if (!this._visible) if (!this._visible)
this.actor.hide(); this.actor.hide();
@ -453,12 +445,6 @@ AppMenuButton.prototype = {
} }
}, },
_onQuit: function() {
if (this._targetApp == null)
return;
this._targetApp.request_quit();
},
_onAppStateChanged: function(appSys, app) { _onAppStateChanged: function(appSys, app) {
let state = app.state; let state = app.state;
if (state != Shell.AppState.STARTING) { if (state != Shell.AppState.STARTING) {
@ -520,8 +506,10 @@ AppMenuButton.prototype = {
} }
if (targetApp == this._targetApp) { if (targetApp == this._targetApp) {
if (targetApp && targetApp.get_state() != Shell.AppState.STARTING) if (targetApp && targetApp.get_state() != Shell.AppState.STARTING) {
this.stopAnimation(); this.stopAnimation();
this._maybeSetMenu();
}
return; return;
} }
@ -535,33 +523,54 @@ AppMenuButton.prototype = {
let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE); let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE);
this._label.setText(targetApp.get_name()); this._label.setText(targetApp.get_name());
// TODO - _quit() doesn't really work on apps in state STARTING yet
this._quitMenu.label.set_text(_("Quit %s").format(targetApp.get_name()));
this._iconBox.set_child(icon); this._iconBox.set_child(icon);
this._iconBox.show(); this._iconBox.show();
if (targetApp.get_state() == Shell.AppState.STARTING) if (targetApp.get_state() == Shell.AppState.STARTING)
this.startAnimation(); this.startAnimation();
else
this._maybeSetMenu();
this.emit('changed'); this.emit('changed');
},
_maybeSetMenu: function() {
let menu;
if (this._targetApp.action_group) {
if (this.menu instanceof PopupMenu.RemoteMenu &&
this.menu.actionGroup == this._targetApp.action_group)
return;
menu = new PopupMenu.RemoteMenu(this.actor, this._targetApp.menu, this._targetApp.action_group);
} else {
if (this.menu && !(this.menu instanceof PopupMenu.RemoteMenu))
return;
// fallback to older menu
menu = new PopupMenu.PopupMenu(this.actor, 0.0, St.Side.TOP, 0);
menu.addAction(_("Quit"), Lang.bind(this, function() {
this._targetApp.request_quit();
}));
}
this.setMenu(menu);
this._menuManager.addMenu(menu);
} }
}; });
Signals.addSignalMethods(AppMenuButton.prototype); Signals.addSignalMethods(AppMenuButton.prototype);
// Activities button. Because everything else in the top bar is a // Activities button. Because everything else in the top bar is a
// PanelMenu.Button, it simplifies some things to make this be one too. // PanelMenu.Button, it simplifies some things to make this be one too.
// We just hack it up to not actually have a menu attached to it. // We just hack it up to not actually have a menu attached to it.
function ActivitiesButton() { const ActivitiesButton = new Lang.Class({
this._init.apply(this, arguments); Name: 'ActivitiesButton',
} Extends: PanelMenu.Button,
ActivitiesButton.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function() { _init: function() {
PanelMenu.Button.prototype._init.call(this, 0.0); this.parent(0.0);
let container = new Shell.GenericContainer(); let container = new Shell.GenericContainer();
container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth)); container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
@ -698,13 +707,11 @@ ActivitiesButton.prototype = {
Mainloop.source_remove(this._xdndTimeOut); Mainloop.source_remove(this._xdndTimeOut);
this._xdndTimeOut = 0; this._xdndTimeOut = 0;
} }
}; });
function PanelCorner(panel, side) { const PanelCorner = new Lang.Class({
this._init(panel, side); Name: 'PanelCorner',
}
PanelCorner.prototype = {
_init: function(box, side) { _init: function(box, side) {
this._side = side; this._side = side;
@ -880,14 +887,12 @@ PanelCorner.prototype = {
this.actor.set_size(cornerRadius, innerBorderWidth + cornerRadius); this.actor.set_size(cornerRadius, innerBorderWidth + cornerRadius);
this.actor.set_anchor_point(0, innerBorderWidth); this.actor.set_anchor_point(0, innerBorderWidth);
} }
}; });
function Panel() { const Panel = new Lang.Class({
this._init(); Name: 'Panel',
}
Panel.prototype = {
_init : function() { _init : function() {
this.actor = new Shell.GenericContainer({ name: 'panel', this.actor = new Shell.GenericContainer({ name: 'panel',
reactive: true }); reactive: true });
@ -938,9 +943,8 @@ Panel.prototype = {
// more cleanly with the rest of the panel // more cleanly with the rest of the panel
this._menus.addMenu(this._activitiesButton.menu); this._menus.addMenu(this._activitiesButton.menu);
this._appMenu = new AppMenuButton(); this._appMenu = new AppMenuButton(this._menus);
this._leftBox.add(this._appMenu.actor); this._leftBox.add(this._appMenu.actor);
this._menus.addMenu(this._appMenu.menu);
} }
/* center */ /* center */
@ -1114,5 +1118,4 @@ Panel.prototype = {
if (box && box._delegate instanceof PanelMenu.ButtonBox) if (box && box._delegate instanceof PanelMenu.ButtonBox)
box.destroy(); box.destroy();
}, },
});
};

View File

@ -11,11 +11,9 @@ const Main = imports.ui.main;
const Params = imports.misc.params; const Params = imports.misc.params;
const PopupMenu = imports.ui.popupMenu; const PopupMenu = imports.ui.popupMenu;
function ButtonBox(params) { const ButtonBox = new Lang.Class({
this._init.apply(this, arguments); Name: 'ButtonBox',
};
ButtonBox.prototype = {
_init: function(params) { _init: function(params) {
params = Params.parse(params, { style_class: 'panel-button' }, true); params = Params.parse(params, { style_class: 'panel-button' }, true);
this.actor = new Shell.GenericContainer(params); this.actor = new Shell.GenericContainer(params);
@ -92,31 +90,45 @@ ButtonBox.prototype = {
child.allocate(childBox, flags); child.allocate(childBox, flags);
}, },
} });
function Button(menuAlignment) { const Button = new Lang.Class({
this._init(menuAlignment); Name: 'PanelMenuButton',
} Extends: ButtonBox,
Button.prototype = { _init: function(menuAlignment, dontCreateMenu) {
__proto__: ButtonBox.prototype, this.parent({ reactive: true,
can_focus: true,
_init: function(menuAlignment) { track_hover: true });
ButtonBox.prototype._init.call(this, { reactive: true,
can_focus: true,
track_hover: true });
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress)); this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress)); this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
this.menu = new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP);
this.menu.actor.add_style_class_name('panel-menu'); if (dontCreateMenu)
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged)); this.menu = null;
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress)); else
Main.uiGroup.add_actor(this.menu.actor); this.setMenu(new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0));
this.menu.actor.hide(); },
setMenu: function(menu) {
if (this.menu)
this.menu.destroy();
this.menu = menu;
if (this.menu) {
this.menu.actor.add_style_class_name('panel-menu');
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
Main.uiGroup.add_actor(this.menu.actor);
this.menu.actor.hide();
}
}, },
_onButtonPress: function(actor, event) { _onButtonPress: function(actor, event) {
if (!this.menu)
return;
if (!this.menu.isOpen) { if (!this.menu.isOpen) {
// Setting the max-height won't do any good if the minimum height of the // Setting the max-height won't do any good if the minimum height of the
// menu is higher then the screen; it's useful if part of the menu is // menu is higher then the screen; it's useful if part of the menu is
@ -130,6 +142,9 @@ Button.prototype = {
}, },
_onSourceKeyPress: function(actor, event) { _onSourceKeyPress: function(actor, event) {
if (!this.menu)
return false;
let symbol = event.get_key_symbol(); let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) { if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
this.menu.toggle(); this.menu.toggle();
@ -175,7 +190,7 @@ Button.prototype = {
this.emit('destroy'); this.emit('destroy');
} }
}; });
Signals.addSignalMethods(Button.prototype); Signals.addSignalMethods(Button.prototype);
/* SystemStatusButton: /* SystemStatusButton:
@ -184,15 +199,13 @@ Signals.addSignalMethods(Button.prototype);
* volume, bluetooth...), which is just a PanelMenuButton with an * volume, bluetooth...), which is just a PanelMenuButton with an
* icon and a tooltip * icon and a tooltip
*/ */
function SystemStatusButton() { const SystemStatusButton = new Lang.Class({
this._init.apply(this, arguments); Name: 'SystemStatusButton',
} Extends: Button,
SystemStatusButton.prototype = {
__proto__: Button.prototype,
_init: function(iconName,tooltipText) { _init: function(iconName,tooltipText) {
Button.prototype._init.call(this, 0.0); this.parent(0.0);
this._iconActor = new St.Icon({ icon_name: iconName, this._iconActor = new St.Icon({ icon_name: iconName,
icon_type: St.IconType.SYMBOLIC, icon_type: St.IconType.SYMBOLIC,
style_class: 'system-status-icon' }); style_class: 'system-status-icon' });
@ -219,4 +232,4 @@ SystemStatusButton.prototype = {
this.tooltip = null; this.tooltip = null;
} }
} }
}; });

View File

@ -22,11 +22,9 @@ const Util = imports.misc.util;
* @iconFactory: A JavaScript callback which will create an icon texture given a size parameter * @iconFactory: A JavaScript callback which will create an icon texture given a size parameter
* @launch: A JavaScript callback to launch the entry * @launch: A JavaScript callback to launch the entry
*/ */
function PlaceInfo(id, name, iconFactory, launch) { const PlaceInfo = new Lang.Class({
this._init(id, name, iconFactory, launch); Name: 'PlaceInfo',
}
PlaceInfo.prototype = {
_init: function(id, name, iconFactory, launch) { _init: function(id, name, iconFactory, launch) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -55,7 +53,7 @@ PlaceInfo.prototype = {
isRemovable: function() { isRemovable: function() {
return false; return false;
} }
}; });
// Helper function to translate launch parameters into a GAppLaunchContext // Helper function to translate launch parameters into a GAppLaunchContext
function _makeLaunchContext(params) function _makeLaunchContext(params)
@ -72,12 +70,9 @@ function _makeLaunchContext(params)
return launchContext; return launchContext;
} }
function PlaceDeviceInfo(mount) { const PlaceDeviceInfo = new Lang.Class({
this._init(mount); Name: 'PlaceDeviceInfo',
} Extends: PlaceInfo,
PlaceDeviceInfo.prototype = {
__proto__: PlaceInfo.prototype,
_init: function(mount) { _init: function(mount) {
this._mount = mount; this._mount = mount;
@ -123,13 +118,11 @@ PlaceDeviceInfo.prototype = {
_("Retry")); _("Retry"));
} }
} }
}; });
function PlacesManager() { const PlacesManager = new Lang.Class({
this._init(); Name: 'PlacesManager',
}
PlacesManager.prototype = {
_init: function() { _init: function() {
this._defaultPlaces = []; this._defaultPlaces = [];
this._mounts = []; this._mounts = [];
@ -360,19 +353,15 @@ PlacesManager.prototype = {
_removeById: function(sourceArray, id) { _removeById: function(sourceArray, id) {
sourceArray.splice(this._lookupIndexById(sourceArray, id), 1); sourceArray.splice(this._lookupIndexById(sourceArray, id), 1);
} }
}; });
Signals.addSignalMethods(PlacesManager.prototype); Signals.addSignalMethods(PlacesManager.prototype);
const PlaceSearchProvider = new Lang.Class({
function PlaceSearchProvider() { Name: 'PlaceSearchProvider',
this._init(); Extends: Search.SearchProvider,
}
PlaceSearchProvider.prototype = {
__proto__: Search.SearchProvider.prototype,
_init: function() { _init: function() {
Search.SearchProvider.prototype._init.call(this, _("PLACES & DEVICES")); this.parent(_("PLACES & DEVICES"));
}, },
getResultMeta: function(resultId) { getResultMeta: function(resultId) {
@ -434,4 +423,4 @@ PlaceSearchProvider.prototype = {
let places = previousResults.map(function (id) { return Main.placesManager.lookupPlaceById(id); }); let places = previousResults.map(function (id) { return Main.placesManager.lookupPlaceById(id); });
return this._searchPlaces(places, terms); return this._searchPlaces(places, terms);
} }
}; });

View File

@ -36,15 +36,12 @@ const PolkitAgent = imports.gi.PolkitAgent;
const ModalDialog = imports.ui.modalDialog; const ModalDialog = imports.ui.modalDialog;
const ShellEntry = imports.ui.shellEntry; const ShellEntry = imports.ui.shellEntry;
function AuthenticationDialog(actionId, message, cookie, userNames) { const AuthenticationDialog = new Lang.Class({
this._init(actionId, message, cookie, userNames); Name: 'AuthenticationDialog',
} Extends: ModalDialog.ModalDialog,
AuthenticationDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(actionId, message, cookie, userNames) { _init: function(actionId, message, cookie, userNames) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'polkit-dialog' }); this.parent({ styleClass: 'polkit-dialog' });
this.actionId = actionId; this.actionId = actionId;
this.message = message; this.message = message;
@ -335,15 +332,12 @@ AuthenticationDialog.prototype = {
this.close(global.get_current_time()); this.close(global.get_current_time());
this._emitDone(false, true); this._emitDone(false, true);
}, },
});
};
Signals.addSignalMethods(AuthenticationDialog.prototype); Signals.addSignalMethods(AuthenticationDialog.prototype);
function AuthenticationAgent() { const AuthenticationAgent = new Lang.Class({
this._init(); Name: 'AuthenticationAgent',
}
AuthenticationAgent.prototype = {
_init: function() { _init: function() {
this._native = new Shell.PolkitAuthenticationAgent(); this._native = new Shell.PolkitAuthenticationAgent();
this._native.connect('initiate', Lang.bind(this, this._onInitiate)); this._native.connect('initiate', Lang.bind(this, this._onInitiate));
@ -404,7 +398,7 @@ AuthenticationAgent.prototype = {
this._reallyCompleteRequest(wasDismissed); this._reallyCompleteRequest(wasDismissed);
} }
} }
} });
function init() { function init() {
let agent = new AuthenticationAgent(); let agent = new AuthenticationAgent();

View File

@ -2,7 +2,9 @@
const Cairo = imports.cairo; const Cairo = imports.cairo;
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio;
const Lang = imports.lang; const Lang = imports.lang;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
@ -26,11 +28,9 @@ function _ensureStyle(actor) {
actor.ensure_style(); actor.ensure_style();
} }
function PopupBaseMenuItem(params) { const PopupBaseMenuItem = new Lang.Class({
this._init(params); Name: 'PopupBaseMenuItem',
}
PopupBaseMenuItem.prototype = {
_init: function (params) { _init: function (params) {
params = Params.parse (params, { reactive: true, params = Params.parse (params, { reactive: true,
activate: true, activate: true,
@ -377,33 +377,27 @@ PopupBaseMenuItem.prototype = {
x -= availWidth + this._spacing; x -= availWidth + this._spacing;
} }
} }
}; });
Signals.addSignalMethods(PopupBaseMenuItem.prototype); Signals.addSignalMethods(PopupBaseMenuItem.prototype);
function PopupMenuItem() { const PopupMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupMenuItem',
} Extends: PopupBaseMenuItem,
PopupMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function (text, params) { _init: function (text, params) {
PopupBaseMenuItem.prototype._init.call(this, params); this.parent(params);
this.label = new St.Label({ text: text }); this.label = new St.Label({ text: text });
this.addActor(this.label); this.addActor(this.label);
} }
}; });
function PopupSeparatorMenuItem() { const PopupSeparatorMenuItem = new Lang.Class({
this._init(); Name: 'PopupSeparatorMenuItem',
} Extends: PopupBaseMenuItem,
PopupSeparatorMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function () { _init: function () {
PopupBaseMenuItem.prototype._init.call(this, { reactive: false }); this.parent({ reactive: false });
this._drawingArea = new St.DrawingArea({ style_class: 'popup-separator-menu-item' }); this._drawingArea = new St.DrawingArea({ style_class: 'popup-separator-menu-item' });
this.addActor(this._drawingArea, { span: -1, expand: true }); this.addActor(this._drawingArea, { span: -1, expand: true });
@ -429,22 +423,19 @@ PopupSeparatorMenuItem.prototype = {
cr.rectangle(margin, gradientOffset, gradientWidth, gradientHeight); cr.rectangle(margin, gradientOffset, gradientWidth, gradientHeight);
cr.fill(); cr.fill();
} }
}; });
const PopupAlternatingMenuItemState = { const PopupAlternatingMenuItemState = {
DEFAULT: 0, DEFAULT: 0,
ALTERNATIVE: 1 ALTERNATIVE: 1
} }
function PopupAlternatingMenuItem() { const PopupAlternatingMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupAlternatingMenuItem',
} Extends: PopupBaseMenuItem,
PopupAlternatingMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function(text, alternateText, params) { _init: function(text, alternateText, params) {
PopupBaseMenuItem.prototype._init.call(this, params); this.parent(params);
this.actor.add_style_class_name('popup-alternating-menu-item'); this.actor.add_style_class_name('popup-alternating-menu-item');
this._text = text; this._text = text;
@ -530,17 +521,14 @@ PopupAlternatingMenuItem.prototype = {
this._updateLabel(); this._updateLabel();
} }
}; });
function PopupSliderMenuItem() { const PopupSliderMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupSliderMenuItem',
} Extends: PopupBaseMenuItem,
PopupSliderMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function(value) { _init: function(value) {
PopupBaseMenuItem.prototype._init.call(this, { activate: false }); this.parent({ activate: false });
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent)); this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
@ -716,13 +704,11 @@ PopupSliderMenuItem.prototype = {
} }
return false; return false;
} }
}; });
function Switch() { const Switch = new Lang.Class({
this._init.apply(this, arguments); Name: 'Switch',
}
Switch.prototype = {
_init: function(state) { _init: function(state) {
this.actor = new St.Bin({ style_class: 'toggle-switch' }); this.actor = new St.Bin({ style_class: 'toggle-switch' });
// Translators: this MUST be either "toggle-switch-us" // Translators: this MUST be either "toggle-switch-us"
@ -745,17 +731,14 @@ Switch.prototype = {
toggle: function() { toggle: function() {
this.setToggleState(!this.state); this.setToggleState(!this.state);
} }
}; });
function PopupSwitchMenuItem() { const PopupSwitchMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupSwitchMenuItem',
} Extends: PopupBaseMenuItem,
PopupSwitchMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function(text, active, params) { _init: function(text, active, params) {
PopupBaseMenuItem.prototype._init.call(this, params); this.parent(params);
this.label = new St.Label({ text: text }); this.label = new St.Label({ text: text });
this._switch = new Switch(active); this._switch = new Switch(active);
@ -790,7 +773,7 @@ PopupSwitchMenuItem.prototype = {
this.toggle(); this.toggle();
} }
PopupBaseMenuItem.prototype.activate.call(this, event); this.parent(event);
}, },
toggle: function() { toggle: function() {
@ -805,17 +788,14 @@ PopupSwitchMenuItem.prototype = {
setToggleState: function(state) { setToggleState: function(state) {
this._switch.setToggleState(state); this._switch.setToggleState(state);
} }
}; });
function PopupImageMenuItem() { const PopupImageMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupImageMenuItem',
} Extends: PopupBaseMenuItem,
PopupImageMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function (text, iconName, params) { _init: function (text, iconName, params) {
PopupBaseMenuItem.prototype._init.call(this, params); this.parent(params);
this.label = new St.Label({ text: text }); this.label = new St.Label({ text: text });
this.addActor(this.label); this.addActor(this.label);
@ -828,13 +808,12 @@ PopupImageMenuItem.prototype = {
setIcon: function(name) { setIcon: function(name) {
this._icon.icon_name = name; this._icon.icon_name = name;
} }
}; });
function PopupMenuBase() { const PopupMenuBase = new Lang.Class({
throw new TypeError('Trying to instantiate abstract class PopupMenuBase'); Name: 'PopupMenuBase',
} Abstract: true,
PopupMenuBase.prototype = {
_init: function(sourceActor, styleClass) { _init: function(sourceActor, styleClass) {
this.sourceActor = sourceActor; this.sourceActor = sourceActor;
@ -1139,18 +1118,15 @@ PopupMenuBase.prototype = {
this.emit('destroy'); this.emit('destroy');
} }
}; });
Signals.addSignalMethods(PopupMenuBase.prototype); Signals.addSignalMethods(PopupMenuBase.prototype);
function PopupMenu() { const PopupMenu = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupMenu',
} Extends: PopupMenuBase,
PopupMenu.prototype = {
__proto__: PopupMenuBase.prototype,
_init: function(sourceActor, arrowAlignment, arrowSide) { _init: function(sourceActor, arrowAlignment, arrowSide) {
PopupMenuBase.prototype._init.call (this, sourceActor, 'popup-menu-content'); this.parent(sourceActor, 'popup-menu-content');
this._arrowAlignment = arrowAlignment; this._arrowAlignment = arrowAlignment;
this._arrowSide = arrowSide; this._arrowSide = arrowSide;
@ -1235,17 +1211,14 @@ PopupMenu.prototype = {
this.isOpen = false; this.isOpen = false;
this.emit('open-state-changed', false); this.emit('open-state-changed', false);
} }
}; });
function PopupSubMenu() { const PopupSubMenu = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupSubMenu',
} Extends: PopupMenuBase,
PopupSubMenu.prototype = {
__proto__: PopupMenuBase.prototype,
_init: function(sourceActor, sourceArrow) { _init: function(sourceActor, sourceArrow) {
PopupMenuBase.prototype._init.call(this, sourceActor); this.parent(sourceActor);
this._arrow = sourceArrow; this._arrow = sourceArrow;
this._arrow.rotation_center_z_gravity = Clutter.Gravity.CENTER; this._arrow.rotation_center_z_gravity = Clutter.Gravity.CENTER;
@ -1400,7 +1373,7 @@ PopupSubMenu.prototype = {
return false; return false;
} }
}; });
/** /**
* PopupMenuSection: * PopupMenuSection:
@ -1410,15 +1383,12 @@ PopupSubMenu.prototype = {
* can add it to another menu), but is completely transparent * can add it to another menu), but is completely transparent
* to the user * to the user
*/ */
function PopupMenuSection() { const PopupMenuSection = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupMenuSection',
} Extends: PopupMenuBase,
PopupMenuSection.prototype = {
__proto__: PopupMenuBase.prototype,
_init: function() { _init: function() {
PopupMenuBase.prototype._init.call(this); this.parent();
this.actor = this.box; this.actor = this.box;
this.actor._delegate = this; this.actor._delegate = this;
@ -1429,17 +1399,14 @@ PopupMenuSection.prototype = {
// corresponding signal so children can still pick it up // corresponding signal so children can still pick it up
open: function(animate) { this.emit('open-state-changed', true); }, open: function(animate) { this.emit('open-state-changed', true); },
close: function() { this.emit('open-state-changed', false); }, close: function() { this.emit('open-state-changed', false); },
} });
function PopupSubMenuMenuItem() { const PopupSubMenuMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupSubMenuMenuItem',
} Extends: PopupBaseMenuItem,
PopupSubMenuMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function(text) { _init: function(text) {
PopupBaseMenuItem.prototype._init.call(this); this.parent();
this.actor.add_style_class_name('popup-submenu-menu-item'); this.actor.add_style_class_name('popup-submenu-menu-item');
@ -1461,7 +1428,8 @@ PopupSubMenuMenuItem.prototype = {
destroy: function() { destroy: function() {
this.menu.destroy(); this.menu.destroy();
PopupBaseMenuItem.prototype.destroy.call(this);
this.parent();
}, },
_onKeyPressEvent: function(actor, event) { _onKeyPressEvent: function(actor, event) {
@ -1476,7 +1444,7 @@ PopupSubMenuMenuItem.prototype = {
return true; return true;
} }
return PopupBaseMenuItem.prototype._onKeyPressEvent.call(this, actor, event); return this.parent(actor, event);
}, },
activate: function(event) { activate: function(event) {
@ -1486,18 +1454,15 @@ PopupSubMenuMenuItem.prototype = {
_onButtonReleaseEvent: function(actor) { _onButtonReleaseEvent: function(actor) {
this.menu.toggle(); this.menu.toggle();
} }
}; });
function PopupComboMenu() { const PopupComboMenu = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupComboMenu',
} Extends: PopupMenuBase,
PopupComboMenu.prototype = {
__proto__: PopupMenuBase.prototype,
_init: function(sourceActor) { _init: function(sourceActor) {
PopupMenuBase.prototype._init.call(this, this.parent(sourceActor, 'popup-combo-menu');
sourceActor, 'popup-combo-menu');
this.actor = this.box; this.actor = this.box;
this.actor._delegate = this; this.actor._delegate = this;
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent)); this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
@ -1602,17 +1567,14 @@ PopupComboMenu.prototype = {
getItemVisible: function(position) { getItemVisible: function(position) {
return this._getMenuItems()[position].actor.visible; return this._getMenuItems()[position].actor.visible;
} }
}; });
function PopupComboBoxMenuItem() { const PopupComboBoxMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'PopupComboBoxMenuItem',
} Extends: PopupBaseMenuItem,
PopupComboBoxMenuItem.prototype = {
__proto__: PopupBaseMenuItem.prototype,
_init: function (params) { _init: function (params) {
PopupBaseMenuItem.prototype._init.call(this, params); this.parent(params);
this._itemBox = new Shell.Stack(); this._itemBox = new Shell.Stack();
this.addActor(this._itemBox); this.addActor(this._itemBox);
@ -1730,16 +1692,262 @@ PopupComboBoxMenuItem.prototype = {
this.setActiveItem(position); this.setActiveItem(position);
this.emit('active-item-changed', position); this.emit('active-item-changed', position);
} }
}; });
/**
* RemoteMenu:
*
* A PopupMenu that tracks a GMenuModel and shows its actions
* (exposed by GApplication/GActionGroup)
*/
const RemoteMenu = new Lang.Class({
Name: 'RemoteMenu',
Extends: PopupMenu,
_init: function(sourceActor, model, actionGroup) {
this.parent(sourceActor, 0.0, St.Side.TOP);
this.model = model;
this.actionGroup = actionGroup;
this._actions = { };
this._modelChanged(this.model, 0, 0, this.model.get_n_items(), this);
this._actionStateChangeId = this.actionGroup.connect('action-state-changed', Lang.bind(this, this._actionStateChanged));
this._actionEnableChangeId = this.actionGroup.connect('action-enabled-changed', Lang.bind(this, this._actionEnabledChanged));
},
destroy: function() {
if (this._actionStateChangeId) {
this.actionGroup.disconnect(this._actionStateChangeId);
this._actionStateChangeId = 0;
}
if (this._actionEnableChangeId) {
this.actionGroup.disconnect(this._actionEnableChangeId);
this._actionEnableChangeId = 0;
}
this.parent();
},
_createMenuItem: function(model, index) {
let section_link = model.get_item_link(index, Gio.MENU_LINK_SECTION);
if (section_link) {
let item = new PopupMenuSection();
this._modelChanged(section_link, 0, 0, section_link.get_n_items(), item);
return [item, true, ''];
}
// labels are not checked for existance, as they're required for all items
let label = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_LABEL, null).deep_unpack();
// remove all underscores that are not followed by another underscore
label = label.replace(/_([^_])/, '$1');
let submenu_link = model.get_item_link(index, Gio.MENU_LINK_SUBMENU);
if (submenu_link) {
let item = new PopupSubMenuMenuItem(label);
this._modelChanged(submenu_link, 0, 0, submenu_link.get_n_items(), item.menu);
return [item, false, ''];
}
let action_id = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_ACTION, null).deep_unpack();
if (!this.actionGroup.has_action(action_id)) {
// the action may not be there yet, wait for action-added
return [null, false, 'action-added'];
}
if (!this._actions[action_id])
this._actions[action_id] = { enabled: this.actionGroup.get_action_enabled(action_id),
state: this.actionGroup.get_action_state(action_id),
items: [ ],
};
let action = this._actions[action_id];
let item, target, destroyId, specificSignalId;
if (action.state) {
// Docs have get_state_hint(), except that the DBus protocol
// has no provision for it (so ShellApp does not implement it,
// and neither GApplication), and g_action_get_state_hint()
// always returns null
// Funny :)
switch (String.fromCharCode(action.state.classify())) {
case 'b':
item = new PopupSwitchMenuItem(label, action.state.get_boolean());
action.items.push(item);
specificSignalId = item.connect('toggled', Lang.bind(this, function(item) {
this.actionGroup.change_action_state(action_id, GLib.Variant.new_boolean(item.state));
}));
break;
case 'd':
item = new PopupSliderMenuItem(label, action.state.get_double());
action.items.push(item);
// value-changed is emitted for each motion-event, maybe an idle is more appropriate here?
specificSignalId = item.connect('value-changed', Lang.bind(this, function(item) {
this.actionGroup.change_action_state(action_id, GLib.Variant.new_double(item.value));
}));
break;
case 's':
item = new PopupMenuItem(label);
item._remoteTarget = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_TARGET, null).deep_unpack();
action.items.push(item);
item.setShowDot(action.state.deep_unpack() == item._remoteTarget);
specificSignalId = item.connect('activate', Lang.bind(this, function(item) {
this.actionGroup.change_action_state(action_id, GLib.Variant.new_string(item._remoteTarget));
}));
break;
default:
log('Action "%s" has state of type %s, which is not supported'.format(action_id, action.state.get_type_string()));
return [null, false, 'action-state-changed'];
}
} else {
target = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_TARGET, null);
item = new PopupMenuItem(label);
action.items.push(item);
specificSignalId = item.connect('activate', Lang.bind(this, function() {
this.actionGroup.activate_action(action_id, target);
}));
}
item.actor.reactive = item.actor.can_focus = action.enabled;
if (action.enabled)
item.actor.remove_style_pseudo_class('insensitive');
else
item.actor.add_style_pseudo_class('insensitive');
destroyId = item.connect('destroy', Lang.bind(this, function() {
item.disconnect(destroyId);
item.disconnect(specificSignalId);
let pos = action.items.indexOf(item);
if (pos != -1)
action.items.splice(pos, 1);
}));
return [item, false, ''];
},
_modelChanged: function(model, position, removed, added, target) {
let j, k;
let j0, k0;
let currentItems = target._getMenuItems();
for (j0 = 0, k0 = 0; j0 < position; j0++, k0++) {
if (currentItems[k0] instanceof PopupSeparatorMenuItem)
k0++;
}
if (removed == -1) {
// special flag to indicate we should destroy everything
for (k = k0; k < currentItems.length; k++)
currentItems[k].destroy();
} else {
for (j = j0, k = k0; j < j0 + removed; j++, k++) {
currentItems[k].destroy();
if (currentItems[k] instanceof PopupSeparatorMenuItem)
j--;
}
}
for (j = j0, k = k0; j < j0 + added; j++, k++) {
let [item, addSeparator, changeSignal] = this._createMenuItem(model, j);
if (item) {
// separators must be added in the parent to make autohiding work
if (addSeparator) {
target.addMenuItem(new PopupSeparatorMenuItem(), k+1);
k++;
}
target.addMenuItem(item, k);
if (addSeparator) {
target.addMenuItem(new PopupSeparatorMenuItem(), k+1);
k++;
}
} else if (changeSignal) {
let signalId = this.actionGroup.connect(changeSignal, Lang.bind(this, function() {
this.actionGroup.disconnect(signalId);
// force a full update
this._modelChanged(model, 0, -1, model.get_n_items(), target);
}));
}
}
if (!model._changedId) {
model._changedId = model.connect('items-changed', Lang.bind(this, this._modelChanged, target));
model._destroyId = target.connect('destroy', function() {
if (model._changedId)
model.disconnect(model._changedId);
if (model._destroyId)
target.disconnect(model._destroyId);
model._changedId = 0;
model._destroyId = 0;
});
}
if (target instanceof PopupMenuSection) {
target.actor.visible = target.numMenuItems != 0;
} else {
let sourceItem = target.sourceActor._delegate;
if (sourceItem instanceof PopupSubMenuMenuItem)
sourceItem.actor.visible = target.numMenuItems != 0;
}
},
_actionStateChanged: function(actionGroup, action_id) {
let action = this._actions[action_id];
if (!action)
return;
action.state = actionGroup.get_action_state(action_id);
if (action.items.length) {
switch (String.fromCharCode(action.state.classify())) {
case 'b':
for (let i = 0; i < action.items.length; i++)
action.items[i].setToggleState(action.state.get_boolean());
break;
case 'd':
for (let i = 0; i < action.items.length; i++)
action.items[i].setValue(action.state.get_double());
break;
case 's':
for (let i = 0; i < action.items.length; i++)
action.items[i].setShowDot(action.items[i]._remoteTarget == action.state.deep_unpack());
}
}
},
_actionEnabledChanged: function(actionGroup, action_id) {
let action = this._actions[action_id];
if (!action)
return;
action.enabled = actionGroup.get_action_enabled(action_id);
if (action.items.length) {
for (let i = 0; i < action.items.length; i++) {
let item = action.items[i];
item.actor.reactive = item.actor.can_focus = action.enabled;
if (action.enabled)
item.actor.remove_style_pseudo_class('insensitive');
else
item.actor.add_style_pseudo_class('insensitive');
}
}
}
});
/* Basic implementation of a menu manager. /* Basic implementation of a menu manager.
* Call addMenu to add menus * Call addMenu to add menus
*/ */
function PopupMenuManager(owner) { const PopupMenuManager = new Lang.Class({
this._init(owner); Name: 'PopupMenuManager',
}
PopupMenuManager.prototype = {
_init: function(owner) { _init: function(owner) {
this._owner = owner; this._owner = owner;
this.grabbed = false; this.grabbed = false;
@ -2011,4 +2219,4 @@ PopupMenuManager.prototype = {
if (this._activeMenu != null) if (this._activeMenu != null)
this._activeMenu.close(true); this._activeMenu.close(true);
} }
}; });

View File

@ -30,11 +30,9 @@ const EXEC_ARG_KEY = 'exec-arg';
const DIALOG_GROW_TIME = 0.1; const DIALOG_GROW_TIME = 0.1;
function CommandCompleter() { const CommandCompleter = new Lang.Class({
this._init(); Name: 'CommandCompleter',
}
CommandCompleter.prototype = {
_init : function() { _init : function() {
this._changedCount = 0; this._changedCount = 0;
this._paths = GLib.getenv('PATH').split(':'); this._paths = GLib.getenv('PATH').split(':');
@ -162,16 +160,14 @@ CommandCompleter.prototype = {
return common.substr(text.length); return common.substr(text.length);
return common; return common;
} }
}; });
function RunDialog() { const RunDialog = new Lang.Class({
this._init(); Name: 'RunDialog',
} Extends: ModalDialog.ModalDialog,
RunDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init : function() { _init : function() {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'run-dialog' }); this.parent({ styleClass: 'run-dialog' });
this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA }); this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
this._terminalSettings = new Gio.Settings({ schema: TERMINAL_SCHEMA }); this._terminalSettings = new Gio.Settings({ schema: TERMINAL_SCHEMA });
@ -384,8 +380,7 @@ __proto__: ModalDialog.ModalDialog.prototype,
if (this._lockdownSettings.get_boolean(DISABLE_COMMAND_LINE_KEY)) if (this._lockdownSettings.get_boolean(DISABLE_COMMAND_LINE_KEY))
return; return;
ModalDialog.ModalDialog.prototype.open.call(this); this.parent();
}, },
});
};
Signals.addSignalMethods(RunDialog.prototype); Signals.addSignalMethods(RunDialog.prototype);

View File

@ -23,11 +23,9 @@ const MatchType = {
MULTIPLE_PREFIX: 4 MULTIPLE_PREFIX: 4
}; };
function SearchResultDisplay(provider) { const SearchResultDisplay = new Lang.Class({
this._init(provider); Name: 'SearchResultDisplay',
}
SearchResultDisplay.prototype = {
_init: function(provider) { _init: function(provider) {
this.provider = provider; this.provider = provider;
this.actor = null; this.actor = null;
@ -96,7 +94,7 @@ SearchResultDisplay.prototype = {
activateSelected: function() { activateSelected: function() {
throw new Error('Not implemented'); throw new Error('Not implemented');
} }
}; });
/** /**
* SearchProvider: * SearchProvider:
@ -105,11 +103,9 @@ SearchResultDisplay.prototype = {
* to the search system, then call registerProvider() * to the search system, then call registerProvider()
* in SearchSystem with an instance. * in SearchSystem with an instance.
*/ */
function SearchProvider(title) { const SearchProvider = new Lang.Class({
this._init(title); Name: 'SearchProvider',
}
SearchProvider.prototype = {
_init: function(title) { _init: function(title) {
this.title = title; this.title = title;
this.searchSystem = null; this.searchSystem = null;
@ -243,14 +239,12 @@ SearchProvider.prototype = {
activateResult: function(id) { activateResult: function(id) {
throw new Error('Not implemented'); throw new Error('Not implemented');
} }
}; });
Signals.addSignalMethods(SearchProvider.prototype); Signals.addSignalMethods(SearchProvider.prototype);
function OpenSearchSystem() { const OpenSearchSystem = new Lang.Class({
this._init(); Name: 'OpenSearchSystem',
}
OpenSearchSystem.prototype = {
_init: function() { _init: function() {
this._providers = []; this._providers = [];
global.settings.connect('changed::' + DISABLED_OPEN_SEARCH_PROVIDERS_KEY, Lang.bind(this, this._refresh)); global.settings.connect('changed::' + DISABLED_OPEN_SEARCH_PROVIDERS_KEY, Lang.bind(this, this._refresh));
@ -338,14 +332,12 @@ OpenSearchSystem.prototype = {
} }
})); }));
} }
} });
Signals.addSignalMethods(OpenSearchSystem.prototype); Signals.addSignalMethods(OpenSearchSystem.prototype);
function SearchSystem() { const SearchSystem = new Lang.Class({
this._init(); Name: 'SearchSystem',
}
SearchSystem.prototype = {
_init: function() { _init: function() {
this._providers = []; this._providers = [];
this.reset(); this.reset();
@ -433,5 +425,5 @@ SearchSystem.prototype = {
this._previousResults = results; this._previousResults = results;
this.emit('search-completed', results); this.emit('search-completed', results);
}, },
}; });
Signals.addSignalMethods(SearchSystem.prototype); Signals.addSignalMethods(SearchSystem.prototype);

View File

@ -15,11 +15,9 @@ const Search = imports.ui.search;
const MAX_SEARCH_RESULTS_ROWS = 1; const MAX_SEARCH_RESULTS_ROWS = 1;
function SearchResult(provider, metaInfo, terms) { const SearchResult = new Lang.Class({
this._init(provider, metaInfo, terms); Name: 'SearchResult',
}
SearchResult.prototype = {
_init: function(provider, metaInfo, terms) { _init: function(provider, metaInfo, terms) {
this.provider = provider; this.provider = provider;
this.metaInfo = metaInfo; this.metaInfo = metaInfo;
@ -97,18 +95,16 @@ SearchResult.prototype = {
else else
this.provider.activateResult(this.metaInfo.id, params); this.provider.activateResult(this.metaInfo.id, params);
} }
}; });
function GridSearchResults(provider, grid) { const GridSearchResults = new Lang.Class({
this._init(provider, grid); Name: 'GridSearchResults',
} Extends: Search.SearchResultDisplay,
GridSearchResults.prototype = {
__proto__: Search.SearchResultDisplay.prototype,
_init: function(provider, grid) { _init: function(provider, grid) {
Search.SearchResultDisplay.prototype._init.call(this, provider); this.parent(provider);
this._grid = grid || new IconGrid.IconGrid({ rowLimit: MAX_SEARCH_RESULTS_ROWS, this._grid = grid || new IconGrid.IconGrid({ rowLimit: MAX_SEARCH_RESULTS_ROWS,
xAlign: St.Align.START }); xAlign: St.Align.START });
this.actor = new St.Bin({ x_align: St.Align.START }); this.actor = new St.Bin({ x_align: St.Align.START });
@ -179,14 +175,11 @@ GridSearchResults.prototype = {
let targetActor = this._grid.getItemAtIndex(this.selectionIndex); let targetActor = this._grid.getItemAtIndex(this.selectionIndex);
targetActor._delegate.activate(); targetActor._delegate.activate();
} }
}; });
const SearchResults = new Lang.Class({
Name: 'SearchResults',
function SearchResults(searchSystem, openSearchSystem) {
this._init(searchSystem, openSearchSystem);
}
SearchResults.prototype = {
_init: function(searchSystem, openSearchSystem) { _init: function(searchSystem, openSearchSystem) {
this._searchSystem = searchSystem; this._searchSystem = searchSystem;
this._searchSystem.connect('search-updated', Lang.bind(this, this._updateCurrentResults)); this._searchSystem.connect('search-updated', Lang.bind(this, this._updateCurrentResults));
@ -486,4 +479,4 @@ SearchResults.prototype = {
resultDisplay.activateSelected(); resultDisplay.activateSelected();
Main.overview.hide(); Main.overview.hide();
} }
}; });

View File

@ -66,11 +66,9 @@ const GnomeShellIface = <interface name="org.gnome.Shell">
</signal> </signal>
</interface>; </interface>;
function GnomeShell() { const GnomeShell = new Lang.Class({
this._init(); Name: 'GnomeShellDBus',
}
GnomeShell.prototype = {
_init: function() { _init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this); this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell'); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
@ -230,4 +228,4 @@ GnomeShell.prototype = {
this._dbusImpl.emit_signal('ExtensionStatusChanged', this._dbusImpl.emit_signal('ExtensionStatusChanged',
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error])); GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
} }
}; });

View File

@ -7,18 +7,14 @@ const Main = imports.ui.main;
const Params = imports.misc.params; const Params = imports.misc.params;
const PopupMenu = imports.ui.popupMenu; const PopupMenu = imports.ui.popupMenu;
const _EntryMenu = new Lang.Class({
function _EntryMenu(entry, params) { Name: 'ShellEntryMenu',
this._init(entry, params); Extends: PopupMenu.PopupMenu,
};
_EntryMenu.prototype = {
__proto__: PopupMenu.PopupMenu.prototype,
_init: function(entry, params) { _init: function(entry, params) {
params = Params.parse (params, { isPassword: false }); params = Params.parse (params, { isPassword: false });
PopupMenu.PopupMenu.prototype._init.call(this, entry, 0, St.Side.TOP); this.parent(entry, 0, St.Side.TOP);
this.actor.add_style_class_name('entry-context-menu'); this.actor.add_style_class_name('entry-context-menu');
@ -60,7 +56,7 @@ _EntryMenu.prototype = {
if (!this.actor.navigate_focus(null, direction, false)) if (!this.actor.navigate_focus(null, direction, false))
this.actor.grab_key_focus(); this.actor.grab_key_focus();
PopupMenu.PopupMenu.prototype.open.call(this); this.parent();
}, },
_updateCopyItem: function() { _updateCopyItem: function() {
@ -103,8 +99,7 @@ _EntryMenu.prototype = {
let visible = !!(this._entry.clutter_text.password_char); let visible = !!(this._entry.clutter_text.password_char);
this._entry.clutter_text.set_password_char(visible ? '' : '\u25cf'); this._entry.clutter_text.set_password_char(visible ? '' : '\u25cf');
} }
}; });
function _setMenuAlignment(entry, stageX) { function _setMenuAlignment(entry, stageX) {
let [success, entryX, entryY] = entry.transform_stage_point(stageX, 0); let [success, entryX, entryY] = entry.transform_stage_point(stageX, 0);

View File

@ -50,11 +50,9 @@ function _setLabelsForMessage(dialog, message) {
/* -------------------------------------------------------- */ /* -------------------------------------------------------- */
function ListItem(app) { const ListItem = new Lang.Class({
this._init(app); Name: 'ListItem',
}
ListItem.prototype = {
_init: function(app) { _init: function(app) {
this._app = app; this._app = app;
@ -86,14 +84,12 @@ ListItem.prototype = {
this.emit('activate'); this.emit('activate');
this._app.activate(); this._app.activate();
} }
}; });
Signals.addSignalMethods(ListItem.prototype); Signals.addSignalMethods(ListItem.prototype);
function ShellMountOperation(source, params) { const ShellMountOperation = new Lang.Class({
this._init(source, params); Name: 'ShellMountOperation',
}
ShellMountOperation.prototype = {
_init: function(source, params) { _init: function(source, params) {
params = Params.parse(params, { reaskPassword: false }); params = Params.parse(params, { reaskPassword: false });
@ -190,17 +186,14 @@ ShellMountOperation.prototype = {
this._processesDialog.update(message, processes, choices); this._processesDialog.update(message, processes, choices);
}, },
} });
function ShellMountQuestionDialog(icon) { const ShellMountQuestionDialog = new Lang.Class({
this._init(icon); Name: 'ShellMountQuestionDialog',
} Extends: ModalDialog.ModalDialog,
ShellMountQuestionDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(icon) { _init: function(icon) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'mount-question-dialog' }); this.parent({ styleClass: 'mount-question-dialog' });
let mainContentLayout = new St.BoxLayout(); let mainContentLayout = new St.BoxLayout();
this.contentLayout.add(mainContentLayout, { x_fill: true, this.contentLayout.add(mainContentLayout, { x_fill: true,
@ -236,19 +229,16 @@ ShellMountQuestionDialog.prototype = {
_setLabelsForMessage(this, message); _setLabelsForMessage(this, message);
_setButtonsForChoices(this, choices); _setButtonsForChoices(this, choices);
} }
} });
Signals.addSignalMethods(ShellMountQuestionDialog.prototype); Signals.addSignalMethods(ShellMountQuestionDialog.prototype);
function ShellMountPasswordSource(message, icon, reaskPassword) { const ShellMountPasswordSource = new Lang.Class({
this._init(message, icon, reaskPassword); Name: 'ShellMountPasswordSource',
} Extends: MessageTray.Source,
ShellMountPasswordSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(message, icon, reaskPassword) { _init: function(message, icon, reaskPassword) {
let strings = message.split('\n'); let strings = message.split('\n');
MessageTray.Source.prototype._init.call(this, strings[0]); this.parent(strings[0]);
this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword); this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword);
@ -256,21 +246,15 @@ ShellMountPasswordSource.prototype = {
Main.messageTray.add(this); Main.messageTray.add(this);
this.notify(this._notification); this.notify(this._notification);
}, },
} });
Signals.addSignalMethods(ShellMountPasswordSource.prototype); Signals.addSignalMethods(ShellMountPasswordSource.prototype);
function ShellMountPasswordNotification(source, strings, icon, reaskPassword) { const ShellMountPasswordNotification = new Lang.Class({
this._init(source, strings, icon, reaskPassword); Name: 'ShellMountPasswordNotification',
} Extends: MessageTray.Notification,
ShellMountPasswordNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, strings, icon, reaskPassword) { _init: function(source, strings, icon, reaskPassword) {
MessageTray.Notification.prototype._init.call(this, source, this.parent(source, strings[0], null, { customContent: true, icon: icon });
strings[0], null,
{ customContent: true,
icon: icon });
// set the notification to transient and urgent, so that it // set the notification to transient and urgent, so that it
// expands out // expands out
@ -305,17 +289,14 @@ ShellMountPasswordNotification.prototype = {
this.source.emit('password-ready', text); this.source.emit('password-ready', text);
} }
} });
function ShellProcessesDialog(icon) { const ShellProcessesDialog = new Lang.Class({
this._init(icon); Name: 'ShellProcessesDialog',
} Extends: ModalDialog.ModalDialog,
ShellProcessesDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(icon) { _init: function(icon) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'show-processes-dialog' }); this.parent({ styleClass: 'show-processes-dialog' });
let mainContentLayout = new St.BoxLayout(); let mainContentLayout = new St.BoxLayout();
this.contentLayout.add(mainContentLayout, { x_fill: true, this.contentLayout.add(mainContentLayout, { x_fill: true,
@ -401,5 +382,5 @@ ShellProcessesDialog.prototype = {
_setLabelsForMessage(this, message); _setLabelsForMessage(this, message);
_setButtonsForChoices(this, choices); _setButtonsForChoices(this, choices);
} }
} });
Signals.addSignalMethods(ShellProcessesDialog.prototype); Signals.addSignalMethods(ShellProcessesDialog.prototype);

View File

@ -1,6 +1,5 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const DBus = imports.dbus;
const GDesktopEnums = imports.gi.GDesktopEnums; const GDesktopEnums = imports.gi.GDesktopEnums;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
@ -40,15 +39,12 @@ const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor';
const HIGH_CONTRAST_THEME = 'HighContrast'; const HIGH_CONTRAST_THEME = 'HighContrast';
function ATIndicator() { const ATIndicator = new Lang.Class({
this._init.apply(this, arguments); Name: 'ATIndicator',
} Extends: PanelMenu.SystemStatusButton,
ATIndicator.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null); this.parent('preferences-desktop-accessibility', null);
let highContrast = this._buildHCItem(); let highContrast = this._buildHCItem();
this.menu.addMenuItem(highContrast); this.menu.addMenuItem(highContrast);
@ -172,5 +168,4 @@ ATIndicator.prototype = {
}); });
return widget; return widget;
} }
}; });
Signals.addSignalMethods(ATIndicator.prototype);

View File

@ -23,15 +23,12 @@ const ConnectionState = {
CONNECTING: 3 CONNECTING: 3
} }
function Indicator() { const Indicator = new Lang.Class({
this._init.apply(this, arguments); Name: 'BTIndicator',
} Extends: PanelMenu.SystemStatusButton,
Indicator.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'bluetooth-disabled', null); this.parent('bluetooth-disabled', null);
GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"'); GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"');
this._applet = new GnomeBluetoothApplet.Applet(); this._applet = new GnomeBluetoothApplet.Applet();
@ -335,17 +332,14 @@ Indicator.prototype = {
_cancelRequest: function() { _cancelRequest: function() {
this._source.destroy(); this._source.destroy();
} }
} });
function Source() { const Source = new Lang.Class({
this._init.apply(this, arguments); Name: 'BluetoothSource',
} Extends: MessageTray.Source,
Source.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function() { _init: function() {
MessageTray.Source.prototype._init.call(this, _("Bluetooth")); this.parent(_("Bluetooth"));
this._setSummaryIcon(this.createNotificationIcon()); this._setSummaryIcon(this.createNotificationIcon());
}, },
@ -359,7 +353,7 @@ Source.prototype = {
} }
})); }));
MessageTray.Source.prototype.notify.call(this, notification); this.parent(notification);
}, },
createNotificationIcon: function() { createNotificationIcon: function() {
@ -367,21 +361,17 @@ Source.prototype = {
icon_type: St.IconType.SYMBOLIC, icon_type: St.IconType.SYMBOLIC,
icon_size: this.ICON_SIZE }); icon_size: this.ICON_SIZE });
} }
} });
function AuthNotification() { const AuthNotification = new Lang.Class({
this._init.apply(this, arguments); Name: 'AuthNotification',
} Extends: MessageTray.Notification,
AuthNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, applet, device_path, name, long_name, uuid) { _init: function(source, applet, device_path, name, long_name, uuid) {
MessageTray.Notification.prototype._init.call(this, this.parent(source,
source, _("Bluetooth"),
_("Bluetooth"), _("Authorization request from %s").format(name),
_("Authorization request from %s").format(name), { customContent: true });
{ customContent: true });
this.setResident(true); this.setResident(true);
this._applet = applet; this._applet = applet;
@ -407,21 +397,17 @@ AuthNotification.prototype = {
this.destroy(); this.destroy();
})); }));
} }
} });
function ConfirmNotification() { const ConfirmNotification = new Lang.Class({
this._init.apply(this, arguments); Name: 'ConfirmNotification',
} Extends: MessageTray.Notification,
ConfirmNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, applet, device_path, name, long_name, pin) { _init: function(source, applet, device_path, name, long_name, pin) {
MessageTray.Notification.prototype._init.call(this, this.parent(source,
source, _("Bluetooth"),
_("Bluetooth"), _("Pairing confirmation for %s").format(name),
_("Pairing confirmation for %s").format(name), { customContent: true });
{ customContent: true });
this.setResident(true); this.setResident(true);
this._applet = applet; this._applet = applet;
@ -440,21 +426,17 @@ ConfirmNotification.prototype = {
this.destroy(); this.destroy();
})); }));
} }
} });
function PinNotification() { const PinNotification = new Lang.Class({
this._init.apply(this, arguments); Name: 'PinNotification',
} Extends: MessageTray.Notification,
PinNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, applet, device_path, name, long_name, numeric) { _init: function(source, applet, device_path, name, long_name, numeric) {
MessageTray.Notification.prototype._init.call(this, this.parent(source,
source, _("Bluetooth"),
_("Bluetooth"), _("Pairing request for %s").format(name),
_("Pairing request for %s").format(name), { customContent: true });
{ customContent: true });
this.setResident(true); this.setResident(true);
this._applet = applet; this._applet = applet;
@ -503,7 +485,7 @@ PinNotification.prototype = {
}, },
grabFocus: function(lockTray) { grabFocus: function(lockTray) {
MessageTray.Notification.prototype.grabFocus.call(this, lockTray); this.parent(lockTray);
global.stage.set_key_focus(this._entry); global.stage.set_key_focus(this._entry);
} }
} });

View File

@ -14,15 +14,12 @@ const PopupMenu = imports.ui.popupMenu;
const PanelMenu = imports.ui.panelMenu; const PanelMenu = imports.ui.panelMenu;
const Util = imports.misc.util; const Util = imports.misc.util;
function LayoutMenuItem() { const LayoutMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'LayoutMenuItem',
} Extends: PopupMenu.PopupBaseMenuItem,
LayoutMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function(config, id, indicator, long_name) { _init: function(config, id, indicator, long_name) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this); this.parent();
this._config = config; this._config = config;
this._id = id; this._id = id;
@ -33,20 +30,18 @@ LayoutMenuItem.prototype = {
}, },
activate: function(event) { activate: function(event) {
PopupMenu.PopupBaseMenuItem.prototype.activate.call(this); this.parent(event);
this._config.lock_group(this._id); this._config.lock_group(this._id);
} }
}; });
function XKBIndicator() { const XKBIndicator = new Lang.Class({
this._init.call(this); Name: 'XKBIndicator',
} Extends: PanelMenu.Button,
XKBIndicator.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function() { _init: function() {
PanelMenu.Button.prototype._init.call(this, St.Align.START); this.parent(0.0);
this._container = new Shell.GenericContainer(); this._container = new Shell.GenericContainer();
this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth)); this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
@ -221,4 +216,4 @@ XKBIndicator.prototype = {
for (let i = 0; i < this._labelActors.length; i++) for (let i = 0; i < this._labelActors.length; i++)
this._labelActors[i].allocate_align_fill(box, 0.5, 0, false, false, flags); this._labelActors[i].allocate_align_fill(box, 0.5, 0, false, false, flags);
} }
}; });

View File

@ -97,15 +97,12 @@ function ssidToLabel(ssid) {
return label; return label;
} }
function NMNetworkMenuItem() { const NMNetworkMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMNetworkMenuItem',
} Extends: PopupMenu.PopupBaseMenuItem,
NMNetworkMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function(accessPoints, title, params) { _init: function(accessPoints, title, params) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, params); this.parent(params);
accessPoints = sortAccessPoints(accessPoints); accessPoints = sortAccessPoints(accessPoints);
this.bestAP = accessPoints[0]; this.bestAP = accessPoints[0];
@ -184,21 +181,18 @@ NMNetworkMenuItem.prototype = {
apObj.updateId = 0; apObj.updateId = 0;
} }
PopupMenu.PopupBaseMenuItem.prototype.destroy.call(this); this.parent();
} }
}; });
function NMWiredSectionTitleMenuItem() { const NMWiredSectionTitleMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMWiredSectionTitleMenuItem',
} Extends: PopupMenu.PopupSwitchMenuItem,
NMWiredSectionTitleMenuItem.prototype = {
__proto__: PopupMenu.PopupSwitchMenuItem.prototype,
_init: function(label, params) { _init: function(label, params) {
params = params || { }; params = params || { };
params.style_class = 'popup-subtitle-menu-item'; params.style_class = 'popup-subtitle-menu-item';
PopupMenu.PopupSwitchMenuItem.prototype._init.call(this, label, false, params); this.parent(label, false, params);
}, },
updateForDevice: function(device) { updateForDevice: function(device) {
@ -211,7 +205,7 @@ NMWiredSectionTitleMenuItem.prototype = {
}, },
activate: function(event) { activate: function(event) {
PopupMenu.PopupSwitchMenuItem.prototype.activate.call(this, event); this.parent(event);
if (!this._device) { if (!this._device) {
log('Section title activated when there is more than one device, should be non reactive'); log('Section title activated when there is more than one device, should be non reactive');
@ -230,19 +224,16 @@ NMWiredSectionTitleMenuItem.prototype = {
else else
this._device.deactivate(); this._device.deactivate();
} }
}; });
function NMWirelessSectionTitleMenuItem() { const NMWirelessSectionTitleMenuItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMWirelessSectionTitleMenuItem',
} Extends: PopupMenu.PopupSwitchMenuItem,
NMWirelessSectionTitleMenuItem.prototype = {
__proto__: PopupMenu.PopupSwitchMenuItem.prototype,
_init: function(client, property, title, params) { _init: function(client, property, title, params) {
params = params || { }; params = params || { };
params.style_class = 'popup-subtitle-menu-item'; params.style_class = 'popup-subtitle-menu-item';
PopupMenu.PopupSwitchMenuItem.prototype._init.call(this, title, false, params); this.parent(title, false, params);
this._client = client; this._client = client;
this._property = property + '_enabled'; this._property = property + '_enabled';
@ -268,7 +259,7 @@ NMWirelessSectionTitleMenuItem.prototype = {
}, },
activate: function(event) { activate: function(event) {
PopupMenu.PopupSwitchMenuItem.prototype.activate.call(this, event); this.parent(event);
this._client[this._setEnabledFunc](this._switch.state); this._client[this._setEnabledFunc](this._switch.state);
}, },
@ -285,13 +276,12 @@ NMWirelessSectionTitleMenuItem.prototype = {
this.emit('enabled-changed', enabled); this.emit('enabled-changed', enabled);
} }
}; });
function NMDevice() { const NMDevice = new Lang.Class({
throw new TypeError('Instantanting abstract class NMDevice'); Name: 'NMDevice',
} Abstract: true,
NMDevice.prototype = {
_init: function(client, device, connections) { _init: function(client, device, connections) {
this.device = device; this.device = device;
if (device) { if (device) {
@ -673,26 +663,23 @@ NMDevice.prototype = {
return out; return out;
} }
}; });
Signals.addSignalMethods(NMDevice.prototype); Signals.addSignalMethods(NMDevice.prototype);
function NMDeviceWired() { const NMDeviceWired = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMDeviceWired',
} Extends: NMDevice,
NMDeviceWired.prototype = {
__proto__: NMDevice.prototype,
_init: function(client, device, connections) { _init: function(client, device, connections) {
this._autoConnectionName = _("Auto Ethernet"); this._autoConnectionName = _("Auto Ethernet");
this.category = NMConnectionCategory.WIRED; this.category = NMConnectionCategory.WIRED;
NMDevice.prototype._init.call(this, client, device, connections); this.parent(client, device, connections);
}, },
_createSection: function() { _createSection: function() {
NMDevice.prototype._createSection.call(this); this.parent();
// if we have only one connection (normal or automatic) // if we have only one connection (normal or automatic)
// we hide the connection list, and use the switch to control // we hide the connection list, and use the switch to control
@ -717,14 +704,11 @@ NMDeviceWired.prototype = {
})); }));
return connection; return connection;
} }
}; });
function NMDeviceModem() { const NMDeviceModem = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMDeviceModem',
} Extends: NMDevice,
NMDeviceModem.prototype = {
__proto__: NMDevice.prototype,
_init: function(client, device, connections) { _init: function(client, device, connections) {
let is_wwan = false; let is_wwan = false;
@ -773,7 +757,7 @@ NMDeviceModem.prototype = {
})); }));
} }
NMDevice.prototype._init.call(this, client, device, connections); this.parent(client, device, connections);
}, },
setEnabled: function(enabled) { setEnabled: function(enabled) {
@ -786,7 +770,7 @@ NMDeviceModem.prototype = {
this.statusItem.setStatus(this.getStatusLabel()); this.statusItem.setStatus(this.getStatusLabel());
} }
NMDevice.prototype.setEnabled.call(this, enabled); this.parent(enabled);
}, },
get connected() { get connected() {
@ -803,7 +787,7 @@ NMDeviceModem.prototype = {
this._signalQualityId = 0; this._signalQualityId = 0;
} }
NMDevice.prototype.destroy.call(this); this.parent();
}, },
_getSignalIcon: function() { _getSignalIcon: function() {
@ -824,13 +808,13 @@ NMDeviceModem.prototype = {
this.section.addMenuItem(this._operatorItem); this.section.addMenuItem(this._operatorItem);
} }
NMDevice.prototype._createSection.call(this); this.parent();
}, },
_clearSection: function() { _clearSection: function() {
this._operatorItem = null; this._operatorItem = null;
NMDevice.prototype._clearSection.call(this); this.parent();
}, },
_createAutomaticConnection: function() { _createAutomaticConnection: function() {
@ -840,14 +824,11 @@ NMDeviceModem.prototype = {
'connect-3g', this.device.get_path()]); 'connect-3g', this.device.get_path()]);
return null; return null;
} }
}; });
function NMDeviceBluetooth() { const NMDeviceBluetooth = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMDeviceBluetooth',
} Extends: NMDevice,
NMDeviceBluetooth.prototype = {
__proto__: NMDevice.prototype,
_init: function(client, device, connections) { _init: function(client, device, connections) {
this._autoConnectionName = this._makeConnectionName(device); this._autoConnectionName = this._makeConnectionName(device);
@ -855,7 +836,7 @@ NMDeviceBluetooth.prototype = {
this.category = NMConnectionCategory.WWAN; this.category = NMConnectionCategory.WWAN;
NMDevice.prototype._init.call(this, client, device, connections); this.parent(client, device, connections);
}, },
_createAutomaticConnection: function() { _createAutomaticConnection: function() {
@ -885,23 +866,20 @@ NMDeviceBluetooth.prototype = {
this._clearSection(); this._clearSection();
this._createSection(); this._createSection();
} }
}; });
// Not a real device, but I save a lot code this way // Not a real device, but I save a lot code this way
function NMDeviceVPN() { const NMDeviceVPN = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMDeviceVPN',
} Extends: NMDevice,
NMDeviceVPN.prototype = {
__proto__: NMDevice.prototype,
_init: function(client) { _init: function(client) {
// Disable autoconnections // Disable autoconnections
this._autoConnectionName = null; this._autoConnectionName = null;
this.category = NMConnectionCategory.VPN; this.category = NMConnectionCategory.VPN;
NMDevice.prototype._init.call(this, client, null, [ ]); this.parent(client, null, [ ]);
}, },
connectionValid: function(connection) { connectionValid: function(connection) {
@ -917,7 +895,7 @@ NMDeviceVPN.prototype = {
}, },
setActiveConnection: function(activeConnection) { setActiveConnection: function(activeConnection) {
NMDevice.prototype.setActiveConnection.call(this, activeConnection); this.parent(activeConnection);
this.emit('active-connection-changed'); this.emit('active-connection-changed');
}, },
@ -934,14 +912,11 @@ NMDeviceVPN.prototype = {
getStatusLabel: function() { getStatusLabel: function() {
return null; return null;
} }
}; });
function NMDeviceWireless() { const NMDeviceWireless = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMDeviceWireless',
} Extends: NMDevice,
NMDeviceWireless.prototype = {
__proto__: NMDevice.prototype,
_init: function(client, device, connections) { _init: function(client, device, connections) {
this.category = NMConnectionCategory.WIRELESS; this.category = NMConnectionCategory.WIRELESS;
@ -1013,7 +988,7 @@ NMDeviceWireless.prototype = {
this._apAddedId = device.connect('access-point-added', Lang.bind(this, this._accessPointAdded)); this._apAddedId = device.connect('access-point-added', Lang.bind(this, this._accessPointAdded));
this._apRemovedId = device.connect('access-point-removed', Lang.bind(this, this._accessPointRemoved)); this._apRemovedId = device.connect('access-point-removed', Lang.bind(this, this._accessPointRemoved));
NMDevice.prototype._init.call(this, client, device, validConnections); this.parent(client, device, validConnections);
}, },
destroy: function() { destroy: function() {
@ -1033,7 +1008,7 @@ NMDeviceWireless.prototype = {
this._apRemovedId = 0; this._apRemovedId = 0;
} }
NMDevice.prototype.destroy.call(this); this.parent();
}, },
setEnabled: function(enabled) { setEnabled: function(enabled) {
@ -1347,7 +1322,7 @@ NMDeviceWireless.prototype = {
}, },
_clearSection: function() { _clearSection: function() {
NMDevice.prototype._clearSection.call(this); this.parent();
for (let i = 0; i < this._networks.length; i++) for (let i = 0; i < this._networks.length; i++)
this._networks[i].item = null; this._networks[i].item = null;
@ -1555,16 +1530,14 @@ NMDeviceWireless.prototype = {
this._createNetworkItem(apObj, j + activeOffset); this._createNetworkItem(apObj, j + activeOffset);
} }
}, },
}; });
function NMApplet() { const NMApplet = new Lang.Class({
this._init.apply(this, arguments); Name: 'NMApplet',
} Extends: PanelMenu.SystemStatusButton,
NMApplet.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'network-error'); this.parent('network-error', null);
this._client = NMClient.Client.new(); this._client = NMClient.Client.new();
@ -2130,17 +2103,14 @@ NMApplet.prototype = {
this._mobileUpdateId = 0; this._mobileUpdateId = 0;
} }
} }
}; });
function NMMessageTraySource() { const NMMessageTraySource = new Lang.Class({
this._init(); Name: 'NMMessageTraySource',
} Extends: MessageTray.Source,
NMMessageTraySource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function() { _init: function() {
MessageTray.Source.prototype._init.call(this, _("Network Manager")); this.parent(_("Network Manager"));
let icon = new St.Icon({ icon_name: 'network-transmit-receive', let icon = new St.Icon({ icon_name: 'network-transmit-receive',
icon_type: St.IconType.SYMBOLIC, icon_type: St.IconType.SYMBOLIC,
@ -2148,4 +2118,4 @@ NMMessageTraySource.prototype = {
}); });
this._setSummaryIcon(icon); this._setSummaryIcon(icon);
} }
}; });

View File

@ -52,15 +52,13 @@ const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface); const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
function Indicator() { const Indicator = new Lang.Class({
this._init.apply(this, arguments); Name: 'PowerIndicator',
} Extends: PanelMenu.SystemStatusButton,
Indicator.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'battery-missing'); this.parent('battery-missing', null);
this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH); this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
this._deviceItems = [ ]; this._deviceItems = [ ];
@ -163,17 +161,14 @@ Indicator.prototype = {
this._readPrimaryDevice(); this._readPrimaryDevice();
this._readOtherDevices(); this._readOtherDevices();
} }
}; });
function DeviceItem() { const DeviceItem = new Lang.Class({
this._init.apply(this, arguments); Name: 'DeviceItem',
} Extends: PopupMenu.PopupBaseMenuItem,
DeviceItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function(device) { _init: function(device) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, { reactive: false }); this.parent({ reactive: false });
let [device_id, device_type, icon, percentage, state, time] = device; let [device_id, device_type, icon, percentage, state, time] = device;
@ -220,4 +215,4 @@ DeviceItem.prototype = {
return _("Unknown"); return _("Unknown");
} }
} }
} });

View File

@ -17,15 +17,12 @@ const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
const VOLUME_NOTIFY_ID = 1; const VOLUME_NOTIFY_ID = 1;
function Indicator() { const Indicator = new Lang.Class({
this._init.apply(this, arguments); Name: 'VolumeIndicator',
} Extends: PanelMenu.SystemStatusButton,
Indicator.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'audio-volume-muted', null); this.parent('audio-volume-muted', null);
this._control = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' }); this._control = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' });
this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged)); this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged));
@ -214,4 +211,4 @@ Indicator.prototype = {
if (property == '_output' && !this._output.is_muted) if (property == '_output' && !this._output.is_muted)
this.setIcon(this._volumeToIcon(this._output.volume)); this.setIcon(this._volumeToIcon(this._output.volume));
} }
}; });

View File

@ -23,11 +23,9 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
'ibus-ui-gtk': 'input-method' 'ibus-ui-gtk': 'input-method'
}; };
function StatusIconDispatcher() { const StatusIconDispatcher = new Lang.Class({
this._init(); Name: 'StatusIconDispatcher',
}
StatusIconDispatcher.prototype = {
_init: function() { _init: function() {
this._traymanager = new Shell.TrayManager(); this._traymanager = new Shell.TrayManager();
this._traymanager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded)); this._traymanager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded));
@ -61,5 +59,5 @@ StatusIconDispatcher.prototype = {
else else
this.emit('message-icon-removed', icon); this.emit('message-icon-removed', icon);
} }
}; });
Signals.addSignalMethods(StatusIconDispatcher.prototype); Signals.addSignalMethods(StatusIconDispatcher.prototype);

View File

@ -72,11 +72,9 @@ function makeMessageFromTplEvent(event) {
}; };
} }
function Client() { const Client = new Lang.Class({
this._init(); Name: 'Client',
};
Client.prototype = {
_init : function() { _init : function() {
// channel path -> ChatSource // channel path -> ChatSource
this._chatSources = {}; this._chatSources = {};
@ -479,17 +477,14 @@ Client.prototype = {
return this._accountSource; return this._accountSource;
} }
}; });
function ChatSource(account, conn, channel, contact, client) { const ChatSource = new Lang.Class({
this._init(account, conn, channel, contact, client); Name: 'ChatSource',
} Extends: MessageTray.Source,
ChatSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(account, conn, channel, contact, client) { _init: function(account, conn, channel, contact, client) {
MessageTray.Source.prototype._init.call(this, contact.get_alias()); this.parent(contact.get_alias());
this.isChat = true; this.isChat = true;
@ -697,7 +692,7 @@ ChatSource.prototype = {
}, },
notify: function() { notify: function() {
MessageTray.Source.prototype.notify.call(this, this._notification); this.parent(this._notification);
}, },
respond: function(text) { respond: function(text) {
@ -798,17 +793,14 @@ ChatSource.prototype = {
this._shouldAck = false; this._shouldAck = false;
} }
}; });
function ChatNotification(source) { const ChatNotification = new Lang.Class({
this._init(source); Name: 'ChatNotification',
} Extends: MessageTray.Notification,
ChatNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source) { _init: function(source) {
MessageTray.Notification.prototype._init.call(this, source, source.title, null, { customContent: true }); this.parent(source, source.title, null, { customContent: true });
this.setResident(true); this.setResident(true);
this._responseEntry = new St.Entry({ style_class: 'chat-response', this._responseEntry = new St.Entry({ style_class: 'chat-response',
@ -1091,17 +1083,14 @@ ChatNotification.prototype = {
this.source.setChatState(Tp.ChannelChatState.ACTIVE); this.source.setChatState(Tp.ChannelChatState.ACTIVE);
} }
} }
}; });
function ApproverSource(dispatchOp, text, gicon) { const ApproverSource = new Lang.Class({
this._init(dispatchOp, text, gicon); Name: 'ApproverSource',
} Extends: MessageTray.Source,
ApproverSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(dispatchOp, text, gicon) { _init: function(dispatchOp, text, gicon) {
MessageTray.Source.prototype._init.call(this, text); this.parent(text);
this._gicon = gicon; this._gicon = gicon;
this._setSummaryIcon(this.createNotificationIcon()); this._setSummaryIcon(this.createNotificationIcon());
@ -1122,7 +1111,7 @@ ApproverSource.prototype = {
this._invalidId = 0; this._invalidId = 0;
} }
MessageTray.Source.prototype.destroy.call(this); this.parent();
}, },
createNotificationIcon: function() { createNotificationIcon: function() {
@ -1130,23 +1119,19 @@ ApproverSource.prototype = {
icon_type: St.IconType.FULLCOLOR, icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE }); icon_size: this.ICON_SIZE });
} }
} });
function RoomInviteNotification(source, dispatchOp, channel, inviter) { const RoomInviteNotification = new Lang.Class({
this._init(source, dispatchOp, channel, inviter); Name: 'RoomInviteNotification',
} Extends: MessageTray.Notification,
RoomInviteNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, dispatchOp, channel, inviter) { _init: function(source, dispatchOp, channel, inviter) {
MessageTray.Notification.prototype._init.call(this, this.parent(source,
source, /* translators: argument is a room name like
/* translators: argument is a room name like * room@jabber.org for example. */
* room@jabber.org for example. */ _("Invitation to %s").format(channel.get_identifier()),
_("Invitation to %s").format(channel.get_identifier()), null,
null, { customContent: true });
{ customContent: true });
this.setResident(true); this.setResident(true);
/* translators: first argument is the name of a contact and the second /* translators: first argument is the name of a contact and the second
@ -1173,15 +1158,12 @@ RoomInviteNotification.prototype = {
this.destroy(); this.destroy();
})); }));
} }
}; });
// Audio Video // Audio Video
function AudioVideoNotification(source, dispatchOp, channel, contact, isVideo) { const AudioVideoNotification = new Lang.Class({
this._init(source, dispatchOp, channel, contact, isVideo); Name: 'AudioVideoNotification',
} Extends: MessageTray.Notification,
AudioVideoNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, dispatchOp, channel, contact, isVideo) { _init: function(source, dispatchOp, channel, contact, isVideo) {
let title = ''; let title = '';
@ -1193,11 +1175,7 @@ AudioVideoNotification.prototype = {
/* translators: argument is a contact name like Alice for example. */ /* translators: argument is a contact name like Alice for example. */
title = _("Call from %s").format(contact.get_alias()); title = _("Call from %s").format(contact.get_alias());
MessageTray.Notification.prototype._init.call(this, this.parent(this, source, title, null, { customContent: true });
source,
title,
null,
{ customContent: true });
this.setResident(true); this.setResident(true);
this.addButton('reject', _("Reject")); this.addButton('reject', _("Reject"));
@ -1220,28 +1198,25 @@ AudioVideoNotification.prototype = {
this.destroy(); this.destroy();
})); }));
} }
}; });
// File Transfer // File Transfer
function FileTransferNotification(source, dispatchOp, channel, contact) { const FileTransferNotification = new Lang.Class({
this._init(source, dispatchOp, channel, contact); Name: 'FileTransferNotification',
} Extends: MessageTray.Notification,
FileTransferNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, dispatchOp, channel, contact) { _init: function(source, dispatchOp, channel, contact) {
MessageTray.Notification.prototype._init.call(this, this.parent(this,
source, source,
/* To translators: The first parameter is /* To translators: The first parameter is
* the contact's alias and the second one is the * the contact's alias and the second one is the
* file name. The string will be something * file name. The string will be something
* like: "Alice is sending you test.ogg" * like: "Alice is sending you test.ogg"
*/ */
_("%s is sending you %s").format(contact.get_alias(), _("%s is sending you %s").format(contact.get_alias(),
channel.get_filename()), channel.get_filename()),
null, null,
{ customContent: true }); { customContent: true });
this.setResident(true); this.setResident(true);
this.addButton('decline', _("Decline")); this.addButton('decline', _("Decline"));
@ -1263,18 +1238,15 @@ FileTransferNotification.prototype = {
this.destroy(); this.destroy();
})); }));
} }
}; });
// A notification source that can embed multiple notifications // A notification source that can embed multiple notifications
function MultiNotificationSource(title, icon) { const MultiNotificationSource = new Lang.Class({
this._init(title, icon); Name: 'MultiNotificationSource',
} Extends: MessageTray.Source,
MultiNotificationSource.prototype = {
__proto__: MessageTray.Source.prototype,
_init: function(title, icon) { _init: function(title, icon) {
MessageTray.Source.prototype._init.call(this, title); this.parent(title);
this._icon = icon; this._icon = icon;
this._setSummaryIcon(this.createNotificationIcon()); this._setSummaryIcon(this.createNotificationIcon());
@ -1282,7 +1254,7 @@ MultiNotificationSource.prototype = {
}, },
notify: function(notification) { notify: function(notification) {
MessageTray.Source.prototype.notify.call(this, notification); this.parent(notification);
this._nbNotifications += 1; this._nbNotifications += 1;
@ -1300,21 +1272,18 @@ MultiNotificationSource.prototype = {
icon_type: St.IconType.FULLCOLOR, icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE }); icon_size: this.ICON_SIZE });
} }
}; });
// Subscription request // Subscription request
function SubscriptionRequestNotification(source, contact) { const SubscriptionRequestNotification = new Lang.Class({
this._init(source, contact); Name: 'SubscriptionRequestNotification',
} Extends: MessageTray.Notification,
SubscriptionRequestNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
_init: function(source, contact) { _init: function(source, contact) {
MessageTray.Notification.prototype._init.call(this, source, this.parent(this, source,
/* To translators: The parameter is the contact's alias */ /* To translators: The parameter is the contact's alias */
_("%s would like permission to see when you are online").format(contact.get_alias()), _("%s would like permission to see when you are online").format(contact.get_alias()),
null, { customContent: true }); null, { customContent: true });
this._contact = contact; this._contact = contact;
this._connection = contact.get_connection(); this._connection = contact.get_connection();
@ -1388,7 +1357,7 @@ SubscriptionRequestNotification.prototype = {
this._invalidatedId = 0; this._invalidatedId = 0;
} }
MessageTray.Notification.prototype.destroy.call(this); this.parent();
}, },
_subscriptionStatesChangedCb: function(contact, subscribe, publish, msg) { _subscriptionStatesChangedCb: function(contact, subscribe, publish, msg) {
@ -1397,12 +1366,7 @@ SubscriptionRequestNotification.prototype = {
if (publish != Tp.SubscriptionState.ASK) if (publish != Tp.SubscriptionState.ASK)
this.destroy(); this.destroy();
} }
}; });
function AccountNotification(source, account, connectionError) {
this._init(source, account, connectionError);
}
// Messages from empathy/libempathy/empathy-utils.c // Messages from empathy/libempathy/empathy-utils.c
// create_errors_to_message_hash() // create_errors_to_message_hash()
@ -1457,15 +1421,16 @@ _connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.CERT_INSECURE)]
_connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED)] _connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED)]
= _("The length of the server certificate, or the depth of the server certificate chain, exceed the limits imposed by the cryptography library"); = _("The length of the server certificate, or the depth of the server certificate chain, exceed the limits imposed by the cryptography library");
AccountNotification.prototype = { const AccountNotification = new Lang.Class({
__proto__: MessageTray.Notification.prototype, Name: 'AccountNotification',
Extends: MessageTray.Notification,
_init: function(source, account, connectionError) { _init: function(source, account, connectionError) {
MessageTray.Notification.prototype._init.call(this, source, this.parent(source,
/* translators: argument is the account name, like /* translators: argument is the account name, like
* name@jabber.org for example. */ * name@jabber.org for example. */
_("Connection to %s failed").format(account.get_display_name()), _("Connection to %s failed").format(account.get_display_name()),
null, { customContent: true }); null, { customContent: true });
this._label = new St.Label(); this._label = new St.Label();
this.addActor(this._label); this.addActor(this._label);
@ -1541,6 +1506,6 @@ AccountNotification.prototype = {
this._connectionStatusId = 0; this._connectionStatusId = 0;
} }
MessageTray.Notification.prototype.destroy.call(this); this.parent();
} }
}; });

View File

@ -202,11 +202,9 @@ function registerSpecialPropertySplitter(name, splitFunction, parameters) {
// time updates; even better is to pay attention to the vertical // time updates; even better is to pay attention to the vertical
// vblank and sync to that when possible.) // vblank and sync to that when possible.)
// //
function ClutterFrameTicker() { const ClutterFrameTicker = new Lang.Class({
this._init(); Name: 'ClutterFrameTicker',
}
ClutterFrameTicker.prototype = {
FRAME_RATE : 60, FRAME_RATE : 60,
_init : function() { _init : function() {
@ -261,6 +259,6 @@ ClutterFrameTicker.prototype = {
this._startTime = -1; this._startTime = -1;
global.end_work(); global.end_work();
} }
}; });
Signals.addSignalMethods(ClutterFrameTicker.prototype); Signals.addSignalMethods(ClutterFrameTicker.prototype);

View File

@ -40,15 +40,12 @@ const IMStatus = {
// Copyright (C) 2008,2009 Red Hat, Inc. // Copyright (C) 2008,2009 Red Hat, Inc.
function IMStatusItem(label, iconName) { const IMStatusItem = new Lang.Class({
this._init(label, iconName); Name: 'IMStatusItem',
} Extends: PopupMenu.PopupBaseMenuItem,
IMStatusItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function(label, iconName) { _init: function(label, iconName) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this); this.parent();
this.actor.add_style_class_name('status-chooser-status-item'); this.actor.add_style_class_name('status-chooser-status-item');
@ -61,19 +58,15 @@ IMStatusItem.prototype = {
this.label = new St.Label({ text: label }); this.label = new St.Label({ text: label });
this.addActor(this.label); this.addActor(this.label);
} }
}; });
function IMUserNameItem() { const IMUserNameItem = new Lang.Class({
this._init(); Name: 'IMUserNameItem',
} Extends: PopupMenu.PopupBaseMenuItem,
IMUserNameItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function() { _init: function() {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, this.parent({ reactive: false,
{ reactive: false, style_class: 'status-chooser-user-name' });
style_class: 'status-chooser-user-name' });
this._wrapper = new Shell.GenericContainer(); this._wrapper = new Shell.GenericContainer();
this._wrapper.connect('get-preferred-width', this._wrapper.connect('get-preferred-width',
@ -102,19 +95,15 @@ IMUserNameItem.prototype = {
_wrapperAllocate: function(actor, box, flags) { _wrapperAllocate: function(actor, box, flags) {
this.label.allocate(box, flags); this.label.allocate(box, flags);
} }
}; });
function IMStatusChooserItem() { const IMStatusChooserItem = new Lang.Class({
this._init(); Name: 'IMStatusChooserItem',
} Extends: PopupMenu.PopupBaseMenuItem,
IMStatusChooserItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
_init: function() { _init: function() {
PopupMenu.PopupBaseMenuItem.prototype._init.call (this, this.parent({ reactive: false,
{ reactive: false, style_class: 'status-chooser' });
style_class: 'status-chooser' });
this._iconBin = new St.Button({ style_class: 'status-chooser-user-icon' }); this._iconBin = new St.Button({ style_class: 'status-chooser-user-icon' });
this.addActor(this._iconBin); this.addActor(this._iconBin);
@ -220,7 +209,7 @@ IMStatusChooserItem.prototype = {
this._userChangedId = 0; this._userChangedId = 0;
} }
PopupMenu.PopupBaseMenuItem.prototype.destroy.call(this); this.parent();
}, },
// Override getColumnWidths()/setColumnWidths() to make the item // Override getColumnWidths()/setColumnWidths() to make the item
@ -422,18 +411,16 @@ IMStatusChooserItem.prototype = {
this._expectedPresence = newPresence; this._expectedPresence = newPresence;
this._accountMgr.set_all_requested_presences(newPresence, status, msg); this._accountMgr.set_all_requested_presences(newPresence, status, msg);
} }
}; });
function UserMenuButton() { const UserMenuButton = new Lang.Class({
this._init(); Name: 'UserMenuButton',
} Extends: PanelMenu.Button,
UserMenuButton.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function() { _init: function() {
PanelMenu.Button.prototype._init.call(this, 0.0); this.parent(0.0);
let box = new St.BoxLayout({ name: 'panelUserMenu' }); let box = new St.BoxLayout({ name: 'panelUserMenu' });
this.actor.add_actor(box); this.actor.add_actor(box);
@ -736,4 +723,4 @@ UserMenuButton.prototype = {
this._session.ShutdownRemote(); this._session.ShutdownRemote();
} }
} }
}; });

View File

@ -15,11 +15,9 @@ const SearchDisplay = imports.ui.searchDisplay;
const ShellEntry = imports.ui.shellEntry; const ShellEntry = imports.ui.shellEntry;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
function BaseTab(titleActor, pageActor, name, a11yIcon) { const BaseTab = new Lang.Class({
this._init(titleActor, pageActor, name, a11yIcon); Name: 'BaseTab',
}
BaseTab.prototype = {
_init: function(titleActor, pageActor, name, a11yIcon) { _init: function(titleActor, pageActor, name, a11yIcon) {
this.title = titleActor; this.title = titleActor;
this.page = new St.Bin({ child: pageActor, this.page = new St.Bin({ child: pageActor,
@ -75,16 +73,13 @@ BaseTab.prototype = {
_activate: function() { _activate: function() {
this.emit('activated'); this.emit('activated');
} }
}; });
Signals.addSignalMethods(BaseTab.prototype); Signals.addSignalMethods(BaseTab.prototype);
function ViewTab(id, label, pageActor, a11yIcon) { const ViewTab = new Lang.Class({
this._init(id, label, pageActor, a11yIcon); Name: 'ViewTab',
} Extends: BaseTab,
ViewTab.prototype = {
__proto__: BaseTab.prototype,
_init: function(id, label, pageActor, a11yIcon) { _init: function(id, label, pageActor, a11yIcon) {
this.id = id; this.id = id;
@ -93,17 +88,14 @@ ViewTab.prototype = {
style_class: 'view-tab-title' }); style_class: 'view-tab-title' });
titleActor.connect('clicked', Lang.bind(this, this._activate)); titleActor.connect('clicked', Lang.bind(this, this._activate));
BaseTab.prototype._init.call(this, titleActor, pageActor, label, a11yIcon); this.parent(titleActor, pageActor, label, a11yIcon);
} }
}; });
function SearchTab() { const SearchTab = new Lang.Class({
this._init(); Name: 'SearchTab',
} Extends: BaseTab,
SearchTab.prototype = {
__proto__: BaseTab.prototype,
_init: function() { _init: function() {
this.active = false; this.active = false;
@ -136,11 +128,7 @@ SearchTab.prototype = {
this._iconClickedId = 0; this._iconClickedId = 0;
this._searchResults = new SearchDisplay.SearchResults(this._searchSystem, this._openSearchSystem); this._searchResults = new SearchDisplay.SearchResults(this._searchSystem, this._openSearchSystem);
BaseTab.prototype._init.call(this, this.parent(this._entry, this._searchResults.actor, _("Search"), 'edit-find');
this._entry,
this._searchResults.actor,
_("Search"),
'edit-find');
this._text.connect('text-changed', Lang.bind(this, this._onTextChanged)); this._text.connect('text-changed', Lang.bind(this, this._onTextChanged));
this._text.connect('key-press-event', Lang.bind(this, function (o, e) { this._text.connect('key-press-event', Lang.bind(this, function (o, e) {
@ -166,7 +154,7 @@ SearchTab.prototype = {
}, },
hide: function() { hide: function() {
BaseTab.prototype.hide.call(this); this.parent();
// Leave the entry focused when it doesn't have any text; // Leave the entry focused when it doesn't have any text;
// when replacing a selected search term, Clutter emits // when replacing a selected search term, Clutter emits
@ -310,14 +298,12 @@ SearchTab.prototype = {
return false; return false;
} }
}; });
function ViewSelector() { const ViewSelector = new Lang.Class({
this._init(); Name: 'ViewSelector',
}
ViewSelector.prototype = {
_init : function() { _init : function() {
this.actor = new St.BoxLayout({ name: 'viewSelector', this.actor = new St.BoxLayout({ name: 'viewSelector',
vertical: true }); vertical: true });
@ -577,5 +563,5 @@ ViewSelector.prototype = {
removeSearchProvider: function(provider) { removeSearchProvider: function(provider) {
this._searchTab.removeSearchProvider(provider); this._searchTab.removeSearchProvider(provider);
} }
}; });
Signals.addSignalMethods(ViewSelector.prototype); Signals.addSignalMethods(ViewSelector.prototype);

View File

@ -6,11 +6,9 @@ const Shell = imports.gi.Shell;
const Main = imports.ui.main; const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray; const MessageTray = imports.ui.messageTray;
function WindowAttentionHandler() { const WindowAttentionHandler = new Lang.Class({
this._init(); Name: 'WindowAttentionHandler',
}
WindowAttentionHandler.prototype = {
_init : function() { _init : function() {
this._tracker = Shell.WindowTracker.get_default(); this._tracker = Shell.WindowTracker.get_default();
global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention)); global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
@ -43,17 +41,14 @@ WindowAttentionHandler.prototype = {
notification.update(title, banner); notification.update(title, banner);
}))); })));
} }
}; });
function Source(app, window) { const Source = new Lang.Class({
this._init(app, window); Name: 'WindowAttentionSource',
} Extends: MessageTray.Source,
Source.prototype = {
__proto__ : MessageTray.Source.prototype,
_init: function(app, window) { _init: function(app, window) {
MessageTray.Source.prototype._init.call(this, app.get_name()); this.parent(app.get_name());
this._window = window; this._window = window;
this._app = app; this._app = app;
this._setSummaryIcon(this.createNotificationIcon()); this._setSummaryIcon(this.createNotificationIcon());
@ -81,4 +76,4 @@ Source.prototype = {
Main.activateWindow(this._window); Main.activateWindow(this._window);
this.destroy(); this.destroy();
} }
}; });

View File

@ -31,11 +31,9 @@ function getTopInvisibleBorder(metaWindow) {
return outerRect.y - inputRect.y; return outerRect.y - inputRect.y;
} }
function WindowDimmer(actor) { const WindowDimmer = new Lang.Class({
this._init(actor); Name: 'WindowDimmer',
}
WindowDimmer.prototype = {
_init: function(actor) { _init: function(actor) {
if (Clutter.feature_available(Clutter.FeatureFlags.SHADERS_GLSL)) { if (Clutter.feature_available(Clutter.FeatureFlags.SHADERS_GLSL)) {
this._effect = new Clutter.ShaderEffect({ shader_type: Clutter.ShaderType.FRAGMENT_SHADER }); this._effect = new Clutter.ShaderEffect({ shader_type: Clutter.ShaderType.FRAGMENT_SHADER });
@ -75,7 +73,7 @@ WindowDimmer.prototype = {
}, },
_dimFraction: 0.0 _dimFraction: 0.0
}; });
function getWindowDimmer(actor) { function getWindowDimmer(actor) {
if (!actor._windowDimmer) if (!actor._windowDimmer)
@ -84,11 +82,9 @@ function getWindowDimmer(actor) {
return actor._windowDimmer; return actor._windowDimmer;
} }
function WindowManager() { const WindowManager = new Lang.Class({
this._init(); Name: 'WindowManager',
}
WindowManager.prototype = {
_init : function() { _init : function() {
this._shellwm = global.window_manager; this._shellwm = global.window_manager;
@ -627,4 +623,4 @@ WindowManager.prototype = {
if (!Main.overview.visible) if (!Main.overview.visible)
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.DOWN, indexToActivate); this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.DOWN, indexToActivate);
} }
}; });

View File

@ -56,11 +56,13 @@ function _clamp(value, min, max) {
} }
function ScaledPoint(x, y, scaleX, scaleY) { const ScaledPoint = new Lang.Class({
[this.x, this.y, this.scaleX, this.scaleY] = arguments; Name: 'ScaledPoint',
}
_init: function(x, y, scaleX, scaleY) {
[this.x, this.y, this.scaleX, this.scaleY] = arguments;
},
ScaledPoint.prototype = {
getPosition : function() { getPosition : function() {
return [this.x, this.y]; return [this.x, this.y];
}, },
@ -86,14 +88,12 @@ ScaledPoint.prototype = {
return [_interpolate(this.scaleX, other.scaleX, step), return [_interpolate(this.scaleX, other.scaleX, step),
_interpolate(this.scaleY, other.scaleY, step)]; _interpolate(this.scaleY, other.scaleY, step)];
} }
}; });
function WindowClone(realWindow) { const WindowClone = new Lang.Class({
this._init(realWindow); Name: 'WindowClone',
}
WindowClone.prototype = {
_init : function(realWindow) { _init : function(realWindow) {
this.realWindow = realWindow; this.realWindow = realWindow;
this.metaWindow = realWindow.meta_window; this.metaWindow = realWindow.meta_window;
@ -418,7 +418,7 @@ WindowClone.prototype = {
this.emit('drag-end'); this.emit('drag-end');
} }
}; });
Signals.addSignalMethods(WindowClone.prototype); Signals.addSignalMethods(WindowClone.prototype);
@ -427,11 +427,9 @@ Signals.addSignalMethods(WindowClone.prototype);
* @parentActor: The actor which will be the parent of all overlay items * @parentActor: The actor which will be the parent of all overlay items
* such as app icon and window caption * such as app icon and window caption
*/ */
function WindowOverlay(windowClone, parentActor) { const WindowOverlay = new Lang.Class({
this._init(windowClone, parentActor); Name: 'WindowOverlay',
}
WindowOverlay.prototype = {
_init : function(windowClone, parentActor) { _init : function(windowClone, parentActor) {
let metaWindow = windowClone.metaWindow; let metaWindow = windowClone.metaWindow;
@ -642,7 +640,7 @@ WindowOverlay.prototype = {
this._parentActor.queue_relayout(); this._parentActor.queue_relayout();
} }
}; });
Signals.addSignalMethods(WindowOverlay.prototype); Signals.addSignalMethods(WindowOverlay.prototype);
const WindowPositionFlags = { const WindowPositionFlags = {
@ -653,11 +651,9 @@ const WindowPositionFlags = {
/** /**
* @metaWorkspace: a #Meta.Workspace, or null * @metaWorkspace: a #Meta.Workspace, or null
*/ */
function Workspace(metaWorkspace, monitorIndex) { const Workspace = new Lang.Class({
this._init(metaWorkspace, monitorIndex); Name: 'Workspace',
}
Workspace.prototype = {
_init : function(metaWorkspace, monitorIndex) { _init : function(metaWorkspace, monitorIndex) {
// When dragging a window, we use this slot for reserve space. // When dragging a window, we use this slot for reserve space.
this._reservedSlot = null; this._reservedSlot = null;
@ -1518,6 +1514,6 @@ Workspace.prototype = {
return false; return false;
} }
}; });
Signals.addSignalMethods(Workspace.prototype); Signals.addSignalMethods(Workspace.prototype);

View File

@ -15,11 +15,9 @@ const DISPLAY_TIMEOUT = 600;
const UP = -1; const UP = -1;
const DOWN = 1; const DOWN = 1;
function WorkspaceSwitcherPopup() { const WorkspaceSwitcherPopup = new Lang.Class({
this._init(); Name: 'WorkspaceSwitcherPopup',
}
WorkspaceSwitcherPopup.prototype = {
_init : function() { _init : function() {
this.actor = new St.Group({ reactive: true, this.actor = new St.Group({ reactive: true,
x: 0, x: 0,
@ -158,4 +156,4 @@ WorkspaceSwitcherPopup.prototype = {
onCompleteScope: this onCompleteScope: this
}); });
} }
}; });

View File

@ -25,11 +25,9 @@ const SLIDE_ANIMATION_TIME = 0.2;
// placeholder exactly. // placeholder exactly.
const WORKSPACE_CUT_SIZE = 10; const WORKSPACE_CUT_SIZE = 10;
function WindowClone(realWindow) { const WindowClone = new Lang.Class({
this._init(realWindow); Name: 'WindowClone',
}
WindowClone.prototype = {
_init : function(realWindow) { _init : function(realWindow) {
this.actor = new Clutter.Clone({ source: realWindow.get_texture(), this.actor = new Clutter.Clone({ source: realWindow.get_texture(),
reactive: true }); reactive: true });
@ -126,7 +124,7 @@ WindowClone.prototype = {
this.emit('drag-end'); this.emit('drag-end');
} }
}; });
Signals.addSignalMethods(WindowClone.prototype); Signals.addSignalMethods(WindowClone.prototype);
@ -144,11 +142,9 @@ const ThumbnailState = {
/** /**
* @metaWorkspace: a #Meta.Workspace * @metaWorkspace: a #Meta.Workspace
*/ */
function WorkspaceThumbnail(metaWorkspace) { const WorkspaceThumbnail = new Lang.Class({
this._init(metaWorkspace); Name: 'WorkspaceThumbnail',
}
WorkspaceThumbnail.prototype = {
_init : function(metaWorkspace) { _init : function(metaWorkspace) {
this.metaWorkspace = metaWorkspace; this.metaWorkspace = metaWorkspace;
this.monitorIndex = Main.layoutManager.primaryIndex; this.monitorIndex = Main.layoutManager.primaryIndex;
@ -469,16 +465,14 @@ WorkspaceThumbnail.prototype = {
return false; return false;
} }
}; });
Signals.addSignalMethods(WorkspaceThumbnail.prototype); Signals.addSignalMethods(WorkspaceThumbnail.prototype);
function ThumbnailsBox() { const ThumbnailsBox = new Lang.Class({
this._init(); Name: 'ThumbnailsBox',
}
ThumbnailsBox.prototype = {
_init: function() { _init: function() {
this.actor = new Shell.GenericContainer({ style_class: 'workspace-thumbnails', this.actor = new Shell.GenericContainer({ style_class: 'workspace-thumbnails',
request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT }); request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT });
@ -1028,4 +1022,4 @@ ThumbnailsBox.prototype = {
onCompleteScope: this onCompleteScope: this
}); });
} }
}; });

View File

@ -23,11 +23,9 @@ const MAX_WORKSPACES = 16;
const CONTROLS_POP_IN_TIME = 0.1; const CONTROLS_POP_IN_TIME = 0.1;
function WorkspacesView(workspaces) { const WorkspacesView = new Lang.Class({
this._init(workspaces); Name: 'WorkspacesView',
}
WorkspacesView.prototype = {
_init: function(workspaces) { _init: function(workspaces) {
this.actor = new St.Group({ style_class: 'workspaces-view' }); this.actor = new St.Group({ style_class: 'workspaces-view' });
@ -452,15 +450,13 @@ WorkspacesView.prototype = {
_getWorkspaceIndexToRemove: function() { _getWorkspaceIndexToRemove: function() {
return global.screen.get_active_workspace_index(); return global.screen.get_active_workspace_index();
} }
}; });
Signals.addSignalMethods(WorkspacesView.prototype); Signals.addSignalMethods(WorkspacesView.prototype);
function WorkspacesDisplay() { const WorkspacesDisplay = new Lang.Class({
this._init(); Name: 'WorkspacesDisplay',
}
WorkspacesDisplay.prototype = {
_init: function() { _init: function() {
this.actor = new Shell.GenericContainer(); this.actor = new Shell.GenericContainer();
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
@ -852,5 +848,5 @@ WorkspacesDisplay.prototype = {
break; break;
} }
} }
}; });
Signals.addSignalMethods(WorkspacesDisplay.prototype); Signals.addSignalMethods(WorkspacesDisplay.prototype);

View File

@ -6,11 +6,9 @@ const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const DND = imports.ui.dnd; const DND = imports.ui.dnd;
function XdndHandler() { const XdndHandler = new Lang.Class({
this._init(); Name: 'XdndHandler',
}
XdndHandler.prototype = {
_init: function() { _init: function() {
// Used to display a clone of the cursor window when the // Used to display a clone of the cursor window when the
// window group is hidden (like it happens in the overview) // window group is hidden (like it happens in the overview)
@ -125,6 +123,6 @@ XdndHandler.prototype = {
pickedActor = pickedActor.get_parent(); pickedActor = pickedActor.get_parent();
} }
} }
} });
Signals.addSignalMethods(XdndHandler.prototype); Signals.addSignalMethods(XdndHandler.prototype);

View File

@ -27,6 +27,9 @@ void _shell_app_do_match (ShellApp *app,
GSList **prefix_results, GSList **prefix_results,
GSList **substring_results); GSList **substring_results);
void _shell_app_set_dbus_name (ShellApp *app,
const char *name);
G_END_DECLS G_END_DECLS
#endif /* __SHELL_APP_PRIVATE_H__ */ #endif /* __SHELL_APP_PRIVATE_H__ */

View File

@ -37,6 +37,13 @@ typedef struct {
/* Whether or not we need to resort the windows; this is done on demand */ /* Whether or not we need to resort the windows; this is done on demand */
gboolean window_sort_stale : 1; gboolean window_sort_stale : 1;
/* See GApplication documentation */
guint name_watcher_id;
gchar *dbus_name;
GDBusActionGroup *remote_actions;
GMenuProxy *remote_menu;
GCancellable *dbus_cancellable;
} ShellAppRunningState; } ShellAppRunningState;
/** /**
@ -72,11 +79,13 @@ struct _ShellApp
char *casefolded_exec; char *casefolded_exec;
}; };
G_DEFINE_TYPE (ShellApp, shell_app, G_TYPE_OBJECT);
enum { enum {
PROP_0, PROP_0,
PROP_STATE PROP_STATE,
PROP_ID,
PROP_DBUS_ID,
PROP_ACTION_GROUP,
PROP_MENU
}; };
enum { enum {
@ -89,6 +98,8 @@ static guint shell_app_signals[LAST_SIGNAL] = { 0 };
static void create_running_state (ShellApp *app); static void create_running_state (ShellApp *app);
static void unref_running_state (ShellAppRunningState *state); static void unref_running_state (ShellAppRunningState *state);
G_DEFINE_TYPE (ShellApp, shell_app, G_TYPE_OBJECT)
static void static void
shell_app_get_property (GObject *gobject, shell_app_get_property (GObject *gobject,
guint prop_id, guint prop_id,
@ -102,6 +113,20 @@ shell_app_get_property (GObject *gobject,
case PROP_STATE: case PROP_STATE:
g_value_set_enum (value, app->state); g_value_set_enum (value, app->state);
break; break;
case PROP_ID:
g_value_set_string (value, shell_app_get_id (app));
break;
case PROP_DBUS_ID:
g_value_set_string (value, shell_app_get_dbus_id (app));
break;
case PROP_ACTION_GROUP:
if (app->running_state)
g_value_set_object (value, app->running_state->remote_actions);
break;
case PROP_MENU:
if (app->running_state)
g_value_set_object (value, app->running_state->remote_menu);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -151,6 +176,15 @@ window_backed_app_get_icon (ShellApp *app,
return actor; return actor;
} }
const char *
shell_app_get_dbus_id (ShellApp *app)
{
if (app->running_state)
return app->running_state->dbus_name;
else
return NULL;
}
/** /**
* shell_app_create_icon_texture: * shell_app_create_icon_texture:
* *
@ -948,6 +982,142 @@ _shell_app_remove_window (ShellApp *app,
g_signal_emit (app, shell_app_signals[WINDOWS_CHANGED], 0); g_signal_emit (app, shell_app_signals[WINDOWS_CHANGED], 0);
} }
static void
on_action_group_acquired (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
ShellApp *self = SHELL_APP (user_data);
ShellAppRunningState *state = self->running_state;
GError *error = NULL;
char *object_path;
state->remote_actions = g_dbus_action_group_new_finish (result,
&error);
if (error)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
!g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD))
{
g_warning ("Unexpected error while reading application actions: %s", error->message);
}
g_clear_error (&error);
g_clear_object (&state->dbus_cancellable);
if (state->name_watcher_id)
{
g_bus_unwatch_name (state->name_watcher_id);
state->name_watcher_id = 0;
}
g_free (state->dbus_name);
state->dbus_name = NULL;
g_object_unref (self);
return;
}
object_path = g_strconcat ("/", state->dbus_name, NULL);
g_strdelimit (object_path, ".", '/');
state->remote_menu = g_menu_proxy_get (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
state->dbus_name,
object_path);
g_object_notify (G_OBJECT (self), "dbus-id");
g_object_notify (G_OBJECT (self), "action-group");
g_object_notify (G_OBJECT (self), "menu");
g_object_unref (self);
g_free (object_path);
}
static void
on_dbus_name_appeared (GDBusConnection *bus,
const gchar *name,
const gchar *name_owner,
gpointer user_data)
{
ShellApp *self = SHELL_APP (user_data);
ShellAppRunningState *state = self->running_state;
char *object_path;
g_assert (state != NULL);
object_path = g_strconcat ("/", name, NULL);
g_strdelimit (object_path, ".", '/');
if (!state->dbus_cancellable)
state->dbus_cancellable = g_cancellable_new ();
g_dbus_action_group_new (bus,
name,
object_path,
G_DBUS_ACTION_GROUP_FLAGS_NONE,
state->dbus_cancellable,
on_action_group_acquired,
g_object_ref (self));
g_free (object_path);
}
static void
on_dbus_name_disappeared (GDBusConnection *bus,
const gchar *name,
gpointer user_data)
{
ShellApp *self = SHELL_APP (user_data);
ShellAppRunningState *state = self->running_state;
g_assert (state != NULL);
if (state->dbus_cancellable)
{
g_cancellable_cancel (state->dbus_cancellable);
g_clear_object (&state->dbus_cancellable);
}
g_clear_object (&state->remote_actions);
g_clear_object (&state->remote_menu);
g_free (state->dbus_name);
state->dbus_name = NULL;
g_bus_unwatch_name (state->name_watcher_id);
state->name_watcher_id = 0;
}
void
_shell_app_set_dbus_name (ShellApp *app,
const char *bus_name)
{
g_return_if_fail (app->running_state != NULL);
if (app->running_state->dbus_name != NULL)
{
/* already associating with another name
(can only happen if you restart the shell in the
middle of the session, in which case it will try
all names seen on the bus; otherwise, it uses
the Hello signal from GApplication and thus knows
for sure which name is the right one)
*/
return;
}
app->running_state->dbus_name = g_strdup (bus_name);
app->running_state->name_watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
bus_name,
G_BUS_NAME_WATCHER_FLAGS_NONE,
on_dbus_name_appeared,
on_dbus_name_disappeared,
g_object_ref (app),
g_object_unref);
}
/** /**
* shell_app_get_pids: * shell_app_get_pids:
* @app: a #ShellApp * @app: a #ShellApp
@ -1167,13 +1337,28 @@ unref_running_state (ShellAppRunningState *state)
{ {
MetaScreen *screen; MetaScreen *screen;
g_assert (state->refcount > 0);
state->refcount--; state->refcount--;
if (state->refcount > 0) if (state->refcount > 0)
return; return;
screen = shell_global_get_screen (shell_global_get ()); screen = shell_global_get_screen (shell_global_get ());
g_signal_handler_disconnect (screen, state->workspace_switch_id); g_signal_handler_disconnect (screen, state->workspace_switch_id);
if (state->dbus_cancellable)
{
g_cancellable_cancel (state->dbus_cancellable);
g_object_unref (state->dbus_cancellable);
}
g_clear_object (&state->remote_actions);
g_clear_object (&state->remote_menu);
g_free (state->dbus_name);
if (state->name_watcher_id)
g_bus_unwatch_name (state->name_watcher_id);
g_slice_free (ShellAppRunningState, state); g_slice_free (ShellAppRunningState, state);
} }
@ -1349,6 +1534,9 @@ shell_app_dispose (GObject *object)
while (app->running_state->windows) while (app->running_state->windows)
_shell_app_remove_window (app, app->running_state->windows->data); _shell_app_remove_window (app, app->running_state->windows->data);
} }
/* We should have been transitioned when we removed all of our windows */
g_assert (app->state == SHELL_APP_STATE_STOPPED);
g_assert (app->running_state == NULL);
G_OBJECT_CLASS(shell_app_parent_class)->dispose (object); G_OBJECT_CLASS(shell_app_parent_class)->dispose (object);
} }
@ -1399,4 +1587,60 @@ shell_app_class_init(ShellAppClass *klass)
SHELL_TYPE_APP_STATE, SHELL_TYPE_APP_STATE,
SHELL_APP_STATE_STOPPED, SHELL_APP_STATE_STOPPED,
G_PARAM_READABLE)); G_PARAM_READABLE));
/**
* ShellApp:id:
*
* The id of this application (a desktop filename, or a special string
* like window:0xabcd1234)
*/
g_object_class_install_property (gobject_class,
PROP_ID,
g_param_spec_string ("id",
"Application id",
"The desktop file id of this ShellApp",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* ShellApp:dbus-id:
*
* The DBus well-known name of the application, if one can be associated
* to this ShellApp (it means that the application is using GApplication)
*/
g_object_class_install_property (gobject_class,
PROP_DBUS_ID,
g_param_spec_string ("dbus-id",
"Application DBus Id",
"The DBus well-known name of the application",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* ShellApp:action-group:
*
* The #GDBusActionGroup associated with this ShellApp, if any. See the
* documentation of #GApplication and #GActionGroup for details.
*/
g_object_class_install_property (gobject_class,
PROP_ACTION_GROUP,
g_param_spec_object ("action-group",
"Application Action Group",
"The action group exported by the remote application",
G_TYPE_DBUS_ACTION_GROUP,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* ShellApp:menu:
*
* The #GMenuProxy associated with this ShellApp, if any. See the
* documentation of #GMenuModel for details.
*/
g_object_class_install_property (gobject_class,
PROP_MENU,
g_param_spec_object ("menu",
"Application Menu",
"The primary menu exported by the remote application",
G_TYPE_MENU_PROXY,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
} }

View File

@ -13,6 +13,7 @@ G_BEGIN_DECLS
typedef struct _ShellApp ShellApp; typedef struct _ShellApp ShellApp;
typedef struct _ShellAppClass ShellAppClass; typedef struct _ShellAppClass ShellAppClass;
typedef struct _ShellAppPrivate ShellAppPrivate; typedef struct _ShellAppPrivate ShellAppPrivate;
typedef struct _ShellAppAction ShellAppAction;
#define SHELL_TYPE_APP (shell_app_get_type ()) #define SHELL_TYPE_APP (shell_app_get_type ())
#define SHELL_APP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SHELL_TYPE_APP, ShellApp)) #define SHELL_APP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SHELL_TYPE_APP, ShellApp))
@ -36,9 +37,12 @@ typedef enum {
GType shell_app_get_type (void) G_GNUC_CONST; GType shell_app_get_type (void) G_GNUC_CONST;
const char *shell_app_get_id (ShellApp *app); const char *shell_app_get_id (ShellApp *app);
GMenuTreeEntry *shell_app_get_tree_entry (ShellApp *app); GMenuTreeEntry *shell_app_get_tree_entry (ShellApp *app);
GDesktopAppInfo *shell_app_get_app_info (ShellApp *app); GDesktopAppInfo *shell_app_get_app_info (ShellApp *app);
const char *shell_app_get_dbus_id (ShellApp *app);
ClutterActor *shell_app_create_icon_texture (ShellApp *app, int size); ClutterActor *shell_app_create_icon_texture (ShellApp *app, int size);
ClutterActor *shell_app_get_faded_icon (ShellApp *app, int size); ClutterActor *shell_app_get_faded_icon (ShellApp *app, int size);
const char *shell_app_get_name (ShellApp *app); const char *shell_app_get_name (ShellApp *app);

View File

@ -49,6 +49,9 @@ struct _ShellWindowTracker
/* <MetaWindow * window, ShellApp *app> */ /* <MetaWindow * window, ShellApp *app> */
GHashTable *window_to_app; GHashTable *window_to_app;
/* <int, gchar *> */
GHashTable *pid_to_dbus_connection;
/* <int, ShellApp *app> */ /* <int, ShellApp *app> */
GHashTable *launched_pid_to_app; GHashTable *launched_pid_to_app;
}; };
@ -436,6 +439,8 @@ track_window (ShellWindowTracker *self,
MetaWindow *window) MetaWindow *window)
{ {
ShellApp *app; ShellApp *app;
GPid pid;
gchar *dbus_name;
if (!shell_window_tracker_is_window_interesting (window)) if (!shell_window_tracker_is_window_interesting (window))
return; return;
@ -451,6 +456,15 @@ track_window (ShellWindowTracker *self,
_shell_app_add_window (app, window); _shell_app_add_window (app, window);
/* Try to associate this ShellApp with a GApplication id, if one exists */
pid = meta_window_get_pid (window);
dbus_name = g_hash_table_lookup (self->pid_to_dbus_connection, GINT_TO_POINTER ((int) pid));
if (dbus_name != NULL)
{
_shell_app_set_dbus_name (app, dbus_name);
g_hash_table_remove (self->pid_to_dbus_connection, GINT_TO_POINTER ((int) pid));
}
g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0); g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0);
} }
@ -581,13 +595,161 @@ on_startup_sequence_changed (MetaScreen *screen,
g_signal_emit (G_OBJECT (self), signals[STARTUP_SEQUENCE_CHANGED], 0, sequence); g_signal_emit (G_OBJECT (self), signals[STARTUP_SEQUENCE_CHANGED], 0, sequence);
} }
typedef struct {
ShellWindowTracker *tracker;
gchar *bus_name;
} LookupAppDBusData;
static void
on_get_connection_unix_pid_reply (GObject *connection,
GAsyncResult *result,
gpointer user_data)
{
LookupAppDBusData *data = user_data;
GError *error = NULL;
GVariant *reply;
guint32 pid;
ShellApp *app;
reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (connection), result, &error);
if (!reply)
{
if (!g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER))
g_warning ("%s\n", error->message);
g_clear_error (&error);
goto out;
}
if (!g_variant_is_of_type (reply, G_VARIANT_TYPE ("(u)")))
{
g_variant_unref (reply);
goto out;
}
g_variant_get (reply, "(u)", &pid);
g_variant_unref (reply);
app = shell_window_tracker_get_app_from_pid (data->tracker, (int)pid);
if (app)
_shell_app_set_dbus_name (app, data->bus_name);
else
{
g_hash_table_insert (data->tracker->pid_to_dbus_connection,
GINT_TO_POINTER ((int) pid),
data->bus_name);
data->bus_name = NULL;
}
out:
g_object_unref (data->tracker);
g_free (data->bus_name);
g_slice_free (LookupAppDBusData, data);
}
static void
lookup_application_from_name (ShellWindowTracker *self,
GDBusConnection *connection,
const gchar *bus_name)
{
LookupAppDBusData *data;
data = g_slice_new0 (LookupAppDBusData);
data->tracker = g_object_ref (self);
data->bus_name = g_strdup (bus_name);
/*
* TODO: Add something to GtkApplication so it definitely knows the .desktop file.
*/
g_dbus_connection_call (connection,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"GetConnectionUnixProcessID",
g_variant_new ("(s)", bus_name),
NULL, 0, -1, NULL, on_get_connection_unix_pid_reply, data);
}
static void
on_application_signal (GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
const gchar *interface_name,
const gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
ShellWindowTracker *tracker = SHELL_WINDOW_TRACKER (user_data);
gchar *bus_name = NULL;
g_variant_get (parameters, "(&s)", &bus_name);
lookup_application_from_name (tracker, connection, bus_name);
g_variant_unref (parameters);
}
static void
on_list_names_end (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GDBusConnection *connection = G_DBUS_CONNECTION (object);
ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data);
GError *error = NULL;
GVariantIter iter;
gchar *bus_name = NULL;
GVariant *res = g_dbus_connection_call_finish (connection, result, &error);
if (!res)
{
g_warning ("ListNames failed: %s", error->message);
g_error_free (error);
return;
}
g_variant_iter_init (&iter, g_variant_get_child_value (res, 0));
while (g_variant_iter_loop (&iter, "s", &bus_name))
{
if (bus_name[0] == ':')
{
/* unique name, uninteresting */
continue;
}
lookup_application_from_name (self, connection, bus_name);
}
g_variant_unref (res);
}
static void static void
shell_window_tracker_init (ShellWindowTracker *self) shell_window_tracker_init (ShellWindowTracker *self)
{ {
MetaScreen *screen; MetaScreen *screen;
self->window_to_app = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_dbus_connection_signal_subscribe (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
NULL, (GDestroyNotify) g_object_unref); NULL,
"org.gtk.Application",
"Hello",
NULL,
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
on_application_signal,
self, NULL);
g_dbus_connection_call (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"ListNames",
NULL, /* parameters */
G_VARIANT_TYPE ("(as)"),
G_DBUS_CALL_FLAGS_NONE,
-1, /* timeout */
NULL, /* cancellable */
on_list_names_end, self);
self->window_to_app = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
self->pid_to_dbus_connection = g_hash_table_new_full (NULL, NULL, NULL, g_free);
self->launched_pid_to_app = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_object_unref); self->launched_pid_to_app = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_object_unref);
@ -607,6 +769,7 @@ shell_window_tracker_finalize (GObject *object)
g_hash_table_destroy (self->window_to_app); g_hash_table_destroy (self->window_to_app);
g_hash_table_destroy (self->launched_pid_to_app); g_hash_table_destroy (self->launched_pid_to_app);
g_hash_table_destroy (self->pid_to_dbus_connection);
G_OBJECT_CLASS (shell_window_tracker_parent_class)->finalize(object); G_OBJECT_CLASS (shell_window_tracker_parent_class)->finalize(object);
} }

99
src/test-gapplication.js Executable file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env gjs
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
function do_action(action, parameter) {
print ("Action '" + action.name + "' invoked");
}
function do_action_param(action, parameter) {
print ("Action '" + action.name + "' invoked with parameter " + parameter.print(true));
}
function do_action_state_change(action) {
print ("Action '" + action.name + "' has now state '" + action.state.deep_unpack() + "'");
}
function main() {
Gtk.init(null, null);
let app = new Gtk.Application({ application_id: 'org.gnome.Shell.GtkApplicationTest' });
app.connect('activate', function() {
print ("Activated");
});
let group = new Gio.SimpleActionGroup();
let action = Gio.SimpleAction.new('one', null);
action.connect('activate', do_action);
group.insert(action);
let action = Gio.SimpleAction.new('two', null);
action.connect('activate', do_action);
group.insert(action);
let action = Gio.SimpleAction.new_stateful('toggle', null, GLib.Variant.new('b', false));
action.connect('activate', do_action);
action.connect('notify::state', do_action_state_change);
group.insert(action);
let action = Gio.SimpleAction.new('disable', null);
action.set_enabled(false);
action.connect('activate', do_action);
group.insert(action);
let action = Gio.SimpleAction.new('parameter-int', GLib.VariantType.new('u'));
action.connect('activate', do_action_param);
group.insert(action);
let action = Gio.SimpleAction.new('parameter-string', GLib.VariantType.new('s'));
action.connect('activate', do_action_param);
group.insert(action);
app.action_group = group;
let menu = new Gio.Menu();
menu.append('An action', 'one');
let section = new Gio.Menu();
section.append('Another action', 'two');
section.append('Same as above', 'two');
menu.append_section(null, section);
// another section, to check separators
section = new Gio.Menu();
section.append('Checkbox', 'toggle');
section.append('Disabled', 'disable');
menu.append_section(null, section);
// empty sections or submenus should be invisible
menu.append_section('Empty section', new Gio.Menu());
menu.append_submenu('Empty submenu', new Gio.Menu());
let submenu = new Gio.Menu();
submenu.append('Open c:\\', 'parameter-string::c:\\');
submenu.append('Open /home', 'parameter-string::/home');
menu.append_submenu('Recent files', submenu);
let item = Gio.MenuItem.new('Say 42', null);
item.set_action_and_target_value('parameter-int', GLib.Variant.new('u', 42));
menu.append_item(item);
let item = Gio.MenuItem.new('Say 43', null);
item.set_action_and_target_value('parameter-int', GLib.Variant.new('u', 43));
menu.append_item(item);
app.menu = menu;
app.connect('startup', function(app) {
let window = new Gtk.Window({ title: "Test Application", application: app });
window.present();
});
app.run(null);
}
main();