* implemented gmt/ local time switch, not working atm but will investigate
note: i think it should be enough to only call _kern_set_tzfilename(..) as the timezone offset and
dst would have been set by clockconfig on boot or from the time prefs panel while switching the
timezone. so the comment in _user_set_tzfilename should not be count and no update would
be needed. it should only take the sIsGmt boolean take into account when getting the time.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22558 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3,6 +3,9 @@ SubDir HAIKU_TOP src preferences time ;
|
|||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
AddSubDirSupportedPlatforms libbe_test ;
|
AddSubDirSupportedPlatforms libbe_test ;
|
||||||
|
|
||||||
|
UsePrivateHeaders kernel ;
|
||||||
|
UseArchHeaders $(TARGET_ARCH) ;
|
||||||
|
|
||||||
Preference Time :
|
Preference Time :
|
||||||
AnalogClock.cpp
|
AnalogClock.cpp
|
||||||
BaseView.cpp
|
BaseView.cpp
|
||||||
|
|||||||
@@ -27,6 +27,17 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
|
#include <syscalls.h>
|
||||||
|
#else
|
||||||
|
void _kset_tzfilename_(const char *name, size_t length, bool isGMT);
|
||||||
|
#define _kern_set_tzfilename _kset_tzfilename_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
TSettingsView::TSettingsView(BRect frame)
|
TSettingsView::TSettingsView(BRect frame)
|
||||||
: BView(frame,"Settings", B_FOLLOW_ALL,
|
: BView(frame,"Settings", B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP),
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP),
|
||||||
@@ -106,6 +117,10 @@ TSettingsView::MessageReceived(BMessage *message)
|
|||||||
Window()->PostMessage(&msg);
|
Window()->PostMessage(&msg);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case kRTCUpdate:
|
||||||
|
_UpdateGmtSettings();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
@@ -186,16 +201,18 @@ TSettingsView::_InitView()
|
|||||||
frameRight.top = text->Frame().bottom + 5.0;
|
frameRight.top = text->Frame().bottom + 5.0;
|
||||||
|
|
||||||
fLocalTime = new BRadioButton(frameRight, "local", "Local time",
|
fLocalTime = new BRadioButton(frameRight, "local", "Local time",
|
||||||
new BMessage(H_RTC_CHANGE));
|
new BMessage(kRTCUpdate));
|
||||||
AddChild(fLocalTime);
|
AddChild(fLocalTime);
|
||||||
fLocalTime->ResizeToPreferred();
|
fLocalTime->ResizeToPreferred();
|
||||||
|
fLocalTime->SetTarget(this);
|
||||||
|
|
||||||
frameRight.left = fLocalTime->Frame().right +10.0f;
|
frameRight.left = fLocalTime->Frame().right +10.0f;
|
||||||
|
|
||||||
fGmtTime = new BRadioButton(frameRight, "gmt", "GMT", new BMessage(H_RTC_CHANGE));
|
fGmtTime = new BRadioButton(frameRight, "gmt", "GMT", new BMessage(kRTCUpdate));
|
||||||
AddChild(fGmtTime);
|
AddChild(fGmtTime);
|
||||||
fGmtTime->ResizeToPreferred();
|
fGmtTime->ResizeToPreferred();
|
||||||
|
fGmtTime->SetTarget(this);
|
||||||
|
|
||||||
if (fIsLocalTime)
|
if (fIsLocalTime)
|
||||||
fLocalTime->SetValue(B_CONTROL_ON);
|
fLocalTime->SetValue(B_CONTROL_ON);
|
||||||
else
|
else
|
||||||
@@ -253,6 +270,29 @@ TSettingsView::_WriteRTCSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TSettingsView::_UpdateGmtSettings()
|
||||||
|
{
|
||||||
|
_WriteRTCSettings();
|
||||||
|
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
path.Append("timezone");
|
||||||
|
BEntry entry(path.Path(), true);
|
||||||
|
|
||||||
|
if (!entry.Exists())
|
||||||
|
return;
|
||||||
|
|
||||||
|
entry.GetPath(&path);
|
||||||
|
|
||||||
|
// take the existing timezone and set it's gmt use
|
||||||
|
_kern_set_tzfilename(path.Path(), B_PATH_NAME_LENGTH
|
||||||
|
, fGmtTime->Value() == B_CONTROL_ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TSettingsView::_UpdateDateTime(BMessage *message)
|
TSettingsView::_UpdateDateTime(BMessage *message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class TSettingsView : public BView {
|
|||||||
void _InitView();
|
void _InitView();
|
||||||
void _ReadRTCSettings();
|
void _ReadRTCSettings();
|
||||||
void _WriteRTCSettings();
|
void _WriteRTCSettings();
|
||||||
|
void _UpdateGmtSettings();
|
||||||
void _UpdateDateTime(BMessage *message);
|
void _UpdateDateTime(BMessage *message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
TimeApplication::TimeApplication()
|
TimeApplication::TimeApplication()
|
||||||
: BApplication(HAIKU_APP_SIGNATURE),
|
: BApplication(HAIKU_APP_SIGNATURE),
|
||||||
fWindow(NULL)
|
fWindow(NULL)
|
||||||
@@ -72,6 +75,7 @@ int
|
|||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
TimeApplication app;
|
TimeApplication app;
|
||||||
|
setuid(0);
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const uint32 H_TM_CHANGED = 'obTC';
|
|||||||
const uint32 H_USER_CHANGE = 'obUC';
|
const uint32 H_USER_CHANGE = 'obUC';
|
||||||
|
|
||||||
// local/ gmt radiobuttons
|
// local/ gmt radiobuttons
|
||||||
const uint32 H_RTC_CHANGE = 'obRC';
|
const uint32 kRTCUpdate = '_rtc';
|
||||||
|
|
||||||
// sunday/ monday radio button
|
// sunday/ monday radio button
|
||||||
const uint32 kWeekStart = '_kws';
|
const uint32 kWeekStart = '_kws';
|
||||||
|
|||||||
Reference in New Issue
Block a user