Commit d0c72c3f authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Move FunctionBar inside Panel

parent 1084a3ff
......@@ -27,9 +27,7 @@ typedef struct ScreenManager_ {
int y2;
Orientation orientation;
Vector* panels;
Vector* fuBars;
int panelCount;
const FunctionBar* fuBar;
const Header* header;
const Settings* settings;
bool owner;
......@@ -43,7 +41,7 @@ void ScreenManager_delete(ScreenManager* this);
extern int ScreenManager_size(ScreenManager* this);
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size);
void ScreenManager_add(ScreenManager* this, Panel* item, int size);
Panel* ScreenManager_remove(ScreenManager* this, int idx);
......
......@@ -62,8 +62,12 @@ static SignalItem signals[] = {
{ .name = "31 SIGSYS", .number = 31 },
};
static const char* SignalsFunctions[] = {"Send ", "Cancel ", NULL};
static const char* SignalsKeys[] = {"Enter", "Esc", NULL};
static int SignalsEvents[] = {13, 27};
Panel* SignalsPanel_new() {
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem));
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_new(SignalsFunctions, SignalsKeys, SignalsEvents));
for(unsigned int i = 0; i < sizeof(signals)/sizeof(SignalItem); i++)
Panel_set(this, i, (Object*) ListItem_new(signals[i].name, signals[i].number));
Panel_setHeader(this, "Send signal:");
......
......@@ -12,6 +12,7 @@ in the source distribution for its full text.
#include "ListItem.h"
#include "IncSet.h"
#include "String.h"
#include "FunctionBar.h"
#include <stdio.h>
#include <unistd.h>
......@@ -27,7 +28,6 @@ in the source distribution for its full text.
/*{
#include "Process.h"
#include "Panel.h"
#include "FunctionBar.h"
typedef struct TraceScreen_ {
Process* process;
......@@ -37,16 +37,17 @@ typedef struct TraceScreen_ {
}*/
static const char* tsFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};
static const char* TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};
static const char* tsKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
static const char* TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
static int tsEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27};
static int TraceScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27};
TraceScreen* TraceScreen_new(Process* process) {
TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen));
this->process = process;
this->display = Panel_new(0, 1, COLS, LINES-2, false, Class(ListItem));
FunctionBar* fuBar = FunctionBar_new(TraceScreenFunctions, TraceScreenKeys, TraceScreenEvents);
this->display = Panel_new(0, 1, COLS, LINES-2, false, Class(ListItem), fuBar);
this->tracing = true;
return this;
}
......@@ -105,7 +106,7 @@ void TraceScreen_run(TraceScreen* this) {
bool follow = false;
bool looping = true;
FunctionBar* bar = FunctionBar_new(tsFunctions, tsKeys, tsEvents);
FunctionBar* bar = panel->defaultBar;
IncSet* inc = IncSet_new(bar);
Vector* lines = Vector_new(panel->items->type, true, DEFAULT_SIZE);
......@@ -219,7 +220,6 @@ void TraceScreen_run(TraceScreen* this) {
}
IncSet_delete(inc);
FunctionBar_delete((Object*)bar);
Vector_delete(lines);
kill(child, SIGTERM);
......
......@@ -11,7 +11,6 @@ in the source distribution for its full text.
#include "Process.h"
#include "Panel.h"
#include "FunctionBar.h"
typedef struct TraceScreen_ {
Process* process;
......
......@@ -34,8 +34,6 @@ static void printVersionFlag() {
stdout);
exit(0);
}
static const char* defaultFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
static void printHelpFlag() {
fputs("htop " VERSION " - " COPYRIGHT "\n"
......@@ -218,13 +216,11 @@ int main(int argc, char** argv) {
settings->colorScheme = COLORSCHEME_MONOCHROME;
CRT_init(settings->delay, settings->colorScheme);
FunctionBar* defaultBar = FunctionBar_new(defaultFunctions, NULL, NULL);
MainPanel* panel = MainPanel_new(defaultBar);
MainPanel* panel = MainPanel_new();
ProcessList_setPanel(pl, (Panel*) panel);
MainPanel_updateTreeFunctions(defaultBar, settings->treeView);
MainPanel_updateTreeFunctions(panel, settings->treeView);
if (flags.sortKey > 0) {
settings->sortKey = flags.sortKey;
......@@ -243,7 +239,7 @@ int main(int argc, char** argv) {
MainPanel_setState(panel, &state);
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
ScreenManager_add(scr, (Panel*) panel, defaultBar, -1);
ScreenManager_add(scr, (Panel*) panel, -1);
ProcessList_scan(pl);
millisleep(75);
......
......@@ -13,8 +13,13 @@ in the source distribution for its full text.
#include "ListItem.h"
}*/
static const char* IOPriorityFunctions[] = {"Set ", "Cancel ", NULL};
static const char* IOPriorityKeys[] = {"Enter", "Esc", NULL};
static int IOPriorityEvents[] = {13, 27};
Panel* IOPriorityPanel_new(IOPriority currPrio) {
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem));
FunctionBar* fuBar = FunctionBar_new(IOPriorityFunctions, IOPriorityKeys, IOPriorityEvents);
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), fuBar);
Panel_setHeader(this, "IO Priority:");
Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None));
......
......@@ -46,8 +46,7 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
if (!p) return HTOP_OK;
IOPriority ioprio = p->ioPriority;
Panel* ioprioPanel = IOPriorityPanel_new(ioprio);
const char* fuFunctions[] = {"Set ", "Cancel ", NULL};
void* set = Action_pickFromVector(st, ioprioPanel, 21, fuFunctions);
void* set = Action_pickFromVector(st, ioprioPanel, 21);
if (set) {
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (size_t) ioprio, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment