summaryrefslogtreecommitdiffstats
path: root/ColumnsPanel.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-01-28 04:09:06 -0200
committerHisham Muhammad <hisham@gobolinux.org>2018-01-30 12:59:11 -0200
commit5beff29a3df7097cc4d256b27888ee730b1a45d0 (patch)
treecdc2d5f30e82db0f7415c2998bbb75cd5beba78f /ColumnsPanel.c
parentd1219abc558141a96ea25aa1db1c2dd3171c5132 (diff)
Add support for multiple screens, switchable using Tab
Diffstat (limited to 'ColumnsPanel.c')
-rw-r--r--ColumnsPanel.c40
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;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy