mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
refactor: derive from EventEmitter
Instead of using the legacy import and adding signal methods, just derive from EventEmitter.
This commit is contained in:
@@ -38,6 +38,7 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
|
||||
import * as BoxPointer from 'resource:///org/gnome/shell/ui/boxpointer.js';
|
||||
import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js';
|
||||
|
||||
import * as Utils from './utils.js';
|
||||
import * as PanelSettings from './panelSettings.js';
|
||||
@@ -47,7 +48,6 @@ import {DTP_EXTENSION, SETTINGS, DESKTOPSETTINGS, EXTENSION_PATH} from './extens
|
||||
import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
const Mainloop = imports.mainloop;
|
||||
const {signals: Signals} = imports;
|
||||
|
||||
//timeout names
|
||||
const T2 = 'mouseScrollTimeout';
|
||||
@@ -1581,9 +1581,11 @@ export function ItemShowLabel() {
|
||||
* use of this class in place of the original showAppsButton.
|
||||
*
|
||||
*/
|
||||
export const ShowAppsIconWrapper = class {
|
||||
export const ShowAppsIconWrapper = class extends EventEmitter {
|
||||
|
||||
constructor(dtpPanel) {
|
||||
super();
|
||||
|
||||
this.realShowAppsIcon = new Dash.ShowAppsIcon();
|
||||
|
||||
/* the variable equivalent to toggleButton has a different name in the appIcon class
|
||||
@@ -1725,7 +1727,6 @@ export const ShowAppsIconWrapper = class {
|
||||
this.realShowAppsIcon.destroy();
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(ShowAppsIconWrapper.prototype);
|
||||
|
||||
/**
|
||||
* A menu for the showAppsIcon
|
||||
|
||||
11
extension.js
11
extension.js
@@ -18,16 +18,16 @@
|
||||
*/
|
||||
|
||||
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import Gio from 'gi://Gio';
|
||||
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js';
|
||||
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
import * as PanelManager from './panelManager.js';
|
||||
import * as Utils from './utils.js';
|
||||
import * as AppIcons from './appIcons.js';
|
||||
|
||||
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
const {signals: Signals} = imports;
|
||||
|
||||
const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com';
|
||||
|
||||
@@ -67,8 +67,7 @@ export default class DashToPanelExtension extends Extension {
|
||||
});
|
||||
|
||||
//create a global object that can emit signals and conveniently expose functionalities to other extensions
|
||||
global.dashToPanel = {};
|
||||
Signals.addSignalMethods(global.dashToPanel);
|
||||
global.dashToPanel = new EventEmitter();
|
||||
|
||||
_enable(this);
|
||||
}
|
||||
|
||||
12
progress.js
12
progress.js
@@ -27,12 +27,14 @@ import St from 'gi://St';
|
||||
import * as Utils from './utils.js';
|
||||
import {SETTINGS} from './extension.js';
|
||||
|
||||
const {signals: Signals} = imports;
|
||||
import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js';
|
||||
|
||||
|
||||
export const ProgressManager = class {
|
||||
export const ProgressManager = class extends EventEmitter {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._entriesByDBusName = {};
|
||||
|
||||
this._launcher_entry_dbus_signal_id =
|
||||
@@ -163,11 +165,12 @@ export const ProgressManager = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(ProgressManager.prototype);
|
||||
|
||||
export class AppProgress {
|
||||
export class AppProgress extends EventEmitter {
|
||||
|
||||
constructor(dbusName, appId, properties) {
|
||||
super();
|
||||
|
||||
this._dbusName = dbusName;
|
||||
this._appId = appId;
|
||||
this._count = 0;
|
||||
@@ -278,7 +281,6 @@ export class AppProgress {
|
||||
}
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(AppProgress.prototype);
|
||||
|
||||
|
||||
export const ProgressIndicator = class {
|
||||
|
||||
@@ -34,6 +34,7 @@ import * as AppFavorites from 'resource:///org/gnome/shell/ui/appFavorites.js';
|
||||
import * as Dash from 'resource:///org/gnome/shell/ui/dash.js';
|
||||
import * as DND from 'resource:///org/gnome/shell/ui/dnd.js';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js';
|
||||
|
||||
import * as AppIcons from './appIcons.js';
|
||||
import * as PanelManager from './panelManager.js';
|
||||
@@ -44,7 +45,6 @@ import * as WindowPreview from './windowPreview.js';
|
||||
import {SETTINGS} from './extension.js';
|
||||
|
||||
const Mainloop = imports.mainloop;
|
||||
const {signals: Signals} = imports;
|
||||
const SearchController = Main.overview.searchController;
|
||||
|
||||
export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1);
|
||||
@@ -194,9 +194,11 @@ export const TaskbarActor = GObject.registerClass({
|
||||
* - Sync minimization application target position.
|
||||
*/
|
||||
|
||||
export const Taskbar = class {
|
||||
export const Taskbar = class extends EventEmitter {
|
||||
|
||||
constructor(panel) {
|
||||
super();
|
||||
|
||||
this.dtpPanel = panel;
|
||||
|
||||
// start at smallest size due to running indicator drawing area expanding but not shrinking
|
||||
@@ -1321,8 +1323,6 @@ export const Taskbar = class {
|
||||
}
|
||||
};
|
||||
|
||||
Signals.addSignalMethods(Taskbar.prototype);
|
||||
|
||||
const CloneContainerConstraint = GObject.registerClass({
|
||||
}, class CloneContainerConstraint extends Clutter.BindConstraint {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user