From ea859f50d9438bc61ae96721a4d255b49de78653 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:20 +0200 Subject: Imported Upstream version 0.6.2 --- TasksMeter.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'TasksMeter.c') diff --git a/TasksMeter.c b/TasksMeter.c index 86bda9b..d970de0 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -1,6 +1,6 @@ /* htop -(C) 2004 Hisham H. Muhammad +(C) 2004-2006 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ @@ -14,33 +14,26 @@ in the source distribution for its full text. #include "debug.h" -/*{ - -typedef struct TasksMeter_ TasksMeter; - -struct TasksMeter_ { - Meter super; - ProcessList* pl; +/* private property */ +int TasksMeter_attributes[] = { TASKS_RUNNING }; + +/* private */ +MeterType TasksMeter = { + .setValues = TasksMeter_setValues, + .display = TasksMeter_display, + .mode = TEXT_METERMODE, + .items = 1, + .total = 100.0, + .attributes = TasksMeter_attributes, + .name = "Tasks", + .uiName = "Task counter", + .caption = "Tasks: " }; -}*/ - -TasksMeter* TasksMeter_new(ProcessList* pl) { - TasksMeter* this = malloc(sizeof(TasksMeter)); - Meter_init((Meter*)this, String_copy("Tasks"), String_copy("Tasks: "), 1); - ((Meter*)this)->attributes[0] = TASKS_RUNNING; - ((Object*)this)->display = TasksMeter_display; - ((Meter*)this)->setValues = TasksMeter_setValues; - this->pl = pl; - Meter_setMode((Meter*)this, TEXT); - return this; -} - -void TasksMeter_setValues(Meter* cast) { - TasksMeter* this = (TasksMeter*)cast; - cast->total = this->pl->totalTasks; - cast->values[0] = this->pl->runningTasks; - snprintf(cast->displayBuffer.c, 20, "%d/%d", (int) cast->values[0], (int) cast->total); +void TasksMeter_setValues(Meter* this, char* buffer, int len) { + this->total = this->pl->totalTasks; + this->values[0] = this->pl->runningTasks; + snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total); } void TasksMeter_display(Object* cast, RichString* out) { -- cgit v1.2.3