corrige temperature
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
// extension.js - Point d'entrée principal de l'extension Pilot Control
|
||||
// Compatible avec GNOME Shell 45+
|
||||
|
||||
import GObject from 'gi://GObject';
|
||||
import St from 'gi://St';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
|
||||
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
import {YamlConfig} from './yamlConfig.js';
|
||||
import {PilotWindow} from './ui/pilotWindow.js';
|
||||
import {ServiceManager} from './serviceManager.js';
|
||||
|
||||
/**
|
||||
* Bouton dans le panel GNOME Shell
|
||||
*/
|
||||
const PilotIndicator = GObject.registerClass(
|
||||
class PilotIndicator extends PanelMenu.Button {
|
||||
_init(extension) {
|
||||
super._init(0.0, 'Pilot Control');
|
||||
|
||||
this._extension = extension;
|
||||
this._yamlConfig = new YamlConfig();
|
||||
this._serviceManager = new ServiceManager();
|
||||
this._window = null;
|
||||
|
||||
// Icône dans le panel
|
||||
const icon = new St.Icon({
|
||||
icon_name: 'computer-symbolic',
|
||||
style_class: 'system-status-icon',
|
||||
});
|
||||
this.add_child(icon);
|
||||
|
||||
// Menu items
|
||||
this._buildMenu();
|
||||
|
||||
// Charger la config au démarrage
|
||||
this._loadConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construit le menu déroulant
|
||||
*/
|
||||
_buildMenu() {
|
||||
// Status du service
|
||||
this._statusItem = new PopupMenu.PopupMenuItem('Status: Unknown', {
|
||||
reactive: false,
|
||||
});
|
||||
this.menu.addMenuItem(this._statusItem);
|
||||
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
|
||||
// Bouton pour ouvrir la fenêtre principale
|
||||
const openWindowItem = new PopupMenu.PopupMenuItem('Open Control Panel');
|
||||
openWindowItem.connect('activate', () => {
|
||||
this._openMainWindow();
|
||||
});
|
||||
this.menu.addMenuItem(openWindowItem);
|
||||
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
|
||||
// Actions rapides
|
||||
const startServiceItem = new PopupMenu.PopupMenuItem('Start Service');
|
||||
startServiceItem.connect('activate', () => {
|
||||
this._serviceManager.startService();
|
||||
this._updateStatus();
|
||||
});
|
||||
this.menu.addMenuItem(startServiceItem);
|
||||
|
||||
const stopServiceItem = new PopupMenu.PopupMenuItem('Stop Service');
|
||||
stopServiceItem.connect('activate', () => {
|
||||
this._serviceManager.stopService();
|
||||
this._updateStatus();
|
||||
});
|
||||
this.menu.addMenuItem(stopServiceItem);
|
||||
|
||||
const restartServiceItem = new PopupMenu.PopupMenuItem('Restart Service');
|
||||
restartServiceItem.connect('activate', () => {
|
||||
this._serviceManager.restartService();
|
||||
this._updateStatus();
|
||||
});
|
||||
this.menu.addMenuItem(restartServiceItem);
|
||||
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
|
||||
// Reload config
|
||||
const reloadConfigItem = new PopupMenu.PopupMenuItem('Reload Config');
|
||||
reloadConfigItem.connect('activate', () => {
|
||||
this._loadConfig();
|
||||
Main.notify('Pilot Control', 'Configuration reloaded');
|
||||
});
|
||||
this.menu.addMenuItem(reloadConfigItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge la configuration depuis le fichier YAML
|
||||
*/
|
||||
_loadConfig() {
|
||||
const config = this._yamlConfig.load();
|
||||
if (config) {
|
||||
console.log('Pilot config loaded successfully');
|
||||
this._updateStatus();
|
||||
} else {
|
||||
console.error('Failed to load Pilot config');
|
||||
Main.notify('Pilot Control', 'Failed to load configuration');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le status du service dans le menu
|
||||
*/
|
||||
_updateStatus() {
|
||||
const isActive = this._serviceManager.isServiceActive();
|
||||
const statusText = isActive ? 'Running' : 'Stopped';
|
||||
const statusIcon = isActive ? '🟢' : '🔴';
|
||||
|
||||
this._statusItem.label.text = `Status: ${statusIcon} ${statusText}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ouvre la fenêtre principale de contrôle
|
||||
*/
|
||||
_openMainWindow() {
|
||||
if (this._window && !this._window.is_destroyed) {
|
||||
this._window.present();
|
||||
return;
|
||||
}
|
||||
|
||||
this._window = new PilotWindow(
|
||||
this._extension,
|
||||
this._yamlConfig,
|
||||
this._serviceManager
|
||||
);
|
||||
|
||||
this._window.connect('destroy', () => {
|
||||
this._window = null;
|
||||
});
|
||||
|
||||
this._window.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nettoyage lors de la destruction
|
||||
*/
|
||||
destroy() {
|
||||
if (this._window && !this._window.is_destroyed) {
|
||||
this._window.destroy();
|
||||
}
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Extension principale
|
||||
*/
|
||||
export default class PilotExtension extends Extension {
|
||||
enable() {
|
||||
console.log('Enabling Pilot Control extension');
|
||||
|
||||
this._indicator = new PilotIndicator(this);
|
||||
Main.panel.addToStatusArea(this.uuid, this._indicator);
|
||||
}
|
||||
|
||||
disable() {
|
||||
console.log('Disabling Pilot Control extension');
|
||||
|
||||
if (this._indicator) {
|
||||
this._indicator.destroy();
|
||||
this._indicator = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user