Skip to content

Commit

Permalink
yfquotes@thegli: Add setting to customize background color (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegli authored Jul 10, 2024
1 parent 9252371 commit 28f264b
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 160 deletions.
17 changes: 15 additions & 2 deletions yfquotes@thegli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This desklet is based on the [desklet from fthuin](https://github.com/fthuin/yah

Tested with

- Linux Mint Cinnamon 17 up to 21
- Linux Mint Cinnamon 17 up to 22
- Debian 9 with Cinnamon 3.2
- Manjaro with Cinnamon 3.8
- Fedora 38 Cinnamon Spin with Cinnamon 5.6 and libsoup3
Expand Down Expand Up @@ -42,6 +42,19 @@ To disable the debug log mode, delete the "DEBUG" file, and restart the Cinnamon

## Release Notes

### 0.13.0 - July 10, 2024

Features:

- new setting to customize the background color
- update Spanish translation (courtesy of [haggen88](https://github.com/haggen88))
- update Hungarian translation (courtesy of [bossbob88](https://github.com/bossbob88))

Bugfixes:

- display better error message if quotes list is empty
- improve description for manual update feature

### 0.12.0 - May 22, 2024

Features:
Expand Down Expand Up @@ -133,7 +146,7 @@ Bugfixes:

Features:

- update Brasilian and German translations
- update Brazilian and German translations
- fetch finance data asynchronously to improve responsiveness

Bugfixes:
Expand Down
26 changes: 20 additions & 6 deletions yfquotes@thegli/files/yfquotes@thegli/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ YahooFinanceQuoteReader.prototype = {

getFinanceData: function(quoteSymbols, customUserAgent, callback) {
const _that = this;

if (quoteSymbols.join().length === 0) {
callback.call(_that, _that.buildErrorResponse(_("Empty quotes list. Open settings and add some symbols.")));
return;
}

const requestUrl = this.createYahooQueryUrl(quoteSymbols);
const message = Soup.Message.new("GET", requestUrl);

Expand Down Expand Up @@ -349,7 +355,7 @@ YahooFinanceQuoteReader.prototype = {
},

createYahooQueryUrl: function(quoteSymbols) {
const queryUrl = "https://query1.finance.yahoo.com/v7/finance/quote?symbols=" + quoteSymbols.join(",") + "&crumb=" + _crumb;
const queryUrl = "https://query1.finance.yahoo.com/v7/finance/quote?symbols=" + quoteSymbols.join() + "&crumb=" + _crumb;
logDebug("YF query URL: " + queryUrl);
return queryUrl;
},
Expand Down Expand Up @@ -616,6 +622,8 @@ StockQuoteDesklet.prototype = {
this.onDisplayChanged, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "showVerticalScrollbar", "showVerticalScrollbar",
this.onSettingsChanged, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "backgroundColor", "backgroundColor",
this.onDisplayChanged, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "delayMinutes", "delayMinutes",
this.onSettingsChanged, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "showLastUpdateTimestamp", "showLastUpdateTimestamp",
Expand Down Expand Up @@ -755,11 +763,17 @@ StockQuoteDesklet.prototype = {

onDisplayChanged: function() {
this.mainBox.set_size(this.width, this.height);
this.setTransparency();
this.setBackground();
},

setTransparency: function() {
this.mainBox.style = "background-color: rgba(0, 0, 0, " + this.transparency + ")";
setBackground: function() {
this.mainBox.style = "background-color: " + this.buildBackgroundColor(this.backgroundColor, this.transparency);
},

buildBackgroundColor: function(rgbColorString, transparencyFactor) {
// parse RGB values between "rgb(...)"
const rgb = rgbColorString.match(/\((.*?)\)/)[1].split(",");
return "rgba(" + parseInt(rgb[0]) + "," + parseInt(rgb[1]) + "," + parseInt(rgb[2]) + "," + transparencyFactor + ")";
},

onSettingsChanged: function() {
Expand All @@ -774,7 +788,7 @@ StockQuoteDesklet.prototype = {
},

onUpdate: function() {
const quoteSymbols = this.quoteSymbolsText.split("\n");
const quoteSymbols = this.quoteSymbolsText.trim().split("\n");
const customUserAgent = this.sendCustomUserAgent ? this.customUserAgent : null;

try {
Expand Down Expand Up @@ -948,7 +962,7 @@ StockQuoteDesklet.prototype = {
height: this.height,
style_class: "quotes-reader"
});
this.setTransparency();
this.setBackground();

this.mainBox.add(scrollView, {
expand: true
Expand Down
2 changes: 1 addition & 1 deletion yfquotes@thegli/files/yfquotes@thegli/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"name": "Yahoo Finance Quotes",
"prevent-decorations": true,
"max-instances": "10",
"version": "0.12.0",
"version": "0.13.0",
"uuid": "yfquotes@thegli"
}
38 changes: 26 additions & 12 deletions yfquotes@thegli/files/yfquotes@thegli/po/da.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2024-05-22 21:38+0200\n"
"POT-Creation-Date: 2024-07-10 00:38+0200\n"
"PO-Revision-Date: 2023-12-08 08:06+0100\n"
"Last-Translator: Alan Mortensen <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -18,48 +18,52 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"

#: desklet.js:326 desklet.js:345
#: desklet.js:310
msgid "Empty quotes list. Open settings and add some symbols."
msgstr ""

#: desklet.js:332 desklet.js:351
msgid "Yahoo Finance service not available!\\nStatus: "
msgstr "Yahoo Finance er ikke tilgængelig!\\nStatus: "

#: desklet.js:730
#: desklet.js:738
msgid "Updated at "
msgstr "Opdateret "

#: desklet.js:751
#: desklet.js:759
msgid "Error: "
msgstr "Fejl: "

#: desklet.js:813
#: desklet.js:827
msgid ""
"Failed to retrieve authorization parameter! Unable to fetch quotes data."
"\\nStatus: "
msgstr ""
"Kunne ikke hente godkendelsesparameter! Kunne ikke hente kursdata.\n"
"Status: "

#: desklet.js:838
#: desklet.js:852
msgid "Consent processing failed! Unable to fetch quotes data.\\nStatus: "
msgstr "Samtykkebehandling mislykkedes! Kunne ikke hente kursdata.\\nStatus: "

#: desklet.js:843
#: desklet.js:857
msgid ""
"Consent processing not completed! Unable to fetch quotes data.\\nStatus: "
msgstr ""
"Samtykkebehandling ikke gennemført! Kunne ikke hente kursdata.\\nStatus: "

#: desklet.js:865
#: desklet.js:879
msgid ""
"Failed to retrieve authorization crumb! Unable to fetch quotes data."
"\\nStatus: "
msgstr ""
"Kunne ikke hente godkendelseskrumme! Kunne ikke hente kursdata.\\nStatus: "

#: desklet.js:892
#: desklet.js:906
msgid "Cannot display quotes information for symbols: "
msgstr "Kan ikke vise kurser for symbolerne: "

#: desklet.js:893
#: desklet.js:907
msgid "The following error occurred: "
msgstr "Følgende fejl opstod: "

Expand Down Expand Up @@ -173,6 +177,14 @@ msgstr "Baggrundens gennemsigtighed"
msgid "The higher the value, the more solid the desklet background"
msgstr "Jo højere værdi, desto mindre gennemsigtig er baggrunden."

#. settings-schema.json->backgroundColor->description
msgid "Background color"
msgstr ""

#. settings-schema.json->backgroundColor->tooltip
msgid "Desklet background color"
msgstr ""

#. settings-schema.json->showVerticalScrollbar->description
msgid "Show vertical scrollbar"
msgstr ""
Expand Down Expand Up @@ -204,11 +216,13 @@ msgid "Display timestamp when quotes were updated last"
msgstr "Viser tidsstempel for den sidste opdatering af kurserne."

#. settings-schema.json->manualDataUpdate->description
msgid "Manual update"
msgid "Manual and automatic update"
msgstr ""

#. settings-schema.json->manualDataUpdate->tooltip
msgid "Click last update timestamp to instantly refresh quotes data"
msgid ""
"Click last update timestamp to instantly refresh quotes data. Automatic "
"update is still performed periodically."
msgstr ""

#. settings-schema.json->sendCustomUserAgent->description
Expand Down
46 changes: 31 additions & 15 deletions yfquotes@thegli/files/yfquotes@thegli/po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2024-05-22 21:38+0200\n"
"POT-Creation-Date: 2024-07-10 00:38+0200\n"
"PO-Revision-Date: 2023-08-28 16:36+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -17,52 +17,57 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3\n"

#: desklet.js:326 desklet.js:345
#: desklet.js:310
msgid "Empty quotes list. Open settings and add some symbols."
msgstr ""
"Liste der Symbole ist leer. Öffne die Einstellungen und füge Symbole hinzu."

#: desklet.js:332 desklet.js:351
msgid "Yahoo Finance service not available!\\nStatus: "
msgstr "Yahoo Finance Service nicht verfügbar!\\nStatus: "

#: desklet.js:730
#: desklet.js:738
msgid "Updated at "
msgstr "Aktualisiert um "

#: desklet.js:751
#: desklet.js:759
msgid "Error: "
msgstr "Fehler: "

#: desklet.js:813
#: desklet.js:827
msgid ""
"Failed to retrieve authorization parameter! Unable to fetch quotes data."
"\\nStatus: "
msgstr ""
"Empfang von Autorisierungsparameter ist fehlgeschlagen! Finanzdaten-Abfrage "
"nicht möglich.\\nStatus: "

#: desklet.js:838
#: desklet.js:852
msgid "Consent processing failed! Unable to fetch quotes data.\\nStatus: "
msgstr ""
"Consent-Erteilung ist fehlgeschlagen! Finanzdaten-Abfrage nicht möglich."
"\\nStatus: "

#: desklet.js:843
#: desklet.js:857
msgid ""
"Consent processing not completed! Unable to fetch quotes data.\\nStatus: "
msgstr ""
"Consent-Erteilung nicht abgeschlossen! Finanzdaten-Abfrage nicht möglich."
"\\nStatus: "

#: desklet.js:865
#: desklet.js:879
msgid ""
"Failed to retrieve authorization crumb! Unable to fetch quotes data."
"\\nStatus: "
msgstr ""
"Emfang von Autorisierungs-Crumb ist fehlgeschlagen! Finanzdaten-Abfrage "
"nicht möglich.\\nStatus: "

#: desklet.js:892
#: desklet.js:906
msgid "Cannot display quotes information for symbols: "
msgstr "Finanzdaten können nicht angezeigt werden für die Symbole: "

#: desklet.js:893
#: desklet.js:907
msgid "The following error occurred: "
msgstr "Folgender Fehler ist aufgetreten: "

Expand Down Expand Up @@ -176,6 +181,14 @@ msgstr "Hintergrund Transparenz"
msgid "The higher the value, the more solid the desklet background"
msgstr "Je grösser der Wert, desto deckender der Desklet Hintergrund"

#. settings-schema.json->backgroundColor->description
msgid "Background color"
msgstr "Hintergrundfarbe"

#. settings-schema.json->backgroundColor->tooltip
msgid "Desklet background color"
msgstr "Desklet Hintergrundfarbe"

#. settings-schema.json->showVerticalScrollbar->description
msgid "Show vertical scrollbar"
msgstr "Senkrechte Bildlaufleiste anzeigen"
Expand Down Expand Up @@ -209,13 +222,16 @@ msgid "Display timestamp when quotes were updated last"
msgstr "Zeigt den Zeitstempel der letzten Aktualisierung der Finanzdaten an"

#. settings-schema.json->manualDataUpdate->description
#, fuzzy
msgid "Manual update"
msgstr "Manuelle Aktualisierung"
msgid "Manual and automatic update"
msgstr "Manuelle und automatische Aktualisierung"

#. settings-schema.json->manualDataUpdate->tooltip
msgid "Click last update timestamp to instantly refresh quotes data"
msgstr "Zeitstempel anklicken für sofortige Aktualisierung"
msgid ""
"Click last update timestamp to instantly refresh quotes data. Automatic "
"update is still performed periodically."
msgstr ""
"Zeitstempel anklicken für sofortige Aktualisierung. Die automatische "
"Aktualisierung findet weiterhin periodisch statt."

#. settings-schema.json->sendCustomUserAgent->description
msgid "Send custom User-Agent header"
Expand Down
Loading

0 comments on commit 28f264b

Please sign in to comment.