Skip to content

Monitor GTK4 port #443

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

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5ab1a68
Switch dependencies to GTK4
stsdc May 15, 2025
188bc76
GTK4 wip
stsdc May 16, 2025
185e7d7
livechart-1 → livechart-2
stsdc May 17, 2025
c94a754
GTK4 wip
stsdc May 17, 2025
b6205d8
first GTK4 run
stsdc May 17, 2025
cd7acbd
bring back searchbox
stsdc May 17, 2025
8ee64a4
Update livechart in CI
stsdc May 17, 2025
448c98b
Merge branch 'main' into stsdc/gtk4-port
stsdc May 17, 2025
fa37ab4
Fix get_style_context dprecation warning
stsdc May 18, 2025
6038748
Bring back search
stsdc Jul 3, 2025
f4058e1
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 10, 2025
74455fc
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 14, 2025
7246a45
Bring back ProcessInfoView
stsdc Jul 14, 2025
0388884
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 16, 2025
95240d2
Do not clone submodules
stsdc Jul 16, 2025
2629e40
Fix lint
stsdc Jul 16, 2025
3841548
Refactor
stsdc Jul 16, 2025
f4d0b46
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 17, 2025
89537b9
Fix GTK4 build
stsdc Jul 17, 2025
e862c27
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 17, 2025
092ea0f
Use `add_css_class ()`
stsdc Jul 18, 2025
b86bbd9
Replace grid with a box
stsdc Jul 18, 2025
febdcb6
Refactor
stsdc Jul 18, 2025
c1e2ffc
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 21, 2025
4b1ea34
Remove `show_all()` comments
stsdc Jul 21, 2025
e4ad9ed
Use Box instead of Grid for labels container on a Chart
stsdc Jul 21, 2025
5ffd5f9
Replace `show_all()` with `present()` in MonitorApp and remove TODO c…
stsdc Jul 21, 2025
8afa0a3
Fix saving is-maximized in settings
stsdc Jul 21, 2025
5a000fc
Update src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala
stsdc Jul 22, 2025
ead2ed6
Update src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala
stsdc Jul 22, 2025
ae0d178
Update src/Views/SystemView/SystemCPUView.vala
stsdc Jul 22, 2025
db50576
Fix formatting of margin properties in SystemView and adjust indentat…
stsdc Jul 22, 2025
d9e157f
Set spacing to 6 in labels_box
stsdc Jul 22, 2025
b857816
Use just `HORIZONTAL`
stsdc Jul 22, 2025
dc3a10b
Fix lint
stsdc Jul 22, 2025
133575c
fix lint
stsdc Jul 22, 2025
c4b3ce4
Set `key_controller` in process tree view
stsdc Jul 23, 2025
3681153
Do not prepend smol charts
stsdc Jul 23, 2025
a8aa44f
Fix visibility handling in ProcessInfoView
stsdc Jul 23, 2025
5c42112
Bring back OpenFilesTreeView
stsdc Jul 23, 2025
5d60804
Fix cpu info popover
stsdc Jul 23, 2025
1cd238f
Delete some `present ()`'s
stsdc Jul 23, 2025
b396bbc
Remove commented `insert_at_cursor ()` in `Search ()`
stsdc Jul 26, 2025
325537e
Remove obsolete commented code in LabelVertical
stsdc Jul 26, 2025
c045b89
Regex matching is unnecessary in CPUProcessTreeView; clean up OpenFil…
stsdc Jul 26, 2025
2b934c6
Remove unused regex variable from CPUProcessTreeView constructor
stsdc Jul 26, 2025
d8f739b
Merge branch 'main' into stsdc/gtk4-port
stsdc Jul 29, 2025
ef76dc1
Refactor permission_error_infobar initialization and improve conditio…
stsdc Jul 29, 2025
536685e
Refactor Statusbar labels
stsdc Jul 29, 2025
e78f54a
re-enable Indicator build
stsdc Aug 1, 2025
5722f47
Merge branch 'main' into stsdc/gtk4-port
stsdc Aug 2, 2025
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
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Dependencies
run: |
apt update
apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev \
libdbus-glib-1-dev libwnck-3-dev libgtop2-dev libwingpanel-3.0-dev libudisks2-dev \
apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-4-dev libadwaita-1-dev \
libdbus-glib-1-dev libgtop2-dev libwingpanel-3.0-dev libudisks2-dev \
libxnvctrl0 libxnvctrl-dev libcurl4-gnutls-dev libflatpak-dev libjson-glib-dev \
liblivechart-1-dev libpci-dev \
liblivechart-2-dev libpci-dev \
meson valac sassc git
- name: Build
run: |
meson setup -Dindicator-wingpanel=enabled build
meson setup -Dindicator-wingpanel=disabled build
meson compile -C build
# Tests disabled since it starts to test live-chart and some tests fail there
# meson test -C build --print-errorlogs
Expand Down
16 changes: 7 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,23 @@ add_project_arguments(['-DWNCK_I_KNOW_THIS_IS_UNSTABLE', '-w'], language: 'c')
# elementary_stylesheet = subproject('stylesheet')

