~ubuntu-branches/ubuntu/feisty/htop/feisty

« back to all changes in this revision

Viewing changes to DisplayOptionsPanel.c

  • Committer: Bazaar Package Importer
  • Author(s): Bartosz Fenski
  • Date: 2006-08-14 13:03:15 UTC
  • mfrom: (1.1.6 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20060814130315-mm00h2owyqz2zr2j
Tags: 0.6.3-1
* New upstream version.
  - allows to rekill tagged group of processes (Closes: #375219)
* Bumped Standards-Version to 3.7.2 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "DisplayOptionsPanel.h"
 
3
 
 
4
#include "Panel.h"
 
5
#include "CheckItem.h"
 
6
#include "Settings.h"
 
7
#include "ScreenManager.h"
 
8
 
 
9
#include "debug.h"
 
10
#include <assert.h>
 
11
 
 
12
/*{
 
13
 
 
14
typedef struct DisplayOptionsPanel_ {
 
15
   Panel super;
 
16
 
 
17
   Settings* settings;
 
18
   ScreenManager* scr;
 
19
} DisplayOptionsPanel;
 
20
 
 
21
}*/
 
22
 
 
23
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
 
24
   DisplayOptionsPanel* this = (DisplayOptionsPanel*) malloc(sizeof(DisplayOptionsPanel));
 
25
   Panel* super = (Panel*) this;
 
26
   Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
 
27
   ((Object*)this)->delete = DisplayOptionsPanel_delete;
 
28
 
 
29
   this->settings = settings;
 
30
   this->scr = scr;
 
31
   super->eventHandler = DisplayOptionsPanel_EventHandler;
 
32
 
 
33
   Panel_setHeader(super, "Display options");
 
34
   Panel_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView)));
 
35
   Panel_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers)));
 
36
   Panel_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads)));
 
37
   Panel_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
 
38
   Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
 
39
   Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
 
40
   Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin)));
 
41
   return this;
 
42
}
 
43
 
 
44
void DisplayOptionsPanel_delete(Object* object) {
 
45
   Panel* super = (Panel*) object;
 
46
   DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
 
47
   Panel_done(super);
 
48
   free(this);
 
49
}
 
50
 
 
51
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch) {
 
52
   DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
 
53
   
 
54
   HandlerResult result = IGNORED;
 
55
   CheckItem* selected = (CheckItem*) Panel_getSelected(super);
 
56
 
 
57
   switch(ch) {
 
58
   case 0x0a:
 
59
   case 0x0d:
 
60
   case KEY_ENTER:
 
61
   case ' ':
 
62
      *(selected->value) = ! *(selected->value);
 
63
      result = HANDLED;
 
64
   }
 
65
 
 
66
   if (result == HANDLED) {
 
67
      this->settings->changed = true;
 
68
      Header* header = this->settings->header;
 
69
      Header_calculateHeight(header);
 
70
      Header_draw(header);
 
71
      ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
 
72
   }
 
73
   return result;
 
74
}
 
75