Skip to content

Commit d95aa07

Browse files
Add background color to timezone label, and text css can be set by setting entry field
1 parent e746f52 commit d95aa07

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

clock@schorschii/files/clock@schorschii/desklet.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ MyDesklet.prototype = {
6464
this.settings.bindProperty(Settings.BindingDirection.IN, "background-color", "background_color", this.on_setting_changed);
6565
this.settings.bindProperty(Settings.BindingDirection.IN, "show-timezone-name", "show_timezone_name", this.on_setting_changed);
6666
this.settings.bindProperty(Settings.BindingDirection.IN, "timezone-name", "timezone_name", this.on_setting_changed);
67+
this.settings.bindProperty(Settings.BindingDirection.IN, "text-font-css", "text_font_css", this.on_setting_changed);
68+
this.settings.bindProperty(Settings.BindingDirection.IN, "label-background-color", "label_bg_color", this.on_setting_changed);
6769

6870
// initialize desklet gui
6971
this.setupUI();
@@ -191,12 +193,19 @@ MyDesklet.prototype = {
191193

192194
// Add Timezone Name and UTC Offset Label
193195
if(this.show_timezone_name && this.use_custom_tz) {
194-
let tz_label_text = "UTC "+this.custom_tz+" \n "+this.timezone_name || "";
195-
let tz_text = new St.Label({
196-
text: tz_label_text,
197-
style: "text-align: center; margin-top: 5px; font-size: 14px;"
198-
});
199-
this.main_container.add_actor(tz_text);
196+
this.tz_container = new St.Bin({
197+
style: `background-color: ${this.label_bg_color}; padding: 5px; border-radius: 5px; margin-top: 5px;`
198+
});
199+
// We create the label and apply the custom font CSS
200+
let tz_label_text = "UTC "+this.custom_tz+" \n "+this.timezone_name || "";
201+
this.tz_label = new St.Label({
202+
text: tz_label_text, // Text will be set in refresh()
203+
style: `text-align: center; ${this.text_font_css}`
204+
});
205+
206+
this.tz_container.set_child(this.tz_label);
207+
this.main_container.add_actor(this.tz_container);
208+
200209
}
201210

202211
this.setContent(this.main_container);

clock@schorschii/files/clock@schorschii/settings-schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@
117117
"dependency": "use-custom-tz",
118118
"tooltip": "Enter your timezone name here."
119119
},
120+
"text_font_css": {
121+
"type": "entry",
122+
"default": "margin-top: 5px; font-size: 12px;",
123+
"description": "CSS for the text displying in label",
124+
"indent": true,
125+
"dependency": "use-custom-tz",
126+
"tooltip": "Enter CSS for the font"
127+
},
128+
"label-background-color": {
129+
"type": "colorchooser",
130+
"default": "rgba(255,255,255,0)",
131+
"description": "Text Label Background color, can be set to transparent"
132+
},
133+
120134
"show-timezone-name": {
121135
"type": "checkbox",
122136
"default": false,

0 commit comments

Comments
 (0)