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:
@@ -1,8 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/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/ProcessController -deskbar
|
||||||
/boot/system/apps/NetworkStatus --deskbar
|
/boot/system/apps/NetworkStatus --deskbar
|
||||||
|
/boot/system/apps/PowerStatus --deskbar
|
||||||
/boot/system/bin/desklink --add-volume
|
/boot/system/bin/desklink --add-volume
|
||||||
|
|
||||||
# install KeymapSwitcher for certain locales
|
# install KeymapSwitcher for certain locales
|
||||||
|
|||||||
@@ -33,8 +33,12 @@ class PowerStatus : public BApplication {
|
|||||||
PowerStatus();
|
PowerStatus();
|
||||||
virtual ~PowerStatus();
|
virtual ~PowerStatus();
|
||||||
|
|
||||||
|
virtual void ArgvReceived(int32 argc, char** argv);
|
||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool fAutoInstallInDeskbar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +65,9 @@ our_image(image_info& image)
|
|||||||
|
|
||||||
|
|
||||||
PowerStatus::PowerStatus()
|
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
|
void
|
||||||
PowerStatus::ReadyToRun()
|
PowerStatus::ReadyToRun()
|
||||||
{
|
{
|
||||||
@@ -83,7 +110,8 @@ PowerStatus::ReadyToRun()
|
|||||||
B_TRANSLATE("No supported battery detected. PowerStatus "
|
B_TRANSLATE("No supported battery detected. PowerStatus "
|
||||||
"cannot be used on your system."), B_TRANSLATE("Too bad!"),
|
"cannot be used on your system."), B_TRANSLATE("Too bad!"),
|
||||||
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
alert->Go();
|
if (!fAutoInstallInDeskbar)
|
||||||
|
alert->Go();
|
||||||
Quit();
|
Quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -93,20 +121,18 @@ PowerStatus::ReadyToRun()
|
|||||||
// if the Deskbar is not alive at this point, it might be after having
|
// if the Deskbar is not alive at this point, it might be after having
|
||||||
// acknowledged the requester below
|
// acknowledged the requester below
|
||||||
BDeskbar deskbar;
|
BDeskbar deskbar;
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
|
||||||
isDeskbarRunning = deskbar.IsRunning();
|
isDeskbarRunning = deskbar.IsRunning();
|
||||||
#endif
|
|
||||||
isInstalled = deskbar.HasItem(kDeskbarItemName);
|
isInstalled = deskbar.HasItem(kDeskbarItemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDeskbarRunning && !isInstalled) {
|
if (isDeskbarRunning && !isInstalled) {
|
||||||
BAlert* alert = new BAlert("",
|
BAlert* alert = new BAlert("",
|
||||||
B_TRANSLATE("You can run PowerStatus in a window "
|
B_TRANSLATE("You can run PowerStatus in a window "
|
||||||
"or install it in the Deskbar."), B_TRANSLATE("Run in window"),
|
"or install it in the Deskbar."), B_TRANSLATE("Run in window"),
|
||||||
B_TRANSLATE("Install in Deskbar"), NULL, B_WIDTH_AS_USUAL,
|
B_TRANSLATE("Install in Deskbar"), NULL, B_WIDTH_AS_USUAL,
|
||||||
B_WARNING_ALERT);
|
B_WARNING_ALERT);
|
||||||
|
|
||||||
if (alert->Go()) {
|
if (fAutoInstallInDeskbar || alert->Go()) {
|
||||||
image_info info;
|
image_info info;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
|
|
||||||
@@ -147,11 +173,10 @@ PowerStatus::AboutRequested()
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int, char**)
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
PowerStatus app;
|
PowerStatus app;
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user