Skip to content
Open
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
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
src/Monitor.vala
src/MainWindow.vala
src/Utils.vala
src/Indicator/Widgets/IndicatorWidgetFrequency.vala
src/Indicator/Widgets/PopoverWidget.vala
src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala
src/Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala
Expand Down
44 changes: 35 additions & 9 deletions src/Indicator/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,41 @@ public class Monitor.Indicator : Wingpanel.Indicator {
dbusclient.interface.indicator_gpu_temperature_state.connect ((state) => display_widget.gpu_temperature_widget.visible = state);

dbusclient.interface.update.connect ((sysres) => {
display_widget.cpu_widget.state_percentage = sysres.cpu_percentage;
display_widget.cpu_frequency_widget.state_frequency = sysres.cpu_frequency;
display_widget.cpu_temperature_widget.state_temperature = (int) Math.round (sysres.cpu_temperature);
display_widget.memory_widget.state_percentage = sysres.memory_percentage;
display_widget.network_up_widget.state_bandwidth = sysres.network_up;
display_widget.network_down_widget.state_bandwidth = sysres.network_down;
display_widget.gpu_widget.state_percentage = sysres.gpu_percentage;
display_widget.gpu_memory_widget.state_percentage = sysres.gpu_memory_percentage;
display_widget.gpu_temperature_widget.state_temperature = (int) Math.round (sysres.gpu_temperature);
var cpu_percentage = Value (typeof (uint));
cpu_percentage.set_uint (sysres.cpu_percentage);
display_widget.cpu_widget.update_label (cpu_percentage);

var cpu_frequency = Value (typeof (double));
cpu_frequency.set_double (sysres.cpu_frequency);
display_widget.cpu_frequency_widget.update_label (cpu_frequency);

var cpu_temperature = Value (typeof (int));
cpu_temperature.set_int ((int) Math.round (sysres.cpu_temperature));
display_widget.cpu_temperature_widget.update_label (cpu_temperature);

var memory_percentage = Value (typeof (uint));
memory_percentage.set_uint (sysres.memory_percentage);
display_widget.memory_widget.update_label (memory_percentage);

var network_up = Value (typeof (uint64));
network_up.set_uint64 (sysres.network_up);
display_widget.network_up_widget.update_label (network_up);

var network_down = Value (typeof (uint64));
network_down.set_uint64 (sysres.network_down);
display_widget.network_down_widget.update_label (network_down);

var gpu_percentage = Value (typeof (uint));
gpu_percentage.set_uint (sysres.gpu_percentage);
display_widget.gpu_widget.update_label (gpu_percentage);

var gpu_memory_percentage = Value (typeof (uint));
gpu_memory_percentage.set_uint (sysres.gpu_memory_percentage);
display_widget.gpu_memory_widget.update_label (gpu_memory_percentage);

var gpu_temperature = Value (typeof (int));
gpu_temperature.set_int ((int) Math.round (sysres.gpu_temperature));
display_widget.gpu_temperature_widget.update_label (gpu_temperature);
});

popover_widget.quit_monitor.connect (() => {
Expand Down
18 changes: 9 additions & 9 deletions src/Indicator/Widgets/DisplayWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
*/

public class Monitor.Widgets.DisplayWidget : Gtk.Grid {
public IndicatorWidget cpu_widget = new IndicatorWidget ("cpu-symbolic");
public IndicatorWidget cpu_frequency_widget = new IndicatorWidget ("cpu-symbolic");
public IndicatorWidget cpu_temperature_widget = new IndicatorWidget ("temperature-sensor-symbolic");
public IndicatorWidgetPercentage cpu_widget = new IndicatorWidgetPercentage ("cpu-symbolic");
public IndicatorWidgetFrequency cpu_frequency_widget = new IndicatorWidgetFrequency ("cpu-symbolic");
public IndicatorWidgetTemperature cpu_temperature_widget = new IndicatorWidgetTemperature ("temperature-sensor-symbolic");

public IndicatorWidget memory_widget = new IndicatorWidget ("ram-symbolic");
public IndicatorWidgetPercentage memory_widget = new IndicatorWidgetPercentage ("ram-symbolic");

public IndicatorWidget network_up_widget = new IndicatorWidget ("go-up-symbolic");
public IndicatorWidget network_down_widget = new IndicatorWidget ("go-down-symbolic");
public IndicatorWidgetBandwidth network_up_widget = new IndicatorWidgetBandwidth ("go-up-symbolic");
public IndicatorWidgetBandwidth network_down_widget = new IndicatorWidgetBandwidth ("go-down-symbolic");

public IndicatorWidget gpu_widget = new IndicatorWidget ("gpu-symbolic");
public IndicatorWidget gpu_memory_widget = new IndicatorWidget ("gpu-vram-symbolic");
public IndicatorWidget gpu_temperature_widget = new IndicatorWidget ("temperature-gpu-symbolic");
public IndicatorWidgetPercentage gpu_widget = new IndicatorWidgetPercentage ("gpu-symbolic");
public IndicatorWidgetPercentage gpu_memory_widget = new IndicatorWidgetPercentage ("gpu-vram-symbolic");
public IndicatorWidgetTemperature gpu_temperature_widget = new IndicatorWidgetTemperature ("temperature-gpu-symbolic");

construct {
valign = Gtk.Align.CENTER;
Expand Down
47 changes: 11 additions & 36 deletions src/Indicator/Widgets/IndicatorWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,7 @@ public class Monitor.IndicatorWidget : Gtk.Box {

public string icon_name { get; construct; }

public uint state_percentage {
set {
label.label = "%u%%".printf (value);
label.get_style_context ().remove_class ("monitor-indicator-label-warning");
label.get_style_context ().remove_class ("monitor-indicator-label-critical");

if (value > 80) {
label.get_style_context ().add_class ("monitor-indicator-label-warning");
}
if (value > 90) {
label.get_style_context ().add_class ("monitor-indicator-label-critical");
}
}
}

public int state_temperature {
set {
label.label = "%i℃".printf (value);
}
}

public double state_frequency {
set {
label.label = ("%.2f %s").printf (value, _("GHz"));
}
}

public uint64 state_bandwidth {
set {
label.label = format_size (value);
}
}

private Gtk.Label label = new Gtk.Label (Utils.NOT_AVAILABLE);
protected Gtk.Label label;

public IndicatorWidget (string icon_name) {
Object (
Expand All @@ -52,9 +19,17 @@ public class Monitor.IndicatorWidget : Gtk.Box {

construct {
var icon = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.SMALL_TOOLBAR);
label.margin = 2;
label.width_chars = 4;

label = new Gtk.Label (Utils.NOT_AVAILABLE) {
margin = 2,
width_chars = 4,
};

pack_start (icon);
pack_start (label);
}

public virtual void update_label (Value value) {
// NOP; should be overridden by child classes
}
}
16 changes: 16 additions & 0 deletions src/Indicator/Widgets/IndicatorWidgetBandwidth.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget {
public IndicatorWidgetBandwidth (string icon_name) {
base (icon_name);
}

public override void update_label (Value value) {
uint64 bandwidth = value.get_uint64 ();

label.label = format_size (bandwidth);
}
}
16 changes: 16 additions & 0 deletions src/Indicator/Widgets/IndicatorWidgetFrequency.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.IndicatorWidgetFrequency : Monitor.IndicatorWidget {
public IndicatorWidgetFrequency (string icon_name) {
base (icon_name);
}

public override void update_label (Value value) {
double frequency = value.get_double ();

label.label = ("%.2f %s").printf (frequency, _("GHz"));
}
}
26 changes: 26 additions & 0 deletions src/Indicator/Widgets/IndicatorWidgetPercentage.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.IndicatorWidgetPercentage : Monitor.IndicatorWidget {
public IndicatorWidgetPercentage (string icon_name) {
base (icon_name);
}

public override void update_label (Value value) {
uint percentage = value.get_uint ();

label.label = "%u%%".printf (percentage);
label.get_style_context ().remove_class ("monitor-indicator-label-warning");
label.get_style_context ().remove_class ("monitor-indicator-label-critical");

if (percentage > 80) {
label.get_style_context ().add_class ("monitor-indicator-label-warning");
}

if (percentage > 90) {
label.get_style_context ().add_class ("monitor-indicator-label-critical");
}
}
}
16 changes: 16 additions & 0 deletions src/Indicator/Widgets/IndicatorWidgetTemperature.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.IndicatorWidgetTemperature : Monitor.IndicatorWidget {
public IndicatorWidgetTemperature (string icon_name) {
base (icon_name);
}

public override void update_label (Value value) {
int temperature = value.get_int ();

label.label = "%i℃".printf (temperature);
}
}
4 changes: 4 additions & 0 deletions src/Indicator/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ source_indicator_files = [
'Services/DBusClient.vala',
'Widgets/DisplayWidget.vala',
'Widgets/IndicatorWidget.vala',
'Widgets/IndicatorWidgetPercentage.vala',
'Widgets/IndicatorWidgetTemperature.vala',
'Widgets/IndicatorWidgetFrequency.vala',
'Widgets/IndicatorWidgetBandwidth.vala',
'Widgets/PopoverWidget.vala',

meson.project_source_root() / 'src' / 'Resources/ResourcesSerialized.vala',
Expand Down