Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 1 commit
  • 8 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 05, 2018
* Use a modify version of the PC PriorityMenu
* More clean up.
Showing with 209 additions and 211 deletions.
  1. +25 −96 src/MainWindow.cpp
  2. +5 −3 src/MainWindow.h
  3. +0 −6 src/MainWindowDefs.h
  4. +1 −0 src/Makefile
  5. +118 −0 src/PriorityMenu.cpp
  6. +47 −0 src/PriorityMenu.h
  7. +6 −97 src/TeamListView.cpp
  8. +7 −9 src/TeamListView.h
@@ -44,6 +44,11 @@ MainWindow::MainWindow(void)
menu->AddItem(new BMenuItem(B_TRANSLATE("Kill"), new BMessage(IE_MAINWINDOW_MAINKILL), 'K'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Suspend"), new BMessage(IE_MAINWINDOW_MAINSUSPEND), 'S'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Resume"), new BMessage(IE_MAINWINDOW_MAINRESUME), 'R'));
menu->AddSeparatorItem();
priorityMenu = new PriorityMenu(teamView);
menu->AddItem(priorityMenu);
priorityMenu->BuildMenu();

menuBar->AddItem(menu);

menu = new BMenu(B_TRANSLATE("Window"));
@@ -110,6 +115,22 @@ MainWindow::MainWindow(void)
}


void
MainWindow::MenusBeginning()
{
BRow* sel = teamView->CurrentSelection();
bool is_sel = (sel != NULL);
BMenu *menu = (BMenu *)FindView("MenuBar");
BMenuItem *item = menu->FindItem(IE_MAINWINDOW_MAINKILL);
if (item) item->SetEnabled(is_sel);
item = menu->FindItem(IE_MAINWINDOW_MAINSUSPEND);
if (item) item->SetEnabled(is_sel);
item = menu->FindItem(IE_MAINWINDOW_MAINRESUME);
if (item) item->SetEnabled(is_sel);
priorityMenu->SetEnabled(is_sel);
priorityMenu->Update();
}

MainWindow::~MainWindow(void)
{
slayer->mainWindow = NULL;
@@ -166,36 +187,13 @@ void MainWindow::MessageReceived(BMessage *message)
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINPRIORITYFIELD_LOW_PRIORITY:
DoPriority(B_LOW_PRIORITY);
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINPRIORITYFIELD_NORMAL_PRIORITY:
DoPriority(B_NORMAL_PRIORITY);
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINPRIORITYFIELD_DISPLAY_PRIORITY:
DoPriority(B_DISPLAY_PRIORITY);
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINPRIORITYFIELD_REAL_TIME_DISPLAY_PRIORITY:
DoPriority(B_REAL_TIME_DISPLAY_PRIORITY);
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINPRIORITYFIELD_URGENT_PRIORITY:
DoPriority(B_URGENT_PRIORITY);
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINPRIORITYFIELD_REAL_TIME_PRIORITY:
DoPriority(B_REAL_TIME_PRIORITY);
case SET_PRIORITY: {
int32 priority = message->FindInt32("priority");
DoPriority(priority);
UpdateTeams();
SetButtonState();
break;
}
case IE_MAINWINDOW_MAINPRIORITYVALUE:
// takes priority from text field
DoPriority();
@@ -564,76 +562,7 @@ void MainWindow::SetButtonState()
fToolBar->FindButton(IE_MAINWINDOW_MAINSUSPEND)->SetEnabled(is_sel);
fToolBar->FindButton(IE_MAINWINDOW_MAINRESUME)->SetEnabled(is_sel);

BMenu *menu = (BMenu *)FindView("MenuBar");
BMenuItem *item = menu->FindItem(IE_MAINWINDOW_MAINKILL);
if (item) item->SetEnabled(is_sel);
item = menu->FindItem(IE_MAINWINDOW_MAINSUSPEND);
if (item) item->SetEnabled(is_sel);
item = menu->FindItem(IE_MAINWINDOW_MAINRESUME);
if (item) item->SetEnabled(is_sel);

// TODO SetPriorityState();
}

