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
13 changes: 13 additions & 0 deletions src/Models/OpenFile.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
*/

public class Monitor.OpenFile : GLib.Object {
public string path { get; set; }

public OpenFile (string path) {
Object (path: path);
}

}
52 changes: 0 additions & 52 deletions src/Models/OpenFilesTreeViewModel.vala

This file was deleted.

67 changes: 33 additions & 34 deletions src/Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,52 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

public class Monitor.OpenFilesTreeView : Gtk.TreeView {
public new OpenFilesTreeViewModel model;
private Gtk.TreeViewColumn path_column;
public class Monitor.OpenFilesTreeView : Granite.Bin {
private GLib.ListStore model;

public signal void process_selected (Process process);

public OpenFilesTreeView () {
this.model = new OpenFilesTreeViewModel ();
model = new GLib.ListStore (typeof (Monitor.OpenFile));
var selection_model = new Gtk.NoSelection (model);

show_expanders = false;
var path_column_factory = new Gtk.SignalListItemFactory ();
path_column_factory.setup.connect (on_path_column_setup);
path_column_factory.bind.connect (on_path_column_bind);

// setup name column
path_column = new Gtk.TreeViewColumn ();
path_column.title = _("Opened files");
path_column.expand = true;
path_column.min_width = 250;
path_column.set_sort_column_id (Column.NAME);
var path_column = new Gtk.ColumnViewColumn (_("Opened files"), path_column_factory) {
expand = true,
};

var icon_cell = new Gtk.CellRendererPixbuf ();
path_column.pack_start (icon_cell, false);
// path_column.add_attribute (icon_cell, "icon_name", Column.ICON);
path_column.set_cell_data_func (icon_cell, icon_cell_layout);
var column_view = new Gtk.ColumnView (selection_model);
column_view.append_column (path_column);

var name_cell = new Gtk.CellRendererText ();
name_cell.ellipsize = Pango.EllipsizeMode.END;
name_cell.set_fixed_height_from_font (1);
path_column.pack_start (name_cell, false);
path_column.add_attribute (name_cell, "text", Column.NAME);
insert_column (path_column, -1);

// resize all of the columns
columns_autosize ();
vexpand = true;

set_model (model);
child = new Gtk.ScrolledWindow () {
child = column_view,
max_content_height = 250,
};
}

hadjustment = null;
vadjustment = null;
vexpand = true;
private void on_path_column_setup (Gtk.SignalListItemFactory factory, GLib.Object list_item_obj) {
var label = new Gtk.Label ("");
label.halign = Gtk.Align.START;
((Gtk.ListItem) list_item_obj).child = label;
}

private void on_path_column_bind (Gtk.SignalListItemFactory factory, GLib.Object list_item_obj) {
var list_item = (Gtk.ListItem) list_item_obj;
var item_data = (OpenFile) list_item.item;
var label = (Gtk.Label) list_item.child;
label.label = item_data.path;
}

public void icon_cell_layout (Gtk.CellLayout cell_layout, Gtk.CellRenderer icon_cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
try {
var icon = Icon.new_for_string ("emblem-documents-symbolic");
((Gtk.CellRendererPixbuf)icon_cell).icon_name = icon.to_string ();
} catch (Error e) {
warning (e.message);
public void update (Process process) {
visible = true;
model.remove_all ();
foreach (var path in process.open_files_paths) {
model.append (new OpenFile (path));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ public class Monitor.ProcessInfoIOStats : Gtk.Grid {

open_files_tree_view = new OpenFilesTreeView ();

var open_files_tree_view_scrolled = new Gtk.ScrolledWindow () {
child = open_files_tree_view
};

column_spacing = 6;
row_spacing = 6;
column_homogeneous = true;
Expand All @@ -35,7 +31,7 @@ public class Monitor.ProcessInfoIOStats : Gtk.Grid {
attach (create_label_with_icon (write_bytes_label, "go-down-symbolic"), 0, 3);
attach (cancelled_write_label, 1, 1);
attach (cancelled_write_bytes_label, 1, 2);
attach (open_files_tree_view_scrolled, 0, 4, 2);
attach (open_files_tree_view, 0, 4, 2);
}

public void update (Process process) {
Expand Down
12 changes: 6 additions & 6 deletions src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ public class Monitor.ProcessInfoView : Gtk.Box {

permission_error_infobar.revealed = false;

process_info_io_stats.open_files_tree_view.model.process = _process;
process_info_io_stats.open_files_tree_view.visible = true;
process_info_io_stats.update (_process);

// Updating open files list on process change (row select) only
// to prevent list jump to the top after a scroll
process_info_io_stats.open_files_tree_view.update (process);

}
}
}
Expand Down Expand Up @@ -125,10 +129,6 @@ public class Monitor.ProcessInfoView : Gtk.Box {
process_info_header.update (process);
process_info_cpu_ram.update (process);
process_info_io_stats.update (process);

process_info_io_stats.open_files_tree_view.model.process = _process;

process_info_io_stats.open_files_tree_view.visible = true;
}
}
}
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ source_app_files = [

# Models
'Models/TreeViewModel.vala',
'Models/OpenFilesTreeViewModel.vala',
'Models/OpenFile.vala',

# Other
# 'Managers/AppManager.vala',
Expand Down