diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js index ebd90dc3..d5d8af7a 100644 --- a/extensions/apps-menu/extension.js +++ b/extensions/apps-menu/extension.js @@ -31,29 +31,23 @@ const HORIZ_FACTOR = 5; const MENU_HEIGHT_OFFSET = 132; const NAVIGATION_REGION_OVERSHOOT = 50; -const ActivitiesMenuItem = new Lang.Class({ - Name: 'ActivitiesMenuItem', - Extends: PopupMenu.PopupBaseMenuItem, - - _init(button) { - this.parent(); +class ActivitiesMenuItem extends PopupMenu.PopupBaseMenuItem { + constructor(button) { + super(); this._button = button; this.actor.add_child(new St.Label({ text: _("Activities Overview") })); - }, + } activate(event) { this._button.menu.toggle(); Main.overview.toggle(); - this.parent(event); - }, -}); + super.activate(event); + } +}; -const ApplicationMenuItem = new Lang.Class({ - Name: 'ApplicationMenuItem', - Extends: PopupMenu.PopupBaseMenuItem, - - _init(button, app) { - this.parent(); +class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem { + constructor(button, app) { + super(); this._app = app; this._button = button; @@ -89,44 +83,41 @@ const ApplicationMenuItem = new Lang.Class({ draggable.connect('drag-end', () => { Shell.util_set_hidden_from_pick(Main.legacyTray.actor, false); }); - }, + } activate(event) { this._app.open_new_window(-1); this._button.selectCategory(null, null); this._button.menu.toggle(); - this.parent(event); - }, + super.activate(event); + } setActive(active, params) { if (active) this._button.scrollToButton(this); - this.parent(active, params); - }, + super.setActive(active, params); + } setDragEnabled(enable) { this._dragEnabled = enable; - }, + } getDragActor() { return this._app.create_icon_texture(APPLICATION_ICON_SIZE); - }, + } getDragActorSource() { return this._iconBin; - }, + } _updateIcon() { this._iconBin.set_child(this.getDragActor()); } -}); +}; -const CategoryMenuItem = new Lang.Class({ - Name: 'CategoryMenuItem', - Extends: PopupMenu.PopupBaseMenuItem, - - _init(button, category) { - this.parent(); +class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { + constructor(button, category) { + super(); this._category = category; this._button = button; @@ -141,13 +132,13 @@ const CategoryMenuItem = new Lang.Class({ this.actor.add_child(new St.Label({ text: name })); this.actor.connect('motion-event', Lang.bind(this, this._onMotionEvent)); - }, + } activate(event) { this._button.selectCategory(this._category, this); this._button.scrollToCatButton(this); - this.parent(event); - }, + super.activate(event); + } _isNavigatingSubmenu([x, y]) { let [posX, posY] = this.actor.get_transformed_position(); @@ -204,7 +195,7 @@ const CategoryMenuItem = new Lang.Class({ return true; return false; - }, + } _onMotionEvent(actor, event) { if (!Clutter.get_pointer_grab()) { @@ -227,44 +218,41 @@ const CategoryMenuItem = new Lang.Class({ source.sync_hover(); return false; - }, + } setActive(active, params) { if (active) { this._button.selectCategory(this._category, this); this._button.scrollToCatButton(this); } - this.parent(active, params); + super.setActive(active, params); } -}); +}; -const ApplicationsMenu = new Lang.Class({ - Name: 'ApplicationsMenu', - Extends: PopupMenu.PopupMenu, - - _init(sourceActor, arrowAlignment, arrowSide, button) { - this.parent(sourceActor, arrowAlignment, arrowSide); +class ApplicationsMenu extends PopupMenu.PopupMenu { + constructor(sourceActor, arrowAlignment, arrowSide, button) { + super(sourceActor, arrowAlignment, arrowSide); this._button = button; - }, + } isEmpty() { return false; - }, + } open(animate) { this._button.hotCorner.setBarrierSize(0); if (this._button.hotCorner.actor) // fallback corner this._button.hotCorner.actor.hide(); - this.parent(animate); - }, + super.open(animate); + } close(animate) { let size = Main.layoutManager.panelBox.height; this._button.hotCorner.setBarrierSize(size); if (this._button.hotCorner.actor) // fallback corner this._button.hotCorner.actor.show(); - this.parent(animate); - }, + super.close(animate); + } toggle() { if (this.isOpen) { @@ -273,14 +261,12 @@ const ApplicationsMenu = new Lang.Class({ if (Main.overview.visible) Main.overview.hide(); } - this.parent(); + super.toggle(); } -}); +}; -const DesktopTarget = new Lang.Class({ - Name: 'DesktopTarget', - - _init() { +class DesktopTarget { + constructor() { this._desktop = null; this._desktopDestroyedId = 0; @@ -291,11 +277,11 @@ const DesktopTarget = new Lang.Class({ global.get_window_actors().forEach(a => { this._onWindowAdded(a.get_parent(), a); }); - }, + } get hasDesktop() { return this._desktop != null; - }, + } _onWindowAdded(group, actor) { if (!(actor instanceof Meta.WindowActor)) @@ -303,7 +289,7 @@ const DesktopTarget = new Lang.Class({ if (actor.meta_window.get_window_type() == Meta.WindowType.DESKTOP) this._setDesktop(actor); - }, + } _setDesktop(desktop) { if (this._desktop) { @@ -322,13 +308,13 @@ const DesktopTarget = new Lang.Class({ }); this._desktop._delegate = this; } - }, + } _getSourceAppInfo(source) { if (!(source instanceof ApplicationMenuItem)) return null; return source._app.app_info; - }, + } _touchFile(file) { let queryFlags = Gio.FileQueryInfoFlags.NONE; @@ -345,7 +331,7 @@ const DesktopTarget = new Lang.Class({ log('Failed to update access time: ' + e.message); } }); - }, + } _markTrusted(file) { let modeAttr = Gio.FILE_ATTRIBUTE_UNIX_MODE; @@ -372,7 +358,7 @@ const DesktopTarget = new Lang.Class({ log('Failed to mark file as trusted: ' + e.message); } }); - }, + } destroy() { if (this._windowAddedId) @@ -380,7 +366,7 @@ const DesktopTarget = new Lang.Class({ this._windowAddedId = 0; this._setDesktop(null); - }, + } handleDragOver(source, actor, x, y, time) { let appInfo = this._getSourceAppInfo(source); @@ -388,7 +374,7 @@ const DesktopTarget = new Lang.Class({ return DND.DragMotionResult.CONTINUE; return DND.DragMotionResult.COPY_DROP; - }, + } acceptDrop(source, actor, x, y, time) { let appInfo = this._getSourceAppInfo(source); @@ -412,15 +398,12 @@ const DesktopTarget = new Lang.Class({ return true; } -}); +}; Signals.addSignalMethods(DesktopTarget.prototype); -const ApplicationsButton = new Lang.Class({ - Name: 'ApplicationsButton', - Extends: PanelMenu.Button, - - _init() { - this.parent(1.0, null, false); +class ApplicationsButton extends PanelMenu.Button { + constructor() { + super(1.0, null, false); this.setMenu(new ApplicationsMenu(this.actor, 1.0, St.Side.TOP, this)); Main.panel.menuManager.addMenu(this.menu); @@ -475,7 +458,7 @@ const ApplicationsButton = new Lang.Class({ this._display(); this._installedChangedId = appSys.connect('installed-changed', Lang.bind(this, this._onTreeChanged)); - }, + } _onTreeChanged() { if (this.menu.isOpen) { @@ -484,18 +467,18 @@ const ApplicationsButton = new Lang.Class({ } else { this.reloadFlag = true; } - }, + } get hotCorner() { return Main.layoutManager.hotCorners[Main.layoutManager.primaryIndex]; - }, + } _createVertSeparator() { let separator = new St.DrawingArea({ style_class: 'calendar-vertical-separator', pseudo_class: 'highlighted' }); separator.connect('repaint', Lang.bind(this, this._onVertSepRepaint)); return separator; - }, + } _onDestroy() { Main.overview.disconnect(this._showingId); @@ -512,7 +495,7 @@ const ApplicationsButton = new Lang.Class({ null); this._desktopTarget.destroy(); - }, + } _onCapturedEvent(actor, event) { if (event.type() == Clutter.EventType.BUTTON_PRESS) { @@ -520,7 +503,7 @@ const ApplicationsButton = new Lang.Class({ return true; } return false; - }, + } _onMenuKeyPress(actor, event) { let symbol = event.get_key_symbol(); @@ -530,8 +513,8 @@ const ApplicationsButton = new Lang.Class({ if (this.menu.actor.navigate_focus(global.stage.key_focus, direction, false)) return true; } - return this.parent(actor, event); - }, + return super._onMenuKeyPress(actor, event); + } _onVertSepRepaint(area) { let cr = area.get_context(); @@ -546,7 +529,7 @@ const ApplicationsButton = new Lang.Class({ cr.setDash([1, 3], 1); // Hard-code for now cr.setLineWidth(stippleWidth); cr.stroke(); - }, + } _onOpenStateChanged(menu, open) { if (open) { @@ -556,21 +539,21 @@ const ApplicationsButton = new Lang.Class({ } this.mainBox.show(); } - this.parent(menu, open); - }, + super._onOpenStateChanged(menu, open); + } _setKeybinding() { Main.wm.setCustomKeybindingHandler('panel-main-menu', Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, () => { this.menu.toggle(); }); - }, + } _redisplay() { this.applicationsBox.destroy_all_children(); this.categoriesBox.destroy_all_children(); this._display(); - }, + } _loadCategory(categoryId, dir) { let iter = dir.iter(); @@ -597,7 +580,7 @@ const ApplicationsButton = new Lang.Class({ this._loadCategory(categoryId, subdir); } } - }, + } scrollToButton(button) { let appsScrollBoxAdj = this.applicationsScrollBox.get_vscroll_bar().get_adjustment(); @@ -612,7 +595,7 @@ const ApplicationsButton = new Lang.Class({ newScrollValue = buttonAlloc.y2 - boxHeight + 10; if (newScrollValue != currentScrollValue) appsScrollBoxAdj.set_value(newScrollValue); - }, + } scrollToCatButton(button) { let catsScrollBoxAdj = this.categoriesScrollBox.get_vscroll_bar().get_adjustment(); @@ -627,7 +610,7 @@ const ApplicationsButton = new Lang.Class({ newScrollValue = buttonAlloc.y2 - boxHeight + 10; if (newScrollValue != currentScrollValue) catsScrollBoxAdj.set_value(newScrollValue); - }, + } _createLayout() { let section = new PopupMenu.PopupMenuSection(); @@ -670,7 +653,7 @@ const ApplicationsButton = new Lang.Class({ this.mainBox.add(this._createVertSeparator(), { expand: false, x_fill: false, y_fill: true}); this.mainBox.add(this.applicationsScrollBox, { expand: true, x_fill: true, y_fill: true }); section.actor.add_actor(this.mainBox); - }, + } _display() { this._applicationsButtons.clear(); @@ -705,7 +688,7 @@ const ApplicationsButton = new Lang.Class({ let height = this.categoriesBox.height + MENU_HEIGHT_OFFSET + 'px'; this.mainBox.style+=('height: ' + height); - }, + } selectCategory(dir, categoryMenuItem) { this.applicationsBox.get_children().forEach(c => { @@ -719,7 +702,7 @@ const ApplicationsButton = new Lang.Class({ this._displayButtons(this._listApplications(dir.get_menu_id())); else this._displayButtons(this._listApplications(null)); - }, + } _displayButtons(apps) { if (apps) { @@ -739,7 +722,7 @@ const ApplicationsButton = new Lang.Class({ this.applicationsBox.add_actor(item.actor); } } - }, + } _listApplications(category_menu_id) { let applist; @@ -757,13 +740,13 @@ const ApplicationsButton = new Lang.Class({ } return applist; - }, + } destroy() { this.menu.actor.get_children().forEach(c => { c.destroy() }); - this.parent(); + super.destroy(); } -}); +}; let appsMenuButton; let activitiesButton; diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js index 19be3520..34da4503 100644 --- a/extensions/auto-move-windows/extension.js +++ b/extensions/auto-move-windows/extension.js @@ -19,31 +19,29 @@ const SETTINGS_KEY = 'application-list'; let settings; -const WindowMover = new Lang.Class({ - Name: 'AutoMoveWindows.WindowMover', - - _init() { +class WindowMover { + constructor() { this._settings = settings; this._windowTracker = Shell.WindowTracker.get_default(); let display = global.screen.get_display(); // Connect after so the handler from ShellWindowTracker has already run this._windowCreatedId = display.connect_after('window-created', Lang.bind(this, this._findAndMove)); - }, + } destroy() { if (this._windowCreatedId) { global.screen.get_display().disconnect(this._windowCreatedId); this._windowCreatedId = 0; } - }, + } _ensureAtLeastWorkspaces(num, window) { for (let j = global.screen.n_workspaces; j <= num; j++) { window.change_workspace_by_index(j-1, false); global.screen.append_new_workspace(false, 0); } - }, + } _findAndMove(display, window, noRecurse) { if (window.skip_taskbar) @@ -77,7 +75,7 @@ const WindowMover = new Lang.Class({ } } } -}); +}; let prevCheckWorkspaces; let winMover; diff --git a/extensions/drive-menu/extension.js b/extensions/drive-menu/extension.js index 12af2362..9356b59a 100644 --- a/extensions/drive-menu/extension.js +++ b/extensions/drive-menu/extension.js @@ -18,12 +18,9 @@ const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Convenience = Me.imports.convenience; -const MountMenuItem = new Lang.Class({ - Name: 'DriveMenu.MountMenuItem', - Extends: PopupMenu.PopupBaseMenuItem, - - _init(mount) { - this.parent(); +class MountMenuItem extends PopupMenu.PopupBaseMenuItem { + constructor(mount) { + super(); this.label = new St.Label({ text: mount.get_name() }); this.actor.add(this.label, { expand: true }); @@ -39,7 +36,7 @@ const MountMenuItem = new Lang.Class({ this._changedId = mount.connect('changed', Lang.bind(this, this._syncVisibility)); this._syncVisibility(); - }, + } destroy() { if (this._changedId) { @@ -47,8 +44,8 @@ const MountMenuItem = new Lang.Class({ this._changedId = 0; } - this.parent(); - }, + super.destroy(); + } _isInteresting() { if (!this.mount.can_eject() && !this.mount.can_unmount()) @@ -65,11 +62,11 @@ const MountMenuItem = new Lang.Class({ } return volume.get_identifier('class') != 'network'; - }, + } _syncVisibility() { this.actor.visible = this._isInteresting(); - }, + } _eject() { let mountOp = new ShellMountOperation.ShellMountOperation(this.mount); @@ -84,7 +81,7 @@ const MountMenuItem = new Lang.Class({ mountOp.mountOp, null, // Gio.Cancellable Lang.bind(this, this._unmountFinish)); - }, + } _unmountFinish(mount, result) { try { @@ -92,7 +89,7 @@ const MountMenuItem = new Lang.Class({ } catch(e) { this._reportFailure(e); } - }, + } _ejectFinish(mount, result) { try { @@ -100,29 +97,26 @@ const MountMenuItem = new Lang.Class({ } catch(e) { this._reportFailure(e); } - }, + } _reportFailure(exception) { // TRANSLATORS: %s is the filesystem name let msg = _("Ejecting drive “%s” failed:").format(this.mount.get_name()); Main.notifyError(msg, exception.message); - }, + } activate(event) { let context = global.create_app_launch_context(event.get_time(), -1); Gio.AppInfo.launch_default_for_uri(this.mount.get_root().get_uri(), context); - this.parent(event); + super.activate(event); } -}); +}; -const DriveMenu = new Lang.Class({ - Name: 'DriveMenu.DriveMenu', - Extends: PanelMenu.Button, - - _init() { - this.parent(0.0, _("Removable devices")); +class DriveMenu extends PanelMenu.Button { + constructor() { + super(0.0, _("Removable devices")); let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); let icon = new St.Icon({ icon_name: 'media-eject-symbolic', @@ -154,20 +148,20 @@ const DriveMenu = new Lang.Class({ }); this._updateMenuVisibility(); - }, + } _updateMenuVisibility() { if (this._mounts.filter(i => i.actor.visible).length > 0) this.actor.show(); else this.actor.hide(); - }, + } _addMount(mount) { let item = new MountMenuItem(mount); this._mounts.unshift(item); this.menu.addMenuItem(item, 0); - }, + } _removeMount(mount) { for (let i = 0; i < this._mounts.length; i++) { @@ -179,7 +173,7 @@ const DriveMenu = new Lang.Class({ } } log ('Removing a mount that was never added to the menu'); - }, + } destroy() { if (this._connectedId) { @@ -189,9 +183,9 @@ const DriveMenu = new Lang.Class({ this._disconnectedId = 0; } - this.parent(); - }, -}); + super.destroy(); + } +}; function init() { Convenience.initTranslations(); diff --git a/extensions/native-window-placement/extension.js b/extensions/native-window-placement/extension.js index 8a479cc8..bf0a4827 100644 --- a/extensions/native-window-placement/extension.js +++ b/extensions/native-window-placement/extension.js @@ -1,6 +1,4 @@ // -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- -const Lang = imports.lang; - const Workspace = imports.ui.workspace; const ExtensionUtils = imports.misc.extensionUtils; @@ -14,19 +12,17 @@ const WINDOW_PLACEMENT_NATURAL_ACCURACY = 20; // accuracy const WINDOW_PLACEMENT_NATURAL_GAPS = 5; // half of the minimum gap between windows const WINDOW_PLACEMENT_NATURAL_MAX_TRANSLATIONS = 5000; // safety limit for preventing endless loop if something is wrong in the algorithm -const Rect = new Lang.Class({ - Name: 'NativeWindowPlacement.Rect', - - _init(x, y, width, height) { +class Rect { + constructor(x, y, width, height) { [this.x, this.y, this.width, this.height] = [x, y, width, height]; - }, + } /** * used in _calculateWindowTransformationsNatural to replace Meta.Rectangle that is too slow. */ copy() { return new Rect(this.x, this.y, this.width, this.height); - }, + } union(rect2) { let dest = this.copy(); @@ -46,7 +42,7 @@ const Rect = new Lang.Class({ dest.height = rect2.y + rect2.height - dest.y; return dest; - }, + } adjusted(dx, dy, dx2, dy2) { let dest = this.copy(); @@ -55,36 +51,34 @@ const Rect = new Lang.Class({ dest.width += -dx + dx2; dest.height += -dy + dy2; return dest; - }, + } overlap(rect2) { return !((this.x + this.width <= rect2.x) || (rect2.x + rect2.width <= this.x) || (this.y + this.height <= rect2.y) || (rect2.y + rect2.height <= this.y)); - }, + } center() { return [this.x + this.width / 2, this.y + this.height / 2]; - }, + } translate(dx, dy) { this.x += dx; this.y += dy; } -}); +}; -const NaturalLayoutStrategy = new Lang.Class({ - Name: 'NaturalLayoutStrategy', - Extends: Workspace.LayoutStrategy, - - _init(settings) { +class NaturalLayoutStrategy extends Workspace.LayoutStrategy { + constructor(settings) { + super(); this._settings = settings; - }, + } computeLayout(windows, layout) { layout.windows = windows; - }, + } /** * Returns clones with matching target coordinates and scales to arrange windows in a natural way that no overlap exists and relative window size is preserved. @@ -246,7 +240,7 @@ const NaturalLayoutStrategy = new Lang.Class({ return slots; } -}); +}; let winInjections, workspaceInjections; diff --git a/extensions/places-menu/extension.js b/extensions/places-menu/extension.js index 0a8bd5e3..45cc9460 100644 --- a/extensions/places-menu/extension.js +++ b/extensions/places-menu/extension.js @@ -23,12 +23,9 @@ const PlaceDisplay = Me.imports.placeDisplay; const PLACE_ICON_SIZE = 16; -const PlaceMenuItem = new Lang.Class({ - Name: 'PlaceMenuItem', - Extends: PopupMenu.PopupBaseMenuItem, - - _init(info) { - this.parent(); +class PlaceMenuItem extends PopupMenu.PopupBaseMenuItem { + constructor(info) { + super(); this._info = info; this._icon = new St.Icon({ gicon: info.icon, @@ -48,7 +45,7 @@ const PlaceMenuItem = new Lang.Class({ this._changedId = info.connect('changed', Lang.bind(this, this._propertiesChanged)); - }, + } destroy() { if (this._changedId) { @@ -56,20 +53,20 @@ const PlaceMenuItem = new Lang.Class({ this._changedId = 0; } - this.parent(); - }, + super.destroy(); + } activate(event) { this._info.launch(event.get_time()); - this.parent(event); - }, + super.activate(event); + } _propertiesChanged(info) { this._icon.gicon = info.icon; this._label.text = info.name; - }, -}); + } +}; const SECTIONS = [ 'special', @@ -78,12 +75,9 @@ const SECTIONS = [ 'network' ] -const PlacesMenu = new Lang.Class({ - Name: 'PlacesMenu.PlacesMenu', - Extends: PanelMenu.Button, - - _init() { - this.parent(0.0, _("Places")); +class PlacesMenu extends PanelMenu.Button { + constructor() { + super(0.0, _("Places")); let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); let label = new St.Label({ text: _("Places"), @@ -108,18 +102,18 @@ const PlacesMenu = new Lang.Class({ this.menu.addMenuItem(this._sections[id]); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); } - }, + } destroy() { this.placesManager.destroy(); - this.parent(); - }, + super.destroy(); + } _redisplay(id) { this._sections[id].removeAll(); this._create(id); - }, + } _create(id) { let places = this.placesManager.get(id); @@ -129,7 +123,7 @@ const PlacesMenu = new Lang.Class({ this._sections[id].actor.visible = places.length > 0; } -}); +}; function init() { Convenience.initTranslations(); diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js index 46ec011e..b1be6572 100644 --- a/extensions/places-menu/placeDisplay.js +++ b/extensions/places-menu/placeDisplay.js @@ -28,22 +28,24 @@ const Hostname1Iface = ' \ '; const Hostname1 = Gio.DBusProxy.makeProxyWrapper(Hostname1Iface); -const PlaceInfo = new Lang.Class({ - Name: 'PlaceInfo', +class PlaceInfo { + constructor() { + this._init.apply(this, arguments); + } _init(kind, file, name, icon) { this.kind = kind; this.file = file; this.name = name || this._getFileName(); this.icon = icon ? new Gio.ThemedIcon({ name: icon }) : this.getIcon(); - }, + } destroy() { - }, + } isRemovable() { return false; - }, + } _createLaunchCallback(launchContext, tryMount) { return (_ignored, result) => { @@ -78,7 +80,7 @@ const PlaceInfo = new Lang.Class({ Main.notifyError(_("Failed to launch “%s”").format(this.name), e.message); } } - }, + } launch(timestamp) { let launchContext = global.create_app_launch_context(timestamp, -1); @@ -87,7 +89,7 @@ const PlaceInfo = new Lang.Class({ launchContext, null, callback); - }, + } getIcon() { this.file.query_info_async('standard::symbolic-icon', 0, 0, null, @@ -116,7 +118,7 @@ const PlaceInfo = new Lang.Class({ else return new Gio.ThemedIcon({ name: 'folder-symbolic' }); } - }, + } _getFileName() { try { @@ -125,16 +127,13 @@ const PlaceInfo = new Lang.Class({ } catch(e if e instanceof Gio.IOErrorEnum) { return this.file.get_basename(); } - }, -}); + } +}; Signals.addSignalMethods(PlaceInfo.prototype); -const RootInfo = new Lang.Class({ - Name: 'RootInfo', - Extends: PlaceInfo, - +class RootInfo extends PlaceInfo { _init() { - this.parent('devices', Gio.File.new_for_path('/'), _("Computer")); + super._init('devices', Gio.File.new_for_path('/'), _("Computer")); this._proxy = new Hostname1(Gio.DBus.system, 'org.freedesktop.hostname1', @@ -147,11 +146,11 @@ const RootInfo = new Lang.Class({ Lang.bind(this, this._propertiesChanged)); this._propertiesChanged(obj); }); - }, + } getIcon() { return new Gio.ThemedIcon({ name: 'drive-harddisk-symbolic' }); - }, + } _propertiesChanged(proxy) { // GDBusProxy will emit a g-properties-changed when hostname1 goes down @@ -160,31 +159,28 @@ const RootInfo = new Lang.Class({ this.name = proxy.PrettyHostname || _("Computer"); this.emit('changed'); } - }, + } destroy() { this._proxy.run_dispose(); - this.parent(); + super.destroy(); } -}); +}; -const PlaceDeviceInfo = new Lang.Class({ - Name: 'PlaceDeviceInfo', - Extends: PlaceInfo, - +class PlaceDeviceInfo extends PlaceInfo { _init(kind, mount) { this._mount = mount; - this.parent(kind, mount.get_root(), mount.get_name()); - }, + super._init(kind, mount.get_root(), mount.get_name()); + } getIcon() { return this._mount.get_symbolic_icon(); - }, + } isRemovable() { return this._mount.can_eject(); - }, + } eject() { let mountOp = new ShellMountOperation.ShellMountOperation(this._mount); @@ -199,7 +195,7 @@ const PlaceDeviceInfo = new Lang.Class({ mountOp.mountOp, null, // Gio.Cancellable Lang.bind(this, this._unmountFinish)); - }, + } _ejectFinish(mount, result) { try { @@ -207,7 +203,7 @@ const PlaceDeviceInfo = new Lang.Class({ } catch(e) { this._reportFailure(e); } - }, + } _unmountFinish(mount, result) { try { @@ -215,26 +211,23 @@ const PlaceDeviceInfo = new Lang.Class({ } catch(e) { this._reportFailure(e); } - }, + } _reportFailure(exception) { let msg = _("Ejecting drive “%s” failed:").format(this._mount.get_name()); Main.notifyError(msg, exception.message); } -}); - -const PlaceVolumeInfo = new Lang.Class({ - Name: 'PlaceVolumeInfo', - Extends: PlaceInfo, +}; +class PlaceVolumeInfo extends PlaceInfo { _init(kind, volume) { this._volume = volume; - this.parent(kind, volume.get_activation_root(), volume.get_name()); - }, + super._init(kind, volume.get_activation_root(), volume.get_name()); + } launch(timestamp) { if (this.file) { - this.parent(timestamp); + super.launch(timestamp); return; } @@ -243,14 +236,14 @@ const PlaceVolumeInfo = new Lang.Class({ let mount = volume.get_mount(); this.file = mount.get_root(); - this.parent(timestamp); + super.launch(timestamp); }); - }, + } getIcon() { return this._volume.get_symbolic_icon(); } -}); +}; const DEFAULT_DIRECTORIES = [ GLib.UserDirectory.DIRECTORY_DOCUMENTS, @@ -260,10 +253,8 @@ const DEFAULT_DIRECTORIES = [ GLib.UserDirectory.DIRECTORY_VIDEOS, ]; -var PlacesManager = new Lang.Class({ - Name: 'PlacesManager', - - _init() { +var PlacesManager = class { + constructor() { this._places = { special: [], devices: [], @@ -303,7 +294,7 @@ var PlacesManager = new Lang.Class({ this._reloadBookmarks(); } - }, + } _connectVolumeMonitorSignals() { const signals = ['volume-added', 'volume-removed', 'volume-changed', @@ -316,7 +307,7 @@ var PlacesManager = new Lang.Class({ let id = this._volumeMonitor.connect(signals[i], func); this._volumeMonitorSignals.push(id); } - }, + } destroy() { if (this._settings) @@ -330,7 +321,7 @@ var PlacesManager = new Lang.Class({ this._monitor.cancel(); if (this._bookmarkTimeoutId) Mainloop.source_remove(this._bookmarkTimeoutId); - }, + } _updateSpecials() { this._places.special.forEach(p => { p.destroy(); }); @@ -367,7 +358,7 @@ var PlacesManager = new Lang.Class({ this._places.special = this._places.special.concat(specials); this.emit('special-updated'); - }, + } _updateMounts() { let networkMounts = []; @@ -450,7 +441,7 @@ var PlacesManager = new Lang.Class({ this.emit('devices-updated'); this.emit('network-updated'); - }, + } _findBookmarksFile() { let paths = [ @@ -464,7 +455,7 @@ var PlacesManager = new Lang.Class({ } return null; - }, + } _reloadBookmarks() { @@ -514,7 +505,7 @@ var PlacesManager = new Lang.Class({ this._places.bookmarks = bookmarks; this.emit('bookmarks-updated'); - }, + } _addMount(kind, mount) { let devItem; @@ -526,7 +517,7 @@ var PlacesManager = new Lang.Class({ } this._places[kind].push(devItem); - }, + } _addVolume(kind, volume) { let volItem; @@ -538,10 +529,10 @@ var PlacesManager = new Lang.Class({ } this._places[kind].push(volItem); - }, + } get(kind) { return this._places[kind]; } -}); +}; Signals.addSignalMethods(PlacesManager.prototype); diff --git a/extensions/user-theme/extension.js b/extensions/user-theme/extension.js index 13dc4570..0c792cfc 100644 --- a/extensions/user-theme/extension.js +++ b/extensions/user-theme/extension.js @@ -12,17 +12,15 @@ const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Convenience = Me.imports.convenience; -const ThemeManager = new Lang.Class({ - Name: 'UserTheme.ThemeManager', - - _init() { +class ThemeManager { + constructor() { this._settings = Convenience.getSettings(); - }, + } enable() { this._changedId = this._settings.connect('changed::'+SETTINGS_KEY, Lang.bind(this, this._changeTheme)); this._changeTheme(); - }, + } disable() { if (this._changedId) { @@ -32,7 +30,7 @@ const ThemeManager = new Lang.Class({ Main.setThemeStylesheet(null); Main.loadTheme(); - }, + } _changeTheme() { let _stylesheet = null; @@ -64,7 +62,7 @@ const ThemeManager = new Lang.Class({ Main.setThemeStylesheet(_stylesheet); Main.loadTheme(); } -}); +}; function init() { return new ThemeManager(); diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js index 5a5ce952..6d09525e 100644 --- a/extensions/window-list/extension.js +++ b/extensions/window-list/extension.js @@ -64,12 +64,9 @@ function _getAppStableSequence(app) { } -const WindowContextMenu = new Lang.Class({ - Name: 'WindowContextMenu', - Extends: PopupMenu.PopupMenu, - - _init(source, metaWindow) { - this.parent(source, 0.5, St.Side.BOTTOM); +class WindowContextMenu extends PopupMenu.PopupMenu { + constructor(source, metaWindow) { + super(source, 0.5, St.Side.BOTTOM); this._metaWindow = metaWindow; @@ -123,31 +120,29 @@ const WindowContextMenu = new Lang.Class({ this._maximizeItem.setSensitive(this._metaWindow.can_maximize()); this._closeItem.setSensitive(this._metaWindow.can_close()); }); - }, + } _updateMinimizeItem() { this._minimizeItem.label.text = this._metaWindow.minimized ? _("Unminimize") : _("Minimize"); - }, + } _updateMaximizeItem() { let maximized = this._metaWindow.maximized_vertically && this._metaWindow.maximized_horizontally; this._maximizeItem.label.text = maximized ? _("Unmaximize") : _("Maximize"); - }, + } _onDestroy() { this._metaWindow.disconnect(this._notifyMinimizedId); this._metaWindow.disconnect(this._notifyMaximizedHId); this._metaWindow.disconnect(this._notifyMaximizedVId); } -}); +}; -const WindowTitle = new Lang.Class({ - Name: 'WindowTitle', - - _init(metaWindow) { +class WindowTitle { + constructor(metaWindow) { this._metaWindow = metaWindow; this.actor = new St.BoxLayout({ style_class: 'window-button-box', x_expand: true, y_expand: true }); @@ -178,12 +173,12 @@ const WindowTitle = new Lang.Class({ this._metaWindow.connect('notify::minimized', Lang.bind(this, this._minimizedChanged)); this._minimizedChanged(); - }, + } _minimizedChanged() { this._icon.opacity = this._metaWindow.minimized ? 128 : 255; this._updateTitle(); - }, + } _updateTitle() { if (!this._metaWindow.title) @@ -193,7 +188,7 @@ const WindowTitle = new Lang.Class({ this.label_actor.text = '[%s]'.format(this._metaWindow.title); else this.label_actor.text = this._metaWindow.title; - }, + } _updateIcon() { let app = Shell.WindowTracker.get_default().get_window_app(this._metaWindow); @@ -202,7 +197,7 @@ const WindowTitle = new Lang.Class({ else this._icon.child = new St.Icon({ icon_name: 'icon-missing', icon_size: ICON_TEXTURE_SIZE }); - }, + } _onDestroy() { this._textureCache.disconnect(this._iconThemeChangedId); @@ -211,14 +206,14 @@ const WindowTitle = new Lang.Class({ this._metaWindow.disconnect(this._notifyWmClass); this._metaWindow.disconnect(this._notifyAppId); } -}); +}; -const BaseButton = new Lang.Class({ - Name: 'BaseButton', - Abstract: true, +class BaseButton { + constructor(perMonitor, monitorIndex) { + if (this.constructor === BaseButton) + throw new TypeError('Cannot instantiate abstract class BaseButton'); - _init(perMonitor, monitorIndex) { this._perMonitor = perMonitor; this._monitorIndex = monitorIndex; @@ -250,47 +245,47 @@ const BaseButton = new Lang.Class({ global.screen.connect('window-left-monitor', Lang.bind(this, this._windowEnteredOrLeftMonitor)); } - }, + } get active() { return this.actor.has_style_class_name('focused'); - }, + } activate() { if (this.active) return; this._onClicked(this.actor, 1); - }, + } _onClicked(actor, button) { throw new Error('Not implemented'); - }, + } _canOpenPopupMenu() { return true; - }, + } _onPopupMenu(actor) { if (!this._canOpenPopupMenu() || this._contextMenu.isOpen) return; _openMenu(this._contextMenu); - }, + } _isFocused() { throw new Error('Not implemented'); - }, + } _updateStyle() { if (this._isFocused()) this.actor.add_style_class_name('focused'); else this.actor.remove_style_class_name('focused'); - }, + } _windowEnteredOrLeftMonitor(metaScreen, monitorIndex, metaWindow) { throw new Error('Not implemented'); - }, + } _isWindowVisible(window) { let workspace = global.screen.get_active_workspace(); @@ -298,11 +293,11 @@ const BaseButton = new Lang.Class({ return !window.skip_taskbar && window.located_on_workspace(workspace) && (!this._perMonitor || window.get_monitor() == this._monitorIndex); - }, + } _updateVisibility() { throw new Error('Not implemented'); - }, + } _getIconGeometry() { let rect = new Meta.Rectangle(); @@ -311,11 +306,11 @@ const BaseButton = new Lang.Class({ [rect.width, rect.height] = this.actor.get_transformed_size(); return rect; - }, + } _updateIconGeometry() { throw new Error('Not implemented'); - }, + } _onDestroy() { global.window_manager.disconnect(this._switchWorkspaceId); @@ -328,15 +323,12 @@ const BaseButton = new Lang.Class({ global.screen.disconnect(this._windowLeftMonitorId); this._windowLeftMonitorId = 0; } -}); +}; -const WindowButton = new Lang.Class({ - Name: 'WindowButton', - Extends: BaseButton, - - _init(metaWindow, perMonitor, monitorIndex) { - this.parent(perMonitor, monitorIndex); +class WindowButton extends BaseButton { + constructor(metaWindow, perMonitor, monitorIndex) { + super(perMonitor, monitorIndex); this.metaWindow = metaWindow; this._updateVisibility(); @@ -359,7 +351,7 @@ const WindowButton = new Lang.Class({ global.display.connect('notify::focus-window', Lang.bind(this, this._updateStyle)); this._updateStyle(); - }, + } _onClicked(actor, button) { if (this._contextMenu.isOpen) { @@ -371,49 +363,46 @@ const WindowButton = new Lang.Class({ _minimizeOrActivateWindow(this.metaWindow); else _openMenu(this._contextMenu); - }, + } _isFocused() { return global.display.focus_window == this.metaWindow; - }, + } _updateStyle() { - this.parent(); + super._updateStyle(); if (this.metaWindow.minimized) this.actor.add_style_class_name('minimized'); else this.actor.remove_style_class_name('minimized'); - }, + } _windowEnteredOrLeftMonitor(metaScreen, monitorIndex, metaWindow) { if (monitorIndex == this._monitorIndex && metaWindow == this.metaWindow) this._updateVisibility(); - }, + } _updateVisibility() { this.actor.visible = this._isWindowVisible(this.metaWindow); - }, + } _updateIconGeometry() { this.metaWindow.set_icon_geometry(this._getIconGeometry()); - }, + } _onDestroy() { - this.parent(); + super._onDestroy(); this.metaWindow.disconnect(this._workspaceChangedId); global.display.disconnect(this._notifyFocusId); this._contextMenu.destroy(); } -}); +}; -const AppContextMenu = new Lang.Class({ - Name: 'AppContextMenu', - Extends: PopupMenu.PopupMenu, - - _init(source, appButton) { - this.parent(source, 0.5, St.Side.BOTTOM); +class AppContextMenu extends PopupMenu.PopupMenu { + constructor(source, appButton) { + super(source, 0.5, St.Side.BOTTOM); this._appButton = appButton; @@ -454,7 +443,7 @@ const AppContextMenu = new Lang.Class({ }); }); this.addMenuItem(item); - }, + } open(animate) { let windows = this._appButton.getWindowList(); @@ -467,16 +456,13 @@ const AppContextMenu = new Lang.Class({ return w.maximized_horizontally && w.maximized_vertically; }); - this.parent(animate); + super.open(animate); } -}); +}; -const AppButton = new Lang.Class({ - Name: 'AppButton', - Extends: BaseButton, - - _init(app, perMonitor, monitorIndex) { - this.parent(perMonitor, monitorIndex); +class AppButton extends BaseButton { + constructor(app, perMonitor, monitorIndex) { + super(perMonitor, monitorIndex); this.app = app; this._updateVisibility(); @@ -531,7 +517,7 @@ const AppButton = new Lang.Class({ this._windowTracker.connect('notify::focus-app', Lang.bind(this, this._updateStyle)); this._updateStyle(); - }, + } _windowEnteredOrLeftMonitor(metaScreen, monitorIndex, metaWindow) { if (this._windowTracker.get_window_app(metaWindow) == this.app && @@ -539,7 +525,7 @@ const AppButton = new Lang.Class({ this._updateVisibility(); this._windowsChanged(); } - }, + } _updateVisibility() { if (!this._perMonitor) { @@ -549,22 +535,22 @@ const AppButton = new Lang.Class({ } else { this.actor.visible = this.getWindowList().length >= 1; } - }, + } _isFocused() { return this._windowTracker.focus_app == this.app; - }, + } _updateIconGeometry() { let rect = this._getIconGeometry(); let windows = this.app.get_windows(); windows.forEach(w => { w.set_icon_geometry(rect); }); - }, + } getWindowList() { return this.app.get_windows().filter(win => this._isWindowVisible(win)); - }, + } _windowsChanged() { let windows = this.getWindowList(); @@ -599,7 +585,7 @@ const AppButton = new Lang.Class({ this.actor.label_actor = this._multiWindowTitle.label_actor; } - }, + } _onClicked(actor, button) { let menuWasOpen = this._menu.isOpen; @@ -636,32 +622,29 @@ const AppButton = new Lang.Class({ return; _openMenu(this._contextMenu); } - }, + } _canOpenPopupMenu() { return !this._menu.isOpen; - }, + } _onMenuActivate(menu, child) { child._window.activate(global.get_current_time()); - }, + } _onDestroy() { - this.parent(); + super._onDestroy(); this._textureCache.disconnect(this._iconThemeChangedId); this._windowTracker.disconnect(this._notifyFocusId); this.app.disconnect(this._windowsChangedId); this._menu.destroy(); } -}); +}; -const WorkspaceIndicator = new Lang.Class({ - Name: 'WindowList.WorkspaceIndicator', - Extends: PanelMenu.Button, - - _init() { - this.parent(0.0, _("Workspace Indicator"), true); +class WorkspaceIndicator extends PanelMenu.Button { + constructor() { + super(0.0, _("Workspace Indicator"), true); this.setMenu(new PopupMenu.PopupMenu(this.actor, 0.0, St.Side.BOTTOM)); this.actor.add_style_class_name('window-list-workspace-indicator'); this.menu.actor.remove_style_class_name('panel-menu'); @@ -687,7 +670,7 @@ const WorkspaceIndicator = new Lang.Class({ this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.wm.preferences' }); this._settingsChangedId = this._settings.connect('changed::workspace-names', Lang.bind(this, this._updateMenu)); - }, + } destroy() { for (let i = 0; i < this._screenSignals.length; i++) @@ -698,8 +681,8 @@ const WorkspaceIndicator = new Lang.Class({ this._settingsChangedId = 0; } - this.parent(); - }, + super.destroy(); + } _updateIndicator() { this.workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.NONE); @@ -707,14 +690,14 @@ const WorkspaceIndicator = new Lang.Class({ this.workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.DOT); this.statusLabel.set_text(this._getStatusText()); - }, + } _getStatusText() { let current = global.screen.get_active_workspace().index(); let total = global.screen.n_workspaces; return '%d / %d'.format(current + 1, total); - }, + } _updateMenu() { this.menu.removeAll(); @@ -738,14 +721,14 @@ const WorkspaceIndicator = new Lang.Class({ } this.statusLabel.set_text(this._getStatusText()); - }, + } _activate(index) { if(index >= 0 && index < global.screen.n_workspaces) { let metaWorkspace = global.screen.get_workspace_by_index(index); metaWorkspace.activate(global.get_current_time()); } - }, + } _onScrollEvent(actor, event) { let direction = event.get_scroll_direction(); @@ -760,18 +743,16 @@ const WorkspaceIndicator = new Lang.Class({ let newIndex = this._currentWorkspace + diff; this._activate(newIndex); - }, + } _allocate(actor, box, flags) { if (actor.get_n_children() > 0) actor.get_first_child().allocate(box, flags); } -}); +}; -const WindowList = new Lang.Class({ - Name: 'WindowList', - - _init(perMonitor, monitor) { +class WindowList { + constructor(perMonitor, monitor) { this._perMonitor = perMonitor; this._monitor = monitor; @@ -895,20 +876,20 @@ const WindowList = new Lang.Class({ Lang.bind(this, this._groupingModeChanged)); this._grouped = undefined; this._groupingModeChanged(); - }, + } _getDynamicWorkspacesSettings() { if (this._workspaceSettings.list_keys().indexOf('dynamic-workspaces') > -1) return this._workspaceSettings; return this._mutterSettings; - }, + } _getWorkspaceSettings() { let settings = global.get_overrides_settings(); if (settings.list_keys().indexOf('workspaces-only-on-primary') > -1) return settings; return this._mutterSettings; - }, + } _onScrollEvent(actor, event) { let direction = event.get_scroll_direction(); @@ -931,12 +912,12 @@ const WindowList = new Lang.Class({ active = Math.max(0, Math.min(active + diff, children.length-1)); children[active].activate(); - }, + } _updatePosition() { this.actor.set_position(this._monitor.x, this._monitor.y + this._monitor.height - this.actor.height); - }, + } _updateWorkspaceIndicatorVisibility() { let hasWorkspaces = this._dynamicWorkspacesSettings.get_boolean('dynamic-workspaces') || @@ -945,7 +926,7 @@ const WindowList = new Lang.Class({ !this._workspaceSettings.get_boolean('workspaces-only-on-primary'); this._workspaceIndicator.actor.visible = hasWorkspaces && workspacesOnMonitor; - }, + } _getPreferredUngroupedWindowListWidth() { if (this._windowList.get_n_children() == 0) @@ -964,12 +945,12 @@ const WindowList = new Lang.Class({ return this._windowList.get_preferred_width(-1)[1]; return nWindows * childWidth + (nWindows - 1) * spacing; - }, + } _getMaxWindowListWidth() { let indicatorsBox = this._workspaceIndicator.actor.get_parent(); return this.actor.width - indicatorsBox.get_preferred_width(-1)[1]; - }, + } _groupingModeChanged() { this._groupingMode = this._settings.get_enum('grouping-mode'); @@ -980,7 +961,7 @@ const WindowList = new Lang.Class({ this._grouped = this._groupingMode == GroupingMode.ALWAYS; this._populateWindowList(); } - }, + } _checkGrouping() { if (this._groupingMode != GroupingMode.AUTO) @@ -994,7 +975,7 @@ const WindowList = new Lang.Class({ this._grouped = grouped; this._populateWindowList(); } - }, + } _populateWindowList() { this._windowList.destroy_all_children(); @@ -1014,7 +995,7 @@ const WindowList = new Lang.Class({ for (let i = 0; i < apps.length; i++) this._addApp(apps[i]); } - }, + } _updateKeyboardAnchor() { if (!Main.keyboard.actor) @@ -1022,7 +1003,7 @@ const WindowList = new Lang.Class({ let anchorY = Main.overview.visible ? 0 : this.actor.height; Main.keyboard.actor.anchor_y = anchorY; - }, + } _onAppStateChanged(appSys, app) { if (!this._grouped) @@ -1032,7 +1013,7 @@ const WindowList = new Lang.Class({ this._addApp(app); else if (app.state == Shell.AppState.STOPPED) this._removeApp(app); - }, + } _addApp(app) { let button = new AppButton(app, this._perMonitor, this._monitor.index); @@ -1040,7 +1021,7 @@ const WindowList = new Lang.Class({ true, true, true, Clutter.BoxAlignment.START, Clutter.BoxAlignment.START); - }, + } _removeApp(app) { let children = this._windowList.get_children(); @@ -1050,7 +1031,7 @@ const WindowList = new Lang.Class({ return; } } - }, + } _onWindowAdded(ws, win) { if (win.skip_taskbar) @@ -1073,7 +1054,7 @@ const WindowList = new Lang.Class({ true, true, true, Clutter.BoxAlignment.START, Clutter.BoxAlignment.START); - }, + } _onWindowRemoved(ws, win) { if (this._grouped) @@ -1092,7 +1073,7 @@ const WindowList = new Lang.Class({ return; } } - }, + } _onWorkspacesChanged() { let numWorkspaces = global.screen.n_workspaces; @@ -1112,7 +1093,7 @@ const WindowList = new Lang.Class({ } this._updateWorkspaceIndicatorVisibility(); - }, + } _disconnectWorkspaceSignals() { let numWorkspaces = global.screen.n_workspaces; @@ -1123,16 +1104,16 @@ const WindowList = new Lang.Class({ workspace.disconnect(signals._windowAddedId); workspace.disconnect(signals._windowRemovedId); } - }, + } _onDragBegin() { DND.addDragMonitor(this._dragMonitor); - }, + } _onDragEnd() { DND.removeDragMonitor(this._dragMonitor); this._removeActivateTimeout(); - }, + } _onDragMotion(dragEvent) { if (Main.overview.visible || @@ -1157,14 +1138,14 @@ const WindowList = new Lang.Class({ Lang.bind(this, this._activateWindow)); return DND.DragMotionResult.CONTINUE; - }, + } _removeActivateTimeout() { if (this._dndTimeoutId) GLib.source_remove (this._dndTimeoutId); this._dndTimeoutId = 0; this._dndWindow = null; - }, + } _activateWindow() { let [x, y] = global.get_pointer(); @@ -1176,7 +1157,7 @@ const WindowList = new Lang.Class({ this._dndTimeoutId = 0; return false; - }, + } _onDestroy() { this._workspaceSettings.disconnect(this._workspacesOnlyOnPrimaryChangedId); @@ -1216,15 +1197,13 @@ const WindowList = new Lang.Class({ for (let i = 0; i < windows.length; i++) windows[i].metaWindow.set_icon_geometry(null); } -}); +}; -const Extension = new Lang.Class({ - Name: 'Extension', - - _init() { +class Extension { + constructor() { this._windowLists = null; this._injections = {}; - }, + } enable() { this._windowLists = []; @@ -1239,7 +1218,7 @@ const Extension = new Lang.Class({ Lang.bind(this, this._buildWindowLists)); this._buildWindowLists(); - }, + } _buildWindowLists() { this._windowLists.forEach(list => { list.actor.destroy(); }); @@ -1251,7 +1230,7 @@ const Extension = new Lang.Class({ if (showOnAllMonitors || monitor == Main.layoutManager.primaryMonitor) this._windowLists.push(new WindowList(showOnAllMonitors, monitor)); }); - }, + } disable() { if (!this._windowLists) @@ -1268,12 +1247,12 @@ const Extension = new Lang.Class({ windowList.actor.destroy(); }); this._windowLists = null; - }, + } someWindowListContains(actor) { return this._windowLists.some(list => list.actor.contains(actor)); } -}); +}; function init() { return new Extension(); diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js index eb4cfe13..5aa8b122 100644 --- a/extensions/workspace-indicator/extension.js +++ b/extensions/workspace-indicator/extension.js @@ -22,12 +22,9 @@ const Convenience = Me.imports.convenience; const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences'; const WORKSPACE_KEY = 'workspace-names'; -const WorkspaceIndicator = new Lang.Class({ - Name: 'WorkspaceIndicator.WorkspaceIndicator', - Extends: PanelMenu.Button, - - _init() { - this.parent(0.0, _("Workspace Indicator")); +class WorkspaceIndicator extends PanelMenu.Button { + constructor() { + super(0.0, _("Workspace Indicator")); this._currentWorkspace = global.screen.get_active_workspace().index(); this.statusLabel = new St.Label({ y_align: Clutter.ActorAlign.CENTER, @@ -52,7 +49,7 @@ const WorkspaceIndicator = new Lang.Class({ this._settings = new Gio.Settings({ schema_id: WORKSPACE_SCHEMA }); this._settingsChangedId = this._settings.connect('changed::' + WORKSPACE_KEY, Lang.bind(this, this._createWorkspacesSection)); - }, + } destroy() { for (let i = 0; i < this._screenSignals.length; i++) @@ -63,8 +60,8 @@ const WorkspaceIndicator = new Lang.Class({ this._settingsChangedId = 0; } - this.parent(); - }, + super.destroy(); + } _updateIndicator() { this.workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.NONE); @@ -72,7 +69,7 @@ const WorkspaceIndicator = new Lang.Class({ this.workspacesItems[this._currentWorkspace].setOrnament(PopupMenu.Ornament.DOT); this.statusLabel.set_text(this._labelText()); - }, + } _labelText(workspaceIndex) { if(workspaceIndex == undefined) { @@ -80,7 +77,7 @@ const WorkspaceIndicator = new Lang.Class({ return (workspaceIndex + 1).toString(); } return Meta.prefs_get_workspace_name(workspaceIndex); - }, + } _createWorkspacesSection() { this._workspaceSection.removeAll(); @@ -103,14 +100,14 @@ const WorkspaceIndicator = new Lang.Class({ } this.statusLabel.set_text(this._labelText()); - }, + } _activate(index) { if(index >= 0 && index < global.screen.n_workspaces) { let metaWorkspace = global.screen.get_workspace_by_index(index); metaWorkspace.activate(global.get_current_time()); } - }, + } _onScrollEvent(actor, event) { let direction = event.get_scroll_direction(); @@ -125,8 +122,8 @@ const WorkspaceIndicator = new Lang.Class({ let newIndex = global.screen.get_active_workspace().index() + diff; this._activate(newIndex); - }, -}); + } +}; function init(meta) { Convenience.initTranslations();