* Remove newlines from text; that should make nicer line breaks in the alert.
* Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19159 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+32
-25
@@ -3,6 +3,7 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -10,43 +11,42 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 TIMEDALERT_UPDATE = 'taup';
|
const uint32 TIMEDALERT_UPDATE = 'taup';
|
||||||
|
|
||||||
class TimedAlert : public BAlert
|
class TimedAlert : public BAlert {
|
||||||
{
|
public:
|
||||||
public:
|
TimedAlert(const char *title, const char *text, const char *button1,
|
||||||
TimedAlert(const char *title, const char *text, const char *button1,
|
const char *button2 = NULL, const char *button3 = NULL,
|
||||||
const char *button2 = NULL, const char *button3 = NULL,
|
button_width width = B_WIDTH_AS_USUAL, alert_type type = B_INFO_ALERT);
|
||||||
button_width width = B_WIDTH_AS_USUAL, alert_type type = B_INFO_ALERT);
|
void MessageReceived(BMessage *);
|
||||||
void MessageReceived(BMessage *);
|
void Show();
|
||||||
void Show();
|
|
||||||
static void GetLabel(BString &string);
|
static void GetLabel(BString &string);
|
||||||
private:
|
|
||||||
BMessageRunner *fRunner;
|
private:
|
||||||
|
BMessageRunner *fRunner;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STRING1 "Attention!\n\nBecause of the switch from daylight saving time,\nyour \
|
|
||||||
computer's clock may be an hour off. Currently,\nyour computer thinks it is "
|
|
||||||
#define STRING2 ".\n\nIs this the correct time?"
|
|
||||||
|
|
||||||
TimedAlert::TimedAlert(const char *title, const char *text, const char *button1,
|
TimedAlert::TimedAlert(const char *title, const char *text, const char *button1,
|
||||||
const char *button2, const char *button3,
|
const char *button2, const char *button3,
|
||||||
button_width width, alert_type type)
|
button_width width, alert_type type)
|
||||||
: BAlert(title, text, button1, button2, button3, width, type),
|
: BAlert(title, text, button1, button2, button3, width, type),
|
||||||
fRunner(NULL)
|
fRunner(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimedAlert::Show()
|
TimedAlert::Show()
|
||||||
{
|
{
|
||||||
fRunner = new BMessageRunner(BMessenger(this), new BMessage(TIMEDALERT_UPDATE), 60000000);
|
fRunner = new BMessageRunner(this, new BMessage(TIMEDALERT_UPDATE), 60000000);
|
||||||
BAlert::Show();
|
BAlert::Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,15 +57,19 @@ TimedAlert::MessageReceived(BMessage *msg)
|
|||||||
if (msg->what == TIMEDALERT_UPDATE) {
|
if (msg->what == TIMEDALERT_UPDATE) {
|
||||||
BString string;
|
BString string;
|
||||||
GetLabel(string);
|
GetLabel(string);
|
||||||
this->TextView()->SetText(string.String());
|
TextView()->SetText(string.String());
|
||||||
} else
|
} else
|
||||||
BAlert::MessageReceived(msg);
|
BAlert::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimedAlert::GetLabel(BString &string)
|
TimedAlert::GetLabel(BString &string)
|
||||||
{
|
{
|
||||||
string = STRING1;
|
string = "Attention!\n\nBecause of the switch from daylight saving time, "
|
||||||
|
"your computer's clock may be an hour off. Currently, your computer "
|
||||||
|
"thinks it is ";
|
||||||
|
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
char timestring[15];
|
char timestring[15];
|
||||||
@@ -73,10 +77,14 @@ TimedAlert::GetLabel(BString &string)
|
|||||||
localtime_r(&t, &tm);
|
localtime_r(&t, &tm);
|
||||||
strftime(timestring, 15, "%I:%M %p", &tm);
|
strftime(timestring, 15, "%I:%M %p", &tm);
|
||||||
string += timestring;
|
string += timestring;
|
||||||
string += STRING2;
|
|
||||||
|
string += ".\n\nIs this the correct time?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -108,13 +116,11 @@ main(int argc, char **argv)
|
|||||||
read(fd, &dst_byte, 1);
|
read(fd, &dst_byte, 1);
|
||||||
|
|
||||||
dst = dst_byte == '1';
|
dst = dst_byte == '1';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dst = tm.tm_isdst;
|
dst = tm.tm_isdst;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst != tm.tm_isdst) {
|
if (dst != tm.tm_isdst) {
|
||||||
|
|
||||||
BApplication app("application/x-vnd.Haiku-cmd-dstconfig");
|
BApplication app("application/x-vnd.Haiku-cmd-dstconfig");
|
||||||
|
|
||||||
BString string;
|
BString string;
|
||||||
@@ -125,11 +131,12 @@ main(int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
if (index == 2) {
|
if (index == 2) {
|
||||||
index = (new BAlert("dstcheck", "Would you like to set the clock using the Time and\nDate preference utility?",
|
index = (new BAlert("dstcheck",
|
||||||
|
"Would you like to set the clock using the Time and\nDate preference utility?",
|
||||||
"No", "Yes"))->Go();
|
"No", "Yes"))->Go();
|
||||||
|
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
be_roster->Launch("application/x-vnd.Haiku-TIME");
|
be_roster->Launch("application/x-vnd.Haiku-Time");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user