diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-12-01 12:31:57 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-12-01 12:31:57 +0000 |
commit | bfd86a60cc1e9edd94c219e6e2018e00a672b7ff (patch) | |
tree | 649b7f7163e834bf2e7f40a6e0b4f94413408095 /ProcessList.c | |
parent | dfad0afb36df9ac104490454c6472625e3ecbe0c (diff) |
Keep panel structure up-to-date as process list changes when headers are updated during the screen manager. Hopefully closes #3444533.
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ProcessList.c b/ProcessList.c index be01ca65..224c18c9 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -16,6 +16,7 @@ in the source distribution for its full text. #include "UsersTable.h" #include "Hashtable.h" #include "String.h" +#include "Panel.h" #include <sys/types.h> #include <sys/stat.h> @@ -109,6 +110,13 @@ typedef struct ProcessList_ { Hashtable* processTable; UsersTable* usersTable; + Panel* panel; + bool follow; + bool userOnly; + uid_t userId; + bool filtering; + const char* incFilter; + int cpuCount; int totalTasks; int userlandThreads; @@ -243,6 +251,10 @@ void ProcessList_delete(ProcessList* this) { free(this); } +void ProcessList_setPanel(ProcessList* this, Panel* panel) { + this->panel = panel; +} + void ProcessList_invertSortOrder(ProcessList* this) { if (this->direction == 1) this->direction = -1; @@ -888,3 +900,47 @@ void ProcessList_expandTree(ProcessList* this) { process->showChildren = true; } } + +void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool userOnly, uid_t userId, bool filtering, const char* incFilter) { + if (!flags) { + follow = this->follow; + userOnly = this->userOnly; + userId = this->userId; + filtering = this->filtering; + incFilter = this->incFilter; + } else { + this->follow = follow; + this->userOnly = userOnly; + this->userId = userId; + this->filtering = filtering; + this->incFilter = incFilter; + } + + int currPos = Panel_getSelectedIndex(this->panel); + pid_t currPid = 0; + int currScrollV = this->panel->scrollV; + if (follow) + currPid = ProcessList_get(this, currPos)->pid; + + Panel_prune(this->panel); + int size = ProcessList_size(this); + int idx = 0; + for (int i = 0; i < size; i++) { + bool hidden = false; + Process* p = ProcessList_get(this, i); + + if ( (!p->show) + || (userOnly && (p->st_uid != userId)) + || (filtering && !(String_contains_i(p->comm, incFilter))) ) + hidden = true; + + if (!hidden) { + Panel_set(this->panel, idx, (Object*)p); + if ((!follow && idx == currPos) || (follow && p->pid == currPid)) { + Panel_setSelected(this->panel, idx); + this->panel->scrollV = currScrollV; + } + idx++; + } + } +} |