* Moved "install to Deskbar" alert into the application.
* 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
This commit is contained in:
@@ -22,21 +22,38 @@
|
||||
|
||||
#include "PCWorld.h"
|
||||
#include "PCWindow.h"
|
||||
#include "PCView.h"
|
||||
#include "PCUtils.h"
|
||||
#include "Preferences.h"
|
||||
#include "ProcessController.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Roster.h>
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Deskbar.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
class PCApplication : public BApplication {
|
||||
public:
|
||||
PCApplication();
|
||||
virtual ~PCApplication();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
virtual void ArgvReceived(int32 argc, char **argv);
|
||||
};
|
||||
|
||||
|
||||
const char* kSignature = "application/x-vnd.Geb-ProcessController";
|
||||
const char* kTrackerSig = "application/x-vnd.Be-TRAK";
|
||||
const char* kDeskbarSig = "application/x-vnd.Be-TSKB";
|
||||
const char* kTerminalSig = "application/x-vnd.Haiku-Terminal";
|
||||
const char* kPreferencesFileName = "ProcessController Prefs";
|
||||
|
||||
const char* kPosPrefName = "Position";
|
||||
const char* kVersionName = "Version";
|
||||
const int kCurrentVersion = 311;
|
||||
|
||||
thread_id id = 0;
|
||||
|
||||
@@ -59,8 +76,51 @@ PCApplication::~PCApplication()
|
||||
void
|
||||
PCApplication::ReadyToRun()
|
||||
{
|
||||
GebsPreferences preferences(kPreferencesFileName);
|
||||
int32 version = 0;
|
||||
preferences.ReadInt32(version, kVersionName);
|
||||
if (version != kCurrentVersion) {
|
||||
BAlert* alert = new BAlert("", "Do you want ProcessController to live in the Deskbar?",
|
||||
"Don't", "Install", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
|
||||
if (alert->Go()) {
|
||||
bool hasOne = false;
|
||||
{
|
||||
BDeskbar deskbar;
|
||||
if (deskbar.HasItem(kDeskbarItemName))
|
||||
hasOne = true;
|
||||
}
|
||||
|
||||
if (hasOne) {
|
||||
// Restart deskbar to make sure the new version is picked up
|
||||
team_id deskbarTeam = be_roster->TeamFor(kDeskbarSig);
|
||||
if (deskbarTeam >= 0) {
|
||||
BMessenger messenger(NULL, deskbarTeam);
|
||||
messenger.SendMessage(B_QUIT_REQUESTED);
|
||||
int k = 500;
|
||||
do {
|
||||
snooze (10000);
|
||||
} while (be_roster->IsRunning(kDeskbarSig) && k-- > 0);
|
||||
}
|
||||
be_roster->Launch(kDeskbarSig);
|
||||
int k = 500;
|
||||
do {
|
||||
snooze (10000);
|
||||
} while (!be_roster->IsRunning(kDeskbarSig) && k-- > 0);
|
||||
}
|
||||
|
||||
BDeskbar deskbar;
|
||||
if (!deskbar.HasItem(kDeskbarItemName))
|
||||
move_to_deskbar(deskbar);
|
||||
|
||||
Quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new PCWindow();
|
||||
|
||||
|
||||
// quit other eventually running instances
|
||||
BList list;
|
||||
be_roster->GetAppList(kSignature, &list);
|
||||
@@ -77,7 +137,7 @@ PCApplication::ReadyToRun()
|
||||
|
||||
|
||||
void
|
||||
PCApplication::ArgvReceived (int32 argc, char **argv)
|
||||
PCApplication::ArgvReceived(int32 argc, char **argv)
|
||||
{
|
||||
if (argc == 2 && strcmp(argv[1], "-desktop-reset") == 0) {
|
||||
team_id tracker = be_roster->TeamFor(kTrackerSig);
|
||||
@@ -97,8 +157,8 @@ PCApplication::ArgvReceived (int32 argc, char **argv)
|
||||
move_to_deskbar(deskbar);
|
||||
} else if (argc > 1) {
|
||||
// print a simple usage string
|
||||
printf( "Usage: %s [-deskbar]\n", argv[0]);
|
||||
printf( "(c) 1997-2001 Georges-Edouard Berenger, [email protected]\n");
|
||||
printf("Usage: %s [-deskbar]\n", argv[0]);
|
||||
printf("(c) 1996-2001 Georges-Edouard Berenger, [email protected]\n");
|
||||
}
|
||||
|
||||
Quit();
|
||||
|
||||
Reference in New Issue
Block a user