diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-01-28 04:09:06 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-02-17 15:30:15 -0200 |
commit | 187a035a769fb490318091fee2b0051d9b188ad5 (patch) | |
tree | ad74fe0bfe51adb320f2f2bbb8ce45fcd335f960 /ColumnsPanel.c | |
parent | ece89b8df0db61b8caaf53679afbe00e1c2ef22f (diff) |
Add support for multiple screens, switchable using Tab
Diffstat (limited to 'ColumnsPanel.c')
-rw-r--r-- | ColumnsPanel.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/ColumnsPanel.c b/ColumnsPanel.c index 8974ffdc..60bd56db 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -22,8 +22,9 @@ in the source distribution for its full text. typedef struct ColumnsPanel_ { Panel super; + ScreenSettings* ss; + bool* changed; - Settings* settings; bool moving; } ColumnsPanel; @@ -123,22 +124,31 @@ PanelClass ColumnsPanel_class = { .eventHandler = ColumnsPanel_eventHandler }; -ColumnsPanel* ColumnsPanel_new(Settings* settings) { +void ColumnsPanel_fill(ColumnsPanel* this, ScreenSettings* ss) { + Panel* super = (Panel*) this; + Panel_prune(super); + ProcessField* fields = ss->fields; + for (; *fields; fields++) { + if (Process_fields[*fields].name) { + Panel_add(super, (Object*) ListItem_new(Process_fields[*fields].name, *fields)); + } + } + this->ss = ss; +} + +ColumnsPanel* ColumnsPanel_new(ScreenSettings* ss, bool* changed) { ColumnsPanel* this = AllocThis(ColumnsPanel); Panel* super = (Panel*) this; FunctionBar* fuBar = FunctionBar_new(ColumnsFunctions, NULL, NULL); Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar); - this->settings = settings; + this->ss = ss; + this->changed = changed; this->moving = false; Panel_setHeader(super, "Active Columns"); + + ColumnsPanel_fill(this, ss); - ProcessField* fields = this->settings->fields; - for (; *fields; fields++) { - if (Process_fields[*fields].name) { - Panel_add(super, (Object*) ListItem_new(Process_fields[*fields].name, *fields)); - } - } return this; } @@ -154,14 +164,14 @@ int ColumnsPanel_fieldNameToIndex(const char* name) { void ColumnsPanel_update(Panel* super) { ColumnsPanel* this = (ColumnsPanel*) super; int size = Panel_size(super); - this->settings->changed = true; - this->settings->fields = xRealloc(this->settings->fields, sizeof(ProcessField) * (size+1)); - this->settings->flags = 0; + *(this->changed) = true; + this->ss->fields = xRealloc(this->ss->fields, sizeof(ProcessField) * (size+1)); + this->ss->flags = 0; for (int i = 0; i < size; i++) { int key = ((ListItem*) Panel_get(super, i))->key; - this->settings->fields[i] = key; - this->settings->flags |= Process_fields[key].flags; + this->ss->fields[i] = key; + this->ss->flags |= key < 1000 ? Process_fields[key].flags : 0; } - this->settings->fields[size] = 0; + this->ss->fields[size] = 0; } |