Removed unused support for saving/loading binary settings files.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39467 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-11-17 17:22:37 +00:00
parent 8875dc741a
commit 116fb65719
2 changed files with 3 additions and 105 deletions

View File

@ -137,20 +137,7 @@ PrefHandler::GetDefaultPath(BPath& path)
if (status != B_OK)
return status;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
status = path.Append("Default");
#else
status = path.Append("HaikuTerminal_settings");
#endif
return status;
}
status_t
PrefHandler::Open(const char *path)
{
return _LoadFromFile(path);
return path.Append("Default");
}
@ -161,22 +148,6 @@ PrefHandler::OpenText(const char *path)
}
status_t
PrefHandler::Save(const char *path)
{
// make sure the target path exists
#if 0
// TODO: currently not needed as we're reusing the standard directory
BPath directoryPath(path);
if (directoryPath.GetParent(&directoryPath) == B_OK)
create_directory(directoryPath.Path(), 0755);
#endif
BFile file(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
return fContainer.Flatten(&file);
}
void
PrefHandler::SaveDefaultAsText()
{
@ -387,49 +358,6 @@ PrefHandler::_ConfirmFont(const char *key, const BFont *fallback)
}
status_t
PrefHandler::_LoadFromFile(const char* path)
{
// Future: It would be nice if we could simply use a flatened BMessage to
// save the settings. (Who cares about compatibility in this case anyway?)
BFile file(path, B_READ_ONLY);
status_t status = file.InitCheck();
if (status != B_OK)
return status;
//fContainer.MakeEmpty();
//fContainer.Unflatten(&file);
off_t size;
if (file.GetSize(&size) != B_OK || size != sizeof(struct termprefs))
return B_ERROR;
struct termprefs prefs;
file.Read(&prefs, size);
if (prefs.magic != TP_MAGIC || prefs.version != TP_VERSION)
return B_ERROR;
// Valid settings file!
setInt32(PREF_COLS, prefs.cols);
setInt32(PREF_ROWS, prefs.rows);
setInt32(PREF_HALF_FONT_SIZE, prefs.font_size);
char *font_family = strtok(prefs.font, "/");
char *font_style = strtok(NULL, "");
setString(PREF_HALF_FONT_FAMILY, font_family);
setString(PREF_HALF_FONT_STYLE, font_style);
setRGB(PREF_TEXT_BACK_COLOR, prefs.bg);
setRGB(PREF_TEXT_FORE_COLOR, prefs.fg);
setRGB(PREF_SELECT_BACK_COLOR, prefs.selbg);
setRGB(PREF_SELECT_FORE_COLOR, prefs.selfg);
setString(PREF_TEXT_ENCODING, EncodingAsString(prefs.encoding));
setBool(PREF_WARN_ON_EXIT, prefs.warn_on_exit);
return B_OK;
}
status_t
PrefHandler::_LoadFromDefault(const pref_defaults* defaults)
{

View File

@ -2,7 +2,7 @@
* Copyright (c) 2003-2006, Haiku, Inc. All Rights Reserved.
* Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net>
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed unter the terms of the MIT License.
*/
@ -18,33 +18,6 @@ class BFont;
class BPath;
#define TP_MAGIC 0xf1f2f3f4
#define TP_VERSION 0x02
#define TP_FONT_NAME_SZ 128
struct termprefs {
uint32 magic;
uint32 version;
float x;
float y;
uint32 cols;
uint32 rows;
uint32 tab_width;
uint32 font_size;
char font[TP_FONT_NAME_SZ]; // "Family/Style"
uint32 cursor_blink_rate; // blinktime in µs = 1000000
uint32 refresh_rate; // ??? = 0
rgb_color bg;
rgb_color fg;
rgb_color curbg;
rgb_color curfg;
rgb_color selbg;
rgb_color selfg;
char encoding; // index in the menu (0 = UTF-8)
bool warn_on_exit;
char unknown[2];
};
struct pref_defaults {
const char *key;
const char *item;
@ -66,9 +39,7 @@ class PrefHandler {
static void DeleteDefault();
static void SetDefault(PrefHandler *handler);
status_t Open(const char *name);
status_t OpenText(const char *path);
status_t Save(const char *name);
void SaveDefaultAsText();
void SaveAsText(const char *path, const char *minmtype = NULL,
const char *signature = NULL);
@ -91,12 +62,11 @@ class PrefHandler {
private:
void _ConfirmFont(const char *key, const BFont *fallback);
status_t _LoadFromFile(const char* path);
status_t _LoadFromDefault(const pref_defaults* defaults = NULL);
status_t _LoadFromTextFile(const char * path);
BMessage fContainer;
static PrefHandler *sPrefHandler;
};