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
This commit is contained in:
Giovanni Campagna 2011-11-20 17:07:14 +01:00
parent 987099ea55
commit d6b6f814d3
16 changed files with 177 additions and 292 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

@ -542,11 +542,9 @@ AltTabPopup.prototype = {
} }
}; };
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,7 +849,7 @@ 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);
@ -879,15 +877,12 @@ AppIcon.prototype = {
} }
}; };
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 +961,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 +1016,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 +1040,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 +1125,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

@ -308,15 +308,13 @@ AllAppDisplay.prototype = {
} }
}; };
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 +362,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,29 +408,24 @@ 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) { function AppWellIcon(app, iconParams, onActivateOverride) {
this._init(app, iconParams, onActivateOverride); this._init(app, iconParams, onActivateOverride);

View File

@ -135,15 +135,12 @@ Contact.prototype = {
/* 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 +179,4 @@ ContactSearchProvider.prototype = {
activateResult: function(id, params) { activateResult: function(id, params) {
launchContact(id); launchContact(id);
} }
}; });

View File

@ -305,15 +305,12 @@ CtrlAltTabPopup.prototype = {
} }
}; };
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 +333,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,22 +214,17 @@ 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' }));
} }
}; });
function Dash() { function Dash() {
this._init(); this._init();

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

@ -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,7 +147,7 @@ BaseIcon.prototype = {
this._createIconTexture(size); this._createIconTexture(size);
} }
}; });
function IconGrid(params) { function IconGrid(params) {
this._init(params); this._init(params);

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

@ -262,12 +262,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 +274,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,7 +283,7 @@ 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) { function Result(command, o, index) {
this._init(command, o, index); this._init(command, o, index);

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,7 +118,7 @@ PlaceDeviceInfo.prototype = {
_("Retry")); _("Retry"));
} }
} }
}; });
function PlacesManager() { function PlacesManager() {
this._init(); this._init();
@ -363,16 +358,12 @@ PlacesManager.prototype = {
}; };
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 +425,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

@ -164,14 +164,12 @@ CommandCompleter.prototype = {
} }
}; };
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 +382,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,7 +239,7 @@ 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() { function OpenSearchSystem() {

View File

@ -100,15 +100,13 @@ SearchResult.prototype = {
}; };
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,8 +177,7 @@ GridSearchResults.prototype = {
let targetActor = this._grid.getItemAtIndex(this.selectionIndex); let targetActor = this._grid.getItemAtIndex(this.selectionIndex);
targetActor._delegate.activate(); targetActor._delegate.activate();
} }
}; });
function SearchResults(searchSystem, openSearchSystem) { function SearchResults(searchSystem, openSearchSystem) {
this._init(searchSystem, openSearchSystem); this._init(searchSystem, openSearchSystem);

View File

@ -278,11 +278,10 @@ const NMWirelessSectionTitleMenuItem = new Lang.Class({
} }
}); });
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) {
@ -664,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
@ -708,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;
@ -764,7 +757,7 @@ NMDeviceModem.prototype = {
})); }));
} }
NMDevice.prototype._init.call(this, client, device, connections); this.parent(client, device, connections);
}, },
setEnabled: function(enabled) { setEnabled: function(enabled) {
@ -777,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() {
@ -794,7 +787,7 @@ NMDeviceModem.prototype = {
this._signalQualityId = 0; this._signalQualityId = 0;
} }
NMDevice.prototype.destroy.call(this); this.parent();
}, },
_getSignalIcon: function() { _getSignalIcon: function() {
@ -815,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() {
@ -831,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);
@ -846,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() {
@ -876,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) {
@ -908,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');
}, },
@ -925,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;
@ -1004,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() {
@ -1024,7 +1008,7 @@ NMDeviceWireless.prototype = {
this._apRemovedId = 0; this._apRemovedId = 0;
} }
NMDevice.prototype.destroy.call(this); this.parent();
}, },
setEnabled: function(enabled) { setEnabled: function(enabled) {
@ -1338,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;
@ -1546,7 +1530,7 @@ NMDeviceWireless.prototype = {
this._createNetworkItem(apObj, j + activeOffset); this._createNetworkItem(apObj, j + activeOffset);
} }
}, },
}; });
const NMApplet = new Lang.Class({ const NMApplet = new Lang.Class({
Name: 'NMApplet', Name: 'NMApplet',

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,7 +298,7 @@ SearchTab.prototype = {
return false; return false;
} }
}; });
function ViewSelector() { function ViewSelector() {