diff --git a/extra-extensions-0004-Add-custom-menu-extension.patch b/extra-extensions-0004-Add-custom-menu-extension.patch index d05215b..008fe81 100644 --- a/extra-extensions-0004-Add-custom-menu-extension.patch +++ b/extra-extensions-0004-Add-custom-menu-extension.patch @@ -1,15 +1,15 @@ -From 9eb73513d7d31fd193e15c53f79c7e3a6aee71da Mon Sep 17 00:00:00 2001 +From 99754dff35dcb2db5eb44271f3bc9ca022cd76e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 12 Jan 2023 19:43:52 +0100 Subject: [PATCH 4/5] Add custom-menu extension --- extensions/custom-menu/config.js | 445 ++++++++++++++++++++++++ - extensions/custom-menu/extension.js | 201 +++++++++++ + extensions/custom-menu/extension.js | 214 ++++++++++++ extensions/custom-menu/meson.build | 7 + extensions/custom-menu/metadata.json.in | 10 + meson.build | 1 + - 5 files changed, 664 insertions(+) + 5 files changed, 677 insertions(+) create mode 100644 extensions/custom-menu/config.js create mode 100644 extensions/custom-menu/extension.js create mode 100644 extensions/custom-menu/meson.build @@ -17,7 +17,7 @@ Subject: [PATCH 4/5] Add custom-menu extension diff --git a/extensions/custom-menu/config.js b/extensions/custom-menu/config.js new file mode 100644 -index 00000000..d08e3201 +index 00000000..e43195d8 --- /dev/null +++ b/extensions/custom-menu/config.js @@ -0,0 +1,445 @@ @@ -177,8 +177,8 @@ index 00000000..d08e3201 + +/** + * This cache is used to reduce detector cost. -+ * Each time creating an item, it check if the result of this detector is cached, -+ * which prevent the togglers from running detector on each creation. ++ * Each time creating an item, it check if the result of this detector is cached, ++ * which prevent the togglers from running detector on each creation. + * This is useful especially in search mode. + */ +let _toggler_state_cache = { }; @@ -451,7 +451,7 @@ index 00000000..d08e3201 + "entries": [ { + "type": "launcher", + "title": "Edit menu", -+ "command": "gedit $HOME/.entries.json" ++ "command": "gnome-text-editor $HOME/.entries.json" + } ] + }, null, 4); + let fileConfig = Gio.File.new_for_path(filename); @@ -468,10 +468,10 @@ index 00000000..d08e3201 +} diff --git a/extensions/custom-menu/extension.js b/extensions/custom-menu/extension.js new file mode 100644 -index 00000000..9edbc548 +index 00000000..5868ebb7 --- /dev/null +++ b/extensions/custom-menu/extension.js -@@ -0,0 +1,201 @@ +@@ -0,0 +1,214 @@ +/* extension.js + * + * This program is free software: you can redistribute it and/or modify @@ -502,7 +502,7 @@ index 00000000..9edbc548 +import GObject from 'gi://GObject'; +import St from 'gi://St'; + -+import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; ++import {Extension, InjectionManager, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; + +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as BackgroundMenu from 'resource:///org/gnome/shell/ui/backgroundMenu.js'; @@ -515,9 +515,6 @@ index 00000000..9edbc548 +const LOGGER_WARNING = 1; +const LOGGER_ERROR = 2; + -+const {BackgroundMenu: OriginalBackgroundMenu} = BackgroundMenu; -+ -+ +class CustomMenu extends PopupMenu.PopupMenu { + constructor(sourceActor) { + super(sourceActor, 0.0, St.Side.TOP, 0); @@ -552,7 +549,7 @@ index 00000000..9edbc548 + + this.actor.add_style_class_name('background-menu'); + -+ layoutManager.uiGroup.add_actor(this.actor); ++ layoutManager.uiGroup.add_child(this.actor); + this.actor.hide(); + + this.connect('open-state-changed', (menu, open) => { @@ -623,7 +620,7 @@ index 00000000..9edbc548 + + _initGnomeLog() { + this.log = function(s) { -+ global.log("custom-menu-panel> " + s); ++ console.log("custom-menu-panel> " + s); + }; + } + @@ -663,13 +660,29 @@ index 00000000..9edbc548 +} /**/ + +export default class CustomMenuExtension extends Extension { ++ constructor(metadata) { ++ super(metadata); ++ ++ this._injectionManager = new InjectionManager(); ++ } ++ + enable() { -+ BackgroundMenu.BackgroundMenu = CustomBackgroundMenu; ++ this._injectionManager.overrideMethod(Main.layoutManager, '_addBackgroundMenu', ++ () => { ++ return function (bgManager) { ++ const actor = bgManager.backgroundActor; ++ BackgroundMenu.addBackgroundMenu(actor, this); ++ ++ actor._backgroundMenu.destroy(); ++ actor._backgroundMenu = new CustomBackgroundMenu(this); ++ actor._backgroundManager.addMenu(actor._backgroundMenu); ++ }; ++ }); + Main.layoutManager._updateBackgrounds(); + } + + disable() { -+ BackgroundMenu.BackgroundMenu = OriginalBackgroundMenu; ++ this._injectionManager.clear(); + Main.layoutManager._updateBackgrounds(); + } +} /**/