summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-11-27 18:38:52 -0200
committerHisham Muhammad <hisham@gobolinux.org>2014-11-27 18:38:52 -0200
commitb192af006f67369881bfc92c963f3d594e71fe0c (patch)
tree561e543ee95e39101baf87c52508b7a355741ce4
parentcda6bdd56b54f4ab9da15e559edce9591ef12ce1 (diff)
Decouple Header from Meter classes.
(Yes, that's dynamic typing!)
-rw-r--r--Header.c26
-rw-r--r--Header.h2
-rw-r--r--Settings.c21
3 files changed, 19 insertions, 30 deletions
diff --git a/Header.c b/Header.c
index 55586843..68249909 100644
--- a/Header.c
+++ b/Header.c
@@ -8,15 +8,6 @@ in the source distribution for its full text.
#include "Header.h"
#include "CRT.h"
-#include "CPUMeter.h"
-#include "MemoryMeter.h"
-#include "SwapMeter.h"
-#include "TasksMeter.h"
-#include "LoadAverageMeter.h"
-#include "UptimeMeter.h"
-#include "BatteryMeter.h"
-#include "ClockMeter.h"
-#include "HostnameMeter.h"
#include "String.h"
#include <assert.h>
@@ -138,23 +129,6 @@ MeterModeId Header_readMeterMode(Header* this, int i, HeaderSide side) {
return meter->mode;
}
-void Header_defaultMeters(Header* this, int cpuCount) {
- if (cpuCount > 8) {
- Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(LeftCPUs2Meter)));
- Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(RightCPUs2Meter)));
- } else if (cpuCount > 4) {
- Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(LeftCPUsMeter)));
- Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(RightCPUsMeter)));
- } else {
- Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(AllCPUsMeter)));
- }
- Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(MemoryMeter)));
- Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(SwapMeter)));
- Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(TasksMeter)));
- Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(LoadAverageMeter)));
- Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(UptimeMeter)));
-}
-
void Header_reinit(Header* this) {
for (int i = 0; i < Vector_size(this->leftMeters); i++) {
Meter* meter = (Meter*) Vector_get(this->leftMeters, i);
diff --git a/Header.h b/Header.h
index e7784598..84774391 100644
--- a/Header.h
+++ b/Header.h
@@ -47,8 +47,6 @@ char* Header_readMeterName(Header* this, int i, HeaderSide side);
MeterModeId Header_readMeterMode(Header* this, int i, HeaderSide side);
-void Header_defaultMeters(Header* this, int cpuCount);
-
void Header_reinit(Header* this);
void Header_draw(const Header* this);
diff --git a/Settings.c b/Settings.c
index cd9e6c13..1dc8b1b2 100644
--- a/Settings.c
+++ b/Settings.c
@@ -61,6 +61,23 @@ static void Settings_readMeterModes(Settings* this, char* line, HeaderSide side)
String_freeArray(ids);
}
+static void Settings_defaultMeters(Header* header, int cpuCount) {
+ if (cpuCount > 8) {
+ Header_createMeter(header, "LeftCPUs2", LEFT_HEADER);
+ Header_createMeter(header, "RightCPUs2", RIGHT_HEADER);
+ } else if (cpuCount > 4) {
+ Header_createMeter(header, "LeftCPUs", LEFT_HEADER);
+ Header_createMeter(header, "RightCPUs", RIGHT_HEADER);
+ } else {
+ Header_createMeter(header, "AllCPUs", LEFT_HEADER);
+ }
+ Header_createMeter(header, "Memory", LEFT_HEADER);
+ Header_createMeter(header, "Swap", LEFT_HEADER);
+ Header_createMeter(header, "Tasks", RIGHT_HEADER);
+ Header_createMeter(header, "LoadAverage", RIGHT_HEADER);
+ Header_createMeter(header, "Uptime", RIGHT_HEADER);
+}
+
static bool Settings_read(Settings* this, const char* fileName, int cpuCount) {
FILE* fd = fopen(fileName, "r");
if (!fd)
@@ -153,7 +170,7 @@ static bool Settings_read(Settings* this, const char* fileName, int cpuCount) {
}
fclose(fd);
if (!readMeters) {
- Header_defaultMeters(this->header, cpuCount);
+ Settings_defaultMeters(this->header, cpuCount);
}
return true;
}
@@ -273,7 +290,7 @@ Settings* Settings_new(ProcessList* pl, Header* header, int cpuCount) {
ok = Settings_read(this, systemSettings, cpuCount);
free(systemSettings);
if (!ok) {
- Header_defaultMeters(this->header, cpuCount);
+ Settings_defaultMeters(this->header, cpuCount);
pl->hideKernelThreads = true;
pl->highlightMegabytes = true;
pl->highlightThreads = false;

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