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"
2015-08-27 21:42:35 +00:00
# include "CRT.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
} */
2017-07-23 02:41:19 +00:00
static const char * const DisplayOptionsFunctions [ ] = { " " , " " , " " , " " , " " , " " , " " , " " , " " , " Done " , NULL } ;
2015-03-23 18:26:56 +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 :
2015-08-27 21:42:35 +00:00
case KEY_RECLICK :
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 ;
2015-01-22 01:27:31 +00:00
const Header * header = this - > scr - > header ;
Header_calculateHeight ( ( Header * ) header ) ;
Header_reinit ( ( Header * ) 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 ;
}
2012-12-05 15:12:20 +00:00
PanelClass DisplayOptionsPanel_class = {
. super = {
. extends = Class ( Panel ) ,
. delete = DisplayOptionsPanel_delete
} ,
. eventHandler = DisplayOptionsPanel_eventHandler
} ;
2008-03-09 08:58:38 +00:00
DisplayOptionsPanel * DisplayOptionsPanel_new ( Settings * settings , ScreenManager * scr ) {
2012-12-05 15:12:20 +00:00
DisplayOptionsPanel * this = AllocThis ( DisplayOptionsPanel ) ;
2008-03-09 08:58:38 +00:00
Panel * super = ( Panel * ) this ;
2015-03-23 18:26:56 +00:00
FunctionBar * fuBar = FunctionBar_new ( DisplayOptionsFunctions , NULL , NULL ) ;
Panel_init ( super , 1 , 1 , 1 , 1 , Class ( CheckItem ) , true , fuBar ) ;
2008-03-09 08:58:38 +00:00
this - > settings = settings ;
this - > scr = scr ;
Panel_setHeader ( super , " Display options " ) ;
2016-02-02 14:53:02 +00:00
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Shadow other users' processes " ) , & ( settings - > shadowOtherUsers ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Hide kernel threads " ) , & ( settings - > hideKernelThreads ) ) ) ;
2016-02-02 15:39:08 +00:00
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Hide userland process threads " ) , & ( settings - > hideUserlandThreads ) ) ) ;
2016-02-02 14:53:02 +00:00
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Display threads in a different color " ) , & ( settings - > highlightThreads ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Show custom thread names " ) , & ( settings - > showThreadNames ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Show program path " ) , & ( settings - > showProgramPath ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Highlight program \" basename \" " ) , & ( settings - > highlightBaseName ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Highlight large numbers in memory counters " ) , & ( settings - > highlightMegabytes ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Leave a margin around header " ) , & ( settings - > headerMargin ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest) " ) , & ( settings - > detailedCPUTime ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Count CPUs from 0 instead of 1 " ) , & ( settings - > countCPUsFromZero ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Update process names on every refresh " ) , & ( settings - > updateProcessNames ) ) ) ;
Panel_add ( super , ( Object * ) CheckItem_newByRef ( xStrdup ( " Add guest time in CPU meter percentage " ) , & ( settings - > accountGuestInCPUMeter ) ) ) ;
2008-03-09 08:58:38 +00:00
return this ;
}