AutoRaise: Just add itself to Deskbar on run
It's simpler, nobody runs things in Terminal, right?
This commit is contained in:
parent
f42cda29e8
commit
46308e28e5
@ -5,7 +5,8 @@ AutoRaiseApp::AutoRaiseApp()
|
|||||||
: BApplication( APP_SIG )
|
: BApplication( APP_SIG )
|
||||||
{
|
{
|
||||||
removeFromDeskbar(NULL);
|
removeFromDeskbar(NULL);
|
||||||
_directToDeskbar = false;
|
fPersist = true;
|
||||||
|
fDone = false;
|
||||||
|
|
||||||
//since the tray item shows an icon, and the class TrayView needs to be
|
//since the tray item shows an icon, and the class TrayView needs to be
|
||||||
//able to know the location of the executing binary, we write into the
|
//able to know the location of the executing binary, we write into the
|
||||||
@ -26,63 +27,34 @@ AutoRaiseApp::~AutoRaiseApp()
|
|||||||
void AutoRaiseApp::ArgvReceived(int32 argc, char ** argv)
|
void AutoRaiseApp::ArgvReceived(int32 argc, char ** argv)
|
||||||
{
|
{
|
||||||
BString option;
|
BString option;
|
||||||
bool inDeskbar = false, persist = false;
|
|
||||||
BString usageNote;
|
|
||||||
usageNote = "\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open "
|
|
||||||
"window, will just put " APP_NAME " into tray\n\t--persist will put "
|
|
||||||
APP_NAME " into tray such that it remains between bootings\n";
|
|
||||||
|
|
||||||
for (int32 i = 1; i < argc; i++)
|
for (int32 i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
option = argv[i];
|
option = argv[i];
|
||||||
if (option.IFindFirst("deskbar") != B_ERROR)
|
if (option.IFindFirst("deskbar") != B_ERROR)
|
||||||
inDeskbar = true;
|
fPersist = false;
|
||||||
|
|
||||||
if (option.IFindFirst("persist") != B_ERROR)
|
if (option.IFindFirst("persist") != B_ERROR)
|
||||||
persist = true;
|
fPersist = true;
|
||||||
|
|
||||||
|
if (option.IFindFirst("-h") != B_ERROR
|
||||||
|
|| option.IFindFirst("help") != B_ERROR) {
|
||||||
|
BString usageNote =
|
||||||
|
"\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open "
|
||||||
|
"window, will just put " APP_NAME " into tray\n\t--persist (default) will put "
|
||||||
|
APP_NAME " into tray such that it remains across reboots\n";
|
||||||
|
printf(usageNote);
|
||||||
|
fDone = true;
|
||||||
|
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inDeskbar && !persist)
|
|
||||||
{
|
|
||||||
printf(APP_NAME " being put into Tray (one shot)...\n");
|
|
||||||
|
|
||||||
PutInTray(false);
|
|
||||||
|
|
||||||
_directToDeskbar = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (inDeskbar && persist)
|
|
||||||
{
|
|
||||||
printf(APP_NAME " being put into Tray (persistant)...\n");
|
|
||||||
|
|
||||||
PutInTray(true);
|
|
||||||
|
|
||||||
_directToDeskbar = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(usageNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoRaiseApp::ReadyToRun()
|
void AutoRaiseApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
if (!_directToDeskbar)
|
if (!fDone)
|
||||||
{
|
PutInTray(fPersist);
|
||||||
printf(usageNote);
|
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
||||||
BAlert *alert = new BAlert("usage box", APP_NAME ", (c) 2002, "
|
|
||||||
"mmu_man\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not "
|
|
||||||
"open window, will just put " APP_NAME " into tray\n\t--persist "
|
|
||||||
"will put " APP_NAME " into tray such that it remains between "
|
|
||||||
"bootings\n", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
|
||||||
B_INFO_ALERT);
|
|
||||||
alert->SetShortcut(0, B_ENTER);
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
alert->Go();
|
|
||||||
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoRaiseApp::PutInTray(bool persist)
|
void AutoRaiseApp::PutInTray(bool persist)
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
|
|
||||||
class AutoRaiseApp: public BApplication{
|
class AutoRaiseApp: public BApplication{
|
||||||
protected:
|
|
||||||
bool _directToDeskbar;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AutoRaiseApp();
|
AutoRaiseApp();
|
||||||
@ -22,7 +20,8 @@ class AutoRaiseApp: public BApplication{
|
|||||||
void PutInTray(bool);
|
void PutInTray(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString usageNote;
|
bool fPersist;
|
||||||
|
bool fDone;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user