1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-03 06:45:51 +01:00

- Finished moving to the new proplist handling code in WINGs.

- Also tested the backward compatibility ability of the WINGs proplist code
  which seems to work quite well.

Starting with this moment, Window Maker no longer needs libPropList and is
now using the better and much more robust proplist code from WINGs. Also the
WINGs based proplist code is actively maintained while the old libPropList
code is practically dead and flawed by the fact that it borrowed concepts
from the UserDefaults which conflicted with the retain/release mechanism,
making some problems that libPropList had, practically unsolvable without a
complete redesign (which can be found in the more robust WINGs code).
This commit is contained in:
dan
2001-10-04 03:07:34 +00:00
parent 8bb50a6320
commit 33cc542e85
79 changed files with 2126 additions and 2638 deletions

View File

@@ -1,6 +1,14 @@
Changes since wmaker 0.65.0:
............................
- fixed problem with WINGs based apps exiting with a "X_RotateProperties"
related error when text was selected in a textfiled.
- moved wstrdup(), wstrconcat() and wstrappend() from memory.c to string.c
- added property list handling code making libPropList unnecessary and
obsolete. Backward compatibility is provided through the
WINGs/proplist-compat.h header file which has #defines from old libPropList
function names to new function names with minimal changes.
- Renamed WMGetUDAllKeys() to WMGetUDKeys()
Changes since wmaker 0.64.0:

View File

@@ -6,8 +6,7 @@ AUTOMAKE_OPTIONS = no-dependencies
noinst_PROGRAMS = connect server fontl puzzle
LDADD= $(top_builddir)/WINGs/libWINGs.a $(top_builddir)/wrlib/libwraster.la \
@LIBPL@
LDADD= $(top_builddir)/WINGs/libWINGs.a $(top_builddir)/wrlib/libwraster.la
fontl_DEPENDENCIES = $(top_builddir)/WINGs/libWINGs.a
@@ -17,12 +16,11 @@ puzzle_DEPENDENCIES = $(top_builddir)/WINGs/libWINGs.a
connect_DEPENDENCIES = $(top_builddir)/WINGs/libWUtil.a
connect_LDADD = $(top_builddir)/WINGs/libWUtil.a @LIBRARY_SEARCH_PATH@ \
@NETLIBS@ @LIBPL@
@NETLIBS@
server_DEPENDENCIES = $(top_builddir)/WINGs/libWUtil.a
server_LDADD = $(top_builddir)/WINGs/libWUtil.a @LIBRARY_SEARCH_PATH@ \
@NETLIBS@ @LIBPL@
server_LDADD = $(top_builddir)/WINGs/libWUtil.a @LIBRARY_SEARCH_PATH@ @NETLIBS@
INCLUDES = -I$(top_srcdir)/WINGs -I$(top_srcdir)/wrlib -I$(top_srcdir)/src \

View File

@@ -290,19 +290,19 @@ showHelp(WMConnection *cPtr) /*FOLD00*/
static void
listUsers(WMConnection *cPtr)
{
proplist_t userList;
WMPropList *userList;
char *id;
int i, time;
userList = WMGetUDAllKeys(timeDB);
userList = WMGetUDKeys(timeDB);
for (i=0; i<PLGetNumberOfElements(userList); i++) {
id = PLGetString(PLGetArrayElement(userList, i));
for (i=0; i<WMGetPropListItemCount(userList); i++) {
id = WMGetFromPLString(WMGetFromPLArray(userList, i));
time = WMGetUDIntegerForKey(timeDB, id);
sendUpdateMessage(cPtr, id, time);
}
PLRelease(userList);
WMReleasePropList(userList);
}
@@ -591,6 +591,12 @@ removeConnection(void *observer, WMNotification *notification)
WMDestroyConnection(cPtr);
}
static void
updatedDomain(void *observer, WMNotification *notification)
{
wmessage("defaults domain file changed on disk. synchronizing.");
}
#if 0
static Bool
@@ -675,6 +681,8 @@ main(int argc, char **argv) /*FOLD00*/
}
timeDB = WMGetDefaultsFromPath("./UserTime.plist");
WMAddNotificationObserver(updatedDomain, NULL,
WMUserDefaultsDidChangeNotification, NULL);
clientConnections = WMCreateArray(4);

View File

@@ -26,8 +26,7 @@ libExtraWINGs_a_SOURCES = \
INCLUDES = -I$(top_srcdir)/wrlib -I$(top_srcdir)/WINGs \
-DRESOURCE_PATH=\"$(datadir)/WINGs\" @HEADER_SEARCH_PATH@ -DDEBUG
LDADD= $(top_builddir)/WINGs/libWINGs.a $(top_builddir)/wrlib/libwraster.la \
@LIBPL@
LDADD= $(top_builddir)/WINGs/libWINGs.a $(top_builddir)/wrlib/libwraster.la
test_LDADD = wtableview.o wtabledelegates.o $(LDADD)

