Skip to content

Commit

Permalink
v1.7 - Fixes linuxmint#1055
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiux committed Feb 15, 2024
1 parent 242fb70 commit a98cff3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
34 changes: 31 additions & 3 deletions clock@schorschii/files/clock@schorschii/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ MyDesklet.prototype = {
_init: function(metadata, desklet_id) {
Desklet.Desklet.prototype._init.call(this, metadata);

this.cLabel = new St.Label();

// initialize settings
this.settings = new Settings.DeskletSettings(this, this.metadata["uuid"], desklet_id);
this.settings.bindProperty(Settings.BindingDirection.IN, "desklet-size", "desklet_size", this.on_setting_changed);
Expand All @@ -66,6 +68,26 @@ MyDesklet.prototype = {
this.setupUI();
},

refreshLabel: function() {
if (this.clock && this.use_custom_label && this.custom_label.length > 0) {
this.cLabel.set_text(this.custom_label);
//~ let themeFontSize = this.clock.get_theme_node().get_length("font-size");
let fontSize = Math.round(this.desklet_size / 10 * global.ui_scale);
//~ global.log("fontSize: "+fontSize);
this.cLabel.style = "font-size: " + fontSize + "px; color: white;";
let clockSize = this.clock.size;
let labelSize = this.cLabel.size;
let x = Math.round((clockSize.width - labelSize.width) / 2.0);
let y = Math.round((clockSize.height - labelSize.height) / 3.0);
//~ global.log("x: "+x);
//~ global.log("y: "+y);
this.cLabel.set_position(x, y);
this.cLabel.show()
} else {
this.cLabel.hide()
}
},

setupUI: function() {
// load images and add actors
this.refreshSize();
Expand Down Expand Up @@ -113,6 +135,8 @@ MyDesklet.prototype = {
this.minute_hand.set_rotation_angle(Clutter.RotateAxis.Z_AXIS, minutes_deg);
this.hour_hand.set_rotation_angle(Clutter.RotateAxis.Z_AXIS, hours_deg);

this.cLabel.show();

// refresh again in 100 milliseconds, or when the second next changes
let timeoutval = 100;
if(this.show_seconds_hand == false)
Expand Down Expand Up @@ -176,17 +200,21 @@ MyDesklet.prototype = {
this.clock_container.add_actor(this.minute_hand);
if(this.show_seconds_hand == true)
this.clock_container.add_actor(this.second_hand);
this.clock_container.add_actor(this.cLabel);

// set root element
this.clock.add_actor(this.clock_container);
this.setContent(this.clock);
},

refreshDecoration: function() {
// set label
this.refreshLabel();

// desklet label (header)
if(this.use_custom_label == true)
this.setHeader(this.custom_label)
else
if(this.use_custom_label == true) {
this.setHeader(this.custom_label);
} else
this.setHeader(_("Clock"));

// prevent decorations?
Expand Down
2 changes: 1 addition & 1 deletion clock@schorschii/files/clock@schorschii/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"max-instances": "10",
"description": "A scaleable analog clock desklet with smooth hands and free choice of images.",
"name": "Analog Chronometer",
"version": "1.6"
"version": "1.7"
}

0 comments on commit a98cff3

Please sign in to comment.