Skip to content

Commit 8fa4251

Browse files
committed
Update make panel index configurable for gnome extension
1 parent fa589da commit 8fa4251

File tree

4 files changed

+208
-167
lines changed

4 files changed

+208
-167
lines changed

gnome-extension/extension.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ export default class RabbitForexExtension extends Extension {
676676
this._positionChangedId = this._settings.connect("changed::panel-position", () => {
677677
this._repositionIndicator();
678678
});
679+
680+
this._indexChangedId = this._settings.connect("changed::panel-index", () => {
681+
this._repositionIndicator();
682+
});
679683
}
680684

681685
_getBoxFromPosition(position) {
@@ -686,8 +690,9 @@ export default class RabbitForexExtension extends Extension {
686690
_addIndicator() {
687691
this._indicator = new RabbitForexIndicator(this);
688692
const position = this._settings.get_string("panel-position");
693+
const index = this._settings.get_int("panel-index");
689694
const box = this._getBoxFromPosition(position);
690-
Main.panel.addToStatusArea(this.uuid, this._indicator, 0, box);
695+
Main.panel.addToStatusArea(this.uuid, this._indicator, index, box);
691696
}
692697

693698
_repositionIndicator() {
@@ -704,8 +709,9 @@ export default class RabbitForexExtension extends Extension {
704709
this._indicator._timestamps = timestamps;
705710

706711
const position = this._settings.get_string("panel-position");
712+
const index = this._settings.get_int("panel-index");
707713
const box = this._getBoxFromPosition(position);
708-
Main.panel.addToStatusArea(this.uuid, this._indicator, 0, box);
714+
Main.panel.addToStatusArea(this.uuid, this._indicator, index, box);
709715

710716
this._indicator._updateDisplay();
711717
}
@@ -717,6 +723,11 @@ export default class RabbitForexExtension extends Extension {
717723
this._positionChangedId = null;
718724
}
719725

726+
if (this._indexChangedId) {
727+
this._settings.disconnect(this._indexChangedId);
728+
this._indexChangedId = null;
729+
}
730+
720731
if (this._indicator) {
721732
this._indicator.destroy();
722733
this._indicator = null;

gnome-extension/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "Rabbit Forex",
3-
"description": "Monitor exchange rates for fiat currencies, precious metals, cryptocurrencies and stocks.\nClick on any rate to copy it to clipboard.",
3+
"description": "Monitor exchange rates for fiat currencies, precious metals, cryptocurrencies and stocks.\n\nClick on any rate to copy it to clipboard.",
44
"uuid": "rabbitforex@rabbit-company.com",
55
"shell-version": ["47", "48", "49"],
6-
"version-name": "1.4.0",
6+
"version-name": "1.5.0",
77
"settings-schema": "org.gnome.shell.extensions.rabbitforex",
88
"url": "https://github.com/Rabbit-Company/RabbitForexAPI",
99
"donations": {

gnome-extension/prefs.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export default class RabbitForexPreferences extends ExtensionPreferences {
334334

335335
const panelPositionRow = new Adw.ComboRow({
336336
title: "Panel Position",
337-
subtitle: "Where to place the indicator",
337+
subtitle: "Where to place the indicator in the panel",
338338
model: panelPositionModel,
339339
});
340340

@@ -348,6 +348,23 @@ export default class RabbitForexPreferences extends ExtensionPreferences {
348348
});
349349
panelGroup.add(panelPositionRow);
350350

351+
// Panel index (order within the box)
352+
const panelIndexRow = new Adw.SpinRow({
353+
title: "Panel Index",
354+
subtitle: "Order within panel area",
355+
adjustment: new Gtk.Adjustment({
356+
lower: 0,
357+
upper: 20,
358+
step_increment: 1,
359+
page_increment: 1,
360+
value: settings.get_int("panel-index"),
361+
}),
362+
});
363+
panelIndexRow.adjustment.connect("value-changed", (adj) => {
364+
settings.set_int("panel-index", adj.value);
365+
});
366+
panelGroup.add(panelIndexRow);
367+
351368
// Panel separator
352369
const separatorRow = new Adw.EntryRow({
353370
title: "Panel Separator",

0 commit comments

Comments
 (0)