From 3383d8e5561dfc6fb2b65e0a194df94ccb5e08af Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 21 Jan 2015 23:27:31 -0200 Subject: Sorry about the mega-patch. This is a work-in-progress, code is currently broken. (Some actions, and notably, the header, are missing.) --- AvailableColumnsPanel.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'AvailableColumnsPanel.c') diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index d954da8c..c0c1f2dd 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -13,18 +13,14 @@ in the source distribution for its full text. #include #include #include +#include /*{ #include "Panel.h" -#include "Settings.h" -#include "ScreenManager.h" typedef struct AvailableColumnsPanel_ { Panel super; Panel* columns; - - Settings* settings; - ScreenManager* scr; } AvailableColumnsPanel; }*/ @@ -38,7 +34,7 @@ static void AvailableColumnsPanel_delete(Object* object) { static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { AvailableColumnsPanel* this = (AvailableColumnsPanel*) super; - char* text = ((ListItem*) Panel_getSelected(super))->value; + int key = ((ListItem*) Panel_getSelected(super))->key; HandlerResult result = IGNORED; switch(ch) { @@ -47,7 +43,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { case KEY_F(5): { int at = Panel_getSelectedIndex(this->columns); - Panel_insert(this->columns, at, (Object*) ListItem_new(text, 0)); + Panel_insert(this->columns, at, (Object*) ListItem_new(Process_fields[key].name, key)); Panel_setSelected(this->columns, at+1); ColumnsPanel_update(this->columns); result = HANDLED; @@ -71,19 +67,19 @@ PanelClass AvailableColumnsPanel_class = { .eventHandler = AvailableColumnsPanel_eventHandler }; -AvailableColumnsPanel* AvailableColumnsPanel_new(Settings* settings, Panel* columns, ScreenManager* scr) { +AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns) { AvailableColumnsPanel* this = AllocThis(AvailableColumnsPanel); Panel* super = (Panel*) this; Panel_init(super, 1, 1, 1, 1, Class(ListItem), true); - - this->settings = settings; - this->scr = scr; Panel_setHeader(super, "Available Columns"); for (int i = 1; i < LAST_PROCESSFIELD; i++) { - if (i != COMM) - Panel_add(super, (Object*) ListItem_new(Process_fieldNames[i], 0)); + if (i != COMM && Process_fields[i].description) { + char description[256]; + snprintf(description, sizeof(description), "%s - %s", Process_fields[i].name, Process_fields[i].description); + Panel_add(super, (Object*) ListItem_new(description, i)); + } } this->columns = columns; return this; -- cgit v1.2.3