Skip to content

Commit c01b8c6

Browse files
committed
LabelRoundy: rewrite
1 parent 62300a6 commit c01b8c6

File tree

8 files changed

+113
-112
lines changed

8 files changed

+113
-112
lines changed

data/stylesheet/_index.scss

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,50 @@ $fg-color: $BLACK_500;
55

66
$text_color: $fg_color;
77

8-
.roundy-label,
9-
.roundy-label:hover,
10-
.roundy-label:selected,
11-
.roundy-label:selected:focus,
12-
.roundy-label:hover:selected {
13-
background-image: none;
14-
box-shadow: none;
15-
color: rgba($text_color, 0.7);
16-
font-weight: 700;
17-
border-radius: 10px;
18-
padding: 0 6px;
8+
roundy-label,
9+
roundy-label:hover,
10+
roundy-label:selected,
11+
roundy-label:selected:focus,
12+
roundy-label:hover:selected {
1913
margin: 0 3px;
20-
border-width: 0;
2114

22-
@if $color-scheme == "light" {
23-
background-color: $SILVER_300;
24-
} @else if $color-scheme == "dark" {
25-
background-color: $SILVER_900;
15+
.small-label {
16+
padding: 0;
2617
}
27-
}
2818

29-
.green {
30-
background-color: rgba($LIME_300, 0.6);
31-
}
19+
.value {
20+
color: #{'alpha(@text_color, 0.7)'};
21+
font-feature-settings: "tnum";
22+
font-weight: 700;
23+
border-radius: 10px;
24+
padding: 0 6px;
25+
26+
@if $color-scheme == "light" {
27+
background-color: $SILVER_300;
28+
} @else if $color-scheme == "dark" {
29+
background-color: $SILVER_900;
30+
}
31+
}
32+
33+
&.green .value {
34+
background-color: rgba($LIME_300, 0.6);
35+
}
36+
37+
&.blue .value {
38+
background-color: rgba($BLUEBERRY_300, 0.6);
39+
}
3240

33-
.blue {
34-
background-color: rgba($BLUEBERRY_300, 0.6);
41+
&.username {
42+
&-other .value {
43+
background-color: $BANANA_300;
44+
color: #381F00;
45+
}
46+
47+
&-root .value {
48+
background-color: $STRAWBERRY_300;
49+
color: $SILVER_100;
50+
}
51+
}
3552
}
3653

3754
.grape_500 {
@@ -53,28 +70,6 @@ $text_color: $fg_color;
5370
}
5471
}
5572

56-
.username {
57-
&-current {
58-
@if $color-scheme == "light" {
59-
background-color: $SILVER_300;
60-
color: $SILVER_900;
61-
} @else if $color-scheme == "dark" {
62-
background-color: $SILVER_900;
63-
color: rgba($text_color, 0.7);
64-
}
65-
}
66-
67-
&-other {
68-
background-color: $BANANA_300;
69-
color: #381F00;
70-
}
71-
72-
&-root {
73-
background-color: $STRAWBERRY_300;
74-
color: $SILVER_100;
75-
}
76-
}
77-
7873
.state_badge,
7974
.state_badge:hover,
8075
.state_badge:selected,
@@ -176,16 +171,6 @@ $text_color: $fg_color;
176171
color: rgba($text_color, 0.5);
177172
}
178173

