diff --git a/data/com.github.stsdc.monitor.gschema.xml b/data/com.github.stsdc.monitor.gschema.xml index 62d25fc8..184b0579 100644 --- a/data/com.github.stsdc.monitor.gschema.xml +++ b/data/com.github.stsdc.monitor.gschema.xml @@ -70,5 +70,11 @@ Opened view The last opened view + + + '00000000' + Process view columns sorting state + Process view columns sorting state + diff --git a/src/MainWindow.vala b/src/MainWindow.vala index f9311a02..ec385068 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -30,6 +30,10 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { resources = new Resources (); process_view = new ProcessView (); + var sorting_state = MonitorApp.settings.get_string ("process-view-columns-sorting-state"); + debug ("sorting state: " + sorting_state); + + process_view.process_tree_view.set_sorting_state (sorting_state); system_view = new SystemView (resources); stack = new Gtk.Stack (); @@ -90,6 +94,7 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { this.present (); setup_window_state (); this.show_all (); + }); shortcuts = new Shortcuts (this); @@ -107,6 +112,8 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { MonitorApp.settings.set_string ("opened-view", stack.visible_child_name); + MonitorApp.settings.set_string ("process-view-columns-sorting-state", process_view.process_tree_view.get_sorting_state ()); + if (MonitorApp.settings.get_boolean ("indicator-state")) { this.hide_on_delete (); } else { @@ -138,6 +145,9 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { } else { move (position_x, position_y); } + + + } } diff --git a/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala b/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala index 8cabe02b..053cc0be 100644 --- a/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala +++ b/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala @@ -77,6 +77,7 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView { cursor_changed.connect (_cursor_changed); // model.process_manager.updated.connect (_cursor_changed); + } public void icon_cell_layout (Gtk.CellLayout cell_layout, Gtk.CellRenderer icon_cell, Gtk.TreeModel model, Gtk.TreeIter iter) { Value icon_name; @@ -207,4 +208,39 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView { } } + public string get_sorting_state () { + string sorting_state = ""; + + foreach (var column in this.get_columns ()) { + int sort_indicator = column.sort_indicator ? 1 : 0; + sorting_state += "%d%d".printf (sort_indicator, column.get_sort_order ()); + + } + debug ("Get sorting state: " + sorting_state); + + return sorting_state; + } + + public void set_sorting_state (string sorting_state) { + debug ("== Going to set sorting state: " + sorting_state); + + var columns = this.get_columns (); + + int index = 0; + foreach (var column in columns) { + + column.sort_indicator = (sorting_state[index] == '1'); + + var sort_type = sorting_state[index + 1] == '1' ? Gtk.SortType.ASCENDING : Gtk.SortType.DESCENDING; + column.set_sort_order (sort_type); + + debug ("== " + (sorting_state[index] == '1').to_string () + " " + sort_type.to_string ()); + + index += 2; + } + get_sorting_state (); + set_model (model); + + } + }