void MainWindow::SetPriorityState()
{
BTextControl *PriorityValue = (BTextControl *)FindView("MainPriorityValue");
BMenuField *Priority = (BMenuField *)FindView("MainPriorityField");
/* int32 sel = teamView->CurrentSelection();
Priority->SetEnabled((sel >= 0 ? true : false));
PriorityValue->SetEnabled((sel >= 0 ? true : false));
if (sel >= 0) {
BListItem *gItem = teamView->ItemAt(sel);
int32 priority;
BMenuItem *it;
// if single thread selected
if (gItem->OutlineLevel() && teamView->CurrentSelection(1) < 0) {
char pr_text[10] = "";
priority = ((ThreadItem *)gItem)->priority;
sprintf(pr_text, "%ld", priority);
// set only if the new value is different from the old
if (strcmp(pr_text, PriorityValue->Text()))
PriorityValue->SetText(pr_text);
SetPriorityField(priority);
}
else if ((it = Priority->Menu()->ItemAt(0))) {
if (strcmp("", PriorityValue->Text()))
// assume the first item is "Select"
PriorityValue->SetText("");
if (!it->IsMarked()) it->SetMarked(true);
}
} */
}

void MainWindow::SetPriorityField(int32 priority)
{
BMenuField *Priority = (BMenuField *)FindView("MainPriorityField");

int32 c = -1;
BMenuItem *it;
/*
if (priority < B_NORMAL_PRIORITY)
c = IE_MAINWINDOW_MAINPRIORITYFIELD_LOW_PRIORITY;
else if (priority < B_DISPLAY_PRIORITY)
c = IE_MAINWINDOW_MAINPRIORITYFIELD_NORMAL_PRIORITY;
else if (priority < B_REAL_TIME_DISPLAY_PRIORITY)
c = IE_MAINWINDOW_MAINPRIORITYFIELD_DISPLAY_PRIORITY;
else if (priority < B_URGENT_PRIORITY)
c = IE_MAINWINDOW_MAINPRIORITYFIELD_REAL_TIME_DISPLAY_PRIORITY;
else if (priority < B_REAL_TIME_PRIORITY)
c = IE_MAINWINDOW_MAINPRIORITYFIELD_URGENT_PRIORITY;
else if (priority >= B_REAL_TIME_PRIORITY)
c = IE_MAINWINDOW_MAINPRIORITYFIELD_REAL_TIME_PRIORITY;
it = Priority->Menu()->FindItem(c);
if (it && !it->IsMarked())
it->SetMarked(true);*/
}


@@ -12,6 +12,7 @@

#include "Hashtable.h"
#include "RefreshThread.h"
#include "PriorityMenu.h"

