Skip to content

Port ProcessTreeView to GTK4#525

Open
stsdc wants to merge 18 commits intomainfrom
stsdc/gtk4-treeview
Open

Port ProcessTreeView to GTK4#525
stsdc wants to merge 18 commits intomainfrom
stsdc/gtk4-treeview

Conversation

@stsdc
Copy link
Member

@stsdc stsdc commented Feb 26, 2026

The intend is to future proof the process list and lay some ground for a tree view reintroduction.

  • All columns are visible
  • Process icons are visible
  • Sorting works
  • Filtering works
  • Change ProcessInfoView on process row select
  • Shutdown/Force Quit works
  • Process add/removal works
  • Values are being updated

@stsdc stsdc linked an issue Feb 26, 2026 that may be closed by this pull request
@stsdc stsdc requested a review from a team March 5, 2026 12:27
@stsdc stsdc marked this pull request as ready for review March 5, 2026 13:11
@stsdc stsdc added this to OS 9 Mar 5, 2026
@stsdc stsdc moved this to Needs Review in OS 9 Mar 5, 2026
'Views/ProcessView/ProcessView.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoView.vala',
'Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala',
# 'Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover comment :)

Comment on lines +139 to +149
public void collapse_all () {
// Method implementation
}

public void focus_on_child_row () {
// Method implementation
}

public void focus_on_first_row () {
// Method implementation
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty functions here?

public class Monitor.ProcessTreeView : Granite.Bin {
private Gtk.ColumnView list;

public ProcessTreeView (TreeViewModel model) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this gobject style?

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few comments about code style etc

var cpu_item_factory = new Gtk.SignalListItemFactory ();
var memory_item_factory = new Gtk.SignalListItemFactory ();
var pid_item_factory = new Gtk.SignalListItemFactory ();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space

Comment on lines +25 to +50
name_item_factory.setup.connect ((factory, obj) => {
var cell = obj as Gtk.ColumnViewCell;

var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 4) {
hexpand = true,
halign = Gtk.Align.START
};
var icon = new Gtk.Image.from_icon_name ("application-x-executable") {
pixel_size = 16
};

box.append (icon);
box.append (new Gtk.Label (Utils.NO_DATA));
cell.child = box;
});

name_item_factory.bind.connect ((factory, obj) => {
var cell = obj as Gtk.ColumnViewCell;
var box = cell.child as Gtk.Box;
var label = box.get_last_child () as Gtk.Label;
var icon = box.get_first_child () as Gtk.Image;

var item = cell.item as ProcessRowData;
label.set_text (item.name);
icon.gicon = item.icon;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do these as functions instead of lambdas?

Comment on lines +67 to +70
var cell = obj as Gtk.ColumnViewCell;
var label = cell.child as Gtk.Label;
var item = cell.item as ProcessRowData;
label.set_text ("%.0f%%".printf (item.cpu));
Copy link
Member

@danirabbit danirabbit Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style is to cast with parentheses and to prefer properties over setter functions:

Suggested change
var cell = obj as Gtk.ColumnViewCell;
var label = cell.child as Gtk.Label;
var item = cell.item as ProcessRowData;
label.set_text ("%.0f%%".printf (item.cpu));
var cell = (Gtk.ColumnViewCell) obj;
var label = (Gtk.Label) cell.child;
var item = (ProcessRowData) cell.item;
label.text = "%.0f%%".printf (item.cpu);

var cell = obj as Gtk.ColumnViewCell;
cell.child = new Gtk.Label (Utils.NO_DATA) {
hexpand = true,
halign = Gtk.Align.START
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ommit namespaces for constants

Suggested change
halign = Gtk.Align.START
halign = START

Comment on lines +93 to +105
string units = _("KiB");

// convert to MiB if needed
if (memory_usage_double > 1024.0) {
memory_usage_double /= 1024.0;
units = _("MiB");
}

// convert to GiB if needed
if (memory_usage_double > 1024.0) {
memory_usage_double /= 1024.0;
units = _("GiB");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danirabbit danirabbit requested a review from a team March 5, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Rewrite process tree view

2 participants