diff --git a/src/preferences/time/Jamfile b/src/preferences/time/Jamfile index b522cd70ba..cbcadbfaa7 100644 --- a/src/preferences/time/Jamfile +++ b/src/preferences/time/Jamfile @@ -3,6 +3,9 @@ SubDir HAIKU_TOP src preferences time ; SetSubDirSupportedPlatformsBeOSCompatible ; AddSubDirSupportedPlatforms libbe_test ; +UsePrivateHeaders kernel ; +UseArchHeaders $(TARGET_ARCH) ; + Preference Time : AnalogClock.cpp BaseView.cpp diff --git a/src/preferences/time/SettingsView.cpp b/src/preferences/time/SettingsView.cpp index 0345df853e..608eb042fa 100644 --- a/src/preferences/time/SettingsView.cpp +++ b/src/preferences/time/SettingsView.cpp @@ -27,6 +27,17 @@ #include +#include + + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +#include +#else +void _kset_tzfilename_(const char *name, size_t length, bool isGMT); +#define _kern_set_tzfilename _kset_tzfilename_ +#endif + + TSettingsView::TSettingsView(BRect frame) : BView(frame,"Settings", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), @@ -106,6 +117,10 @@ TSettingsView::MessageReceived(BMessage *message) Window()->PostMessage(&msg); } break; + case kRTCUpdate: + _UpdateGmtSettings(); + break; + default: BView::MessageReceived(message); break; @@ -186,16 +201,18 @@ TSettingsView::_InitView() frameRight.top = text->Frame().bottom + 5.0; fLocalTime = new BRadioButton(frameRight, "local", "Local time", - new BMessage(H_RTC_CHANGE)); + new BMessage(kRTCUpdate)); AddChild(fLocalTime); fLocalTime->ResizeToPreferred(); + fLocalTime->SetTarget(this); 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); fGmtTime->ResizeToPreferred(); - + fGmtTime->SetTarget(this); + if (fIsLocalTime) fLocalTime->SetValue(B_CONTROL_ON); 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 TSettingsView::_UpdateDateTime(BMessage *message) { diff --git a/src/preferences/time/SettingsView.h b/src/preferences/time/SettingsView.h index 92aefe06c7..8279050d74 100644 --- a/src/preferences/time/SettingsView.h +++ b/src/preferences/time/SettingsView.h @@ -35,6 +35,7 @@ class TSettingsView : public BView { void _InitView(); void _ReadRTCSettings(); void _WriteRTCSettings(); + void _UpdateGmtSettings(); void _UpdateDateTime(BMessage *message); private: diff --git a/src/preferences/time/Time.cpp b/src/preferences/time/Time.cpp index 5c7aa79f49..a36b42a317 100644 --- a/src/preferences/time/Time.cpp +++ b/src/preferences/time/Time.cpp @@ -18,6 +18,9 @@ #include +#include + + TimeApplication::TimeApplication() : BApplication(HAIKU_APP_SIGNATURE), fWindow(NULL) @@ -72,6 +75,7 @@ int main(int argc, char** argv) { TimeApplication app; + setuid(0); app.Run(); return 0; diff --git a/src/preferences/time/TimeMessages.h b/src/preferences/time/TimeMessages.h index 85cb99783e..73fb36e67c 100644 --- a/src/preferences/time/TimeMessages.h +++ b/src/preferences/time/TimeMessages.h @@ -36,7 +36,7 @@ const uint32 H_TM_CHANGED = 'obTC'; const uint32 H_USER_CHANGE = 'obUC'; // local/ gmt radiobuttons -const uint32 H_RTC_CHANGE = 'obRC'; +const uint32 kRTCUpdate = '_rtc'; // sunday/ monday radio button const uint32 kWeekStart = '_kws';