#include <ToolBar.h>
/*
@@ -49,7 +50,8 @@ class MainWindow : public BWindow {
virtual void Quit();
virtual void Minimize(bool minimize);
virtual void WindowActivated(bool active);

virtual void MenusBeginning();

void UpdateTeams();
void RemoveProcessItems(BList *);
void SaveStatus();
@@ -59,10 +61,10 @@ class MainWindow : public BWindow {
void DoSuspend();
void DoResume();
void SetButtonState();
void SetPriorityState();
void SetPriorityField(int32 priority);

BBitmap *ResourceVectorToBitmap(const char *resName, float iconSize = 24.0);

PriorityMenu* priorityMenu;
BToolBar* fToolBar;
};

@@ -34,12 +34,6 @@ enum {

IE_MAINWINDOW_MAINMENU_WINDOWS_SETTINGS = 0x12AL,
IE_MAINWINDOW_MAINUPDATE = 0x62757570L,
IE_MAINWINDOW_MAINPRIORITYFIELD_LOW_PRIORITY = 0x7BL,
IE_MAINWINDOW_MAINPRIORITYFIELD_NORMAL_PRIORITY = 0xC8L,
IE_MAINWINDOW_MAINPRIORITYFIELD_DISPLAY_PRIORITY = 0xCAL,
IE_MAINWINDOW_MAINPRIORITYFIELD_REAL_TIME_DISPLAY_PRIORITY = 0xCCL,
IE_MAINWINDOW_MAINPRIORITYFIELD_URGENT_PRIORITY = 0xCEL,
IE_MAINWINDOW_MAINPRIORITYFIELD_REAL_TIME_PRIORITY = 0xD0L,
IE_MAINWINDOW_MAINPRIORITYVALUE = 0x109L,
IE_MAINWINDOW_MAINKILL = 0x626E6B69L,
IE_MAINWINDOW_MAINSUSPEND = 0x626E7375L,
@@ -39,6 +39,7 @@ SRCS= Hashtable.cpp \
MiniSlayer.cpp \
miscSlayer.cpp \
Options.cpp \
PriorityMenu.cpp \
RefreshThread.cpp \
SettingsWindow.cpp \
SizeColumn.cpp \
@@ -0,0 +1,118 @@
/*
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 "SlayerApp.h"
#include <Catalog.h>
#include <MenuItem.h>
#include <Window.h>

#include <stdio.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "PriorityMenu"

PriorityMenu::PriorityMenu(TeamListView* teamListView)
: BMenu(B_TRANSLATE("SetPriority")),
fTeamListView(teamListView),
fPriority(-2),
fEnabled(false)
{
}


void
PriorityMenu::Update()
{
BRow* selected = fTeamListView->CurrentSelection(NULL);
int32 priority;
bool enabled = selected != NULL;

if (enabled && fTeamListView->CurrentSelection(selected) == NULL && !selected->HasLatch())
priority = ((ThreadItem *)selected)->priority;
else
priority = -1;

if (priority != fPriority || fEnabled != enabled)
{
fPriority = priority;
fEnabled = enabled;
if (CountItems() > 0)
RemoveItems(0, CountItems(), true);
if (CountItems() < 1)
BuildMenu();
}

}


typedef struct {
const char* name;
long priority;
} PriorityRec;

static PriorityRec priorities[] = {
{ B_TRANSLATE("Idle priority"), 0 },
{ B_TRANSLATE("Lowest active priority"), 1 },
{ B_TRANSLATE("Low priority"), 5 },
{ B_TRANSLATE("Normal priority"), 10 },
{ B_TRANSLATE("Display priority"), 15 },
{ B_TRANSLATE("Urgent display priority"), 20 },
{ B_TRANSLATE("Real-time display priority"), 100 },
{ B_TRANSLATE("Urgent priority"), 110 },
{ B_TRANSLATE("Real-time priority"), 120 },
{ "", -1 }
};

PriorityRec customPriority = { B_TRANSLATE("Custom priority"), 0 };


void
PriorityMenu::BuildMenu()
{
BMenuItem* item;
BMessage* message;
long found = false;

for (long index = 0; ; index++) {
PriorityRec *priority = &priorities[index];
if (priority->priority < 0)
break;
if (!found && fPriority < priority->priority && fPriority >= 0) {
priority = &customPriority;
priority->priority = fPriority;
index--;
}
message = new BMessage(SET_PRIORITY);
message->AddInt32("priority", priority->priority);
BString name;
const size_t size = B_OS_NAME_LENGTH * 4;
snprintf(name.LockBuffer(size), size,
"%s [%d]", priority->name, (int)priority->priority);
name.UnlockBuffer();
item = new BMenuItem(name.String(), message);
item->SetTarget(slayer->mainWindow);
item->SetEnabled(fEnabled);
if (fPriority == priority->priority)
found = true, item->SetMarked(true);
AddItem(item);
}
}

@@ -0,0 +1,47 @@
/*
PriorityMenu.h
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
*/

#ifndef _PRIORITY_MENU_H_
#define _PRIORITY_MENU_H_

#include <Menu.h>

#include "TeamListView.h"

class PriorityMenu : public BMenu
{
public:
PriorityMenu(TeamListView* teamListView);

void Update ();
void BuildMenu ();

private:
TeamListView* fTeamListView;
int32 fPriority;
bool fEnabled;
};


#endif // _PRIORITY_MENU_H_

No commit comments for this range

You can’t perform that action at this time.