Skip to content

Commit

Permalink
dual-datetime@rcalixte: Add an option for time string alignment in bo…
Browse files Browse the repository at this point in the history
…th layouts (#905)
  • Loading branch information
rcalixte authored Aug 7, 2023
1 parent 9a769be commit 9d4873f
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 24 deletions.
4 changes: 4 additions & 0 deletions dual-datetime@rcalixte/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

### 1.1

* Add an option for time string alignment in both layouts

### 1.0

* Initial release
3 changes: 2 additions & 1 deletion dual-datetime@rcalixte/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ DESCRIPTION
Adjust the following options for each datetime value using the settings:

* Time Format
* Time Alignment (per Layout)
* Font
* Color
* Size

Additional desklet options include:

* Fixed Width
* Vertical or Horizontal
* Layout (Vertical or Horizontal)
* Show Decorations
* Background Color

Expand Down
22 changes: 19 additions & 3 deletions dual-datetime@rcalixte/files/dual-datetime@rcalixte/5.4/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -103,7 +149,7 @@
"title_align": {
"type": "combobox",
"default": "vertical",
"description": "Alignment for time strings",
"description": "Layout",
"options": {
"Vertical": "vertical",
"Horizontal": "horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
],
"multiversion": true,
"max-instances": "10",
"version": "1.0"
"version": "1.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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
Expand Down
52 changes: 48 additions & 4 deletions dual-datetime@rcalixte/files/dual-datetime@rcalixte/po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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"
Expand Down
Loading

0 comments on commit 9d4873f

Please sign in to comment.