2011-12-26 21:35:57 +00:00
/*
htop - DisplayOptionsPanel . c
( C ) 2004 - 2011 Hisham H . Muhammad
Released under the GNU GPL , see the COPYING file
in the source distribution for its full text .
*/
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
# include "CheckItem.h"
# include "debug.h"
2011-12-26 21:35:57 +00:00
2006-03-04 18:16:49 +00:00
# include <assert.h>
2011-12-26 21:35:57 +00:00
# include <stdlib.h>
# include <string.h>
2006-03-04 18:16:49 +00:00
/*{
2011-12-26 21:35:57 +00:00
# include "Panel.h"
# include "Settings.h"
# include "ScreenManager.h"
2006-03-04 18:16:49 +00:00
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
} */
2008-03-09 08:58:38 +00:00
static void DisplayOptionsPanel_delete ( Object * object ) {
2006-05-30 13:47:28 +00:00
Panel * super = ( Panel * ) object ;
DisplayOptionsPanel * this = ( DisplayOptionsPanel * ) object ;
Panel_done ( super ) ;
2006-03-04 18:16:49 +00:00
free ( this ) ;
}
2008-03-09 08:58:38 +00:00
static HandlerResult DisplayOptionsPanel_eventHandler ( Panel * super , int ch ) {
2006-05-30 13:47:28 +00:00
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 :
2008-05-07 23:01:45 +00:00
case KEY_MOUSE :
2006-03-04 18:16:49 +00:00
case ' ' :
2007-11-08 23:23:01 +00:00
CheckItem_set ( selected , ! ( CheckItem_get ( selected ) ) ) ;
2006-03-04 18:16:49 +00:00
result = HANDLED ;
}
if ( result = = HANDLED ) {
this - > settings - > changed = true ;
Header * header = this - > settings - > header ;
Header_calculateHeight ( header ) ;
2011-03-22 20:37:08 +00:00
Header_reinit ( header ) ;
2006-03-04 18:16:49 +00:00
Header_draw ( header ) ;
ScreenManager_resize ( this - > scr , this - > scr - > x1 , header - > height , this - > scr - > x2 , this - > scr - > y2 ) ;
}
return result ;
}
2008-03-09 08:58:38 +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 ;
this - > settings = settings ;
this - > scr = scr ;
super - > eventHandler = DisplayOptionsPanel_eventHandler ;
Panel_setHeader ( super , " Display options " ) ;
2011-12-25 20:23:53 +00:00
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Tree view " ) , & ( settings - > pl - > treeView ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Shadow other users' processes " ) , & ( settings - > pl - > shadowOtherUsers ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Hide kernel threads " ) , & ( settings - > pl - > hideKernelThreads ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Hide userland threads " ) , & ( settings - > pl - > hideUserlandThreads ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Display threads in a different color " ) , & ( settings - > pl - > highlightThreads ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Show custom thread names " ) , & ( settings - > pl - > showThreadNames ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Highlight program \" basename \" " ) , & ( settings - > pl - > highlightBaseName ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Highlight large numbers in memory counters " ) , & ( settings - > pl - > highlightMegabytes ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Leave a margin around header " ) , & ( settings - > header - > margin ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest) " ) , & ( settings - > pl - > detailedCPUTime ) , false ) ) ;
Panel_add ( super , ( Object * ) CheckItem_new ( strdup ( " Count CPUs from 0 instead of 1 " ) , & ( settings - > pl - > countCPUsFromZero ) , false ) ) ;
2008-03-09 08:58:38 +00:00
return this ;
}