1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Fixed some problems with WMGetDefaultsFromPath().

This commit is contained in:
dan
1999-04-19 00:09:21 +00:00
parent 2b1dfb439d
commit cf6fbf7e13
2 changed files with 109 additions and 106 deletions

View File

@@ -30,10 +30,11 @@ typedef struct W_UserDefaults {
static UserDefaults *sharedUserDefaults = NULL;
static UserDefaults **sharedDefaultsList = NULL;
static Bool registeredSaveOnExit = False;
extern char *WMGetApplicationName();
#define DEFAULTS_DIR "/Defaults"
@@ -90,17 +91,12 @@ saveDefaultsChanges(int foo, void *bar)
saveDefaultsChanges(void)
#endif
{
/* save the user defaults database */
if (sharedUserDefaults && sharedUserDefaults->dirty) {
PLSave(sharedUserDefaults->appDomain, YES);
}
/* now save the extra defaults databases we may have */
if (sharedDefaultsList) {
UserDefaults *tmp = *sharedDefaultsList;
/* save the user defaults databases */
if (sharedUserDefaults) {
UserDefaults *tmp = sharedUserDefaults;
while (tmp) {
if (tmp->dirty)
if (tmp->appDomain && tmp->dirty)
PLSave(tmp->appDomain, YES);
tmp = tmp->next;
}
@@ -134,14 +130,23 @@ WMSynchronizeUserDefaults(WMUserDefaults *database)
WMUserDefaults*
WMGetStandardUserDefaults(void)
{
if (!sharedUserDefaults) {
WMUserDefaults *defaults;
proplist_t domain;
proplist_t key;
char *path;
int i;
if (sharedUserDefaults) {
defaults = sharedUserDefaults;
while (defaults) {
/* Trick, path == NULL only for StandardUserDefaults db */
if (defaults->path == NULL)
return defaults;
defaults = defaults->next;
}
}
/* we didn't found the database we are looking for. Go read it. */
defaults = wmalloc(sizeof(WMUserDefaults));
memset(defaults, 0, sizeof(WMUserDefaults));
@@ -213,13 +218,13 @@ WMGetStandardUserDefaults(void)
i++;
}
if (sharedUserDefaults)
defaults->next = sharedUserDefaults;
sharedUserDefaults = defaults;
registerSaveOnExit();
}
return sharedUserDefaults;
return defaults;
}
@@ -234,10 +239,10 @@ WMGetDefaultsFromPath(char *path)
assert(path != NULL);
if (sharedDefaultsList) {
defaults = *sharedDefaultsList;
if (sharedUserDefaults) {
defaults = sharedUserDefaults;
while (defaults) {
if (strcmp(defaults->path, path) == 0)
if (defaults->path && strcmp(defaults->path, path) == 0)
return defaults;
defaults = defaults->next;
}
@@ -251,12 +256,13 @@ WMGetDefaultsFromPath(char *path)
defaults->searchList = wmalloc(sizeof(proplist_t)*2);
/* the domain we want go first */
/* the domain we want, go in the first position */
name = strrchr(path, '/');
if (!name)
name = path;
else
name++;
key = PLMakeString(name);
defaults->searchList[0] = key;
@@ -292,16 +298,12 @@ WMGetDefaultsFromPath(char *path)
i++;
}
if (sharedDefaultsList)
defaults->next = *sharedDefaultsList;
sharedDefaultsList = &defaults;
if (sharedUserDefaults)
defaults->next = sharedUserDefaults;
sharedUserDefaults = defaults;
registerSaveOnExit();
name = PLGetDescriptionIndent(defaults->defaults, 0);
puts(name);
free(name);
return defaults;
}

View File

@@ -425,6 +425,7 @@ wClipMakeTile(WScreen *scr, RImage *normalTile)
ROperateLine(tile, RAddOperation, tp, 2, wPreferences.icon_size-3,
pt, &light);
/* arrow bevel */
ROperateLine(tile, RSubtractOperation, ICON_SIZE - 5 - as, 5,
ICON_SIZE - 6, 5, &dark);
ROperateLine(tile, RSubtractOperation, ICON_SIZE - 6 - as, 5,
@@ -439,11 +440,11 @@ wClipMakeTile(WScreen *scr, RImage *normalTile)
ROperateLine(tile, RSubtractOperation, 0, tp-2, pt+1,
wPreferences.icon_size-2, &light);
/* arrow bevel */
ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 6 - as,
5 + as, ICON_SIZE - 6, &dark);
ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 5 - as, 5,
ICON_SIZE - 6, &dark);
ROperateLine(tile, RAddOperation, 5, ICON_SIZE - 6, 5 + as, ICON_SIZE - 6,
&light);