mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
PowerStatus: Add logic to automatically install in Deskbar.
Modeled after NetworkStatus. Also add it to default_deskbar_items.sh. Fixes #18748.
This commit is contained in:
parent
6a47944773
commit
ef1427bb58
@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# install ProcessController, NetworkStatus & volume control in the Deskbar
|
||||
# install ProcessController, NetworkStatus, PowerStatus & volume control in the Deskbar
|
||||
/boot/system/apps/ProcessController -deskbar
|
||||
/boot/system/apps/NetworkStatus --deskbar
|
||||
/boot/system/apps/PowerStatus --deskbar
|
||||
/boot/system/bin/desklink --add-volume
|
||||
|
||||
# install KeymapSwitcher for certain locales
|
||||
|
@ -33,8 +33,12 @@ class PowerStatus : public BApplication {
|
||||
PowerStatus();
|
||||
virtual ~PowerStatus();
|
||||
|
||||
virtual void ArgvReceived(int32 argc, char** argv);
|
||||
virtual void ReadyToRun();
|
||||
virtual void AboutRequested();
|
||||
|
||||
private:
|
||||
bool fAutoInstallInDeskbar;
|
||||
};
|
||||
|
||||
|
||||
@ -61,7 +65,9 @@ our_image(image_info& image)
|
||||
|
||||
|
||||
PowerStatus::PowerStatus()
|
||||
: BApplication(kSignature)
|
||||
:
|
||||
BApplication(kSignature),
|
||||
fAutoInstallInDeskbar(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -71,6 +77,27 @@ PowerStatus::~PowerStatus()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PowerStatus::ArgvReceived(int32 argc, char** argv)
|
||||
{
|
||||
if (argc <= 1)
|
||||
return;
|
||||
|
||||
if (strcmp(argv[1], "--help") == 0
|
||||
|| strcmp(argv[1], "-h") == 0) {
|
||||
const char* str = "PowerStatus options:\n"
|
||||
"\t--deskbar\tautomatically add replicant to Deskbar\n"
|
||||
"\t--help\t\tprint this info and exit";
|
||||
puts(str);
|
||||
Quit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "--deskbar") == 0)
|
||||
fAutoInstallInDeskbar = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PowerStatus::ReadyToRun()
|
||||
{
|
||||
@ -83,7 +110,8 @@ PowerStatus::ReadyToRun()
|
||||
B_TRANSLATE("No supported battery detected. PowerStatus "
|
||||
"cannot be used on your system."), B_TRANSLATE("Too bad!"),
|
||||
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->Go();
|
||||
if (!fAutoInstallInDeskbar)
|
||||
alert->Go();
|
||||
Quit();
|
||||
return;
|
||||
}
|
||||
@ -93,20 +121,18 @@ PowerStatus::ReadyToRun()
|
||||
// if the Deskbar is not alive at this point, it might be after having
|
||||
// acknowledged the requester below
|
||||
BDeskbar deskbar;
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
isDeskbarRunning = deskbar.IsRunning();
|
||||
#endif
|
||||
isInstalled = deskbar.HasItem(kDeskbarItemName);
|
||||
}
|
||||
|
||||
if (isDeskbarRunning && !isInstalled) {
|
||||
BAlert* alert = new BAlert("",
|
||||
BAlert* alert = new BAlert("",
|
||||
B_TRANSLATE("You can run PowerStatus in a window "
|
||||
"or install it in the Deskbar."), B_TRANSLATE("Run in window"),
|
||||
B_TRANSLATE("Install in Deskbar"), NULL, B_WIDTH_AS_USUAL,
|
||||
B_WARNING_ALERT);
|
||||
|
||||
if (alert->Go()) {
|
||||
if (fAutoInstallInDeskbar || alert->Go()) {
|
||||
image_info info;
|
||||
entry_ref ref;
|
||||
|
||||
@ -147,11 +173,10 @@ PowerStatus::AboutRequested()
|
||||
|
||||
|
||||
int
|
||||
main(int, char**)
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
PowerStatus app;
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user