mirror of
https://github.com/zoriya/fairy.git
synced 2026-06-05 11:40:18 +00:00
Move the indicator to another file
This commit is contained in:
+4
-30
@@ -9,52 +9,26 @@ const PanelMenu = imports.ui.panelMenu;
|
||||
const State = Me.imports.sources.state;
|
||||
const Renderer = Me.imports.sources.renderer;
|
||||
const Keybinds = Me.imports.sources.keybinds;
|
||||
const Indicator = Me.imports.sources.indicator;
|
||||
|
||||
class Extension {
|
||||
constructor() {
|
||||
this._state = new State.StateManager();
|
||||
this._renderer = new Renderer.Renderer(this._state);
|
||||
this._keybinds = new Keybinds.KeyboardManager(this._state, this._renderer);
|
||||
|
||||
this._layoutIndicator = null;
|
||||
this._indicator = new Indicator.Indicator(this._state, this._renderer);
|
||||
}
|
||||
|
||||
enable() {
|
||||
this._renderer.enable();
|
||||
this._keybinds.enable();
|
||||
|
||||
this.settings = ExtensionUtils.getSettings(
|
||||
"org.gnome.shell.extensions.fairy"
|
||||
);
|
||||
|
||||
let indicatorName = `${Me.metadata.name} Layout Indicator`;
|
||||
|
||||
this._layoutIndicator = new PanelMenu.Button(0.0, indicatorName, false);
|
||||
|
||||
// Add an icon
|
||||
let icon = new St.Icon({
|
||||
gicon: new Gio.ThemedIcon({ name: "face-laugh-symbolic" }),
|
||||
style_class: "system-status-icon",
|
||||
});
|
||||
this._layoutIndicator.add_child(icon);
|
||||
|
||||
this.settings.bind(
|
||||
"show-layout",
|
||||
this._layoutIndicator,
|
||||
"visible",
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
|
||||
Main.panel.addToStatusArea(indicatorName, this._layoutIndicator);
|
||||
this._indicator.enable();
|
||||
}
|
||||
|
||||
disable() {
|
||||
this._renderer.disable();
|
||||
this._keybinds.disable();
|
||||
this._layoutIndicator.destroy();
|
||||
this._layoutIndicator = null;
|
||||
|
||||
this.settings = null;
|
||||
this._indicator.disable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
const GObject = imports.gi.GObject;
|
||||
const Main = imports.ui.main;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
var Indicator = GObject.registerClass(
|
||||
class Indicator extends GObject.Object {
|
||||
_init(state, renderer) {
|
||||
super._init();
|
||||
this._state = state;
|
||||
this._renderer = renderer;
|
||||
}
|
||||
|
||||
enable() {
|
||||
this.settings = ExtensionUtils.getSettings(
|
||||
"org.gnome.shell.extensions.fairy"
|
||||
);
|
||||
|
||||
let indicatorName = `${Me.metadata.name} Indicator`;
|
||||
|
||||
this._layoutIndicator = new PanelMenu.Button(0.0, indicatorName, false);
|
||||
|
||||
// Add an icon
|
||||
let icon = new St.Icon({
|
||||
gicon: new Gio.ThemedIcon({ name: "face-laugh-symbolic" }),
|
||||
style_class: "system-status-icon",
|
||||
});
|
||||
this._layoutIndicator.add_child(icon);
|
||||
|
||||
this.settings.bind(
|
||||
"show-layout",
|
||||
this._layoutIndicator,
|
||||
"visible",
|
||||
Gio.SettingsBindFlags.DEFAULT
|
||||
);
|
||||
|
||||
Main.panel.addToStatusArea(indicatorName, this._layoutIndicator);
|
||||
}
|
||||
|
||||
disable() {
|
||||
this._layoutIndicator.destroy();
|
||||
this._layoutIndicator = null;
|
||||
|
||||
this.settings = null;
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user