View File

@@ -1,6 +1,7 @@
#include <WINGs/WINGs.h>
#include <stdio.h>
#include "wtableview.h"
#include "wtabledelegates.h"
@@ -33,7 +34,7 @@ void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
char buf[128];
sprintf(buf, "Test row %i", i);
col1[i] = wstrdup(buf);
col2[i] = 0;
}
@@ -73,7 +74,7 @@ void clickedTable(WMWidget *w, void *self)
int
main(int argc, char **argv)
{
WMScreen *scr;
@@ -128,4 +129,6 @@ main(int argc, char **argv)
WMMapWidget(table);
WMRealizeWidget(win);
WMScreenMainLoop(scr);
return 0;
}

View File

@@ -1,6 +1,6 @@
#include <WINGs/WINGs.h>
#include <WINGs/WINGsP.h>
#include "wtableview.h"

View File

@@ -908,6 +908,7 @@ static void drawRow(WMTableView *table, int row, WMRect clipRect)
}
#if 0
static void drawFullRow(WMTableView *table, int row)
{
int i;
@@ -926,6 +927,7 @@ static void drawFullRow(WMTableView *table, int row)
(*column->delegate->drawCell)(column->delegate, column, row, d);
}
}
#endif
static void setRowSelected(WMTableView *table, unsigned row, Bool flag)
@@ -1054,8 +1056,6 @@ void WMSelectTableViewRow(WMTableView *table, int row)
void WMReloadTableView(WMTableView *table)
{
WMRect rect = getVisibleRect(table);
if (table->editingRow >= 0)
stopRowEdit(table, table->editingRow);
@@ -1163,7 +1163,6 @@ static void handleResize(W_ViewDelegate *self, WMView *view)
int height;
WMTableView *table = view->self;
WMSize size = getTotalSize(table);
WMScreen *scr = WMWidgetScreen(table);
int vw, vh;
width = W_VIEW_WIDTH(view) - 2;

View File

@@ -13,7 +13,7 @@ bin_SCRIPTS = get-wings-flags get-wutil-flags
lib_LIBRARIES = libWINGs.a libWUtil.a
LDADD= libWINGs.a $(top_builddir)/wrlib/libwraster.la @LIBPL@ @INTLIBS@
LDADD= libWINGs.a $(top_builddir)/wrlib/libwraster.la @INTLIBS@
EXTRA_DIST = BUGS

View File

@@ -1,4 +1,22 @@
*** Thu Oct 04 06:00:09 EEST 2001 -Dan
Property lists handling code
----------------------------
Code to handle property lists was added to WINGs. It is more robust
than the libPropList code, mostly because some conflicting concepts
borrowed from UserDefaults (which libPropList uses) are no longer used in
the property lists code.
It is also better integrated with the other data types from WINGs.
Old libPropList based code can still run with the new WINGs proplist
code with minimal changes which are described in detail in the comments
at the top of the WINGs/proplist-compat.h header file (the same file
carries the #defines for mapping old libPropList functions to the new
WINGs proplist functions).
*** Sat Apr 21 09:12:09 EEST 2001 -Dan
API change

View File

@@ -4,8 +4,7 @@ AUTOMAKE_OPTIONS = no-dependencies
noinst_PROGRAMS = wtest wmquery wmfile testmywidget
LDADD= $(top_builddir)/WINGs/libWINGs.a $(top_builddir)/wrlib/libwraster.la \
@LIBPL@
LDADD= $(top_builddir)/WINGs/libWINGs.a $(top_builddir)/wrlib/libwraster.la
testmywidget_SOURCES = testmywidget.c mywidget.c mywidget.h

View File

@@ -10,14 +10,6 @@
#define NULL ((void*)0)
#endif
/*
* Warning: proplist.h #defines BOOL which will clash with the
* typedef BOOL in Xmd.h
* proplist.h should use Bool (which is a #define in Xlib.h) instead.
*
*/
#include <proplist.h>
#ifndef WMAX
# define WMAX(a,b) ((a)>(b) ? (a) : (b))
@@ -231,7 +223,7 @@ char* wfindfile(char *paths, char *file);
char* wfindfileinlist(char **path_list, char *file);
char* wfindfileinarray(proplist_t array, char *file);
char* wfindfileinarray(WMPropList* array, char *file);
char* wexpandpath(char *path);
@@ -761,6 +753,10 @@ WMPropList* WMRetainPropList(WMPropList *plist);
void WMReleasePropList(WMPropList *plist);
/* Objects inserted in arrays and dictionaries will be retained,
* so you can safely release them after insertion.
* For dictionaries both the key and value are retained.
* Objects removed from arrays or dictionaries are released */
void WMInsertInPLArray(WMPropList *plist, int index, WMPropList *item);
void WMAddToPLArray(WMPropList *plist, WMPropList *item);
@@ -773,6 +769,9 @@ void WMPutInPLDictionary(WMPropList *plist, WMPropList *key, WMPropList *value);
void WMRemoveFromPLDictionary(WMPropList *plist, WMPropList *key);
/* It inserts all key/value pairs from source into dest, overwriting
* the values with the same keys from dest, keeping all values with keys
* only present in dest unchanged */
WMPropList* WMMergePLDictionaries(WMPropList *dest, WMPropList *source);
int WMGetPropListItemCount(WMPropList *plist);
@@ -787,26 +786,38 @@ Bool WMIsPLDictionary(WMPropList *plist);
Bool WMIsPropListEqualTo(WMPropList *plist, WMPropList *other);
/* Returns a reference. Do not free it! */
char* WMGetFromPLString(WMPropList *plist);
/* Returns a reference. Do not free it! */
WMData* WMGetFromPLData(WMPropList *plist);
/* Returns a reference. Do not free it! */
const unsigned char* WMGetPLDataBytes(WMPropList *plist);
int WMGetPLDataLength(WMPropList *plist);
/* Returns a reference. */
WMPropList* WMGetFromPLArray(WMPropList *plist, int index);
/* Returns a reference. */
WMPropList* WMGetFromPLDictionary(WMPropList *plist, WMPropList *key);
/* Returns a PropList array with all the dictionary keys. Release it when
* you're done. Keys in array are retained from the original dictionary
* not copied */
WMPropList* WMGetPLDictionaryKeys(WMPropList *plist);
/* Creates only the first level deep object. All the elements inside are
* retained from the original */
WMPropList* WMShallowCopyPropList(WMPropList *plist);
/* Makes a completely separate replica of the original proplist */
WMPropList* WMDeepCopyPropList(WMPropList *plist);
WMPropList* WMCreatePropListFromDescription(char *desc);
/* Free the returned string when you're done */
char* WMGetPropListDescription(WMPropList *plist, Bool indented);
WMPropList* WMReadPropListFromFile(char *file);
@@ -825,14 +836,14 @@ void WMSaveUserDefaults(WMUserDefaults *database);
void WMEnableUDPeriodicSynchronization(WMUserDefaults *database, Bool enable);
/* Returns a PLArray with all keys in the user defaults database.
* Free the returned array with PLRelease() when no longer needed,
* but do not free the elements of the array! They're just references. */
proplist_t WMGetUDAllKeys(WMUserDefaults *database);
/* Returns a WMPropList array with all the keys in the user defaults database.
* Free the array with WMReleasePropList() when no longer needed.
* Keys in array are just retained references to the original keys */
WMPropList* WMGetUDKeys(WMUserDefaults *database);
proplist_t WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName);
WMPropList* WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName);
void WMSetUDObjectForKey(WMUserDefaults *database, proplist_t object,
void WMSetUDObjectForKey(WMUserDefaults *database, WMPropList *object,
char *defaultName);
void WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName);
@@ -857,9 +868,9 @@ void WMSetUDFloatForKey(WMUserDefaults *database, float value,
void WMSetUDBoolForKey(WMUserDefaults *database, Bool value,
char *defaultName);
proplist_t WMGetUDSearchList(WMUserDefaults *database);
WMPropList* WMGetUDSearchList(WMUserDefaults *database);
void WMSetUDSearchList(WMUserDefaults *database, proplist_t list);
void WMSetUDSearchList(WMUserDefaults *database, WMPropList *list);
extern char *WMUserDefaultsDidChangeNotification;

View File

@@ -1,3 +1,56 @@
/*
* This header file is provided for old libPropList compatibility.
* DO _NOT_ USE this except for letting your old libPropList-based code to
* work with the new property list code from WINGs, with minimal changes.
*
* All code written with old libPropList functions should work, given
* that the following changes are made:
*
* 1. Replace all
* #include <proplist.h>
* with
* #include <WINGs/proplist-compat.h>
* in your code.
*
* 2. Change all calls to PLSave() to have the extra filename parameter like:
* PLSave(proplist_t proplist, char* filename, Bool atomically)
*
* 3. The PLSetStringCmpHook() function is no longer available. There is a
* similar but simpler function provided which is enough for practical
* purposes:
* PLSetCaseSensitive(Bool caseSensitive)
*
* 4. The following functions do no longer exist. They were removed because
* they were based on concepts borrowed from UserDefaults which conflict
* with the retain/release mechanism:
* PLSynchronize(), PLDeepSynchronize(), PLShallowSynchronize()
* PLSetFilename(), PLGetFilename()
* PLGetContainer()
* You should change your code to not use them anymore.
*
* 5. The following functions are no longer available. They were removed
* because they also used borrowed concepts which have no place in a
* property list as defined in the OpenStep specifications. Also these
* functions were hardly ever used in programs to our knowledge.
* PLGetDomainNames(), PLGetDomain(), PLSetDomain(), PLDeleteDomain()
* PLRegister(), PLUnregister()
* You should also change your code to not use them anymore (in case you
* ever used them anyway ;-) ).
*
* 6. Link your program with libWINGs or libWUtil instead of libPropList.
* (libWINGs should be used for GUI apps, while libWUtil for non-GUI apps)
*
*
* Our recommandation is to rewrite your code to use the new functions and
* link against libWINGs/libWUtil. We do not recommend you to keep using old
* libPropList function names. This file is provided just to allow existing
* libropList based applications to run with minimal changes with the new
* proplist code from WINGs before their authors get the time to rewrite
* them. New proplist code from WINGs provide a better integration with the
* other data types from WINGs, not to mention that the proplist code in WINGs
* is actively maintained while the old libPropList is dead.
*
*/
#ifndef _PROPLIST_COMPAT_H_
@@ -12,8 +65,8 @@ typedef WMPropList* proplist_t;
#define PLMakeString(bytes) WMCreatePLString(bytes)
#define PLMakeData(bytes, length) WMCreatePLDataFromBytes(bytes, length)
#define PLMakeArrayFromElements(pl, ...) WMCreatePLArray(pl, ...)
#define PLMakeDictionaryFromEntries(key, value, ...) WMCreatePLDictionary(key, value, ...)
#define PLMakeArrayFromElements WMCreatePLArray
#define PLMakeDictionaryFromEntries WMCreatePLDictionary
#define PLRetain(pl) WMRetainPropList(pl)
#define PLRelease(pl) WMReleasePropList(pl)
@@ -38,7 +91,7 @@ typedef WMPropList* proplist_t;
#define PLGetString(pl) WMGetFromPLString(pl)
#define PLGetDataBytes(pl) WMGetPLDataBytes(pl)
#define PLGetDataLength(pl) WMGetPLDataLength(pl)
#define PLGetArrayElement(pl, index) WMGetFromArray(pl, index)
#define PLGetArrayElement(pl, index) WMGetFromPLArray(pl, index)
#define PLGetDictionaryEntry(pl, key) WMGetFromPLDictionary(pl, key)
#define PLGetAllDictionaryKeys(pl) WMGetPLDictionaryKeys(pl)
@@ -55,20 +108,22 @@ typedef WMPropList* proplist_t;
#define PLSave(pl, file, atm) WMWritePropListToFile(pl, file, atm)
#if 0
#define PLSetStringCmpHook(fn)
#define PLDeepSynchronize(pl) PLDeepSynchronize_is_not_supported
#define PLSynchronize(pl) PLSynchronize_is_not_supported
#define PLShallowSynchronize(pl) error_PLShallowSynchronize_is_not_supported
#define PLSetFilename(pl, filename) error_PLSetFilename_is_not_supported
#define PLGetFilename(pl, filename) error_PLGetFilename_is_not_supported
#define PLGetContainer(pl)
//#define PLSetStringCmpHook(fn)
//#define PLDeepSynchronize(pl) PLDeepSynchronize_is_not_supported
//#define PLSynchronize(pl) PLSynchronize_is_not_supported
//#define PLShallowSynchronize(pl) error_PLShallowSynchronize_is_not_supported
//#define PLSetFilename(pl, filename) error_PLSetFilename_is_not_supported
//#define PLGetFilename(pl, filename) error_PLGetFilename_is_not_supported
//#define PLGetDomainNames()
//#define PLGetDomain(name)
//#define PLSetDomain(name, value, kickme)
//#define PLDeleteDomain(name, kickme)
//#define PLRegister(name, callback)
//#define PLUnregister(name)
//#define PLGetContainer(pl)
#define PLGetDomainNames()
#define PLGetDomain(name)
#define PLSetDomain(name, value, kickme)
#define PLDeleteDomain(name, kickme)
#define PLRegister(name, callback)
#define PLUnregister(name)
#endif
#endif

View File

@@ -4,8 +4,6 @@
#include <X11/Xlocale.h>
#include <proplist.h>
_WINGsConfiguration WINGsConfiguration;

View File

@@ -286,7 +286,7 @@ wfindfileinlist(char **path_list, char *file)
char*
wfindfileinarray(proplist_t array, char *file)
wfindfileinarray(WMPropList *array, char *file)
{
int i;
char *path;
@@ -314,14 +314,14 @@ wfindfileinarray(proplist_t array, char *file)
}
flen = strlen(file);
for (i=0; i<PLGetNumberOfElements(array); i++) {
proplist_t prop;
for (i=0; i<WMGetPropListItemCount(array); i++) {
WMPropList *prop;
char *p;
prop = PLGetArrayElement(array, i);
prop = WMGetFromPLArray(array, i);
if (!prop)
continue;
p = PLGetString(prop);
p = WMGetFromPLString(prop);
len = strlen(p);
path = wmalloc(len+flen+2);

View File

@@ -435,8 +435,6 @@ Bool
WMNextHashEnumeratorItemAndKey(WMHashEnumerator *enumerator,
void **item, void **key)
{
const void *data = NULL;
/* this assumes the table doesn't change between
* WMEnumerateHashTable() and WMNextHashEnumeratorItemAndKey() calls */

View File

@@ -409,6 +409,17 @@ indentedDescription(WMPropList *plist, int level)
WMHashEnumerator e;
int i;
if (plist->type==WPLArray || plist->type==WPLDictionary) {
retstr = description(plist);
if (retstr && ((2*(level+1) + strlen(retstr)) <= 77)) {
return retstr;
} else if (retstr) {
wfree(retstr);
retstr = NULL;
}
}
switch (plist->type) {
case WPLString:
retstr = stringDescription(plist);
@@ -1175,10 +1186,12 @@ WMPutInPLDictionary(WMPropList *plist, WMPropList *key, WMPropList *value)
{
wassertr(plist->type==WPLDictionary);
/*WMRetainPropList(key);*/
WMRemoveFromPLDictionary(plist, key);
retainPropListByCount(key, plist->retainCount);
retainPropListByCount(value, plist->retainCount);
WMHashInsert(plist->d.dict, key, value);
/*WMReleasePropList(key);*/
}

View File

@@ -9,18 +9,19 @@
#include "../src/config.h"
#include "wconfig.h"
#include "WINGs.h"
#include <proplist.h>
typedef struct W_UserDefaults {
proplist_t defaults;
WMPropList *defaults;
proplist_t appDomain;
WMPropList *appDomain;
proplist_t searchListArray;
proplist_t *searchList; /* cache for searchListArray */
WMPropList *searchListArray;
WMPropList **searchList; /* cache for searchListArray */
char dirty;
@@ -163,7 +164,8 @@ WMEnableUDPeriodicSynchronization(WMUserDefaults *database, Bool enable)
void
WMSynchronizeUserDefaults(WMUserDefaults *database)
{
Bool fileIsNewer = False, release = False;
Bool fileIsNewer = False, release = False, notify = False;
WMPropList *plF, *key;
char *path;
struct stat stbuf;
@@ -178,14 +180,45 @@ WMSynchronizeUserDefaults(WMUserDefaults *database)
fileIsNewer = True;
if (database->appDomain && (database->dirty || fileIsNewer)) {
if (database->dirty && fileIsNewer) {
plF = WMReadPropListFromFile(path);
if (plF) {
plF = WMMergePLDictionaries(plF, database->appDomain);
WMReleasePropList(database->appDomain);
database->appDomain = plF;
key = database->searchList[0];
WMPutInPLDictionary(database->defaults, key, plF);
notify = True;
} else {
/* something happened with the file. just overwrite it */
wwarning(_("cannot read domain from file '%s' when syncing"),
path);
WMWritePropListToFile(database->appDomain, path, True);
}
} else if (database->dirty) {
WMWritePropListToFile(database->appDomain, path, True);
} else if (fileIsNewer) {
plF = WMReadPropListFromFile(path);
if (plF) {
WMReleasePropList(database->appDomain);
database->appDomain = plF;
key = database->searchList[0];
WMPutInPLDictionary(database->defaults, key, plF);
notify = True;
} else {
/* something happened with the file. just overwrite it */
wwarning(_("cannot read domain from file '%s' when syncing"),
path);
WMWritePropListToFile(database->appDomain, path, True);
}
}
/*fprintf(stderr, "syncing: %s %d %d\n", path, database->dirty, fileIsNewer);*/
PLShallowSynchronize(database->appDomain);
database->dirty = 0;
if (stat(path, &stbuf) >= 0)
database->timestamp = stbuf.st_mtime;
if (fileIsNewer) {
if (notify) {
WMPostNotificationName(WMUserDefaultsDidChangeNotification,
database, NULL);
}
@@ -205,14 +238,14 @@ WMSaveUserDefaults(WMUserDefaults *database)
char *path;
Bool release = False;
PLSave(database->appDomain, YES);
database->dirty = 0;
if (!database->path) {
path = wdefaultspathfordomain(WMGetApplicationName());
release = True;
} else {
path = database->path;
}
WMWritePropListToFile(database->appDomain, path, True);
database->dirty = 0;
if (stat(path, &stbuf) >= 0)
database->timestamp = stbuf.st_mtime;
if (release)
@@ -225,8 +258,8 @@ WMUserDefaults*
WMGetStandardUserDefaults(void)
{
WMUserDefaults *defaults;
proplist_t domain;
proplist_t key;
WMPropList *domain;
WMPropList *key;
struct stat stbuf;
char *path;
int i;
@@ -245,12 +278,12 @@ WMGetStandardUserDefaults(void)
defaults = wmalloc(sizeof(WMUserDefaults));
memset(defaults, 0, sizeof(WMUserDefaults));
defaults->defaults = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
defaults->defaults = WMCreatePLDictionary(NULL, NULL, NULL);
defaults->searchList = wmalloc(sizeof(proplist_t)*3);
defaults->searchList = wmalloc(sizeof(WMPropList*)*3);
/* application domain */
key = PLMakeString(WMGetApplicationName());
key = WMCreatePLString(WMGetApplicationName());
defaults->searchList[0] = key;
/* temporary kluge */
@@ -258,59 +291,49 @@ WMGetStandardUserDefaults(void)
domain = NULL;
path = NULL;
} else {
path = wdefaultspathfordomain(PLGetString(key));
path = wdefaultspathfordomain(WMGetFromPLString(key));
if (stat(path, &stbuf) >= 0)
defaults->timestamp = stbuf.st_mtime;
domain = PLGetProplistWithPath(path);
domain = WMReadPropListFromFile(path);
}
if (!domain) {
proplist_t p;
domain = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
if (path) {
p = PLMakeString(path);
PLSetFilename(domain, p);
PLRelease(p);
}
}
if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL);
if (path)
wfree(path);
defaults->appDomain = domain;
if (domain)
PLInsertDictionaryEntry(defaults->defaults, key, domain);
PLRelease(key);
WMPutInPLDictionary(defaults->defaults, key, domain);
/* global domain */
key = PLMakeString("WMGLOBAL");
key = WMCreatePLString("WMGLOBAL");
defaults->searchList[1] = key;
path = wdefaultspathfordomain(PLGetString(key));
path = wdefaultspathfordomain(WMGetFromPLString(key));
domain = PLGetProplistWithPath(path);
domain = WMReadPropListFromFile(path);
wfree(path);
if (!domain)
domain = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
domain = WMCreatePLDictionary(NULL, NULL, NULL);
if (domain)
PLInsertDictionaryEntry(defaults->defaults, key, domain);
PLRelease(key);
WMPutInPLDictionary(defaults->defaults, key, domain);
/* terminate list */
defaults->searchList[2] = NULL;
defaults->searchListArray = PLMakeArrayFromElements(NULL,NULL);
defaults->searchListArray = WMCreatePLArray(NULL,NULL);
i = 0;
while (defaults->searchList[i]) {
PLAppendArrayElement(defaults->searchListArray,
WMAddToPLArray(defaults->searchListArray,
defaults->searchList[i]);
i++;
}
@@ -330,8 +353,8 @@ WMUserDefaults*
WMGetDefaultsFromPath(char *path)
{
WMUserDefaults *defaults;
proplist_t domain;
proplist_t key;
WMPropList *domain;
WMPropList *key;
struct stat stbuf;
char *name;
int i;
@@ -351,9 +374,9 @@ WMGetDefaultsFromPath(char *path)
defaults = wmalloc(sizeof(WMUserDefaults));
memset(defaults, 0, sizeof(WMUserDefaults));
defaults->defaults = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
defaults->defaults = WMCreatePLDictionary(NULL, NULL, NULL);
defaults->searchList = wmalloc(sizeof(proplist_t)*2);
defaults->searchList = wmalloc(sizeof(WMPropList*)*2);
/* the domain we want, go in the first position */
name = strrchr(path, '/');
@@ -362,40 +385,32 @@ WMGetDefaultsFromPath(char *path)
else
name++;
key = PLMakeString(name);
key = WMCreatePLString(name);
defaults->searchList[0] = key;
if (stat(path, &stbuf) >= 0)
defaults->timestamp = stbuf.st_mtime;
domain = PLGetProplistWithPath(path);
domain = WMReadPropListFromFile(path);
if (!domain) {
proplist_t p;
domain = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
p = PLMakeString(path);
PLSetFilename(domain, p);
PLRelease(p);
}
if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL);
defaults->path = wstrdup(path);
defaults->appDomain = domain;
if (domain)
PLInsertDictionaryEntry(defaults->defaults, key, domain);
PLRelease(key);
WMPutInPLDictionary(defaults->defaults, key, domain);
/* terminate list */
defaults->searchList[1] = NULL;
defaults->searchListArray = PLMakeArrayFromElements(NULL,NULL);
defaults->searchListArray = WMCreatePLArray(NULL,NULL);
i = 0;
while (defaults->searchList[i]) {
PLAppendArrayElement(defaults->searchListArray,
WMAddToPLArray(defaults->searchListArray,
defaults->searchList[i]);
i++;
}
@@ -411,85 +426,85 @@ WMGetDefaultsFromPath(char *path)
}
/* Returns a PLArray with all keys in the user defaults database.
* Free the returned array with PLRelease() when no longer needed,
/* Returns a WMPropList array with all keys in the user defaults database.
* Free the array with WMReleasePropList() when no longer needed,
* but do not free the elements of the array! They're just references. */
proplist_t
WMGetUDAllKeys(WMUserDefaults *database)
WMPropList*
WMGetUDKeys(WMUserDefaults *database)
{
return PLGetAllDictionaryKeys(database->appDomain);
return WMGetPLDictionaryKeys(database->appDomain);
}
proplist_t
WMPropList*
WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName)
{
proplist_t domainName, domain;
proplist_t object = NULL;
proplist_t key = PLMakeString(defaultName);
WMPropList *domainName, *domain;
WMPropList *object = NULL;
WMPropList *key = WMCreatePLString(defaultName);
int i = 0;
while (database->searchList[i] && !object) {
domainName = database->searchList[i];
domain = PLGetDictionaryEntry(database->defaults, domainName);
domain = WMGetFromPLDictionary(database->defaults, domainName);
if (domain) {
object = PLGetDictionaryEntry(domain, key);
object = WMGetFromPLDictionary(domain, key);
}
i++;
}
PLRelease(key);
WMReleasePropList(key);
return object;
}
void
WMSetUDObjectForKey(WMUserDefaults *database, proplist_t object,
WMSetUDObjectForKey(WMUserDefaults *database, WMPropList *object,
char *defaultName)
{
proplist_t key = PLMakeString(defaultName);
WMPropList *key = WMCreatePLString(defaultName);
database->dirty = 1;
PLInsertDictionaryEntry(database->appDomain, key, object);
PLRelease(key);
WMPutInPLDictionary(database->appDomain, key, object);
WMReleasePropList(key);
}
void
WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName)
{
proplist_t key = PLMakeString(defaultName);
WMPropList *key = WMCreatePLString(defaultName);
database->dirty = 1;
PLRemoveDictionaryEntry(database->appDomain, key);
WMRemoveFromPLDictionary(database->appDomain, key);
PLRelease(key);
WMReleasePropList(key);
}
char*
WMGetUDStringForKey(WMUserDefaults *database, char *defaultName)
{
proplist_t val;
WMPropList *val;
val = WMGetUDObjectForKey(database, defaultName);
if (!val)
return NULL;
if (!PLIsString(val))
if (!WMIsPLString(val))
return NULL;
return PLGetString(val);
return WMGetFromPLString(val);
}
int
WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName)
{
proplist_t val;
WMPropList *val;
char *str;
int value;
@@ -498,10 +513,10 @@ WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName)
if (!val)
return 0;
if (!PLIsString(val))
if (!WMIsPLString(val))
return 0;
str = PLGetString(val);
str = WMGetFromPLString(val);
if (!str)
return 0;
@@ -516,16 +531,16 @@ WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName)
float
WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName)
{
proplist_t val;
WMPropList *val;
char *str;
float value;
val = WMGetUDObjectForKey(database, defaultName);
if (!val || !PLIsString(val))
if (!val || !WMIsPLString(val))
return 0.0;
if (!(str = PLGetString(val)))
if (!(str = WMGetFromPLString(val)))
return 0.0;
if (sscanf(str, "%f", &value)!=1)
@@ -539,7 +554,7 @@ WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName)
Bool
WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName)
{
proplist_t val;
WMPropList *val;
int value;
char *str;
@@ -548,10 +563,10 @@ WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName)
if (!val)
return False;
if (!PLIsString(val))
if (!WMIsPLString(val))
return False;
str = PLGetString(val);
str = WMGetFromPLString(val);
if (!str)
return False;
@@ -571,14 +586,14 @@ WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName)
void
WMSetUDIntegerForKey(WMUserDefaults *database, int value, char *defaultName)
{
proplist_t object;
WMPropList *object;
char buffer[128];
sprintf(buffer, "%i", value);
object = PLMakeString(buffer);
object = WMCreatePLString(buffer);
WMSetUDObjectForKey(database, object, defaultName);
PLRelease(object);
WMReleasePropList(object);
}
@@ -587,12 +602,12 @@ WMSetUDIntegerForKey(WMUserDefaults *database, int value, char *defaultName)
void
WMSetUDStringForKey(WMUserDefaults *database, char *value, char *defaultName)
{
proplist_t object;
WMPropList *object;
object = PLMakeString(value);
object = WMCreatePLString(value);
WMSetUDObjectForKey(database, object, defaultName);
PLRelease(object);
WMReleasePropList(object);
}
@@ -600,14 +615,14 @@ WMSetUDStringForKey(WMUserDefaults *database, char *value, char *defaultName)
void
WMSetUDFloatForKey(WMUserDefaults *database, float value, char *defaultName)
{
proplist_t object;
WMPropList *object;
char buffer[128];
sprintf(buffer, "%f", value);
object = PLMakeString(buffer);
object = WMCreatePLString(buffer);
WMSetUDObjectForKey(database, object, defaultName);
PLRelease(object);
WMReleasePropList(object);
}
@@ -615,18 +630,18 @@ WMSetUDFloatForKey(WMUserDefaults *database, float value, char *defaultName)
void
WMSetUDBoolForKey(WMUserDefaults *database, Bool value, char *defaultName)
{
static proplist_t yes = NULL, no = NULL;
static WMPropList *yes = NULL, *no = NULL;
if (!yes) {
yes = PLMakeString("YES");
no = PLMakeString("NO");
yes = WMCreatePLString("YES");
no = WMCreatePLString("NO");
}
WMSetUDObjectForKey(database, value ? yes : no, defaultName);
}
proplist_t
WMPropList*
WMGetUDSearchList(WMUserDefaults *database)
{
return database->searchListArray;
@@ -634,30 +649,30 @@ WMGetUDSearchList(WMUserDefaults *database)
void
WMSetUDSearchList(WMUserDefaults *database, proplist_t list)
WMSetUDSearchList(WMUserDefaults *database, WMPropList *list)
{
int i, c;
if (database->searchList) {
i = 0;
while (database->searchList[i]) {
PLRelease(database->searchList[i]);
WMReleasePropList(database->searchList[i]);
i++;
}
wfree(database->searchList);
}
if (database->searchListArray) {
PLRelease(database->searchListArray);
WMReleasePropList(database->searchListArray);
}
c = PLGetNumberOfElements(list);
database->searchList = wmalloc(sizeof(proplist_t)*(c+1));
c = WMGetPropListItemCount(list);
database->searchList = wmalloc(sizeof(WMPropList*)*(c+1));
for (i=0; i<c; i++) {
database->searchList[i] = PLGetArrayElement(list, i);
database->searchList[i] = WMGetFromPLArray(list, i);
}
database->searchListArray = PLDeepCopy(list);
database->searchListArray = WMDeepCopyPropList(list);
}

View File

@@ -6,20 +6,8 @@
#include <X11/Xutil.h>
/* Xmd.h which is indirectly included by GNUstep.h defines BOOL,
* but libPropList also defines it. So we do this kluge to get rid of BOOL
* temporarily */
#ifdef BOOL
# define WINGS_BOOL
# undef BOOL
#endif
#include "GNUstep.h"
#ifdef WINGS_BOOL
# define BOOL
# undef WINGS_BOOL
#endif
extern struct W_Application WMApplication;

View File

@@ -30,7 +30,7 @@ typedef struct W_FontPanel {
WMButton *revertB;
WMButton *setB;
proplist_t fdb;
WMPropList *fdb;
} FontPanel;

View File

@@ -153,7 +153,7 @@ handleEvents(XEvent *event, void *data)
if (item) {
WMSelectTabViewItem(tPtr, item);
} else if (tPtr->flags.dontFitAll) {
int redraw;
int redraw = 0;
int lastVisible = tPtr->firstVisible+tPtr->visibleTabs-1;
if (event->xbutton.x < BUTTONED_SIDE_OFFSET) {

View File

@@ -1001,7 +1001,6 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
int cancelSelection = 1;
Bool shifted, controled, modified;
Bool relay = True;
WMScreen *scr = tPtr->view->screen;
/*printf("(%d,%d) -> ", tPtr->selection.position, tPtr->selection.count);*/
if (((XKeyEvent *) event)->state & WM_EMACSKEYMASK)