patch by Julun:
* write the RTC settings (GMT versus Local time) * small cleanups git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22251 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
TSettingsView::TSettingsView(BRect frame)
|
||||
: BView(frame,"Settings", B_FOLLOW_ALL,
|
||||
@@ -35,6 +37,7 @@ TSettingsView::TSettingsView(BRect frame)
|
||||
|
||||
TSettingsView::~TSettingsView()
|
||||
{
|
||||
WriteRTCSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +239,7 @@ TSettingsView::ReadRTCSettings()
|
||||
char localTime[6];
|
||||
file.Read(localTime, 6);
|
||||
BString text(localTime);
|
||||
if (text.Compare("local\n", 5) == 0)
|
||||
if (text.Compare("local", 4) == 0)
|
||||
fIsLocalTime = true;
|
||||
else
|
||||
fIsLocalTime = false;
|
||||
@@ -245,7 +248,25 @@ TSettingsView::ReadRTCSettings()
|
||||
// create set to local
|
||||
fIsLocalTime = true;
|
||||
file.SetTo(&entry, B_CREATE_FILE | B_READ_WRITE);
|
||||
file.Write("local\n", 6);
|
||||
file.Write("local", 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TSettingsView::WriteRTCSettings()
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||
return;
|
||||
|
||||
path.Append("RTC_time_settings");
|
||||
|
||||
BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
if (fLocalTime->Value() == B_CONTROL_ON)
|
||||
file.Write("local", 5);
|
||||
else
|
||||
file.Write("gmt", 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ class TSettingsView : public BView {
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
|
||||
void ChangeRTCSetting();
|
||||
bool GMTime();
|
||||
|
||||
private:
|
||||
void InitView();
|
||||
void ReadRTCSettings();
|
||||
void WriteRTCSettings();
|
||||
void UpdateDateTime(BMessage *message);
|
||||
|
||||
BRadioButton *fLocalTime;
|
||||
|
||||
Reference in New Issue
Block a user