179-
.small-text {
180-
font-weight:bold;
181-
font-size:9px;
182-
@if $color-scheme == "light" {
183-
color:grey;
184-
} @else if $color-scheme == "dark" {
185-
color: $SILVER_500;
186-
}
187-
}
188-
189174
.graph {
190175
border-radius: 6px;
191176

src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,27 @@ public class Monitor.ProcessInfoHeader : Gtk.Grid {
6969
public void update (Process process) {
7070
application_name.set_text (process.application_name);
7171
application_name.tooltip_text = process.command;
72-
pid.set_text (process.stat.pid.to_string ());
73-
nice.set_text (process.stat.nice.to_string ());
74-
priority.set_text (process.stat.priority.to_string ());
72+
pid.text = process.stat.pid.to_string ();
73+
nice.text = process.stat.nice.to_string ();
74+
priority.text = process.stat.priority.to_string ();
7575

7676
if (process.uid == 0) {
77-
username.val.get_style_context ().add_class ("username-root");
78-
username.val.get_style_context ().remove_class ("username-other");
79-
username.val.get_style_context ().remove_class ("username-current");
77+
username.get_style_context ().add_class ("username-root");
78+
username.get_style_context ().remove_class ("username-other");
8079
} else if (process.uid == (int) Posix.getuid ()) {
81-
username.val.get_style_context ().add_class ("username-current");
82-
username.val.get_style_context ().remove_class ("username-other");
83-
username.val.get_style_context ().remove_class ("username-root");
80+
username.get_style_context ().remove_class ("username-other");
81+
username.get_style_context ().remove_class ("username-root");
8482
} else {
85-
username.val.get_style_context ().add_class ("username-other");
86-
username.val.get_style_context ().remove_class ("username-root");
87-
username.val.get_style_context ().remove_class ("username-current");
83+
username.get_style_context ().add_class ("username-other");
84+
username.get_style_context ().remove_class ("username-root");
8885
}
8986

90-
username.set_text (process.username);
87+
username.text = process.username;
9188
username.tooltip_text = process.uid.to_string ();
92-
num_threads.set_text (process.stat.num_threads.to_string ());
89+
num_threads.text = process.stat.num_threads.to_string ();
9390
state.set_text (process.stat.state);
9491
state.tooltip_text = set_state_tooltip ();
95-
num_threads.set_text (process.stat.num_threads.to_string ());
92+
num_threads.text = process.stat.num_threads.to_string ();
9693
set_icon (process);
9794
}
9895

src/Views/SystemView/SystemCPUView.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource {
8282
// temperature_index++;
8383
// }]
8484
cpu_temperature_chart.update (0, cpu.temperature_mean);
85-
cpu_temperature_label.set_text (("%.2f %s").printf (cpu.temperature_mean, _("")));
85+
cpu_temperature_label.text = ("%.2f %s").printf (cpu.temperature_mean, _(""));
8686

8787
double cpu_prev_util = 0;
8888

@@ -128,7 +128,7 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource {
128128
}
129129
}
130130
label_vertical_main_metric = ("%d%%").printf (cpu.percentage);
131-
cpu_frequency_label.set_text (("%.2f %s").printf (cpu.frequency, _("GHz")));
131+
cpu_frequency_label.text = ("%.2f %s").printf (cpu.frequency, _("GHz"));
132132
}
133133

134134
private Gtk.Grid grid_core_labels () {

src/Views/SystemView/SystemGPUView.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public class Monitor.SystemGPUView : Monitor.WidgetResource {
8080

8181
gpu_vram_percentage_chart.update (0, gpu.memory_percentage);
8282
gpu_temperature_chart.update (0, gpu.temperature);
83-
gpu_vram_percentage_label.set_text (("%.2f %s").printf (gpu.memory_percentage, "%"));
84-
gpu_temperature_label.set_text (("%.2f %s").printf (gpu.temperature, _("")));
83+
gpu_vram_percentage_label.text = ("%.2f %s").printf (gpu.memory_percentage, "%");
84+
gpu_temperature_label.text = ("%.2f %s").printf (gpu.temperature, _(""));
8585

8686
}
8787

src/Views/SystemView/SystemMemoryView.vala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public class Monitor.SystemMemoryView : Monitor.WidgetResource {
6262
// memory_chart.update (3, memory.shared_percentage + memory.buffer_percentage + memory.cached_percentage);
6363
// memory_chart.update (3, memory.shared_percentage + memory.buffer_percentage + memory.cached_percentage + memory.locked_percentage);
6464

65-
memory_total_label.set_text (format_size ((uint64) memory.total, IEC_UNITS));
66-
memory_used_label.set_text (format_size ((uint64) memory.used, IEC_UNITS));
67-
memory_buffered_label.set_text (format_size ((uint64) memory.buffer, IEC_UNITS));
68-
memory_cached_label.set_text (format_size ((uint64) memory.cached, IEC_UNITS));
69-
memory_locked_label.set_text (format_size ((uint64) memory.locked, IEC_UNITS));
65+
memory_total_label.text = format_size ((uint64) memory.total, IEC_UNITS);
66+
memory_used_label.text = format_size ((uint64) memory.used, IEC_UNITS);
67+
memory_buffered_label.text = format_size ((uint64) memory.buffer, IEC_UNITS);
68+
memory_cached_label.text = format_size ((uint64) memory.cached, IEC_UNITS);
69+
memory_locked_label.text = format_size ((uint64) memory.locked, IEC_UNITS);
7070

71-
memory_shared_label.set_text (format_size ((uint64) memory.shared, IEC_UNITS));
71+
memory_shared_label.text = format_size ((uint64) memory.shared, IEC_UNITS);
7272
}
7373

7474
}

src/Views/SystemView/SystemNetworkView.vala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public class Monitor.SystemNetworkView : Gtk.Grid {
2222

2323
network_name_label = new Granite.HeaderLabel (_("Network"));
2424

25-
network_download_label = new LabelRoundy (_("DOWN"));
26-
network_download_label.val.set_width_chars (7);
27-
network_download_label.set_color ("blue");
25+
network_download_label = new LabelRoundy (_("DOWN")) {
26+
width_chars = 7
27+
};
28+
network_download_label.get_style_context ().add_class ("blue");
2829

29-
network_upload_label = new LabelRoundy (_("UP"));
30-
network_upload_label.val.set_width_chars (7);
31-
network_upload_label.set_color ("green");
30+
network_upload_label = new LabelRoundy (_("UP")) {
31+
width_chars = 7
32+
};
33+
network_upload_label.get_style_context ().add_class ("green");
3234

3335
network_chart = new Chart (2);
3436
network_chart.config.y_axis.fixed_max = null;
@@ -52,8 +54,8 @@ public class Monitor.SystemNetworkView : Gtk.Grid {
5254
double up_bytes = network.bytes_out;
5355
double down_bytes = network.bytes_in;
5456
if (up_bytes >= 0 && down_bytes >= 0) {
55-
network_download_label.set_text (("%s/s").printf (format_size ((uint64) down_bytes, IEC_UNITS)));
56-
network_upload_label.set_text (("%s/s").printf (format_size ((uint64) up_bytes, IEC_UNITS)));
57+
network_download_label.text = ("%s/s").printf (format_size ((uint64) down_bytes, IEC_UNITS));
58+
network_upload_label.text = ("%s/s").printf (format_size ((uint64) up_bytes, IEC_UNITS));
5759
network_chart.update (0, up_bytes);
5860
network_chart.update (1, down_bytes);
5961
}

src/Views/SystemView/SystemStorageView.vala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ public class Monitor.SystemStorageView : Gtk.Grid {
2424

2525
storage_name_label = new Granite.HeaderLabel (_("Storage"));
2626

27-
storage_write_label = new LabelRoundy (_("WRITE"));
28-
storage_write_label.val.set_width_chars (7);
29-
storage_write_label.set_color ("blue");
27+
storage_write_label = new LabelRoundy (_("WRITE")) {
28+
width_chars = 7
29+
};
30+
storage_write_label.get_style_context ().add_class ("blue");
3031

31-
storage_read_label = new LabelRoundy (_("READ"));
32-
storage_read_label.val.set_width_chars (7);
33-
storage_read_label.set_color ("green");
32+
storage_read_label = new LabelRoundy (_("READ")) {
33+
width_chars = 7
34+
};
35+
storage_read_label.get_style_context ().add_class ("green");
3436

3537
storage_chart = new Chart (2);
3638
storage_chart.config.y_axis.fixed_max = null;
@@ -123,8 +125,8 @@ public class Monitor.SystemStorageView : Gtk.Grid {
123125
double up_bytes = storage.bytes_read;
124126
double down_bytes = storage.bytes_write;
125127
if (up_bytes >= 0 && down_bytes >= 0) {
126-
storage_write_label.set_text (("%s/s").printf (format_size ((uint64) down_bytes, IEC_UNITS)));
127-
storage_read_label.set_text (("%s/s").printf (format_size ((uint64) up_bytes, IEC_UNITS)));
128+
storage_write_label.text = ("%s/s").printf (format_size ((uint64) down_bytes, IEC_UNITS));
129+
storage_read_label.text = ("%s/s").printf (format_size ((uint64) up_bytes, IEC_UNITS));
128130
storage_chart.update (0, up_bytes);
129131
storage_chart.update (1, down_bytes);
130132
}

src/Widgets/Labels/LabelRoundy.vala

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,44 @@
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*/
55

6-
public class Monitor.LabelRoundy : Gtk.Fixed {
7-
public Gtk.Label val;
8-
public Gtk.Label desc;
6+
public class Monitor.LabelRoundy : Gtk.Box {
7+
public string title { get; construct; }
98

10-
public LabelRoundy (string description) {
11-
val = new Gtk.Label (Utils.NO_DATA) {
12-
selectable = true
13-
};
14-
val.get_style_context ().add_class ("roundy-label");
15-
16-
desc = new Gtk.Label (description.up ());
17-
desc.get_style_context ().add_class ("small-text");
9+
public string text {
10+
set {
11+
val.label = value;
12+
}
13+
}
1814

19-
put (val, 0, 12);
20-
put (desc, 6, 0);
15+
public int width_chars {
16+
set {
17+
val.width_chars = value;
18+
}
2119
}
2220

23-
public void set_color (string colorname) {
24-
val.get_style_context ().add_class (colorname);
21+
private Gtk.Label val;
22+
23+
public LabelRoundy (string title) {
24+
Object (title: title);
2525
}
2626

27-
public void set_text (string text) {
28-
val.set_text (text);
27+
class construct {
28+
set_css_name ("roundy-label");
2929
}
3030

31+
construct {
32+
val = new Gtk.Label (Utils.NO_DATA) {
33+
selectable = true
34+
};
35+
val.get_style_context ().add_class ("value");
36+
37+
var header_label = new Granite.HeaderLabel (title.up ()) {
38+
mnemonic_widget = val
39+
};
40+
header_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL);
41+
42+
orientation = VERTICAL;
43+
add (header_label);
44+
add (val);
45+
}
3146
}

0 commit comments

Comments
 (0)