1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
// $Id: UserDefaults.cc,v 1.2 2002/10/01 18:04:31 flaterco Exp $
/* UserDefaults Interface to ~/.xtide.xml
Copyright (C) 1998 David Flater.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common.hh"
UserDefaults::UserDefaults () {
// (homedir is later set in TideContext)
xmlfilename = getenv ("HOME");
if (xmlfilename.isNull())
barf (NOHOMEDIR);
xmlfilename += "/.xtide.xml";
xmlparsetree = NULL;
if ((xmlin = fopen (xmlfilename.aschar(), "r"))) {
xmlparse();
fclose (xmlin);
struct xmltag *tag = xmlparsetree;
while (tag) {
if ((*(tag->name)) == "xtideoptions") {
struct xmlattribute *a = tag->attributes;
while (a) {
{
int b;
for (b=0; b<numcolors; b++) {
if ((*(a->name)) == colorarg[b]) {
colors[b] = (*(a->value));
goto harmful;
}
}
}
if ((*(a->name)) == "el")
el = (*(a->value));
else if ((*(a->name)) == "fe")
fe = (*(a->value));
else if ((*(a->name)) == "u")
u = (*(a->value));
else if ((*(a->name)) == "z")
z = (*(a->value));
else if ((*(a->name)) == "df")
df = (*(a->value));
else if ((*(a->name)) == "hf")
hf = (*(a->value));
else if ((*(a->name)) == "tf")
tf = (*(a->value));
else if ((*(a->name)) == "tl")
tl = (*(a->value));
else if ((*(a->name)) == "nf")
nf = (*(a->value));
else if ((*(a->name)) == "ns")
ns = (*(a->value));
else if ((*(a->name)) == "in")
in = (*(a->value));
else if ((*(a->name)) == "ga") {
ga_isnull = 0;
ga = getposdouble (*(a->value));
} else if ((*(a->name)) == "gl") {
gl_isnull = 0;
gl = getgldouble (*(a->value));
} else if ((*(a->name)) == "lw") {
lw_isnull = 0;
lw = getposdouble (*(a->value));
} else if ((*(a->name)) == "gw") {
gw_isnull = 0;
gw = max (mingwidth, getposint (*(a->value)));
} else if ((*(a->name)) == "gh") {
gh_isnull = 0;
gh = max (mingheight, getposint (*(a->value)));
} else if ((*(a->name)) == "tw") {
tw_isnull = 0;
tw = max (minttywidth, getposint (*(a->value)));
} else if ((*(a->name)) == "th") {
th_isnull = 0;
th = max (minttyheight, getposint (*(a->value)));
} else if ((*(a->name)) == "cw") {
cw_isnull = 0;
cw = max (mingwidth, getposint (*(a->value)));
}
harmful:
a = a->next;
}
}
tag = tag->next;
}
}
freexml (xmlparsetree);
xmlparsetree = NULL;
}
char
*UserDefaults::settingsid() {
return "~/.xtide.xml";
}
|