Stefan Schuermans commited on 2020-11-08 14:28:26
Showing 2 changed files, with 59 additions and 6 deletions.
This is useful when sorting, e.g., for memory.
| ... | ... |
@@ -60,6 +60,39 @@ |
| 60 | 60 |
<property name="visible">True</property> |
| 61 | 61 |
<property name="can_focus">False</property> |
| 62 | 62 |
<property name="orientation">vertical</property> |
| 63 |
+ <child> |
|
| 64 |
+ <object class="GtkButtonBox" id="ButtonBox"> |
|
| 65 |
+ <property name="visible">True</property> |
|
| 66 |
+ <property name="can_focus">False</property> |
|
| 67 |
+ <property name="layout_style">start</property> |
|
| 68 |
+ <child> |
|
| 69 |
+ <object class="GtkToggleButton" id="TreeToggle"> |
|
| 70 |
+ <property name="label" translatable="yes">Tree</property> |
|
| 71 |
+ <property name="visible">True</property> |
|
| 72 |
+ <property name="can_focus">True</property> |
|
| 73 |
+ <property name="receives_default">True</property> |
|
| 74 |
+ <property name="active">True</property> |
|
| 75 |
+ <signal name="toggled" handler="onTreeToggled" swapped="no"/> |
|
| 76 |
+ </object> |
|
| 77 |
+ <packing> |
|
| 78 |
+ <property name="expand">True</property> |
|
| 79 |
+ <property name="fill">True</property> |
|
| 80 |
+ <property name="position">0</property> |
|
| 81 |
+ </packing> |
|
| 82 |
+ </child> |
|
| 83 |
+ <child> |
|
| 84 |
+ <placeholder/> |
|
| 85 |
+ </child> |
|
| 86 |
+ <child> |
|
| 87 |
+ <placeholder/> |
|
| 88 |
+ </child> |
|
| 89 |
+ </object> |
|
| 90 |
+ <packing> |
|
| 91 |
+ <property name="expand">False</property> |
|
| 92 |
+ <property name="fill">True</property> |
|
| 93 |
+ <property name="position">0</property> |
|
| 94 |
+ </packing> |
|
| 95 |
+ </child> |
|
| 63 | 96 |
<child> |
| 64 | 97 |
<object class="GtkBox" id="TopHBox"> |
| 65 | 98 |
<property name="visible">True</property> |
| ... | ... |
@@ -297,7 +330,7 @@ |
| 297 | 330 |
<packing> |
| 298 | 331 |
<property name="expand">True</property> |
| 299 | 332 |
<property name="fill">True</property> |
| 300 |
- <property name="position">0</property> |
|
| 333 |
+ <property name="position">1</property> |
|
| 301 | 334 |
</packing> |
| 302 | 335 |
</child> |
| 303 | 336 |
</object> |
| ... | ... |
@@ -175,15 +175,18 @@ class UptGui: |
| 175 | 175 |
self.builder = Gtk.Builder() |
| 176 | 176 |
self.builder.add_from_string(uproctrace.gui_glade.DATA) |
| 177 | 177 |
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) |
| 178 |
+ self.show_processes_as_tree = True |
|
| 178 | 179 |
self.wid_details_tree = self.builder.get_object('DetailsTree')
|
| 179 | 180 |
self.wid_details_view = self.builder.get_object('DetailsView')
|
| 180 | 181 |
self.wid_processes_tree = self.builder.get_object('ProcessesTree')
|
| 181 | 182 |
self.wid_processes_view = self.builder.get_object('ProcessesView')
|
| 183 |
+ self.wid_tree_toggle = self.builder.get_object('TreeToggle')
|
|
| 182 | 184 |
handlers = {
|
| 183 | 185 |
'onDestroy': self.onDestroy, |
| 184 | 186 |
'onDetailsRowActivated': self.onDetailsRowActivated, |
| 185 | 187 |
'onProcessesCursorChanged': self.onProcessesCursorChanged, |
| 186 |
- 'onProcessesRowActivated': self.onProcessesRowActivated |
|
| 188 |
+ 'onProcessesRowActivated': self.onProcessesRowActivated, |
|
| 189 |
+ 'onTreeToggled': self.onTreeToggled |
|
| 187 | 190 |
} |
| 188 | 191 |
self.builder.connect_signals(handlers) |
| 189 | 192 |
# open trace file |
| ... | ... |
@@ -329,15 +332,31 @@ class UptGui: |
| 329 | 332 |
self.clipboard.set_text(string, -1) |
| 330 | 333 |
self.clipboard.store() |
| 331 | 334 |
|
| 335 |
+ def onTreeToggled(self, _widget): |
|
| 336 |
+ """ |
|
| 337 |
+ Tree button toggled: switch between tree and list. |
|
| 338 |
+ """ |
|
| 339 |
+ # get new state |
|
| 340 |
+ self.show_processes_as_tree = self.wid_tree_toggle.get_active() |
|
| 341 |
+ # re-populate processes view |
|
| 342 |
+ self.populateProcesses() |
|
| 343 |
+ |
|
| 332 | 344 |
def openTrace(self, proto_filename: str): |
| 333 | 345 |
""" |
| 334 | 346 |
Open a trace file. |
| 335 | 347 |
""" |
| 336 |
- # forget old processes |
|
| 337 |
- self.wid_processes_tree.clear() |
|
| 338 |
- # lead new data |
|
| 348 |
+ # load new data |
|
| 339 | 349 |
with open(proto_filename, 'rb') as proto_file: |
| 340 | 350 |
self.processes = uproctrace.processes.Processes(proto_file) |
| 351 |
+ # populate processes view |
|
| 352 |
+ self.populateProcesses() |
|
| 353 |
+ |
|
| 354 |
+ def populateProcesses(self): |
|
| 355 |
+ """ |
|
| 356 |
+ Populate processes view. |
|
| 357 |
+ """ |
|
| 358 |
+ # forget old processes |
|
| 359 |
+ self.wid_processes_tree.clear() |
|
| 341 | 360 |
# add processes to processes tree store |
| 342 | 361 |
to_be_output = [(self.processes.toplevel, None)] |
| 343 | 362 |
while to_be_output: |
| ... | ... |
@@ -347,7 +366,8 @@ class UptGui: |
| 347 | 366 |
continue |
| 348 | 367 |
proc = procs[0] |
| 349 | 368 |
del procs[0] |
| 350 |
- proc_iter = self.wid_processes_tree.append(parent_iter) |
|
| 369 |
+ proc_iter = self.wid_processes_tree.append( |
|
| 370 |
+ parent_iter if self.show_processes_as_tree else None) |
|
| 351 | 371 |
self.fillProcessesEntry(proc_iter, proc) |
| 352 | 372 |
to_be_output.append((proc.children, proc_iter)) |
| 353 | 373 |
# show all processes |
| 354 | 374 |