2 ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
3 Copyright (C) 2004 beunited.org
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "PriorityMenu.h"
22 #include "ProcessController.h"
30 #undef B_TRANSLATION_CONTEXT
31 #define B_TRANSLATION_CONTEXT "ProcessController"
33 PriorityMenu::PriorityMenu(thread_id thread
, int32 priority
)
34 : BMenu(B_EMPTY_STRING
),
42 PriorityMenu::Update(int32 priority
)
44 if (priority
!= fPriority
&& CountItems() > 0)
45 RemoveItems(0, CountItems(), true);
58 static PriorityRec priorities
[] = {
59 { B_TRANSLATE("Idle priority"), 0 },
60 { B_TRANSLATE("Lowest active priority"), 1 },
61 { B_TRANSLATE("Low priority"), 5 },
62 { B_TRANSLATE("Normal priority"), 10 },
63 { B_TRANSLATE("Display priority"), 15 },
64 { B_TRANSLATE("Urgent display priority"), 20 },
65 { B_TRANSLATE("Real-time display priority"), 100 },
66 { B_TRANSLATE("Urgent priority"), 110 },
67 { B_TRANSLATE("Real-time priority"), 120 },
71 PriorityRec customPriority
= { B_TRANSLATE("Custom priority"), 0 };
75 PriorityMenu::BuildMenu()
81 for (long index
= 0; ; index
++) {
82 PriorityRec
*priority
= &priorities
[index
];
83 if (priority
->priority
< 0)
85 if (!found
&& fPriority
< priority
->priority
) {
86 priority
= &customPriority
;
87 priority
->priority
= fPriority
;
90 message
= new BMessage('PrTh');
91 message
->AddInt32("thread", fThreadID
);
92 message
->AddInt32("priority", priority
->priority
);
94 const size_t size
= B_OS_NAME_LENGTH
* 4;
95 snprintf(name
.LockBuffer(size
), size
,
96 "%s [%d]", priority
->name
, (int)priority
->priority
);
98 item
= new BMenuItem(name
.String(), message
);
99 item
->SetTarget(gPCView
);
100 if (fPriority
== priority
->priority
)
101 found
= true, item
->SetMarked(true);