Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@schorschii desklets: unify desklet width #948

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions battery@schorschii/files/battery@schorschii/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MyDesklet.prototype = {
setupUI: function() {
// defaults and initial values
this.default_size_font = 25;
this.default_size_battery_width = 149;
this.default_size_battery_width = 150;
this.default_size_battery_height = 74;
this.default_size_symbol = 36;
this.default_segment_offset = 14;
Expand Down Expand Up @@ -240,6 +240,7 @@ MyDesklet.prototype = {
let symbolSize = this.default_size_symbol * scale;
let segmentWidthMax = segmentWidth * 0.95;
let segmentWidthCalced = segmentWidthMax * (this.currentCapacity / 100);
let xCorrection = -3 * scale;

// set images
let bar_img = "green.svg";
Expand Down Expand Up @@ -267,13 +268,17 @@ MyDesklet.prototype = {
// plug/warn/flash icon
if(symbol_img != "") {
this.imageIcon = getImageAtScale(DESKLET_ROOT + "/img/" + symbol_img, symbolSize, symbolSize);
this.imageIcon.set_position((segmentWidth / 2) - (symbolSize / 2), (segmentHeight / 2) - (symbolSize / 2));
this.imageIcon.set_position(
(segmentWidth / 2) - (symbolSize / 2) + xCorrection,
(segmentHeight / 2) - (symbolSize / 2)
);
}

// label for percent string
this.labelText = new St.Label({style_class:"text"});
this.labelText.set_position((segmentWidth / 2) - ((newFontSize * global.ui_scale * currentCapacityText.length / 1.25) / 2), (segmentHeight / 2) - (newFontSize * global.ui_scale / 1.7));
this.labelText.style = "font-size: " + newFontSizeRounded.toString() + "px;";
this.labelText.set_position(0, (segmentHeight / 2) - (newFontSize * global.ui_scale / 1.7));
this.labelText.style = "width: " + segmentWidthMax.toString() + "px; "
+ "font-size: " + newFontSizeRounded.toString() + "px;";
if(showText)
this.labelText.set_text(currentCapacityText);
else
Expand Down
2 changes: 1 addition & 1 deletion battery@schorschii/files/battery@schorschii/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"uuid": "battery@schorschii",
"max-instances": "10",
"description": "A battery desklet in iOS style with multi-battery support.",
"version": "2.7",
"version": "2.8",
"name": "Battery Level Indicator"
}
2 changes: 1 addition & 1 deletion battery@schorschii/files/battery@schorschii/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
font-family: "DejaVu Sans", Sans-serif;
font-weight: 100;
font-size: 24px;

text-align: center;
/* text-shadow: 0px 0px 5px rgba(0,0,0,0.85); */
}
16 changes: 8 additions & 8 deletions calendar@schorschii/files/calendar@schorschii/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ MyDesklet.prototype = {
// defaults and initial values
this.default_size_font_month_big = 45;
this.default_size_font_month_sub = 14;
this.default_size_battery_width = 130;
this.default_size_battery_height = 140;
this.default_month_big_top = 50;
this.default_month_sub_top = 105;
this.default_month_top_top = 27;
this.default_size_calendar_width = 150;
this.default_size_calendar_height = 162;
this.default_month_top_top = 35;
this.default_month_big_top = 61;
this.default_month_sub_top = 125;
this.dayofmonth = 0; this.monthofyear = 0; this.dayofweek = 0; this.year = 0;
this.dayofweek_string = ""; this.monthofyear_string = "";
this.last_notification_amount = 0;
Expand Down Expand Up @@ -197,9 +197,9 @@ MyDesklet.prototype = {

// calc new sizes based on scale factor
let scale = this.scale_size * global.ui_scale;
let desklet_width = this.default_size_battery_width * scale;
let desklet_height = this.default_size_battery_height * scale;
let label_width = Math.round(this.default_size_battery_width * this.scale_size);
let desklet_width = this.default_size_calendar_width * scale;
let desklet_height = this.default_size_calendar_height * scale;
let label_width = Math.round(this.default_size_calendar_width * this.scale_size);
let size_font_month_big = Math.round(this.default_size_font_month_big * this.scale_size);
let size_font_month_sub = Math.round(this.default_size_font_month_sub * this.scale_size);
let month_big_top = this.default_month_big_top * scale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"max-instances": "10",
"description": "A calendar desklet that can display the number of today's appointments from an ical/ics file.",
"name": "Calendar",
"version": "1.5"
"version": "1.6"
}
6 changes: 3 additions & 3 deletions diskspace@schorschii/files/diskspace@schorschii/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ MyDesklet.prototype = {

setupUI: function() {
// defaults and initial values
this.default_size = 160;
this.default_size_font = 32;
this.default_size_font_sub = 16;
this.default_size = 150;
this.default_size_font = 31;
this.default_size_font_sub = 15;

// create and set root element
this.canvas = new Clutter.Actor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"max-instances": "10",
"description": "Displays the usage of a filesystem or RAM.",
"name": "Disk Space",
"version": "1.16",
"version": "1.17",
"uuid": "diskspace@schorschii"
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"default": 1,
"min": 0.4,
"max": 10,
"step": 0.2,
"step": 0.05,
"units": "scale factor",
"description": "Desklet size",
"tooltip": "Increase or decrease the size of this desklet using this scale factor."
Expand Down
18 changes: 10 additions & 8 deletions hostcheck@schorschii/files/hostcheck@schorschii/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ MyDesklet.prototype = {

setupUI: function() {
// defaults and initial values
this.defaultWidth = 120;
this.defaultHeight = 38;
this.defaultInset = 8; // 2*Padding
this.defaultWidth = 140;
this.defaultHeight = 42;
this.defaultInset = 10; // 2*Padding
this.defaultFontSize = 16;

// create objects
this.statusLabel = new St.Label({style_class:"statusbox"});
Expand Down Expand Up @@ -156,17 +157,18 @@ MyDesklet.prototype = {
showStatus: function() {
// refresh desklet content
// calc new sizes based on scale factor
let absolute_size_x = (this.defaultWidth * this.scale_size * global.ui_scale) + (this.defaultInset * this.scale_size * global.ui_scale);
let absolute_size_y = (this.defaultHeight * this.scale_size * global.ui_scale) + (this.defaultInset * this.scale_size * global.ui_scale);
let absolute_width = (this.defaultWidth * this.scale_size * global.ui_scale) + (this.defaultInset * this.scale_size * global.ui_scale);
let absolute_height = (this.defaultHeight * this.scale_size * global.ui_scale) + (this.defaultInset * this.scale_size * global.ui_scale);
let label_size_x = this.defaultWidth * this.scale_size * global.ui_scale;
let label_size_y = this.defaultHeight * this.scale_size * global.ui_scale
let label_size_y = this.defaultHeight * this.scale_size * global.ui_scale;
let font_size = Math.round(this.defaultFontSize * this.scale_size * global.ui_scale);
// modify label
let statusString = this.statusTagString + " (" + this.interval + _('s') + ")\n" + this.host;
this.statusLabel.set_text(statusString);
this.statusLabel.style_class = "statusbox "+this.colorClass;
this.statusLabel.style = "width:"+label_size_x+"px; height:"+label_size_y+"px;";
this.statusLabel.style = "width:"+label_size_x+"px; height:"+label_size_y+"px; font-size:"+font_size+"px";
// modify desklet canvas
this.canvas.set_size(absolute_size_x, absolute_size_y);
this.canvas.set_size(absolute_width, absolute_height);

// desktop notification
if(this.prevStatusTagString != "" && this.prevStatusTagString != this.statusTagString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"max-instances": "10",
"description": "Checks a host via ping or HTTP(S) and displays if it is available.",
"name": "Host Check",
"version": "1.2",
"version": "1.3",
"uuid": "hostcheck@schorschii"
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"default": 1,
"min": 0.5,
"max": 10,
"step": 0.2,
"step": 0.05,
"units": "scale factor",
"description": "Desklet size",
"tooltip": "Increase or decrease the size of this desklet using this scale factor."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
.statusbox {
font-family: "Ubuntu", sans-serif;
font-weight: bold;
font-size: 15px;
font-size: 16px;
text-align: center;
vertical-align: middle;
width: 120px;
height: 38px;
width: 140px;
height: 42px;
background-color: #DDDDDD;
color: black;
border-radius: 4px;
box-shadow: 0px 0px 5px black;
padding: 4px;
padding: 5px;
padding-top: 7px;
}
.statusbox.green {
background-color: #2BB938;
Expand Down
Loading