|
|
@ -1,7 +1,7 @@
|
|
|
|
From ce63b1027e8bf79688f38babecae0dcd867778f8 Mon Sep 17 00:00:00 2001
|
|
|
|
From 6623a374036e0f2458d4b36e268f6e4dcc19a2d7 Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
Date: Wed, 20 May 2015 17:44:50 +0200
|
|
|
|
Date: Wed, 20 May 2015 17:44:50 +0200
|
|
|
|
Subject: [PATCH 1/6] Add top-icons extension
|
|
|
|
Subject: [PATCH 1/7] Add top-icons extension
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
extensions/top-icons/extension.js | 96 +++++++++++++++++++++++++++
|
|
|
|
extensions/top-icons/extension.js | 96 +++++++++++++++++++++++++++
|
|
|
@ -152,7 +152,7 @@ index 00000000..25134b65
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+/* This extensions requires no special styling */
|
|
|
|
+/* This extensions requires no special styling */
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
index 188e19e5..1d94882f 100644
|
|
|
|
index 41a7e99d..f754767c 100644
|
|
|
|
--- a/meson.build
|
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
@@ -45,6 +45,7 @@ all_extensions = default_extensions
|
|
|
|
@@ -45,6 +45,7 @@ all_extensions = default_extensions
|
|
|
@ -164,13 +164,13 @@ index 188e19e5..1d94882f 100644
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.33.1
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From 40aa60ef32f9283147745ac960e7e22b2d608df5 Mon Sep 17 00:00:00 2001
|
|
|
|
From a38891b5a6b0ba51998298963988bf146b2e1f86 Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
Date: Wed, 20 May 2015 18:05:41 +0200
|
|
|
|
Date: Wed, 20 May 2015 18:05:41 +0200
|
|
|
|
Subject: [PATCH 2/6] Add dash-to-dock extension
|
|
|
|
Subject: [PATCH 2/7] Add dash-to-dock extension
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
extensions/dash-to-dock/Settings.ui | 2660 +++++++++++++++++
|
|
|
|
extensions/dash-to-dock/Settings.ui | 2660 +++++++++++++++++
|
|
|
@ -29865,7 +29865,7 @@ index 00000000..8cb14b88
|
|
|
|
+});
|
|
|
|
+});
|
|
|
|
\ No newline at end of file
|
|
|
|
\ No newline at end of file
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
index 1d94882f..e3a64a92 100644
|
|
|
|
index f754767c..e3d94918 100644
|
|
|
|
--- a/meson.build
|
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
@@ -44,6 +44,7 @@ default_extensions += [
|
|
|
|
@@ -44,6 +44,7 @@ default_extensions += [
|
|
|
@ -44398,13 +44398,13 @@ index 6a40e212..14e60ccb 100644
|
|
|
|
+#~ msgid "0.000"
|
|
|
|
+#~ msgid "0.000"
|
|
|
|
+#~ msgstr "0.000"
|
|
|
|
+#~ msgstr "0.000"
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.33.1
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From 7bcecaa3b0532221690b8cb0df5184a80ed15dd5 Mon Sep 17 00:00:00 2001
|
|
|
|
From 6cad2aac52022030bcbbf03066fc08937f6d177f Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
Date: Wed, 20 May 2015 18:55:47 +0200
|
|
|
|
Date: Wed, 20 May 2015 18:55:47 +0200
|
|
|
|
Subject: [PATCH 3/6] Add panel-favorites extension
|
|
|
|
Subject: [PATCH 3/7] Add panel-favorites extension
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
extensions/panel-favorites/extension.js | 257 ++++++++++++++++++++
|
|
|
|
extensions/panel-favorites/extension.js | 257 ++++++++++++++++++++
|
|
|
@ -44729,7 +44729,7 @@ index 00000000..120adacb
|
|
|
|
+ -y-offset: 6px;
|
|
|
|
+ -y-offset: 6px;
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
index e3a64a92..47b6c46c 100644
|
|
|
|
index e3d94918..12706001 100644
|
|
|
|
--- a/meson.build
|
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
@@ -46,6 +46,7 @@ all_extensions += [
|
|
|
|
@@ -46,6 +46,7 @@ all_extensions += [
|
|
|
@ -44741,13 +44741,13 @@ index e3a64a92..47b6c46c 100644
|
|
|
|
'user-theme'
|
|
|
|
'user-theme'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.33.1
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From 7a4402c27a93cfff76504f561013498f31966da8 Mon Sep 17 00:00:00 2001
|
|
|
|
From dbd3ebbb2d3cf380f2c0a13f13618fedfd8bbad4 Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
Date: Fri, 4 Mar 2016 17:07:21 +0100
|
|
|
|
Date: Fri, 4 Mar 2016 17:07:21 +0100
|
|
|
|
Subject: [PATCH 4/6] Add updates-dialog extension
|
|
|
|
Subject: [PATCH 4/7] Add updates-dialog extension
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
extensions/updates-dialog/extension.js | 504 ++++++++++++++++++
|
|
|
|
extensions/updates-dialog/extension.js | 504 ++++++++++++++++++
|
|
|
@ -45347,7 +45347,7 @@ index 00000000..25134b65
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+/* This extensions requires no special styling */
|
|
|
|
+/* This extensions requires no special styling */
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
index 47b6c46c..c54ef777 100644
|
|
|
|
index 12706001..c609ae52 100644
|
|
|
|
--- a/meson.build
|
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
@@ -48,6 +48,7 @@ all_extensions += [
|
|
|
|
@@ -48,6 +48,7 @@ all_extensions += [
|
|
|
@ -45372,13 +45372,13 @@ index 0ed12762..10b1d517 100644
|
|
|
|
extensions/window-list/extension.js
|
|
|
|
extensions/window-list/extension.js
|
|
|
|
extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
|
|
|
|
extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.33.1
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From d04e5acf2bf6076aeca3c2da27c8edfdd5098606 Mon Sep 17 00:00:00 2001
|
|
|
|
From 5de33c69acd297659ac3182e85f0fe32771dd75e Mon Sep 17 00:00:00 2001
|
|
|
|
From: Carlos Soriano <csoriano@gnome.org>
|
|
|
|
From: Carlos Soriano <csoriano@gnome.org>
|
|
|
|
Date: Mon, 13 Aug 2018 17:28:41 +0200
|
|
|
|
Date: Mon, 13 Aug 2018 17:28:41 +0200
|
|
|
|
Subject: [PATCH 5/6] Add desktop icons extension
|
|
|
|
Subject: [PATCH 5/7] Add desktop icons extension
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
.../desktop-icons/createFolderDialog.js | 165 +++
|
|
|
|
.../desktop-icons/createFolderDialog.js | 165 +++
|
|
|
@ -56921,7 +56921,7 @@ index 00000000..a468f4ab
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
index c54ef777..08213618 100644
|
|
|
|
index c609ae52..b83f0795 100644
|
|
|
|
--- a/meson.build
|
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
@@ -28,6 +28,7 @@ uuid_suffix = '@gnome-shell-extensions.gcampax.github.com'
|
|
|
|
@@ -28,6 +28,7 @@ uuid_suffix = '@gnome-shell-extensions.gcampax.github.com'
|
|
|
@ -66729,13 +66729,13 @@ index 14e60ccb..4bdf7154 100644
|
|
|
|
+#~ msgid "Huge"
|
|
|
|
+#~ msgid "Huge"
|
|
|
|
+#~ msgstr "巨大圖示"
|
|
|
|
+#~ msgstr "巨大圖示"
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.33.1
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From 01a4309a2574768c037f14732e8595c1f436170f Mon Sep 17 00:00:00 2001
|
|
|
|
From 794dd76a7b7caf3324736de6c26bb992fe403daf Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
Date: Thu, 2 Dec 2021 19:39:50 +0100
|
|
|
|
Date: Thu, 2 Dec 2021 19:39:50 +0100
|
|
|
|
Subject: [PATCH 6/6] Add classification-banner
|
|
|
|
Subject: [PATCH 6/7] Add classification-banner
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
---
|
|
|
|
extensions/classification-banner/adwShim.js | 202 ++++++++++++++++++
|
|
|
|
extensions/classification-banner/adwShim.js | 202 ++++++++++++++++++
|
|
|
@ -67417,7 +67417,7 @@ index 00000000..fb6a697e
|
|
|
|
+.classification-message { font-weight: bold; }
|
|
|
|
+.classification-message { font-weight: bold; }
|
|
|
|
+.classification-banner { font-size: 0.9em; }
|
|
|
|
+.classification-banner { font-size: 0.9em; }
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
index 08213618..dea0a409 100644
|
|
|
|
index b83f0795..c71636cb 100644
|
|
|
|
--- a/meson.build
|
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
+++ b/meson.build
|
|
|
|
@@ -45,6 +45,7 @@ default_extensions += [
|
|
|
|
@@ -45,6 +45,7 @@ default_extensions += [
|
|
|
@ -67429,5 +67429,789 @@ index 08213618..dea0a409 100644
|
|
|
|
'native-window-placement',
|
|
|
|
'native-window-placement',
|
|
|
|
'panel-favorites',
|
|
|
|
'panel-favorites',
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.33.1
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From 4cde1aa62f4605cde761c9f0f2f95af64515720d Mon Sep 17 00:00:00 2001
|
|
|
|
|
|
|
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
|
|
|
|
|
Date: Thu, 12 Jan 2023 19:43:52 +0100
|
|
|
|
|
|
|
|
Subject: [PATCH 7/7] Add custom-menu extension
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
extensions/custom-menu/config.js | 484 ++++++++++++++++++++++++
|
|
|
|
|
|
|
|
extensions/custom-menu/extension.js | 217 +++++++++++
|
|
|
|
|
|
|
|
extensions/custom-menu/meson.build | 7 +
|
|
|
|
|
|
|
|
extensions/custom-menu/metadata.json.in | 10 +
|
|
|
|
|
|
|
|
extensions/custom-menu/stylesheet.css | 1 +
|
|
|
|
|
|
|
|
meson.build | 1 +
|
|
|
|
|
|
|
|
6 files changed, 720 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
|
|
|
|
|
|
|
|
create mode 100644 extensions/custom-menu/metadata.json.in
|
|
|
|
|
|
|
|
create mode 100644 extensions/custom-menu/stylesheet.css
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/extensions/custom-menu/config.js b/extensions/custom-menu/config.js
|
|
|
|
|
|
|
|
new file mode 100644
|
|
|
|
|
|
|
|
index 00000000..652c0223
|
|
|
|
|
|
|
|
--- /dev/null
|
|
|
|
|
|
|
|
+++ b/extensions/custom-menu/config.js
|
|
|
|
|
|
|
|
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
+const Gio = imports.gi.Gio;
|
|
|
|
|
|
|
|
+const GLib = imports.gi.GLib;
|
|
|
|
|
|
|
|
+const Json = imports.gi.Json;
|
|
|
|
|
|
|
|
+const Lang = imports.lang;
|
|
|
|
|
|
|
|
+const Main = imports.ui.main;
|
|
|
|
|
|
|
|
+const PopupMenu = imports.ui.popupMenu;
|
|
|
|
|
|
|
|
+const ByteArray = imports.byteArray;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
|
|
|
|
|
|
+const getLogger = Me.imports.extension.getLogger;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const Entry = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'Entry',
|
|
|
|
|
|
|
|
+ Abstract: true,
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(prop) {
|
|
|
|
|
|
|
|
+ this.type = prop.type;
|
|
|
|
|
|
|
|
+ this.title = prop.title || "";
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.__vars = prop.__vars || [];
|
|
|
|
|
|
|
|
+ this.updateEnv(prop);
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ setTitle: function(text) {
|
|
|
|
|
|
|
|
+ this.item.label.get_clutter_text().set_text(text);
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ updateEnv: function(prop) {
|
|
|
|
|
|
|
|
+ this.__env = {}
|
|
|
|
|
|
|
|
+ if(!this.__vars) return;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ for(let i in this.__vars) {
|
|
|
|
|
|
|
|
+ let v = this.__vars[i];
|
|
|
|
|
|
|
|
+ this.__env[v] = prop[v] ? String(prop[v]) : "";
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ // the pulse function should be read as "a pulse arrives"
|
|
|
|
|
|
|
|
+ pulse: function() { },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _try_destroy: function() {
|
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
|
|
|
+ if(this.item && this.item.destroy)
|
|
|
|
|
|
|
|
+ this.item.destroy();
|
|
|
|
|
|
|
|
+ } catch(e) { /* Ignore all errors during destory*/ }
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const DerivedEntry = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'DerivedEntry',
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(prop) {
|
|
|
|
|
|
|
|
+ if(!prop.base)
|
|
|
|
|
|
|
|
+ throw new Error("Base entry not specified in type definition.");
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.base = prop.base;
|
|
|
|
|
|
|
|
+ this.vars = prop.vars || [];
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ delete prop.base;
|
|
|
|
|
|
|
|
+ delete prop.vars;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.prop = prop;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ createInstance: function(addit_prop) {
|
|
|
|
|
|
|
|
+ let cls = type_map[this.base];
|
|
|
|
|
|
|
|
+ if(!cls) throw new Error("Bad base class.");
|
|
|
|
|
|
|
|
+ if(cls.createInstance) throw new Error("Not allowed to derive from dervied types");
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ for(let rp in this.prop)
|
|
|
|
|
|
|
|
+ addit_prop[rp] = this.prop[rp];
|
|
|
|
|
|
|
|
+ addit_prop.__vars = this.vars;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ let instance = new cls(addit_prop);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ return instance;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
|
|
|
+ * callback: function (stdout, stderr, exit_status) { }
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+let __pipeOpenQueue = [];
|
|
|
|
|
|
|
|
+let __pipeExecTimer = null;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+function pipeOpen(cmdline, env, callback) {
|
|
|
|
|
|
|
|
+ let param = [cmdline, env, callback]
|
|
|
|
|
|
|
|
+ __pipeOpenQueue.push(param);
|
|
|
|
|
|
|
|
+ if(__pipeExecTimer === null) {
|
|
|
|
|
|
|
|
+ __pipeExecTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 50,
|
|
|
|
|
|
|
|
+ function() {
|
|
|
|
|
|
|
|
+ let param = __pipeOpenQueue.shift();
|
|
|
|
|
|
|
|
+ if(param === undefined) {
|
|
|
|
|
|
|
|
+ __pipeExecTimer = null;
|
|
|
|
|
|
|
|
+ return false;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if(realPipeOpen) realPipeOpen(param[0], param[1], param[2]);
|
|
|
|
|
|
|
|
+ return true;
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+function realPipeOpen(cmdline, env, callback) {
|
|
|
|
|
|
|
|
+ let user_cb = callback;
|
|
|
|
|
|
|
|
+ let proc;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ function wait_cb(_, _res) {
|
|
|
|
|
|
|
|
+ let stdout_pipe = proc.get_stdout_pipe();
|
|
|
|
|
|
|
|
+ let stderr_pipe = proc.get_stderr_pipe();
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ let stdout_content;
|
|
|
|
|
|
|
|
+ let stderr_content;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ // Only the first GLib.MAXINT16 characters are fetched for optimization.
|
|
|
|
|
|
|
|
+ stdout_pipe.read_bytes_async(GLib.MAXINT16, 0, null, function(osrc, ores) {
|
|
|
|
|
|
|
|
+ stdout_content = ByteArray.toString(stdout_pipe.read_bytes_finish(ores).get_data());
|
|
|
|
|
|
|
|
+ stdout_pipe.close(null);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ stderr_pipe.read_bytes_async(GLib.MAXINT16, 0, null, function(esrc, eres) {
|
|
|
|
|
|
|
|
+ stderr_content = ByteArray.toString(stderr_pipe.read_bytes_finish(eres).get_data());
|
|
|
|
|
|
|
|
+ stderr_pipe.close(null);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ user_cb(stdout_content, stderr_content, proc.get_exit_status());
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if(user_cb) {
|
|
|
|
|
|
|
|
+ let _pipedLauncher = new Gio.SubprocessLauncher({
|
|
|
|
|
|
|
|
+ flags:
|
|
|
|
|
|
|
|
+ Gio.SubprocessFlags.STDERR_PIPE |
|
|
|
|
|
|
|
|
+ Gio.SubprocessFlags.STDOUT_PIPE
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ for(let key in env) {
|
|
|
|
|
|
|
|
+ _pipedLauncher.setenv(key, env[key], true);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ proc = _pipedLauncher.spawnv(['bash', '-c', cmdline]);
|
|
|
|
|
|
|
|
+ proc.wait_async(null, wait_cb);
|
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
|
|
|
+ // Detached launcher is used to spawn commands that we are not concerned
|
|
|
|
|
|
|
|
+ // about its result.
|
|
|
|
|
|
|
|
+ let _detacLauncher = new Gio.SubprocessLauncher();
|
|
|
|
|
|
|
|
+ for(let key in env) {
|
|
|
|
|
|
|
|
+ _detacLauncher.setenv(key, env[key], true);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ proc = _detacLauncher.spawnv(['bash', '-c', cmdline]);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ getLogger().info("Spawned " + cmdline);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ // log(`Spawning ${cmdline}`); TODO: BEN
|
|
|
|
|
|
|
|
+ return proc.get_identifier();
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+function _generalSpawn(command, env, title) {
|
|
|
|
|
|
|
|
+ title = title || "Process";
|
|
|
|
|
|
|
|
+ pipeOpen(command, env, function(stdout, stderr, exit_status) {
|
|
|
|
|
|
|
|
+ if(exit_status != 0) {
|
|
|
|
|
|
|
|
+ log
|
|
|
|
|
|
|
|
+ getLogger().warning(stderr);
|
|
|
|
|
|
|
|
+ getLogger().notify("proc", title +
|
|
|
|
|
|
|
|
+ " exited with status " + exit_status, stderr);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+function quoteShellArg(arg) {
|
|
|
|
|
|
|
|
+ arg = arg.replace(/'/g, "'\"'\"'");
|
|
|
|
|
|
|
|
+ return "'" + arg + "'";
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+// 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. This is useful especially in search
|
|
|
|
|
|
|
|
+// mode.
|
|
|
|
|
|
|
|
+let _toggler_state_cache = { };
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const TogglerEntry = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'TogglerEntry',
|
|
|
|
|
|
|
|
+ Extends: Entry,
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(prop) {
|
|
|
|
|
|
|
|
+ this.parent(prop);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.command_on = prop.command_on || "";
|
|
|
|
|
|
|
|
+ this.command_off = prop.command_off || "";
|
|
|
|
|
|
|
|
+ this.detector = prop.detector || "";
|
|
|
|
|
|
|
|
+ this.auto_on = prop.auto_on || false;
|
|
|
|
|
|
|
|
+ this.notify_when = prop.notify_when || [];
|
|
|
|
|
|
|
|
+ // if the switch is manually turned off, auto_on is disabled.
|
|
|
|
|
|
|
|
+ this._manually_switched_off = false;
|
|
|
|
|
|
|
|
+ this.pulse(); // load initial state
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ createItem: function() {
|
|
|
|
|
|
|
|
+ this._try_destroy();
|
|
|
|
|
|
|
|
+ this.item = new PopupMenu.PopupSwitchMenuItem(this.title, false);
|
|
|
|
|
|
|
|
+ this.item.label.get_clutter_text().set_use_markup(true);
|
|
|
|
|
|
|
|
+ this.item.connect('toggled', Lang.bind(this, this._onManuallyToggled));
|
|
|
|
|
|
|
|
+ this._loadState();
|
|
|
|
|
|
|
|
+ return this.item;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _onManuallyToggled: function(_, state) {
|
|
|
|
|
|
|
|
+ // when switched on again, this flag will get cleared.
|
|
|
|
|
|
|
|
+ this._manually_switched_off = !state;
|
|
|
|
|
|
|
|
+ this._storeState(state);
|
|
|
|
|
|
|
|
+ this._onToggled(state);
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _onToggled: function(state) {
|
|
|
|
|
|
|
|
+ if(state)
|
|
|
|
|
|
|
|
+ _generalSpawn(this.command_on, this.__env, this.title);
|
|
|
|
|
|
|
|
+ else
|
|
|
|
|
|
|
|
+ _generalSpawn(this.command_off, this.__env, this.title);
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _detect: function(callback) {
|
|
|
|
|
|
|
|
+ // abort detecting if detector is an empty string
|
|
|
|
|
|
|
|
+ if(!this.detector)
|
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ pipeOpen(this.detector, this.__env, function(out) {
|
|
|
|
|
|
|
|
+ out = String(out);
|
|
|
|
|
|
|
|
+ callback(!Boolean(out.match(/^\s*$/)));
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ compareState: function(new_state) {
|
|
|
|
|
|
|
|
+ // compare the new state with cached state
|
|
|
|
|
|
|
|
+ // notify when state is different
|
|
|
|
|
|
|
|
+ let old_state = _toggler_state_cache[this.detector];
|
|
|
|
|
|
|
|
+ if(old_state === undefined) return;
|
|
|
|
|
|
|
|
+ if(old_state == new_state) return;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if(this.notify_when.indexOf(new_state ? "on" : "off") >= 0) {
|
|
|
|
|
|
|
|
+ let not_str = this.title + (new_state ? " started." : " stopped.");
|
|
|
|
|
|
|
|
+ if(!new_state && this.auto_on)
|
|
|
|
|
|
|
|
+ not_str += " Attempt to restart it now.";
|
|
|
|
|
|
|
|
+ getLogger().notify("state", not_str);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _storeState: function(state) {
|
|
|
|
|
|
|
|
+ let hash = JSON.stringify({ env: this.__env, detector: this.detector });
|
|
|
|
|
|
|
|
+ _toggler_state_cache[hash] = state;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _loadState: function() {
|
|
|
|
|
|
|
|
+ let hash = JSON.stringify({ env: this.__env, detector: this.detector });
|
|
|
|
|
|
|
|
+ let state = _toggler_state_cache[hash];
|
|
|
|
|
|
|
|
+ if(state !== undefined)
|
|
|
|
|
|
|
|
+ this.item.setToggleState(state); // doesn't emit 'toggled'
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ pulse: function() {
|
|
|
|
|
|
|
|
+ this._detect(Lang.bind(this, function(state) {
|
|
|
|
|
|
|
|
+ this.compareState(state);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this._storeState(state);
|
|
|
|
|
|
|
|
+ this._loadState();
|
|
|
|
|
|
|
|
+ //global.log(this.title + ': ' + this._manually_switched_off);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if(!state && !this._manually_switched_off && this.auto_on)
|
|
|
|
|
|
|
|
+ // do not call setToggleState here, because command_on may fail
|
|
|
|
|
|
|
|
+ this._onToggled(this.item, true);
|
|
|
|
|
|
|
|
+ }));
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ perform: function() {
|
|
|
|
|
|
|
|
+ this.item.toggle();
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const LauncherEntry = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'LauncherEntry',
|
|
|
|
|
|
|
|
+ Extends: Entry,
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(prop) {
|
|
|
|
|
|
|
|
+ this.parent(prop);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.command = prop.command || "";
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ createItem: function() {
|
|
|
|
|
|
|
|
+ this._try_destroy();
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.item = new PopupMenu.PopupMenuItem(this.title);
|
|
|
|
|
|
|
|
+ this.item.label.get_clutter_text().set_use_markup(true);
|
|
|
|
|
|
|
|
+ this.item.connect('activate', Lang.bind(this, this._onClicked));
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ return this.item;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _onClicked: function(_) {
|
|
|
|
|
|
|
|
+ _generalSpawn(this.command, this.__env, this.title);
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ perform: function() {
|
|
|
|
|
|
|
|
+ this.item.emit('activate');
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const SubMenuEntry = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'SubMenuEntry',
|
|
|
|
|
|
|
|
+ Extends: Entry,
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(prop) {
|
|
|
|
|
|
|
|
+ this.parent(prop)
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if(prop.entries == undefined)
|
|
|
|
|
|
|
|
+ throw new Error("Expected entries provided in submenu entry.");
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.entries = [];
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ for(let i in prop.entries) {
|
|
|
|
|
|
|
|
+ let entry_prop = prop.entries[i];
|
|
|
|
|
|
|
|
+ let entry = createEntry(entry_prop);
|
|
|
|
|
|
|
|
+ this.entries.push(entry);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ createItem: function() {
|
|
|
|
|
|
|
|
+ this._try_destroy();
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.item = new PopupMenu.PopupSubMenuMenuItem(this.title);
|
|
|
|
|
|
|
|
+ this.item.label.get_clutter_text().set_use_markup(true);
|
|
|
|
|
|
|
|
+ for(let i in this.entries) {
|
|
|
|
|
|
|
|
+ let entry = this.entries[i];
|
|
|
|
|
|
|
|
+ this.item.menu.addMenuItem(entry.createItem());
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ return this.item;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ pulse: function() {
|
|
|
|
|
|
|
|
+ for(let i in this.entries) {
|
|
|
|
|
|
|
|
+ let entry = this.entries[i];
|
|
|
|
|
|
|
|
+ entry.pulse();
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const SeparatorEntry = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'SeparatorEntry',
|
|
|
|
|
|
|
|
+ Extends: Entry,
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(prop) { },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ createItem: function() {
|
|
|
|
|
|
|
|
+ this._try_destroy();
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.item = new PopupMenu.PopupSeparatorMenuItem(this.title);
|
|
|
|
|
|
|
|
+ this.item.label.get_clutter_text().set_use_markup(true);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ return this.item;
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+let type_map = {};
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
+// Config Loader loads config from JSON file.
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+// convert Json Nodes (GLib based) to native javascript value.
|
|
|
|
|
|
|
|
+function convertJson(node) {
|
|
|
|
|
|
|
|
+ if(node.get_node_type() == Json.NodeType.VALUE)
|
|
|
|
|
|
|
|
+ return node.get_value();
|
|
|
|
|
|
|
|
+ if(node.get_node_type() == Json.NodeType.OBJECT) {
|
|
|
|
|
|
|
|
+ let obj = {}
|
|
|
|
|
|
|
|
+ node.get_object().foreach_member(function(_, k, v_n) {
|
|
|
|
|
|
|
|
+ obj[k] = convertJson(v_n);
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ return obj;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if(node.get_node_type() == Json.NodeType.ARRAY) {
|
|
|
|
|
|
|
|
+ let arr = []
|
|
|
|
|
|
|
|
+ node.get_array().foreach_element(function(_, i, elem) {
|
|
|
|
|
|
|
|
+ arr.push(convertJson(elem));
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ return arr;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ return null;
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+//
|
|
|
|
|
|
|
|
+function createEntry(entry_prop) {
|
|
|
|
|
|
|
|
+ if(!entry_prop.type)
|
|
|
|
|
|
|
|
+ throw new Error("No type specified in entry.");
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ let cls = type_map[entry_prop.type];
|
|
|
|
|
|
|
|
+ if(!cls)
|
|
|
|
|
|
|
|
+ throw new Error("Incorrect type '" + entry_prop.type + "'");
|
|
|
|
|
|
|
|
+ else if(cls.createInstance)
|
|
|
|
|
|
|
|
+ return cls.createInstance(entry_prop);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ return new cls(entry_prop);
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+var Loader = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'ConfigLoader',
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(filename) {
|
|
|
|
|
|
|
|
+ if(filename)
|
|
|
|
|
|
|
|
+ this.loadConfig(filename);
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ loadConfig: function(filename) {
|
|
|
|
|
|
|
|
+ // reset type_map everytime load the config
|
|
|
|
|
|
|
|
+ type_map = {
|
|
|
|
|
|
|
|
+ launcher: LauncherEntry,
|
|
|
|
|
|
|
|
+ toggler: TogglerEntry,
|
|
|
|
|
|
|
|
+ submenu: SubMenuEntry,
|
|
|
|
|
|
|
|
+ separator: SeparatorEntry
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ type_map.systemd = new DerivedEntry({
|
|
|
|
|
|
|
|
+ base: 'toggler',
|
|
|
|
|
|
|
|
+ vars: ['unit'],
|
|
|
|
|
|
|
|
+ command_on: "pkexec systemctl start ${unit}",
|
|
|
|
|
|
|
|
+ command_off: "pkexec systemctl stop ${unit}",
|
|
|
|
|
|
|
|
+ detector: "systemctl status ${unit} | grep Active:\\\\s\\*activ[ei]",
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ type_map.tmux = new DerivedEntry({
|
|
|
|
|
|
|
|
+ base: 'toggler',
|
|
|
|
|
|
|
|
+ vars: ['command', 'session'],
|
|
|
|
|
|
|
|
+ command_on: 'tmux new -d -s ${session} bash -c "${command}"',
|
|
|
|
|
|
|
|
+ command_off: 'tmux kill-session -t ${session}',
|
|
|
|
|
|
|
|
+ detector: 'tmux has -t "${session}" 2>/dev/null && echo yes',
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
|
|
|
+ * Refer to README file for detailed config file format.
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+ this.entries = []; // CAUTION: remove all entries.
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ let config_parser = new Json.Parser();
|
|
|
|
|
|
|
|
+ config_parser.load_from_file(filename);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ let conf = convertJson(config_parser.get_root());
|
|
|
|
|
|
|
|
+ if (conf.entries == undefined)
|
|
|
|
|
|
|
|
+ throw new Error("Key 'entries' not found.");
|
|
|
|
|
|
|
|
+ if (conf.deftype) {
|
|
|
|
|
|
|
|
+ for (let tname in conf.deftype) {
|
|
|
|
|
|
|
|
+ if (type_map[tname])
|
|
|
|
|
|
|
|
+ throw new Error("Type \""+tname+"\" duplicated.");
|
|
|
|
|
|
|
|
+ type_map[tname] = new DerivedEntry(conf.deftype[tname]);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ for (let conf_i in conf.entries) {
|
|
|
|
|
|
|
|
+ let entry_prop = conf.entries[conf_i];
|
|
|
|
|
|
|
|
+ this.entries.push(createEntry(entry_prop));
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ saveDefaultConfig: function(filename) {
|
|
|
|
|
|
|
|
+ // Write default config
|
|
|
|
|
|
|
|
+ const PERMISSIONS_MODE = 0o640;
|
|
|
|
|
|
|
|
+ const jsonString = JSON.stringify({
|
|
|
|
|
|
|
|
+ "_homepage_": "https://github.com/andreabenini/gnome-plugin.custom-menu-panel",
|
|
|
|
|
|
|
|
+ "_examples_": "https://github.com/andreabenini/gnome-plugin.custom-menu-panel/tree/main/examples",
|
|
|
|
|
|
|
|
+ "entries": [ {
|
|
|
|
|
|
|
|
+ "type": "launcher",
|
|
|
|
|
|
|
|
+ "title": "Edit menu",
|
|
|
|
|
|
|
|
+ "command": "gedit $HOME/.entries.json"
|
|
|
|
|
|
|
|
+ } ]
|
|
|
|
|
|
|
|
+ }, null, 4);
|
|
|
|
|
|
|
|
+ let fileConfig = Gio.File.new_for_path(filename);
|
|
|
|
|
|
|
|
+ if (GLib.mkdir_with_parents(fileConfig.get_parent().get_path(), PERMISSIONS_MODE) === 0) {
|
|
|
|
|
|
|
|
+ fileConfig.replace_contents(jsonString, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // Try to load newly saved file
|
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
|
|
|
+ this.loadConfig(filename);
|
|
|
|
|
|
|
|
+ } catch(e) {
|
|
|
|
|
|
|
|
+ Main.notify(_('Cannot create and load file: '+filename));
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }, /**/
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
diff --git a/extensions/custom-menu/extension.js b/extensions/custom-menu/extension.js
|
|
|
|
|
|
|
|
new file mode 100644
|
|
|
|
|
|
|
|
index 00000000..9f3e3ce8
|
|
|
|
|
|
|
|
--- /dev/null
|
|
|
|
|
|
|
|
+++ b/extensions/custom-menu/extension.js
|
|
|
|
|
|
|
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
+/* extension.js
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
|
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
|
|
|
+ * (at your option) any later version.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
|
|
+ * GNU General Public License for more details.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
|
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
|
|
|
+ * @author Ben
|
|
|
|
|
|
|
|
+ * @see https://github.com/andreabenini/gnome-plugin.custom-menu-panel
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+/* exported init */
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const GETTEXT_DOMAIN = 'custom-menu-panel';
|
|
|
|
|
|
|
|
+const CONFIGURATION_FILE = '/.entries.json';
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const { GObject, St } = imports.gi;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const Gettext = imports.gettext.domain(GETTEXT_DOMAIN);
|
|
|
|
|
|
|
|
+const _ = Gettext.gettext;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const ExtensionUtils = imports.misc.extensionUtils;
|
|
|
|
|
|
|
|
+const Lang = imports.lang;
|
|
|
|
|
|
|
|
+const GLib = imports.gi.GLib;
|
|
|
|
|
|
|
|
+const Gio = imports.gi.Gio;
|
|
|
|
|
|
|
|
+const BackgroundMenu = imports.ui.backgroundMenu;
|
|
|
|
|
|
|
|
+const Main = imports.ui.main;
|
|
|
|
|
|
|
|
+const PanelMenu = imports.ui.panelMenu;
|
|
|
|
|
|
|
|
+const PopupMenu = imports.ui.popupMenu;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const Me = imports.misc.extensionUtils.getCurrentExtension();
|
|
|
|
|
|
|
|
+const Config = Me.imports.config
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const LOGGER_INFO = 0;
|
|
|
|
|
|
|
|
+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);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this._loadSetup();
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
|
|
|
+ * LOAD Program settings from .entries.json file
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+ _loadSetup() {
|
|
|
|
|
|
|
|
+ this.removeAll();
|
|
|
|
|
|
|
|
+ // Loading configuration from file
|
|
|
|
|
|
|
|
+ this.configLoader = new Config.Loader();
|
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
|
|
|
+ this.configLoader.loadConfig(GLib.get_home_dir() + CONFIGURATION_FILE); // $HOME/.entries.json
|
|
|
|
|
|
|
|
+ } catch(e) {
|
|
|
|
|
|
|
|
+ this.configLoader.saveDefaultConfig(GLib.get_home_dir() + CONFIGURATION_FILE); // create default entries
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // Build the menu
|
|
|
|
|
|
|
|
+ let i = 0;
|
|
|
|
|
|
|
|
+ for (let i in this.configLoader.entries) {
|
|
|
|
|
|
|
|
+ let item = this.configLoader.entries[i].createItem();
|
|
|
|
|
|
|
|
+ this.addMenuItem(item);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ } /**/
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+class CustomBackgroundMenu extends CustomMenu {
|
|
|
|
|
|
|
|
+ constructor(layoutManager) {
|
|
|
|
|
|
|
|
+ super(layoutManager.dummyCursor);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.actor.add_style_class_name('background-menu');
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ layoutManager.uiGroup.add_actor(this.actor);
|
|
|
|
|
|
|
|
+ this.actor.hide();
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.connect('open-state-changed', (menu, open) => {
|
|
|
|
|
|
|
|
+ if (open)
|
|
|
|
|
|
|
|
+ this._updateMaxHeight();
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _updateMaxHeight() {
|
|
|
|
|
|
|
|
+ const monitor = Main.layoutManager.findMonitorForActor(this.actor);
|
|
|
|
|
|
|
|
+ const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
|
|
|
|
|
|
|
|
+ const {scaleFactor} = St.ThemeContext.get_for_stage(global.stage);
|
|
|
|
|
|
|
|
+ const vMargins = this.actor.margin_top + this.actor.margin_bottom;
|
|
|
|
|
|
|
|
+ const {y: offsetY} = this.sourceActor;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ const maxHeight = Math.round((monitor.height - offsetY - vMargins) / scaleFactor);
|
|
|
|
|
|
|
|
+ this.actor.style = `max-height: ${maxHeight}px;`;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const Indicator = GObject.registerClass(
|
|
|
|
|
|
|
|
+ class Indicator extends PanelMenu.Button {
|
|
|
|
|
|
|
|
+ _init() {
|
|
|
|
|
|
|
|
+ super._init(0.0, _('Custom Menu Panel Indicator'), true);
|
|
|
|
|
|
|
|
+ this.add_child(new St.Icon({
|
|
|
|
|
|
|
|
+ icon_name: 'view-list-bullet-symbolic',
|
|
|
|
|
|
|
|
+ style_class: 'system-status-icon',
|
|
|
|
|
|
|
|
+ }));
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.setMenu(new CustomMenu(this));
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+const Logger = new Lang.Class({
|
|
|
|
|
|
|
|
+ Name: 'Logger',
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _init: function(log_file) {
|
|
|
|
|
|
|
|
+ this._log_file = log_file;
|
|
|
|
|
|
|
|
+ // initailize log_backend
|
|
|
|
|
|
|
|
+ if(!log_file)
|
|
|
|
|
|
|
|
+ this._initEmptyLog();
|
|
|
|
|
|
|
|
+ else if(log_file == "gnome-shell")
|
|
|
|
|
|
|
|
+ this._initGnomeLog();
|
|
|
|
|
|
|
|
+ else
|
|
|
|
|
|
|
|
+ this._initFileLog();
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.level = LOGGER_WARNING;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this.info = function(t) {
|
|
|
|
|
|
|
|
+ if(this.level <= LOGGER_INFO) this.log(t)
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ this.warning = function(t) {
|
|
|
|
|
|
|
|
+ if(this.level <= LOGGER_WARNING) this.log(t)
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ this.error = function(t) {
|
|
|
|
|
|
|
|
+ if(this.level <= LOGGER_ERROR) this.log(t);
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _initEmptyLog: function() {
|
|
|
|
|
|
|
|
+ this.log = function(_) { };
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _initGnomeLog: function() {
|
|
|
|
|
|
|
|
+ this.log = function(s) {
|
|
|
|
|
|
|
|
+ global.log("custom-menu-panel> " + s);
|
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ _initFileLog: function() {
|
|
|
|
|
|
|
|
+ this.log = function(s) {
|
|
|
|
|
|
|
|
+ // all operations are synchronous: any needs to optimize?
|
|
|
|
|
|
|
|
+ if(!this._output_file || !this._output_file.query_exists(null) ||
|
|
|
|
|
|
|
|
+ !this._fstream || this._fstream.is_closed()) {
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this._output_file = Gio.File.new_for_path(this._log_file);
|
|
|
|
|
|
|
|
+ this._fstream = this._output_file.append_to(
|
|
|
|
|
|
|
|
+ Gio.FileCreateFlags.NONE, null);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if(!this._fstream instanceof Gio.FileIOStream) {
|
|
|
|
|
|
|
|
+ this._initGnomeLog();
|
|
|
|
|
|
|
|
+ this.log("IOError: Failed to append to " + this._log_file +
|
|
|
|
|
|
|
|
+ " [Gio.IOErrorEnum:" + this._fstream + "]");
|
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ this._fstream.write(String(new Date())+" "+s+"\n", null);
|
|
|
|
|
|
|
|
+ this._fstream.flush(null);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ notify: function(t, str, details) {
|
|
|
|
|
|
|
|
+ this.ncond = this.ncond || ['proc', 'ext', 'state'];
|
|
|
|
|
|
|
|
+ if(this.ncond.indexOf(t) < 0) return;
|
|
|
|
|
|
|
|
+ Main.notify(str, details || "");
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+// lazy-evaluation
|
|
|
|
|
|
|
|
+let logger = null;
|
|
|
|
|
|
|
|
+function getLogger() {
|
|
|
|
|
|
|
|
+ if(logger === null)
|
|
|
|
|
|
|
|
+ logger = new Logger("gnome-shell");
|
|
|
|
|
|
|
|
+ return logger;
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+class Extension {
|
|
|
|
|
|
|
|
+ constructor(uuid) {
|
|
|
|
|
|
|
|
+ this._uuid = uuid;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ ExtensionUtils.initTranslations(GETTEXT_DOMAIN);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ enable() {
|
|
|
|
|
|
|
|
+ BackgroundMenu.BackgroundMenu = CustomBackgroundMenu;
|
|
|
|
|
|
|
|
+ Main.layoutManager._updateBackgrounds();
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ disable() {
|
|
|
|
|
|
|
|
+ BackgroundMenu.BackgroundMenu = OriginalBackgroundMenu;
|
|
|
|
|
|
|
|
+ Main.layoutManager._updateBackgrounds();
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+function init(meta) {
|
|
|
|
|
|
|
|
+ return new Extension(meta.uuid);
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
diff --git a/extensions/custom-menu/meson.build b/extensions/custom-menu/meson.build
|
|
|
|
|
|
|
|
new file mode 100644
|
|
|
|
|
|
|
|
index 00000000..92450963
|
|
|
|
|
|
|
|
--- /dev/null
|
|
|
|
|
|
|
|
+++ b/extensions/custom-menu/meson.build
|
|
|
|
|
|
|
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
+extension_data += configure_file(
|
|
|
|
|
|
|
|
+ input: metadata_name + '.in',
|
|
|
|
|
|
|
|
+ output: metadata_name,
|
|
|
|
|
|
|
|
+ configuration: metadata_conf
|
|
|
|
|
|
|
|
+)
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+extension_sources += files('config.js')
|
|
|
|
|
|
|
|
diff --git a/extensions/custom-menu/metadata.json.in b/extensions/custom-menu/metadata.json.in
|
|
|
|
|
|
|
|
new file mode 100644
|
|
|
|
|
|
|
|
index 00000000..054f639b
|
|
|
|
|
|
|
|
--- /dev/null
|
|
|
|
|
|
|
|
+++ b/extensions/custom-menu/metadata.json.in
|
|
|
|
|
|
|
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
+{
|
|
|
|
|
|
|
|
+"extension-id": "@extension_id@",
|
|
|
|
|
|
|
|
+"uuid": "@uuid@",
|
|
|
|
|
|
|
|
+"settings-schema": "@gschemaname@",
|
|
|
|
|
|
|
|
+"gettext-domain": "@gettext_domain@",
|
|
|
|
|
|
|
|
+"name": "Custom menu",
|
|
|
|
|
|
|
|
+"description": "Quick custom menu for launching your favorite applications",
|
|
|
|
|
|
|
|
+"shell-version": [ "@shell_current@" ],
|
|
|
|
|
|
|
|
+"url": "@url@"
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
diff --git a/extensions/custom-menu/stylesheet.css b/extensions/custom-menu/stylesheet.css
|
|
|
|
|
|
|
|
new file mode 100644
|
|
|
|
|
|
|
|
index 00000000..25134b65
|
|
|
|
|
|
|
|
--- /dev/null
|
|
|
|
|
|
|
|
+++ b/extensions/custom-menu/stylesheet.css
|
|
|
|
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
|
+/* This extensions requires no special styling */
|
|
|
|
|
|
|
|
diff --git a/meson.build b/meson.build
|
|
|
|
|
|
|
|
index c71636cb..23fb2c89 100644
|
|
|
|
|
|
|
|
--- a/meson.build
|
|
|
|
|
|
|
|
+++ b/meson.build
|
|
|
|
|
|
|
|
@@ -46,6 +46,7 @@ all_extensions = default_extensions
|
|
|
|
|
|
|
|
all_extensions += [
|
|
|
|
|
|
|
|
'auto-move-windows',
|
|
|
|
|
|
|
|
'classification-banner',
|
|
|
|
|
|
|
|
+ 'custom-menu',
|
|
|
|
|
|
|
|
'dash-to-dock',
|
|
|
|
|
|
|
|
'native-window-placement',
|
|
|
|
|
|
|
|
'panel-favorites',
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
2.38.1
|
|
|
|
|
|
|
|
|
|
|
|