Updates for GNOME 43

This commit is contained in:
Grégory Soutadé 2022-10-27 17:54:37 +02:00
parent d3665f2ff0
commit 4c73986596
3 changed files with 48 additions and 26 deletions

View File

@ -56,7 +56,7 @@ class PicturePopup(GenericMonitor):
popup = GenericMonitorPopup([url_widget, picture_widget])
signals = {
'on-click':'toggle-popup',
# Could also use this behavior
# Could also use this behavior [bugged since GNOME 42]
# 'on-enter':'open-popup',
# 'on-leave':'close-popup',
'on-dblclick':'signal',

View File

@ -24,9 +24,9 @@
https://github.com/bananenfisch/RecentItems/blob/master/extension.js
https://github.com/julio641742/gnome-shell-extension-reference/blob/master/tutorials/POPUPMENU-EXTENSION.md
https://gjs-docs.gnome.org/st10~1.0_api/st.widget
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panelMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/popupMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panel.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/panelMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/popupMenu.js
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/panel.js
*/
const St = imports.gi.St;
@ -56,16 +56,17 @@ function log(message) {
class SignalMgt {
constructor(item, name, group, dbus, menu) {
constructor(item, name, group, dbus, buttonMenu) {
this.name = name;
this.group = group;
this.fullname = this.name + '@' + this.group;
this.dbus = dbus;
this.menu = menu;
this.buttonMenu = buttonMenu;
this.signals = new WeakMap();
this.widgets = new Array();
this.timeouts = new Array();
this.menuOpen = false;
this.nbClicks = 0;
this.button = -1;
@ -118,23 +119,40 @@ class SignalMgt {
this.signals.set(widget, null);
}
toggleMenu() {
if (this.menuOpen)
{
this.buttonMenu.menu.close();
this.menuOpen = false;
}
else
{
this.buttonMenu.menu.open(true);
this.menuOpen = true;
}
}
_manageEventAction(action, signalName) {
if (action === 'open-popup')
this.menu.open(true);
{
this.buttonMenu.menu.open(true);
this.menuOpen = true;
}
else if (action === 'close-popup')
this.menu.close();
{
this.buttonMenu.menu.close();
this.menuOpen = false;
}
else if (action === 'toggle-popup')
this.menu.toggle();
else if (action == 'delete')
{
this.toggleMenu();
}
else if (action === 'delete')
this.dbus.deleteItem(this, this.group);
else if (action === 'signal')
this.dbus.emitSignal(signalName, this.fullname);
return Clutter.EVENT_PROPAGATE;
}
_manageLeaveEvent() {
this._manageEventAction(this.onLeave);
return Clutter.EVENT_STOP;
}
_doClickCallback() {
@ -229,7 +247,8 @@ class MonitorWidget extends PanelMenu.Button {
this.group = group;
this.fullname = this.name + '@' + this.group;
this.dbus = dbus;
this.signalManager = new SignalMgt(item, this.name, group, dbus, this.menu);
this.menuItem = null;
this.signalManager = new SignalMgt(item, this.name, group, dbus, this);
this.popup_signals = null;
this.popup_widgets = null;
@ -414,7 +433,7 @@ class MonitorWidget extends PanelMenu.Button {
const name = hashGet(nestedItem, 'name', '');
this.popup_signals[widget] = new SignalMgt(nestedItem, name,
this.fullname, this.dbus,
this.menu);
this);
this.popup_signals[widget].connectWidgetSignals(widget);
this.popup_widgets.push(widget);
}
@ -791,15 +810,19 @@ class Extension {
}
}
const extension = new Extension();
let extension = null;
function init() {
}
function enable() {
extension = new Extension();
extension.enable();
}
function disable() {
extension.disable();
if (extension) {
extension.disable();
extension = null;
}
}

View File

@ -2,13 +2,12 @@
"uuid": "generic-monitor@gnome-shell-extensions",
"name": "Generic Monitor",
"description": "Display text & icon on systray using DBUS",
"version": "10",
"version": "11",
"shell-version": [
"42",
"41",
"40",
"3.38",
"3.36"
"43",
"42.3",
"42",
"41"
],
"url": "http://indefero.soutade.fr/p/genericmonitor"
}