From 9d4873f3c39b46c67c9f6b75caee0c6472153802 Mon Sep 17 00:00:00 2001 From: Rick Calixte <10281587+rcalixte@users.noreply.github.com> Date: Sun, 6 Aug 2023 20:53:20 -0400 Subject: [PATCH] dual-datetime@rcalixte: Add an option for time string alignment in both layouts (#905) --- dual-datetime@rcalixte/CHANGELOG.md | 4 ++ dual-datetime@rcalixte/README.md | 3 +- .../dual-datetime@rcalixte/5.4/desklet.js | 22 ++++++- .../5.4/settings-schema.json | 48 +++++++++++++- .../dual-datetime@rcalixte/metadata.json | 2 +- .../po/dual-datetime@rcalixte.pot | 50 +++++++++++++- .../files/dual-datetime@rcalixte/po/es.po | 52 +++++++++++++-- .../files/dual-datetime@rcalixte/po/fr.po | 65 +++++++++++++++---- 8 files changed, 222 insertions(+), 24 deletions(-) diff --git a/dual-datetime@rcalixte/CHANGELOG.md b/dual-datetime@rcalixte/CHANGELOG.md index 58d99ae81..1975822d6 100644 --- a/dual-datetime@rcalixte/CHANGELOG.md +++ b/dual-datetime@rcalixte/CHANGELOG.md @@ -1,4 +1,8 @@ +### 1.1 + +* Add an option for time string alignment in both layouts + ### 1.0 * Initial release diff --git a/dual-datetime@rcalixte/README.md b/dual-datetime@rcalixte/README.md index 3032181d4..c15c373d8 100644 --- a/dual-datetime@rcalixte/README.md +++ b/dual-datetime@rcalixte/README.md @@ -11,6 +11,7 @@ DESCRIPTION Adjust the following options for each datetime value using the settings: * Time Format +* Time Alignment (per Layout) * Font * Color * Size @@ -18,7 +19,7 @@ Adjust the following options for each datetime value using the settings: Additional desklet options include: * Fixed Width -* Vertical or Horizontal +* Layout (Vertical or Horizontal) * Show Decorations * Background Color diff --git a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/desklet.js b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/desklet.js index 6c11d3740..038ce7592 100644 --- a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/desklet.js +++ b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/desklet.js @@ -18,6 +18,12 @@ function _(str) { return Gettext.dgettext(UUID, str); } +const ST_ALIGNMENT = { + "left": St.Align.START, + "center": St.Align.MIDDLE, + "right": St.Align.END +}; + function DateTimeDesklet(metadata, desklet_id) { this._init(metadata, desklet_id); } @@ -37,11 +43,15 @@ DateTimeDesklet.prototype = { this.settings = new Settings.DeskletSettings(this, UUID, this.desklet_id); this.settings.bindProperty(Settings.BindingDirection.IN, "time_custom1", "time_custom1", this.setupUI); this.settings.bindProperty(Settings.BindingDirection.IN, "time_format1", "time_format1", this.setupUI); + this.settings.bindProperty(Settings.BindingDirection.IN, "time_align1", "time_align1", this.setupUI); + this.settings.bindProperty(Settings.BindingDirection.IN, "time_yalign1", "time_yalign1", this.setupUI); this.settings.bindProperty(Settings.BindingDirection.IN, "time_font1", "time_font1", this.on_font_setting_changed, 1); this.settings.bindProperty(Settings.BindingDirection.IN, "time_color1", "time_color1", this.setupUI); this.settings.bindProperty(Settings.BindingDirection.IN, "time_size1", "time_size1", this.on_font_setting_changed, 1); this.settings.bindProperty(Settings.BindingDirection.IN, "time_custom2", "time_custom2", this.setupUI); this.settings.bindProperty(Settings.BindingDirection.IN, "time_format2", "time_format2", this.setupUI); + this.settings.bindProperty(Settings.BindingDirection.IN, "time_align2", "time_align2", this.setupUI); + this.settings.bindProperty(Settings.BindingDirection.IN, "time_yalign2", "time_yalign2", this.setupUI); this.settings.bindProperty(Settings.BindingDirection.IN, "time_font2", "time_font2", this.on_font_setting_changed, 2); this.settings.bindProperty(Settings.BindingDirection.IN, "time_color2", "time_color2", this.setupUI); this.settings.bindProperty(Settings.BindingDirection.IN, "time_size2", "time_size2", this.on_font_setting_changed, 2); @@ -82,12 +92,17 @@ DateTimeDesklet.prototype = { this[`container${num}`] = new St.BoxLayout({ vertical: false }); this[`datetime${num}`] = new St.Label({ text: "" }); this[`datetime${num}`].clutterText.ellipsize = Pango.EllipsizeMode.NONE; - this[`container${num}`].add(this[`datetime${num}`]); + let _other_num = num == 1 ? 2 : 1; + let _y_alignment = !this._vertical && this.time_custom1 && this.time_format1 && + this.time_custom2 && this.time_format2 && this[`time_size${_other_num}`] > this[`time_size${num}`] ? + { y_fill: false, y_align: ST_ALIGNMENT[this[`time_yalign${num}`]] } : null; + this[`container${num}`].add(this[`datetime${num}`], _y_alignment); this[`time_font${num}`] = this[`time_font${num}`].replace(/['"`]/g, ""); this[`font${num}`] = this[`time_font${num}`] !== "" ? ` font-family: '${this["time_font" + num]}';` : ""; let _padding = this._vertical || num == 1 ? "" : "padding-left: 0.5em; "; this[`container${num}`].style = `${_padding}color: ${this['time_color' + num]}; font-size: ${this['time_size' + num]}em;${this['font' + num]}`; - this._main.add(this[`container${num}`]); + let _alignment = this._vertical ? { x_fill: false, x_align: ST_ALIGNMENT[this[`time_align${num}`]] } : null; + this._main.add(this[`container${num}`], _alignment); }, _updateUI: function () { @@ -126,7 +141,8 @@ DateTimeDesklet.prototype = { } catch (e) { global.logError(e); } finally { - this[`container${num}`].style = `color: ${this["time_color" + num]}; font-size: ${this["time_size" + num]}em;${this["font" + num]}`; + let _padding = this._vertical || num == 1 ? "" : "padding-left: 0.5em; "; + this[`container${num}`].style = `${_padding}color: ${this["time_color" + num]}; font-size: ${this["time_size" + num]}em;${this["font" + num]}`; } }); } catch (e) { diff --git a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/settings-schema.json b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/settings-schema.json index 2fdd32310..c816561bf 100644 --- a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/settings-schema.json +++ b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/settings-schema.json @@ -15,6 +15,29 @@ "tooltip": "The datetime format to use for the output. See 'Format String Help' below for additional details.", "dependency": "time_custom1" }, + "time_align1": { + "type": "combobox", + "description": "Time Alignment", + "default": "left", + "dependency": "title_align=vertical", + "options": { + "Left": "left", + "Center": "center", + "Right": "right" + } + }, + "time_yalign1": { + "type": "combobox", + "description": "Time Alignment", + "default": "left", + "tooltip": "This value only applies if the this time value is a smaller size than the other", + "dependency": "title_align!=vertical", + "options": { + "Top": "left", + "Middle": "center", + "Bottom": "right" + } + }, "time_font1": { "type": "entry", "description": "Font Family (blank for default)", @@ -54,6 +77,29 @@ "tooltip": "The datetime format to use for the output. See 'Format String Help' below for additional details.", "dependency": "time_custom2" }, + "time_align2": { + "type": "combobox", + "description": "Time Alignment", + "default": "left", + "dependency": "title_align=vertical", + "options": { + "Left": "left", + "Center": "center", + "Right": "right" + } + }, + "time_yalign2": { + "type": "combobox", + "description": "Time Alignment", + "default": "left", + "tooltip": "This value only applies if the this time value is a smaller size than the other", + "dependency": "title_align!=vertical", + "options": { + "Top": "left", + "Middle": "center", + "Bottom": "right" + } + }, "time_font2": { "type": "entry", "description": "Font Family (blank for default)", @@ -103,7 +149,7 @@ "title_align": { "type": "combobox", "default": "vertical", - "description": "Alignment for time strings", + "description": "Layout", "options": { "Vertical": "vertical", "Horizontal": "horizontal" diff --git a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/metadata.json b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/metadata.json index dc67022d1..6d7f64aee 100644 --- a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/metadata.json +++ b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/metadata.json @@ -9,5 +9,5 @@ ], "multiversion": true, "max-instances": "10", - "version": "1.0" + "version": "1.1" } diff --git a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/dual-datetime@rcalixte.pot b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/dual-datetime@rcalixte.pot index 42c52687c..9669bf12f 100644 --- a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/dual-datetime@rcalixte.pot +++ b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/dual-datetime@rcalixte.pot @@ -5,9 +5,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: 1.0\n" +"Project-Id-Version: 1.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-06 23:40-0400\n" +"POT-Creation-Date: 2023-08-06 20:33-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -41,6 +41,50 @@ msgid "" "for additional details." msgstr "" +#. 5.4->settings-schema.json->time_align1->description +#. 5.4->settings-schema.json->time_yalign1->description +#. 5.4->settings-schema.json->time_align2->description +#. 5.4->settings-schema.json->time_yalign2->description +msgid "Time Alignment" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Left" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Center" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Right" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->tooltip +#. 5.4->settings-schema.json->time_yalign2->tooltip +msgid "" +"This value only applies if the this time value is a smaller size than the " +"other" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Top" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Middle" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Bottom" +msgstr "" + #. 5.4->settings-schema.json->time_font1->description #. 5.4->settings-schema.json->time_font2->description msgid "Font Family (blank for default)" @@ -94,7 +138,7 @@ msgid "" msgstr "" #. 5.4->settings-schema.json->title_align->description -msgid "Alignment for time strings" +msgid "Layout" msgstr "" #. 5.4->settings-schema.json->title_align->options diff --git a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/es.po b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/es.po index 172603d1c..9e555e032 100644 --- a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/es.po +++ b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-06 23:40-0400\n" -"PO-Revision-Date: \n" +"POT-Creation-Date: 2023-08-06 20:33-0400\n" +"PO-Revision-Date: 2023-08-06 20:35-0400\n" "Last-Translator: \n" "Language-Team: \n" "Language: es\n" @@ -42,6 +42,50 @@ msgstr "" "Formato de fecha y hora que se usará para la salida. Consulte 'Ayuda para " "dar formato a cadenas' a continuación para obtener detalles adicionales." +#. 5.4->settings-schema.json->time_align1->description +#. 5.4->settings-schema.json->time_yalign1->description +#. 5.4->settings-schema.json->time_align2->description +#. 5.4->settings-schema.json->time_yalign2->description +msgid "Time Alignment" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Left" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Center" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Right" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->tooltip +#. 5.4->settings-schema.json->time_yalign2->tooltip +msgid "" +"This value only applies if the this time value is a smaller size than the " +"other" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Top" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Middle" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Bottom" +msgstr "" + #. 5.4->settings-schema.json->time_font1->description #. 5.4->settings-schema.json->time_font2->description msgid "Font Family (blank for default)" @@ -99,8 +143,8 @@ msgstr "" "desklet" #. 5.4->settings-schema.json->title_align->description -msgid "Alignment for time strings" -msgstr "Alineación de las cadenas" +msgid "Layout" +msgstr "" #. 5.4->settings-schema.json->title_align->options msgid "Vertical" diff --git a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/fr.po b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/fr.po index fdbff1891..4d174cc26 100644 --- a/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/fr.po +++ b/dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-06 23:40-0400\n" -"PO-Revision-Date: \n" +"POT-Creation-Date: 2023-08-06 20:33-0400\n" +"PO-Revision-Date: 2023-08-06 20:35-0400\n" "Last-Translator: Claudiux \n" "Language-Team: \n" "Language: fr\n" @@ -15,7 +15,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Generator: Poedit 3.0.1\n" +"X-Generator: Poedit 3.3.1\n" #. metadata.json->description msgid "A desklet that can display dual datetime strings" @@ -42,8 +42,52 @@ msgid "" "The datetime format to use for the output. See 'Format String Help' below " "for additional details." msgstr "" -"Le format de date à utiliser pour la sortie. Voir l'aide sur les chaînes " -"de format ci-dessous pour plus de détails." +"Le format de date à utiliser pour la sortie. Voir l'aide sur les chaînes de " +"format ci-dessous pour plus de détails." + +#. 5.4->settings-schema.json->time_align1->description +#. 5.4->settings-schema.json->time_yalign1->description +#. 5.4->settings-schema.json->time_align2->description +#. 5.4->settings-schema.json->time_yalign2->description +msgid "Time Alignment" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Left" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Center" +msgstr "" + +#. 5.4->settings-schema.json->time_align1->options +#. 5.4->settings-schema.json->time_align2->options +msgid "Right" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->tooltip +#. 5.4->settings-schema.json->time_yalign2->tooltip +msgid "" +"This value only applies if the this time value is a smaller size than the " +"other" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Top" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Middle" +msgstr "" + +#. 5.4->settings-schema.json->time_yalign1->options +#. 5.4->settings-schema.json->time_yalign2->options +msgid "Bottom" +msgstr "" #. 5.4->settings-schema.json->time_font1->description #. 5.4->settings-schema.json->time_font2->description @@ -71,8 +115,8 @@ msgstr "Taille de la police de caractères" msgid "" "Increase or decrease this value to change the font size scale (1.2 = 120%)" msgstr "" -"Augmentez ou diminuez cette valeur pour modifier l'échelle de la taille " -"de la police (1,2 = 120%)." +"Augmentez ou diminuez cette valeur pour modifier l'échelle de la taille de " +"la police (1,2 = 120%)." #. 5.4->settings-schema.json->time_custom2->description msgid "Customize Second Time Value" @@ -97,12 +141,11 @@ msgstr "Largeur fixée pour ce desklet" #. 5.4->settings-schema.json->width->tooltip msgid "" "Increase or decrease this value to set the boundary width of the desklet" -msgstr "" -"Augmentez ou diminuez cette valeur pour définir la largeur du desklet." +msgstr "Augmentez ou diminuez cette valeur pour définir la largeur du desklet." #. 5.4->settings-schema.json->title_align->description -msgid "Alignment for time strings" -msgstr "Alignement des heures et dates" +msgid "Layout" +msgstr "" #. 5.4->settings-schema.json->title_align->options msgid "Vertical"