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-02-26 20:13:09 -0300
commitb815e4c7a3cdcc64e3c5a28414ef2450bc9d5ebd (patch)
tree664a7c3d8366b13e48410cd11df55aa0ccd641a3 /ColumnsPanel.c
parent4791050ceaf24a32e08505015faf07c43580763c (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