Skip to content

Commit 904917a

Browse files
authored
maximus-buttons@hanspr & maximus-title@hanspr: Fix reported bugs (#8185)
* Fixes #8177
1 parent bbbe3b9 commit 904917a

File tree

7 files changed

+167
-56
lines changed

7 files changed

+167
-56
lines changed

maximus-buttons@hanspr/files/maximus-buttons@hanspr/applet.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class MyApplet extends Applet.TextIconApplet {
4949
this.settings.bind("buttons-theme", "buttonsTheme")
5050
this.settings.bind("only-maximized", "onlyMaximized", this.on_settings_changed)
5151
this.settings.bind("hide-buttons", "hideButtons", this.on_settings_changed)
52-
this.settings.bind("on-desktop-shutdown", "onDesktopShutdown", this.on_settings_changed)
5352
}
5453

5554
connectSignals() {
@@ -209,8 +208,6 @@ class MyApplet extends Applet.TextIconApplet {
209208
if (button == 1) {
210209
this.closeWindow()
211210
return true
212-
} else if (button == 3) {
213-
this._applet_context_menu.toggle()
214211
}
215212
return true
216213
})
@@ -223,12 +220,7 @@ class MyApplet extends Applet.TextIconApplet {
223220
let activeWindow = global.display.focus_window
224221
let app = tracker.get_window_app(activeWindow)
225222

226-
if (!app) {
227-
if (this.onDesktopShutdown == true) {
228-
this._session.ShutdownRemote()
229-
}
230-
return
231-
} else {
223+
if (app) {
232224
activeWindow.delete(global.get_current_time())
233225
}
234226

@@ -268,7 +260,7 @@ class MyApplet extends Applet.TextIconApplet {
268260
return
269261
}
270262
//console.log("WINDOW TYPE = ", w.get_window_type())
271-
if (w.get_window_type() >= 5) {
263+
if (w.get_window_type() >= 5 || w.get_window_type() == 1) {
272264
this.setButtons("hide")
273265
return
274266
}

maximus-buttons@hanspr/files/maximus-buttons@hanspr/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"uuid": "maximus-buttons@hanspr",
55
"name": "Maximus Buttons",
66
"website": "https://github.com/linuxmint/cinnamon-spices-applets",
7-
"version": "0.0.2",
7+
"version": "0.0.3",
88
"author": "hanspr",
99
"contributors": "Hans Peyrot"
1010
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# MAXIMUS BUTTONS
2+
# This file is put in the public domain.
3+
# hanspr, 2025
4+
#
5+
#, fuzzy
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: maximus-buttons@hanspr 0.0.3\n"
9+
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
10+
"issues\n"
11+
"POT-Creation-Date: 2026-01-11 16:54-0500\n"
12+
"PO-Revision-Date: \n"
13+
"Last-Translator: \n"
14+
"Language-Team: \n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
20+
#. metadata.json->description
21+
msgid "Maximus buttons"
22+
msgstr ""
23+
24+
#. metadata.json->name
25+
msgid "Maximus Buttons"
26+
msgstr ""
27+
28+
#. metadata.json->contributors
29+
msgid "Hans Peyrot"
30+
msgstr ""
31+
32+
#. settings-schema.json->head->description
33+
msgid "Window Buttons Settings"
34+
msgstr ""
35+
36+
#. settings-schema.json->buttons-style->description
37+
msgid "Window Buttons Style (Example: minimize:maximize:close:icon)"
38+
msgstr ""
39+
40+
#. settings-schema.json->buttons-theme->description
41+
msgid "Buttons Theme (Needs Restart Cinnamon)"
42+
msgstr ""
43+
44+
#. settings-schema.json->buttons-theme->options
45+
msgid "Default"
46+
msgstr ""
47+
48+
#. settings-schema.json->buttons-theme->options
49+
msgid "Mac-OS-X"
50+
msgstr ""
51+
52+
#. settings-schema.json->buttons-theme->options
53+
msgid "Mint-X"
54+
msgstr ""
55+
56+
#. settings-schema.json->buttons-theme->options
57+
msgid "Radiance"
58+
msgstr ""
59+
60+
#. settings-schema.json->buttons-theme->options
61+
msgid "UniMetro"
62+
msgstr ""
63+
64+
#. settings-schema.json->buttons-theme->options
65+
msgid "UniMetro-Black"
66+
msgstr ""
67+
68+
#. settings-schema.json->buttons-theme->options
69+
msgid "Vimix"
70+
msgstr ""
71+
72+
#. settings-schema.json->buttons-theme->tooltip
73+
msgid "Please select a theme for window buttons"
74+
msgstr ""
75+
76+
#. settings-schema.json->hide-buttons->description
77+
msgid "Hide buttons: instead of removing (no applets jump left right)"
78+
msgstr ""
79+
80+
#. settings-schema.json->only-maximized->description
81+
msgid "Show buttons: only when focused window is maximized"
82+
msgstr ""

maximus-buttons@hanspr/files/maximus-buttons@hanspr/settings-schema.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"buttons-style": {
77
"type": "entry",
8-
"description": "Window Buttons Style (Example: title:minimize:maximize:close:icon)",
8+
"description": "Window Buttons Style (Example: minimize:maximize:close:icon)",
99
"default": "minimize:maximize:close"
1010
},
1111

@@ -24,11 +24,6 @@
2424
},
2525
"tooltip": "Please select a theme for window buttons"
2626
},
27-
"on-desktop-shutdown": {
28-
"type": "switch",
29-
"default": false,
30-
"description": "Click on close: poweroff if desktop is focused"
31-
},
3227
"hide-buttons": {
3328
"type": "switch",
3429
"default": true,

maximus-title@hanspr/files/maximus-title@hanspr/applet.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class MyApplet extends Applet.TextIconApplet {
1515
this.regex = null
1616
this.bindSettings()
1717
this.connectSignals()
18-
this.lastTitle = ""
1918
this.cssFocus = "background-color:;border-radius:5px;padding-right:10px;padding-left:5px;"
2019
this._regexChanged()
2120
this._bgChanged()
@@ -41,72 +40,74 @@ class MyApplet extends Applet.TextIconApplet {
4140
let w = global.display.focus_window
4241
if (w) {
4342
this.signalManager.connect(w, 'notify::title', () => {
44-
this._onTitleChange(w.lastTitle, w.get_monitor())
43+
this._onTitleChange()
4544
})
46-
this._onTitleChange(w.lastTitle, w.get_monitor())
47-
} else {
48-
this._onTitleChange(undefined, 0)
4945
}
46+
this._onTitleChange()
5047
}, this)
5148
this.signalManager.connect(global.screen, 'window-monitor-changed', () => {
5249
let w = global.display.focus_window
5350
if (w) {
54-
this._onMonitorChange(w.lastTitle, w.get_monitor())
51+
this._onMonitorChange(w.get_monitor())
5552
}
5653
}, this)
5754
}
5855

59-
_onMonitorChange(title, monitorIndex) {
56+
_onMonitorChange(monitorIndex) {
6057
if (monitorIndex != this.panel.monitorIndex) {
61-
let title = ""
62-
const windows = global.get_window_actors();
63-
for (let i = 0; i < windows.length; i++) {
64-
if (this.panel.monitorIndex != windows[i].metaWindow.get_monitor() || windows[i].metaWindow.get_window_type() > 1) {
65-
continue
66-
}
67-
//console.log("pass :", i)
68-
//console.log("title:", windows[i].metaWindow.title)
69-
//console.log("type :", windows[i].metaWindow.get_window_type())
70-
title = windows[i].metaWindow.title
71-
}
72-
this._onTitleChange(title, this.panel.monitorIndex)
73-
this.actor.set_style("")
58+
let title = this._getTopWindowFromMonitor(this.panel.monitorIndex)
59+
this._setTitle(title, "")
7460
return
7561
}
76-
this._onTitleChange(title, monitorIndex)
62+
this._onTitleChange()
7763
}
7864

79-
_onTitleChange(title, monitorIndex) {
80-
if (monitorIndex != this.panel.monitorIndex) {
81-
this.actor.set_style("")
82-
return
83-
}
84-
if (title == undefined) {
85-
try {
86-
title = global.display.focus_window.get_title()
87-
} catch (e) {
88-
return
65+
_getTopWindowFromMonitor(monitorIndex) {
66+
const panelMonitorIndex = this.panel.monitorIndex
67+
const windows = global.get_window_actors();
68+
for (let i = windows.length - 1; i > 0; i--) {
69+
if (panelMonitorIndex != windows[i].metaWindow.get_monitor() || windows[i].metaWindow.get_window_type() > 10) {
70+
continue
8971
}
72+
//console.log("pass :", i)
73+
//console.log("title:", windows[i].metaWindow.title)
74+
//console.log("type :", windows[i].metaWindow.get_window_type())
75+
return windows[i].metaWindow.title
9076
}
91-
if (this.lastTitle == title) {
92-
this.actor.set_style(this.cssFocus)
77+
return ""
78+
}
79+
80+
_onTitleChange() {
81+
let w
82+
try {
83+
w = global.display.focus_window
84+
} catch (e) {
85+
return
86+
}
87+
if (w.get_monitor() != this.panel.monitorIndex) {
88+
let title = this._getTopWindowFromMonitor(w.get_monitor())
89+
this._setTitle(title, "")
9390
return
9491
}
95-
this.lastTitle = title
92+
this._setTitle(w.get_title(), this.cssFocus)
93+
}
94+
95+
_setTitle(title, css) {
9696
if (this.regex != null) {
9797
title = title.replace(this.regex, "")
9898
}
9999
title = title.substring(0, this.titleLength)
100100
this.set_applet_label(title)
101-
this.actor.set_style(this.cssFocus)
101+
this.actor.set_style(css)
102102
}
103103

104104
_lengthChanged() {
105-
this._onTitleChange(this.lastTitle)
105+
this._onTitleChange()
106106
}
107107

108108
_bgChanged() {
109109
this.cssFocus = "background-color:" + this.titleBg + ";border-radius:5px;padding-right:10px;padding-left:5px;"
110+
this._onTitleChange()
110111
}
111112

112113
_regexChanged() {
@@ -116,11 +117,10 @@ class MyApplet extends Applet.TextIconApplet {
116117
try {
117118
this.regex = new RegExp(this.titleRegex)
118119
} catch (e) {
119-
console.log("Regex error:", e)
120+
console.log("Maximus-title: user Regex error:", e)
120121
this.regex = null
121122
}
122123
}
123-
this.lastTitle = ""
124124
this._onTitleChange()
125125
}
126126
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"uuid": "maximus-title@hanspr",
33
"description": "Maximus show title for the current window",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"name": "Maximus window title",
66
"max-instances": -1
77
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# MAXIMUS WINDOW TITLE
2+
# This file is put in the public domain.
3+
# hanspr, 2025
4+
#
5+
#, fuzzy
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: maximus-title@hanspr 0.0.2\n"
9+
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
10+
"issues\n"
11+
"POT-Creation-Date: 2026-01-11 16:54-0500\n"
12+
"PO-Revision-Date: \n"
13+
"Last-Translator: \n"
14+
"Language-Team: \n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
20+
#. metadata.json->description
21+
msgid "Maximus show title for the current window"
22+
msgstr ""
23+
24+
#. metadata.json->name
25+
msgid "Maximus window title"
26+
msgstr ""
27+
28+
#. settings-schema.json->head->description
29+
msgid "Window Title Settings"
30+
msgstr ""
31+
32+
#. settings-schema.json->title-len->description
33+
msgid "Maximum title lenght"
34+
msgstr ""
35+
36+
#. settings-schema.json->title-bg->description
37+
msgid "Title focused background color"
38+
msgstr ""
39+
40+
#. settings-schema.json->title-regex->description
41+
msgid "Apply regex to title to remove string, before showing"
42+
msgstr ""

0 commit comments

Comments
 (0)