* If you install ProcessController to the Deskbar after startup, its window is not opened anymore. * When you install ProcessController, the Deskbar is only restarted if needed; this can probably be removed completely under Haiku. * Renamed some menu items. * Removed "Use Pulse's settings" menu item. * Fixed remaining issues from bug #633 as far as ProcessController was concerned. * Removed unused source files. * Big cleanup, even though there could be done much much more. * Compacted the source files a bit, merged PCView.cpp and PCView2.cpp to ProcessController.cpp to match the name of the class. * Renamed PCUtils.{cpp|h} to Utilities.{cpp|h} git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17647 a95241bf-73f2-0310-859d-f6bbb57e9c96
99 lines
2.3 KiB
C++
99 lines
2.3 KiB
C++
/*
|
|
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
|
Copyright (C) 2004 beunited.org
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
|
|
#include "PriorityMenu.h"
|
|
#include "ProcessController.h"
|
|
|
|
#include <MenuItem.h>
|
|
#include <Window.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
PriorityMenu::PriorityMenu(thread_id thread, int32 priority)
|
|
: BMenu(B_EMPTY_STRING),
|
|
fThreadID(thread),
|
|
fPriority(priority)
|
|
{
|
|
}
|
|
|
|
|
|
void
|
|
PriorityMenu::Update(int32 priority)
|
|
{
|
|
if (priority != fPriority && CountItems() > 0)
|
|
RemoveItems(0, CountItems(), true);
|
|
if (CountItems() < 1)
|
|
BuildMenu();
|
|
|
|
fPriority = priority;
|
|
}
|
|
|
|
|
|
typedef struct {
|
|
char name[32];
|
|
long priority;
|
|
} PriorityRec;
|
|
|
|
static PriorityRec priorities[] = {
|
|
{"Idle", 0},
|
|
{"Lowest Active", 1},
|
|
{"Low", 5},
|
|
{"Normal", 10},
|
|
{"Display", 15},
|
|
{"Urgent Display", 20},
|
|
{"Real Time Display", 100},
|
|
{"Urgent", 110},
|
|
{"Real Time", 120},
|
|
{"", -1}
|
|
};
|
|
|
|
PriorityRec customPriority = { "Custom", 0 };
|
|
|
|
|
|
void
|
|
PriorityMenu::BuildMenu()
|
|
{
|
|
BMenuItem* item;
|
|
BMessage* message;
|
|
char name[B_OS_NAME_LENGTH + 20];
|
|
long found = false;
|
|
|
|
for (long index = 0; ; index++) {
|
|
PriorityRec *priority = &priorities[index];
|
|
if (priority->priority < 0)
|
|
break;
|
|
if (!found && fPriority < priority->priority) {
|
|
priority = &customPriority;
|
|
priority->priority = fPriority;
|
|
index--;
|
|
}
|
|
message = new BMessage('PrTh');
|
|
message->AddInt32("thread", fThreadID);
|
|
message->AddInt32("priority", priority->priority);
|
|
sprintf(name, "%s Priority [%d]", priority->name, (int)priority->priority);
|
|
item = new BMenuItem(name, message);
|
|
item->SetTarget(gPCView);
|
|
if (fPriority == priority->priority)
|
|
found = true, item->SetMarked(true);
|
|
AddItem(item);
|
|
}
|
|
}
|