aboutsummaryrefslogtreecommitdiffstats
path: root/linux/IOPriorityPanel.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /linux/IOPriorityPanel.c
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'linux/IOPriorityPanel.c')
-rw-r--r--linux/IOPriorityPanel.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/linux/IOPriorityPanel.c b/linux/IOPriorityPanel.c
new file mode 100644
index 0000000..9e12c75
--- /dev/null
+++ b/linux/IOPriorityPanel.c
@@ -0,0 +1,44 @@
+/*
+htop - IOPriorityPanel.c
+(C) 2004-2012 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "IOPriorityPanel.h"
+
+/*{
+#include "Panel.h"
+#include "IOPriority.h"
+#include "ListItem.h"
+}*/
+
+Panel* IOPriorityPanel_new(IOPriority currPrio) {
+ Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_newEnterEsc("Set ", "Cancel "));
+
+ Panel_setHeader(this, "IO Priority:");
+ Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None));
+ if (currPrio == IOPriority_None) Panel_setSelected(this, 0);
+ struct { int klass; const char* name; } classes[] = {
+ { .klass = IOPRIO_CLASS_RT, .name = "Realtime" },
+ { .klass = IOPRIO_CLASS_BE, .name = "Best-effort" },
+ { .klass = 0, .name = NULL }
+ };
+ for (int c = 0; classes[c].name; c++) {
+ for (int i = 0; i < 8; i++) {
+ char name[50];
+ snprintf(name, sizeof(name)-1, "%s %d %s", classes[c].name, i, i == 0 ? "(High)" : (i == 7 ? "(Low)" : ""));
+ IOPriority ioprio = IOPriority_tuple(classes[c].klass, i);
+ Panel_add(this, (Object*) ListItem_new(name, ioprio));
+ if (currPrio == ioprio) Panel_setSelected(this, Panel_size(this) - 1);
+ }
+ }
+ Panel_add(this, (Object*) ListItem_new("Idle", IOPriority_Idle));
+ if (currPrio == IOPriority_Idle) Panel_setSelected(this, Panel_size(this) - 1);
+ return this;
+}
+
+IOPriority IOPriorityPanel_getIOPriority(Panel* this) {
+ return (IOPriority) ( ((ListItem*) Panel_getSelected(this))->key );
+}
+

© 2014-2024 Faster IT GmbH | imprint | privacy policy