diff --git a/README.md b/README.md index 0a97125..8c3a532 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ Check out the desklet configuration settings, and choose the data refresh period ## Release Notes +### 0.5.0 - October 4, 2020 +Features: +* new setting to color percentage change according to trend. Enabled by default if percentage change is displayed. Courtesy of [plaihonen](https://github.com/plaihonen). +* new setting to add Yahoo Finance hyperlink to symbol/quote. Enabled by default if symbol is displayed. Proposed by [ngaro](https://github.com/ngaro). +* new setting to use long version for verbose quote name. Enabled by default if verbose name is displayed. Courtesy of [ngaro](https://github.com/ngaro). + ### 0.4.2 - September 20, 2020 Bugfixes: * update translation files with new setting diff --git a/files/yfquotes@thegli/desklet.js b/files/yfquotes@thegli/desklet.js index 1c978e3..42e0b51 100644 --- a/files/yfquotes@thegli/desklet.js +++ b/files/yfquotes@thegli/desklet.js @@ -1,5 +1,5 @@ /* - * Yahoo Finance Quotes - 0.4.1 + * Yahoo Finance Quotes - 0.5.0 * * Shows financial market information provided by Yahoo Finance. * This desklet is based on the work of fthuin's stocks desklet. @@ -28,6 +28,7 @@ const Gettext = imports.gettext; const UUID = "yfquotes@thegli"; const DESKLET_DIR = imports.ui.deskletManager.deskletMeta[UUID].path; const ABSENT = "N/A"; +const YF_PAGE = "https://finance.yahoo.com/quote/"; Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale"); @@ -105,10 +106,10 @@ QuotesTable.prototype = { cellContents.push(this.createPercentChangeIcon(quote)); } if (shouldShow.quoteName) { - cellContents.push(this.createQuoteNameLabel(quote, shouldShow.linkQuote)); + cellContents.push(this.createQuoteNameLabel(quote, shouldShow.useLongName, shouldShow.linkQuote)); } if (shouldShow.quoteSymbol) { - cellContents.push(this.createQuoteSymbolLabel(quote)); + cellContents.push(this.createQuoteSymbolLabel(quote, shouldShow.linkSymbol)); } if (shouldShow.marketPrice) { cellContents.push(this.createMarketPriceLabel(quote, shouldShow.currencySymbol, shouldShow.decimalPlaces)); @@ -117,7 +118,7 @@ QuotesTable.prototype = { cellContents.push(this.createAbsoluteChangeLabel(quote, shouldShow.currencySymbol, shouldShow.decimalPlaces)); } if (shouldShow.percentChange) { - cellContents.push(this.createPercentChangeLabel(quote)); + cellContents.push(this.createPercentChangeLabel(quote, shouldShow.colorPercentChange)); } if (shouldShow.tradeTime) { cellContents.push(this.createTradeTimeLabel(quote)); @@ -134,11 +135,22 @@ QuotesTable.prototype = { existsProperty : function(object, property) { return object.hasOwnProperty(property) && object[property] !== undefined && object[property] !== null; }, - createQuoteSymbolLabel : function (quote) { - return new St.Label({ + createQuoteSymbolLabel : function (quote, addLink) { + const symbolLabel = new St.Label({ text : quote.symbol, - style_class : "quotes-label" + style_class : "quotes-label", + reactive : addLink ? true : false }); + if (addLink) { + const symbolButton = new St.Button(); + symbolButton.add_actor(symbolLabel); + symbolButton.connect("clicked", Lang.bind(this, function() { + Gio.app_info_launch_default_for_uri(YF_PAGE + quote.symbol, global.create_app_launch_context()); + })); + return symbolButton; + } else { + return symbolLabel; + } }, createMarketPriceLabel : function (quote, withCurrencySymbol, decimalPlaces) { let currencySymbol = ""; @@ -150,9 +162,18 @@ QuotesTable.prototype = { style_class : "quotes-label" }); }, - createQuoteNameLabel : function (quote, addLink) { + determineQuoteName : function (quote, useLongName) { + if (useLongName && this.existsProperty(quote, "longName")) { + return quote.longName; + } else if (this.existsProperty(quote, "shortName")) { + return quote.shortName; + } + + return ABSENT; + }, + createQuoteNameLabel : function (quote, useLongName, addLink) { const nameLabel = new St.Label({ - text : this.existsProperty(quote, "shortName") ? quote.shortName : ABSENT, + text : this.determineQuoteName(quote, useLongName), style_class : "quotes-label", reactive : addLink ? true : false }); @@ -160,7 +181,7 @@ QuotesTable.prototype = { const nameButton = new St.Button(); nameButton.add_actor(nameLabel); nameButton.connect("clicked", Lang.bind(this, function() { - Gio.app_info_launch_default_for_uri("https://finance.yahoo.com/quote/" + quote.symbol, global.create_app_launch_context()); + Gio.app_info_launch_default_for_uri(YF_PAGE + quote.symbol, global.create_app_launch_context()); })); return nameButton; } else { @@ -207,10 +228,19 @@ QuotesTable.prototype = { binIcon.set_child(image); return binIcon; }, - createPercentChangeLabel : function (quote) { + createPercentChangeLabel : function (quote, useTrendColors) { + let trendClassSuffix = ""; + if (useTrendColors && this.existsProperty(quote, "regularMarketChangePercent")) { + const percentageChange = parseFloat(quote.regularMarketChangePercent); + if (percentageChange > 0) { + trendClassSuffix = "-up"; + } else if (percentageChange < 0) { + trendClassSuffix = "-down"; + } + } return new St.Label({ text : this.existsProperty(quote, "regularMarketChangePercent") ? (this.roundAmount(quote.regularMarketChangePercent, 2) + "%") : ABSENT, - style_class : "quotes-label" + style_class : "quotes-label" + trendClassSuffix }); }, roundAmount : function (amount, maxDecimals) { @@ -291,10 +321,14 @@ StockQuoteDesklet.prototype = { this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "showQuoteName", "showQuoteName", this.onSettingsChanged, null); + this.settings.bindProperty(Settings.BindingDirection.IN, "useLongQuoteName", "useLongQuoteName", + this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "linkQuoteName", "linkQuoteName", this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "showQuoteSymbol", "showQuoteSymbol", this.onSettingsChanged, null); + this.settings.bindProperty(Settings.BindingDirection.IN, "linkQuoteSymbol", "linkQuoteSymbol", + this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "showMarketPrice", "showMarketPrice", this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "showCurrencyCode", "showCurrencyCode", @@ -303,6 +337,8 @@ StockQuoteDesklet.prototype = { this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "showPercentChange", "showPercentChange", this.onSettingsChanged, null); + this.settings.bindProperty(Settings.BindingDirection.IN, "colorPercentChange", "colorPercentChange", + this.onSettingsChanged, null); this.settings.bindProperty(Settings.BindingDirection.IN, "showTradeTime", "showTradeTime", this.onSettingsChanged, null); }, @@ -310,12 +346,15 @@ StockQuoteDesklet.prototype = { return { "changeIcon" : this.showChangeIcon, "quoteName" : this.showQuoteName, + "useLongName" : this.useLongQuoteName, "linkQuote" : this.linkQuoteName, "quoteSymbol" : this.showQuoteSymbol, + "linkSymbol" : this.linkQuoteSymbol, "marketPrice" : this.showMarketPrice, "currencySymbol" : this.showCurrencyCode, "absoluteChange": this.showAbsoluteChange, "percentChange" : this.showPercentChange, + "colorPercentChange" : this.colorPercentChange, "tradeTime" : this.showTradeTime, "decimalPlaces" : this.roundNumbers ? this.decimalPlaces : -1 }; diff --git a/files/yfquotes@thegli/metadata.json b/files/yfquotes@thegli/metadata.json index faf8cd9..957b8c1 100644 --- a/files/yfquotes@thegli/metadata.json +++ b/files/yfquotes@thegli/metadata.json @@ -3,6 +3,6 @@ "name": "Yahoo Finance Quotes", "prevent-decorations": true, "max-instances": "10", - "version": "0.4.2", + "version": "0.5.0", "uuid": "yfquotes@thegli" } diff --git a/files/yfquotes@thegli/po/de.po b/files/yfquotes@thegli/po/de.po index c023a8f..81f6c84 100644 --- a/files/yfquotes@thegli/po/de.po +++ b/files/yfquotes@thegli/po/de.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2020-07-17 18:00+0200\n" -"PO-Revision-Date: 2020-09-20 14:00+0200\n" +"PO-Revision-Date: 2020-10-04 18:45+0200\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -168,7 +168,7 @@ msgid "Quote details" msgstr "Finanzinstrument Details" #. settings-schema.json->showChangeIcon->description -msgid "Show change icon" +msgid "Show change/trend icon" msgstr "Änderungssymbol anzeigen" #. settings-schema.json->showChangeIcon->tooltip @@ -183,13 +183,21 @@ msgstr "Name anzeigen" msgid "Display the quote name (eg. International Business Machines)." msgstr "Zeigt den Namen des Instruments an (z.B. International Business Machines)." +#. settings-schema.json->useLongQuoteName->description +msgid "Use long version for verbose name" +msgstr "Verwende die längere Version des Namens" + +#. settings-schema.json->useLongQuoteName->tooltip +msgid "Use the long version for quote name, if available (eg. International Business Machines Corporation)." +msgstr "Verwende die längere Version des Namens, falls vorhanden (z.B. International Business Machines Corporation)." + #. settings-schema.json->linkQuoteName->description msgid "Add web link to name" msgstr "Name mit Web Link hinterlegen" #. settings-schema.json->linkQuoteName->tooltip -msgid "Click to open quote in browser." -msgstr "Anklicken, um das Instrument im Browser zu öffnen." +msgid "Click name to open quote in browser." +msgstr "Name anklicken, um das Instrument im Browser zu öffnen." #. settings-schema.json->showQuoteSymbol->description msgid "Show ticker/symbol" @@ -199,6 +207,14 @@ msgstr "Symbol anzeigen" msgid "Display the quote symbol (eg. IBM)." msgstr "Zeigt das Symbol des Instruments an (z.B. IBM)." +#. settings-schema.json->linkQuoteSymbol->description +msgid "Add web link to ticker/symbol" +msgstr "Symbol mit Web Link hinterlegen" + +#. settings-schema.json->linkQuoteSymbol->tooltip +msgid "Click symbol to open quote in browser." +msgstr "Symbol anklicken, um das Instrument im Browser zu öffnen." + #. settings-schema.json->showMarketPrice->description msgid "Show price" msgstr "Marktpreis anzeigen" @@ -231,6 +247,14 @@ msgstr "Prozentuale Veränderung anzeigen" msgid "Display the percent change of the market price (eg. +0.53%)." msgstr "Zeigt die relative Veränderung des Marktpreises an (z.B. +0.53%)." +#. settings-schema.json->colorPercentChange->description +msgid "Use trend colors for percent change" +msgstr "Verwende Trend-Farben bei prozentualer Veränderung" + +#. settings-schema.json->colorPercentChange->tooltip +msgid "Color the percent change to show the trend (green for up, red for down)." +msgstr "Färbt die prozentuale Veränderung gemäss Trend (grün für höher, rot für tiefer)." + #. settings-schema.json->showTradeTime->description msgid "Show trading time" msgstr "Handelszeitpunkt anzeigen" diff --git a/files/yfquotes@thegli/po/yfquotes@thegli.pot b/files/yfquotes@thegli/po/yfquotes@thegli.pot index 3664353..25ee4f0 100644 --- a/files/yfquotes@thegli/po/yfquotes@thegli.pot +++ b/files/yfquotes@thegli/po/yfquotes@thegli.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2020-07-17 18:00+0200\n" -"PO-Revision-Date: 2020-09-20 14:00+0200\n" +"PO-Revision-Date: 2020-10-04 18:45+0200\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -181,12 +181,20 @@ msgstr "" msgid "Display the quote name (eg. International Business Machines)." msgstr "" +#. settings-schema.json->useLongQuoteName->description +msgid "Use long version for verbose name" +msgstr "" + +#. settings-schema.json->useLongQuoteName->tooltip +msgid "Use the long version for quote name, if available (eg. International Business Machines Corporation)." +msgstr "" + #. settings-schema.json->linkQuoteName->description msgid "Add web link to name" msgstr "" #. settings-schema.json->linkQuoteName->tooltip -msgid "Click to open quote in browser." +msgid "Click name to open quote in browser." msgstr "" #. settings-schema.json->showQuoteSymbol->description @@ -197,6 +205,14 @@ msgstr "" msgid "Display the quote symbol (eg. IBM)." msgstr "" +#. settings-schema.json->linkQuoteSymbol->description +msgid "Add web link to ticker/symbol" +msgstr "" + +#. settings-schema.json->linkQuoteSymbol->tooltip +msgid "Click symbol to open quote in browser." +msgstr "" + #. settings-schema.json->showMarketPrice->description msgid "Show price" msgstr "" @@ -229,6 +245,14 @@ msgstr "" msgid "Display the percent change of the market price (eg. +0.53%)." msgstr "" +#. settings-schema.json->colorPercentChange->description +msgid "Use trend colors for percent change" +msgstr "" + +#. settings-schema.json->colorPercentChange->tooltip +msgid "Color the percent change to show the trend (green for up, red for down)." +msgstr "" + #. settings-schema.json->showTradeTime->description msgid "Show trading time" msgstr "" diff --git a/files/yfquotes@thegli/settings-schema.json b/files/yfquotes@thegli/settings-schema.json index 8980f1b..3eceba2 100644 --- a/files/yfquotes@thegli/settings-schema.json +++ b/files/yfquotes@thegli/settings-schema.json @@ -5,7 +5,7 @@ }, "width": { "type": "spinbutton", - "default": 480, + "default": 560, "min": 40, "max": 4000, "step": 20, @@ -102,7 +102,7 @@ "showChangeIcon": { "type": "checkbox", "default": true, - "description": "Show change icon", + "description": "Show change/trend icon", "tooltip": "Indicates whether the market price moved up, down, or is unchanged." }, "showQuoteName": { @@ -111,11 +111,18 @@ "description": "Show verbose name", "tooltip": "Display the quote name (eg. International Business Machines)." }, + "useLongQuoteName": { + "type": "checkbox", + "default": true, + "description": "Use long version for verbose name", + "tooltip": "Use the long version for quote name, if available (eg. International Business Machines Corporation).", + "dependency": "showQuoteName" + }, "linkQuoteName": { "type": "checkbox", "default": true, "description": "Add web link to name", - "tooltip": "Click to open quote in browser.", + "tooltip": "Click name to open quote in browser.", "dependency": "showQuoteName" }, "showQuoteSymbol": { @@ -124,6 +131,13 @@ "description": "Show ticker/symbol", "tooltip": "Display the quote symbol (eg. IBM)." }, + "linkQuoteSymbol": { + "type": "checkbox", + "default": true, + "description": "Add web link to ticker/symbol", + "tooltip": "Click symbol to open quote in browser.", + "dependency": "showQuoteSymbol" + }, "showMarketPrice": { "type": "checkbox", "default": true, @@ -149,6 +163,13 @@ "description": "Show percent change", "tooltip": "Display the percent change of the market price (eg. +0.53%)." }, + "colorPercentChange": { + "type": "checkbox", + "default": true, + "description": "Use trend colors for percent change", + "tooltip": "Color the percent change to show the trend (green for up, red for down).", + "dependency": "showPercentChange" + }, "showTradeTime": { "type": "checkbox", "default": true, diff --git a/files/yfquotes@thegli/stylesheet.css b/files/yfquotes@thegli/stylesheet.css index 5b6e1ea..7d301af 100644 --- a/files/yfquotes@thegli/stylesheet.css +++ b/files/yfquotes@thegli/stylesheet.css @@ -14,6 +14,16 @@ text-align: center; } +.quotes-label-up { + text-align: center; + color: #00cc55; +} + +.quotes-label-down { + text-align: center; + color: #cc0000; +} + .error-label { text-align: left; color: #cc0000; diff --git a/screenshot.png b/screenshot.png index 036d72c..afe0fee 100644 Binary files a/screenshot.png and b/screenshot.png differ