app_dependencies = [
dependency('granite', version: '>= 5.2.0'),
dependency('granite-7'),
dependency('glib-2.0'),
dependency('gtk+-3.0'),
dependency('gtk4'),
dependency('gee-0.8'),
dependency('gio-2.0'),
dependency('gobject-2.0'),
dependency('libgtop-2.0'),
dependency('libwnck-3.0'),
dependency('libhandy-1', version: '>=0.90.0'),
dependency('gdk-x11-3.0'),
dependency('x11'),
# dependency('libwnck-3.0'),
dependency('libadwaita-1', version: '>=1.0.0'),
dependency('gtk4-x11'),
dependency('udisks2'),
dependency('json-glib-1.0'),
dependency('flatpak'),

# FIXME Bump required version to >= 1.10.0 when GTK 4 porting
dependency(
'livechart',
version: '< 1.10.0',
'livechart-2',
version: '>= 1.10.0',
fallback: ['live-chart', 'livechart_dep'],
),

Expand Down
52 changes: 21 additions & 31 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.MainWindow : Hdy.ApplicationWindow {

public class Monitor.MainWindow : Gtk.ApplicationWindow {
public Search search { get; private set; }
public ProcessView process_view { get; private set; }

Expand Down Expand Up @@ -32,15 +33,14 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow {
valign = CENTER
};

var sv = new PreferencesView ();
sv.show_all ();
var preferences_view = new PreferencesView ();

var preferences_popover = new Gtk.Popover (null) {
child = sv
var preferences_popover = new Gtk.Popover () {
child = preferences_view
};

var preferences_button = new Gtk.MenuButton () {
image = new Gtk.Image.from_icon_name ("open-menu", Gtk.IconSize.LARGE_TOOLBAR),
icon_name = "open-menu",
popover = preferences_popover,
tooltip_text = (_("Settings"))
};
Expand All @@ -54,25 +54,20 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow {
transition_type = SLIDE_LEFT
};

var headerbar = new Hdy.HeaderBar () {
has_subtitle = false,
show_close_button = true,
title = _("Monitor")
};
var headerbar = new Adw.HeaderBar ();
headerbar.pack_start (search_revealer);
headerbar.set_custom_title (stack_switcher);
headerbar.set_title_widget (stack_switcher);
headerbar.pack_end (preferences_button);

var statusbar = new Statusbar ();

var box = new Gtk.Box (VERTICAL, 0);
box.add (headerbar);
box.add (stack);
box.add (statusbar);
var main_container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);

child = box;
set_titlebar (headerbar);
main_container.append (stack);
main_container.append (statusbar);

show_all ();
child = main_container;

var dbusserver = DBusServer.get_default ();

Expand Down Expand Up @@ -100,31 +95,26 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow {

dbusserver.quit.connect (() => application.quit ());
dbusserver.show.connect (() => {
this.deiconify ();
this.present ();
setup_window_state ();
this.show_all ();
present ();
});

key_press_event.connect (search.handle_event);

this.delete_event.connect (() => {
int window_width, window_height;
get_size (out window_width, out window_height);
MonitorApp.settings.set_int ("window-width", window_width);
MonitorApp.settings.set_int ("window-height", window_height);
MonitorApp.settings.set_boolean ("is-maximized", this.is_maximized);
application.window_removed.connect (() => {
MonitorApp.settings.set_int ("window-width", get_size (Gtk.Orientation.HORIZONTAL));
MonitorApp.settings.set_int ("window-height", get_size (Gtk.Orientation.VERTICAL));

MonitorApp.settings.set_boolean ("is-maximized", this.is_maximized ());

MonitorApp.settings.set_string ("opened-view", stack.visible_child_name);

if (MonitorApp.settings.get_boolean ("indicator-state")) {
this.hide_on_delete ();
// Read: https://discourse.gnome.org/t/how-to-hide-widget-instead-removing-them-in-gtk-4/8176
this.hide ();
} else {
dbusserver.indicator_state (false);
application.quit ();
}

return true;
});

dbusserver.indicator_state (MonitorApp.settings.get_boolean ("indicator-state"));
Expand Down
5 changes: 3 additions & 2 deletions src/Managers/Process.vala
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ public class Monitor.Process : GLib.Object {

// also if it is using X Window Server
if (Gdk.Display.get_default () is Gdk.X11.Display) {
Wnck.ResourceUsage resu = Wnck.ResourceUsage.pid_read (Gdk.Display.get_default (), stat.pid);
mem_usage += (resu.total_bytes_estimate / 1024);
// @TODO figure this out for wayland and X11 in gtk4
// Wnck.ResourceUsage resu = Wnck.ResourceUsage.pid_read (Gdk.Display.get_default (), stat.pid);
// mem_usage += (resu.total_bytes_estimate / 1024);
}

var total_installed_memory = (double) mem.total / 1024;
Expand Down
33 changes: 14 additions & 19 deletions src/Models/OpenFilesTreeViewModel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

public class Monitor.OpenFilesTreeViewModel : Gtk.TreeStore {
private Gee.Map<string, Gtk.TreeIter ? > open_files_paths = new Gee.HashMap<string, Gtk.TreeIter ? > ();
private Gee.Map<string, Gtk.TreeIter ?> open_files_paths = new Gee.HashMap<string, Gtk.TreeIter ?> ();

private Process _process;

Expand Down Expand Up @@ -41,32 +41,27 @@ public class Monitor.OpenFilesTreeViewModel : Gtk.TreeStore {
Gtk.TreeIter iter;
append (out iter, null);

set (iter,
Column.NAME, path,
-1);
set (iter, Column.NAME, path, -1);

// open_files_paths.set (path, iter);
open_files_paths.set (path, iter);
return true;
}
return false;
}

public void update_model (Process process) {
if (process.open_files_paths.size > 0) {
foreach (var path in process.open_files_paths) {
// if (process.open_files_paths.size > 0) {
// foreach (var path in process.open_files_paths) {

// print("sdsd");
// Gtk.TreeIter iter = open_files_paths[path];
print (path);
//// display only real paths
//// probably should be done in process class
// if (path.substring (0, 1) == "/") {
// set (iter,
// Column.NAME, path,
// -1);
// }
}
}
// Gtk.TreeIter iter = open_files_paths[path];
// print (path);
//// display only real paths
//// probably should be done in process class
// if (path.substring (0, 1) == "/") {
// set (iter, Column.NAME, path, -1);
// }
// }
// }
}

}
13 changes: 10 additions & 3 deletions src/Monitor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace Monitor {
public override void startup () {
base.startup ();

Hdy.init ();
Granite.init ();
Adw.init ();

Appearance.set_prefered_style ();

Expand All @@ -58,7 +59,6 @@ namespace Monitor {
public override void activate () {
// only have one window
if (get_windows () != null) {
window.show_all ();
window.present ();
return;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace Monitor {
window.hide ();
MonitorApp.settings.set_boolean ("background-state", true);
} else {
window.show_all ();
window.present ();
}

window.process_view.process_tree_view.focus_on_first_row ();
Expand All @@ -108,6 +108,13 @@ namespace Monitor {
PCIUtils.LIBPCI_PATCH_VER
);

print (
"Gtk %d.%d.%d\n",
Gtk.MAJOR_VERSION,
Gtk.MINOR_VERSION,
Gtk.MICRO_VERSION
);

// add command line options
try {
var opt_context = new OptionContext ("");
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Appearance.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Monitor.Appearance : Object {
provider.load_from_resource ("/io/elementary/monitor/monitor-light.css");
}

Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

// We listen to changes in Granite.Settings and update our app if the user changes their preference
granite_settings.notify["prefers-color-scheme"].connect (() => {
Expand Down
46 changes: 23 additions & 23 deletions src/Views/PreferencesView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.PreferencesView : Gtk.Bin {
public class Monitor.PreferencesView : Granite.Bin {
private Gtk.Adjustment update_freq_adjustment;

construct {
Expand All @@ -23,8 +23,8 @@ public class Monitor.PreferencesView : Gtk.Bin {
halign = START,
margin_bottom = 6
};
update_freq_description.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
update_freq_description.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL);
update_freq_description.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);
update_freq_description.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL);

update_freq_scale.add_mark (1.0, BOTTOM, _("1s"));
update_freq_scale.add_mark (2.0, BOTTOM, _("2s"));
Expand All @@ -38,9 +38,9 @@ public class Monitor.PreferencesView : Gtk.Bin {
margin_top = 12,
margin_bottom = 12
};
update_freq_box.add (update_freq_label);
update_freq_box.add (update_freq_description);
update_freq_box.add (update_freq_scale);
update_freq_box.append (update_freq_label);
update_freq_box.append (update_freq_description);
update_freq_box.append (update_freq_scale);

update_freq_adjustment.value_changed.connect (() => {
MonitorApp.settings.set_int ("update-time", (int) update_freq_adjustment.get_value ());
Expand Down Expand Up @@ -112,18 +112,18 @@ public class Monitor.PreferencesView : Gtk.Bin {
margin_bottom = 6,
margin_start = 12
};
indicator_options_box.add (cpu_check);
indicator_options_box.add (cpu_freq_check);
indicator_options_box.add (cpu_temp_check);
indicator_options_box.add (new Gtk.Separator (HORIZONTAL));
indicator_options_box.add (memory_check);
indicator_options_box.add (new Gtk.Separator (HORIZONTAL));
indicator_options_box.add (gpu_check);
indicator_options_box.add (gpu_memory_check);
indicator_options_box.add (gpu_temp_check);
indicator_options_box.add (new Gtk.Separator (HORIZONTAL));
indicator_options_box.add (network_upload_check);
indicator_options_box.add (network_download_check);
indicator_options_box.append (cpu_check);
indicator_options_box.append (cpu_freq_check);
indicator_options_box.append (cpu_temp_check);
indicator_options_box.append (new Gtk.Separator (HORIZONTAL));
indicator_options_box.append (memory_check);
indicator_options_box.append (new Gtk.Separator (HORIZONTAL));
indicator_options_box.append (gpu_check);
indicator_options_box.append (gpu_memory_check);
indicator_options_box.append (gpu_temp_check);
indicator_options_box.append (new Gtk.Separator (HORIZONTAL));
indicator_options_box.append (network_upload_check);
indicator_options_box.append (network_download_check);

var indicator_options_revealer = new Gtk.Revealer () {
child = indicator_options_box
Expand All @@ -132,11 +132,11 @@ public class Monitor.PreferencesView : Gtk.Bin {
var box = new Gtk.Box (VERTICAL, 0) {
margin_bottom = 6
};
box.add (update_freq_box);
box.add (enable_smooth_lines_switch);
box.add (background_switch);
box.add (indicator_switch);
box.add (indicator_options_revealer);
box.append (update_freq_box);
box.append (enable_smooth_lines_switch);
box.append (background_switch);
box.append (indicator_switch);
box.append (indicator_options_revealer);

child = box;

Expand Down
8 changes: 2 additions & 6 deletions src/Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
public class Monitor.OpenFilesTreeView : Gtk.TreeView {
public new OpenFilesTreeViewModel model;
private Gtk.TreeViewColumn path_column;
private Regex ? regex;

public signal void process_selected (Process process);

public OpenFilesTreeView (OpenFilesTreeViewModel model) {
this.model = model;
/* *INDENT-OFF* */
regex = /(?i:^.*\.(xpm|png)$)/; // vala-lint=space-before-paren,
/* *INDENT-ON* */
public OpenFilesTreeView () {
this.model = new OpenFilesTreeViewModel ();

show_expanders = false;

Expand Down
8 changes: 4 additions & 4 deletions src/Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ public class Monitor.ProcessInfoCPURAM : Gtk.Grid {
ram_chart.height_request = 60;

var cpu_graph_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
cpu_graph_box.add (cpu_chart);
cpu_graph_box.append (cpu_chart);

var mem_graph_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
mem_graph_box.add (ram_chart);
mem_graph_box.append (ram_chart);

cpu_label = new Gtk.Label ("CPU: " + Utils.NO_DATA);
cpu_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);
cpu_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL);
cpu_label.halign = Gtk.Align.START;

ram_label = new Gtk.Label ("RAM: " + Utils.NO_DATA);
ram_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);
ram_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL);
ram_label.halign = Gtk.Align.START;

attach (cpu_label, 0, 0, 1, 1);
Expand Down
Loading
Loading