htop/DisplayOptionsPanel.c

77 lines
2.6 KiB
C
Raw Permalink Normal View History

2006-03-04 18:16:49 +00:00
2006-05-30 13:47:28 +00:00
#include "DisplayOptionsPanel.h"
2006-03-04 18:16:49 +00:00
2006-05-30 13:47:28 +00:00
#include "Panel.h"
2006-03-04 18:16:49 +00:00
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
#include "debug.h"
#include <assert.h>
/*{
2006-05-30 13:47:28 +00:00
typedef struct DisplayOptionsPanel_ {
Panel super;
2006-03-04 18:16:49 +00:00
Settings* settings;
ScreenManager* scr;
2006-05-30 13:47:28 +00:00
} DisplayOptionsPanel;
2006-03-04 18:16:49 +00:00
}*/
2006-05-30 13:47:28 +00:00
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
DisplayOptionsPanel* this = (DisplayOptionsPanel*) malloc(sizeof(DisplayOptionsPanel));
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
((Object*)this)->delete = DisplayOptionsPanel_delete;
2006-03-04 18:16:49 +00:00
this->settings = settings;
this->scr = scr;
2006-05-30 13:47:28 +00:00
super->eventHandler = DisplayOptionsPanel_EventHandler;
2006-03-04 18:16:49 +00:00
2006-05-30 13:47:28 +00:00
Panel_setHeader(super, "Display options");
Panel_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin)));
Panel_add(super, (Object*) CheckItem_new(String_copy("Split System Time into System/IO-Wait/Hard-IRQ/Soft-IRQ"), &(settings->pl->expandSystemTime)));
2006-03-04 18:16:49 +00:00
return this;
}
2006-05-30 13:47:28 +00:00
void DisplayOptionsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
Panel_done(super);
2006-03-04 18:16:49 +00:00
free(this);
}
2006-05-30 13:47:28 +00:00
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch) {
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
2006-03-04 18:16:49 +00:00
HandlerResult result = IGNORED;
2006-05-30 13:47:28 +00:00
CheckItem* selected = (CheckItem*) Panel_getSelected(super);
2006-03-04 18:16:49 +00:00
switch(ch) {
case 0x0a:
case 0x0d:
case KEY_ENTER:
case ' ':
*(selected->value) = ! *(selected->value);
result = HANDLED;
}
if (result == HANDLED) {
this->settings->changed = true;
Header* header = this->settings->header;
Header_calculateHeight(header);
Header_draw(header);
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
}
return result;
}