Hello, here are two patches for WPrefs. My target is renew the menus, because they are not using WINGs and they have a lot of duplicated code.
The code in the WINGs library is not good to make menus, because they have tools to create menu items, but not full menu. On the other hand, WPrefs has a lot of function to create menus (panels with menuitems). IMO, we should clear the current WPrefs functions, then move this functions to WINGs (with WPrefs usint the libraries at WINGs) and then rewrite the menu. The problem is that we should clean a bit the WPrefs code. Here are two patches. The first to start with this work, and the second to remove old files. Subject: [PATCH 1/2] WPrefs.app: Removing duplicated code Subject: [PATCH 2/2] WINGs: Removed proplist-compat.h Comments are welcome. I hope the patches could be applied :-? ---8<--- >From a1fd666180bcbd6738e8854ff128d57c25eb1f6d Mon Sep 17 00:00:00 2001 From: Rodolfo García Peñas (kix) <[email protected]> Date: Tue, 17 Jan 2012 19:29:36 +0100 Subject: [PATCH 1/2] WPrefs.app: Removing duplicated code The code for the struct _Panel is the same in the files KeyboardShortcuts.c and Menu.c. The common code has been moved to KeyboardShortcuts.h and the name of some variables has been unified. The type of int was changed to Bool for one variable. The only difference is that the function captureShortcut had only two parameters, and in one case the panel text is changed to lowercase and not in the other. I add a parameter (boolean flag as int) to do it. Other difference is the function captureShortcut, now is not static. The new file KeyboardShortcuts.h is included in the Makefile.am file. --- WPrefs.app/KeyboardShortcuts.c | 170 ++++++++------------------------------ WPrefs.app/KeyboardShortcuts.h | 178 ++++++++++++++++++++++++++++++++++++++++ WPrefs.app/Makefile.am | 1 + WPrefs.app/Menu.c | 140 +------------------------------- 4 files changed, 217 insertions(+), 272 deletions(-) create mode 100644 WPrefs.app/KeyboardShortcuts.h diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 1d70854..f2ffda5 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -19,108 +19,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" /* for HAVE_XCONVERTCASE */ +#include "KeyboardShortcuts.h" -#include "WPrefs.h" -#include <ctype.h> - -#include <X11/keysym.h> - -typedef struct _Panel { - WMBox *box; - - char *sectionName; - - char *description; - - CallbackRec callbacks; - - WMWidget *parent; - - WMLabel *actL; - WMList *actLs; - - WMFrame *shoF; - WMTextField *shoT; - WMButton *cleB; - WMButton *defB; - - WMLabel *instructionsL; - - WMColor *white; - WMColor *black; - WMColor *gray; - WMFont *font; - - /**/ char capturing; - char **shortcuts; - int actionCount; -} _Panel; - -#define ICON_FILE "keyshortcuts" - -/* - * Must be in the same order as the corresponding items in - * "actions list" in createPanel() - */ -static char *keyOptions[] = { - "RootMenuKey", - "WindowListKey", - "WindowMenuKey", - "HideKey", - "HideOthersKey", - "MiniaturizeKey", - "MinimizeAllKey", - "CloseKey", - "MaximizeKey", - "VMaximizeKey", - "HMaximizeKey", - "LHMaximizeKey", - "RHMaximizeKey", - "MaximusKey", - "RaiseKey", - "LowerKey", - "RaiseLowerKey", - "ShadeKey", - "MoveResizeKey", - "SelectKey", - "FocusNextKey", - "FocusPrevKey", - "GroupNextKey", - "GroupPrevKey", - "NextWorkspaceKey", - "PrevWorkspaceKey", - "NextWorkspaceLayerKey", - "PrevWorkspaceLayerKey", - "Workspace1Key", - "Workspace2Key", - "Workspace3Key", - "Workspace4Key", - "Workspace5Key", - "Workspace6Key", - "Workspace7Key", - "Workspace8Key", - "Workspace9Key", - "Workspace10Key", - "WindowShortcut1Key", - "WindowShortcut2Key", - "WindowShortcut3Key", - "WindowShortcut4Key", - "WindowShortcut5Key", - "WindowShortcut6Key", - "WindowShortcut7Key", - "WindowShortcut8Key", - "WindowShortcut9Key", - "WindowShortcut10Key", - "ScreenSwitchKey", - "DockRaiseLowerKey", -#ifndef XKB_MODELOCK - "ClipRaiseLowerKey" -#else - "ClipRaiseLowerKey", - "ToggleKbdModeKey" -#endif /* XKB_MODELOCK */ -}; +#define ICON_FILE "keyshortcuts" #ifndef HAVE_XCONVERTCASE /* from Xlib */ @@ -230,7 +131,7 @@ static void XConvertCase(register KeySym sym, KeySym * lower, KeySym * upper) } #endif -static char *captureShortcut(Display * dpy, _Panel * panel) +char *captureShortcut(Display * dpy, _Panel * panel, int convertCase) { XEvent ev; KeySym ksym, lksym, uksym; @@ -243,7 +144,8 @@ static char *captureShortcut(Display * dpy, _Panel * panel) if (ev.type == KeyPress && ev.xkey.keycode != 0) { ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); if (!IsModifierKey(ksym)) { - XConvertCase(ksym, &lksym, &uksym); + if (convertCase) + XConvertCase(ksym, &lksym, &uksym); key = XKeysymToString(uksym); panel->capturing = 0; @@ -296,11 +198,11 @@ static void captureClick(WMWidget * w, void *data) WMSetLabelText(panel->instructionsL, _("Press the desired shortcut key(s) or click Cancel to stop capturing.")); XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime); - shortcut = captureShortcut(dpy, panel); + shortcut = captureShortcut(dpy, panel, 1); if (shortcut) { int row = WMGetListSelectedItemRow(panel->actLs); - WMSetTextFieldText(panel->shoT, shortcut); + WMSetTextFieldText(panel->shortT, shortcut); if (row >= 0) { if (panel->shortcuts[row]) wfree(panel->shortcuts[row]); @@ -323,7 +225,7 @@ static void clearShortcut(WMWidget * w, void *data) _Panel *panel = (_Panel *) data; int row = WMGetListSelectedItemRow(panel->actLs); - WMSetTextFieldText(panel->shoT, NULL); + WMSetTextFieldText(panel->shortT, NULL); if (row >= 0) { if (panel->shortcuts[row]) @@ -343,7 +245,7 @@ static void typedKeys(void *observerData, WMNotification * notification) if (panel->shortcuts[row]) wfree(panel->shortcuts[row]); - panel->shortcuts[row] = WMGetTextFieldText(panel->shoT); + panel->shortcuts[row] = WMGetTextFieldText(panel->shortT); if (strlen(panel->shortcuts[row]) == 0) { wfree(panel->shortcuts[row]); panel->shortcuts[row] = NULL; @@ -356,7 +258,7 @@ static void listClick(WMWidget * w, void *data) _Panel *panel = (_Panel *) data; int row = WMGetListSelectedItemRow(w); - WMSetTextFieldText(panel->shoT, panel->shortcuts[row]); + WMSetTextFieldText(panel->shortT, panel->shortcuts[row]); } static char *trimstr(char *str) @@ -423,7 +325,7 @@ static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int stat WMReleasePixmap(pix); } - WMDrawString(scr, d, panel->black, panel->font, x + 20, y, text, strlen(text)); + WMDrawString(scr, d, panel->black, panel->normalFont, x + 20, y, text, strlen(text)); } static void createPanel(Panel * p) @@ -438,7 +340,7 @@ static void createPanel(Panel * p) panel->white = WMWhiteColor(scr); panel->black = WMBlackColor(scr); panel->gray = WMGrayColor(scr); - panel->font = WMSystemFontOfSize(scr, 12); + panel->normalFont = WMSystemFontOfSize(scr, 12); panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); @@ -527,36 +429,36 @@ static void createPanel(Panel * p) /***************** Shortcut ****************/ - panel->shoF = WMCreateFrame(panel->box); - WMResizeWidget(panel->shoF, 190, 210); - WMMoveWidget(panel->shoF, 315, 10); - WMSetFrameTitle(panel->shoF, _("Shortcut")); - - panel->shoT = WMCreateTextField(panel->shoF); - WMResizeWidget(panel->shoT, 160, 20); - WMMoveWidget(panel->shoT, 15, 65); - WMAddNotificationObserver(typedKeys, panel, WMTextDidChangeNotification, panel->shoT); - - panel->cleB = WMCreateCommandButton(panel->shoF); - WMResizeWidget(panel->cleB, 75, 24); - WMMoveWidget(panel->cleB, 15, 95); - WMSetButtonText(panel->cleB, _("Clear")); - WMSetButtonAction(panel->cleB, clearShortcut, panel); - - panel->defB = WMCreateCommandButton(panel->shoF); - WMResizeWidget(panel->defB, 75, 24); - WMMoveWidget(panel->defB, 100, 95); - WMSetButtonText(panel->defB, _("Capture")); - WMSetButtonAction(panel->defB, captureClick, panel); - - panel->instructionsL = WMCreateLabel(panel->shoF); + panel->shortF = WMCreateFrame(panel->box); + WMResizeWidget(panel->shortF, 190, 210); + WMMoveWidget(panel->shortF, 315, 10); + WMSetFrameTitle(panel->shortF, _("Shortcut")); + + panel->shortT = WMCreateTextField(panel->shortF); + WMResizeWidget(panel->shortT, 160, 20); + WMMoveWidget(panel->shortT, 15, 65); + WMAddNotificationObserver(typedKeys, panel, WMTextDidChangeNotification, panel->shortT); + + panel->sclearB = WMCreateCommandButton(panel->shortF); + WMResizeWidget(panel->sclearB, 75, 24); + WMMoveWidget(panel->sclearB, 15, 95); + WMSetButtonText(panel->sclearB, _("Clear")); + WMSetButtonAction(panel->sclearB, clearShortcut, panel); + + panel->sgrabB = WMCreateCommandButton(panel->shortF); + WMResizeWidget(panel->sgrabB, 75, 24); + WMMoveWidget(panel->sgrabB, 100, 95); + WMSetButtonText(panel->sgrabB, _("Capture")); + WMSetButtonAction(panel->sgrabB, captureClick, panel); + + panel->instructionsL = WMCreateLabel(panel->shortF); WMResizeWidget(panel->instructionsL, 160, 55); WMMoveWidget(panel->instructionsL, 15, 140); WMSetLabelTextAlignment(panel->instructionsL, WACenter); WMSetLabelWraps(panel->instructionsL, True); WMSetLabelText(panel->instructionsL, _("Click on Capture to interactively define the shortcut key.")); - WMMapSubwidgets(panel->shoF); + WMMapSubwidgets(panel->shortF); WMReleaseFont(boldFont); diff --git a/WPrefs.app/KeyboardShortcuts.h b/WPrefs.app/KeyboardShortcuts.h new file mode 100644 index 0000000..9fb2ca8 --- /dev/null +++ b/WPrefs.app/KeyboardShortcuts.h @@ -0,0 +1,178 @@ +#include "config.h" /* for HAVE_XCONVERTCASE */ +#include "WPrefs.h" +#include <ctype.h> +#include <X11/keysym.h> +#include "editmenu.h" + +#define MAX_SECTION_SIZE 4 + +typedef enum { + NoInfo, + ExecInfo, + CommandInfo, + ExternalInfo, + PipeInfo, + DirectoryInfo, + WSMenuInfo, + WWindowListInfo, + LastInfo +} InfoType; + +typedef struct _Panel { + /* In Menu.c and KeyboardShortcuts.c */ + WMBox *box; + char *sectionName; + + char *description; + + CallbackRec callbacks; + WMWidget *parent; + + WMFont *boldFont; + WMFont *normalFont; + WMColor *white; + WMColor *gray; + WMColor *black; + + WMFrame *shortF; + WMTextField *shortT; + WMButton *sgrabB; + WMButton *sclearB; + + Bool capturing; + + /* KeyboardShortcuts.c */ + WMLabel *actL; + WMList *actLs; + WMLabel *instructionsL; + char **shortcuts; + int actionCount; + + /* Menu.c */ + WMPixmap *markerPix[LastInfo]; + WMPopUpButton *typeP; + + WMWidget *itemPad[3]; + int currentPad; + + WEditMenu *menu; + char *menuPath; + + WMFrame *optionsF; + + WMFrame *commandF; + WMTextField *commandT; /* command to run */ + WMButton *browseB; + WMButton *xtermC; /* inside xterm? */ + + WMFrame *pathF; + WMTextField *pathT; + + WMFrame *pipeF; + WMTextField *pipeT; + WMButton *pipeCacheB; + + WMFrame *dpathF; + WMTextField *dpathT; + + WMFrame *dcommandF; + WMTextField *dcommandT; + + WMButton *dstripB; + + WMList *icommandL; + + WMFrame *paramF; + WMTextField *paramT; + + WMButton *quickB; + + Bool dontAsk; /* whether to comfirm submenu remove */ + Bool dontSave; + + /* about the currently selected item */ + WEditMenuItem *currentItem; + InfoType currentType; + WMWidget *sections[LastInfo][MAX_SECTION_SIZE]; +} _Panel; + +/* + * Must be in the same order as the corresponding items in + * "actions list" in createPanel() + */ +static char *keyOptions[] = { + "RootMenuKey", + "WindowListKey", + "WindowMenuKey", + "HideKey", + "HideOthersKey", + "MiniaturizeKey", + "MinimizeAllKey", + "CloseKey", + "MaximizeKey", + "VMaximizeKey", + "HMaximizeKey", + "LHMaximizeKey", + "RHMaximizeKey", + "MaximusKey", + "RaiseKey", + "LowerKey", + "RaiseLowerKey", + "ShadeKey", + "MoveResizeKey", + "SelectKey", + "FocusNextKey", + "FocusPrevKey", + "GroupNextKey", + "GroupPrevKey", + "NextWorkspaceKey", + "PrevWorkspaceKey", + "NextWorkspaceLayerKey", + "PrevWorkspaceLayerKey", + "Workspace1Key", + "Workspace2Key", + "Workspace3Key", + "Workspace4Key", + "Workspace5Key", + "Workspace6Key", + "Workspace7Key", + "Workspace8Key", + "Workspace9Key", + "Workspace10Key", + "WindowShortcut1Key", + "WindowShortcut2Key", + "WindowShortcut3Key", + "WindowShortcut4Key", + "WindowShortcut5Key", + "WindowShortcut6Key", + "WindowShortcut7Key", + "WindowShortcut8Key", + "WindowShortcut9Key", + "WindowShortcut10Key", + "ScreenSwitchKey", + "DockRaiseLowerKey", +#ifndef XKB_MODELOCK + "ClipRaiseLowerKey" +#else + "ClipRaiseLowerKey", + "ToggleKbdModeKey" +#endif /* XKB_MODELOCK */ +}; + +char *captureShortcut(Display * dpy, _Panel * panel, int convertCase); /* No static now! */ + +static void captureClick(WMWidget * w, void *data); +static void clearShortcut(WMWidget * w, void *data); +static void typedKeys(void *observerData, WMNotification * notification); +static void listClick(WMWidget * w, void *data); +static char *trimstr(char *str); +static void showData(_Panel * panel); +static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect); +static void createPanel(Panel * p); +static void storeData(_Panel * panel); +Panel *InitKeyboardShortcuts(WMScreen * scr, WMWidget * parent); + +#ifndef HAVE_XCONVERTCASE +/* from Xlib */ +static void XConvertCase(register KeySym sym, KeySym * lower, KeySym * upper); +#endif diff --git a/WPrefs.app/Makefile.am b/WPrefs.app/Makefile.am index 654457f..7c40d2e 100644 --- a/WPrefs.app/Makefile.am +++ b/WPrefs.app/Makefile.am @@ -23,6 +23,7 @@ WPrefs_SOURCES = \ FontSimple.c \ Icons.c \ KeyboardSettings.c \ + KeyboardShortcuts.h \ KeyboardShortcuts.c \ Menu.c \ MenuPreferences.c \ diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index 21a9fe1..67ef654 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -25,93 +25,7 @@ #include <X11/keysym.h> #include <X11/cursorfont.h> - -#include "editmenu.h" - -typedef enum { - NoInfo, - ExecInfo, - CommandInfo, - ExternalInfo, - PipeInfo, - DirectoryInfo, - WSMenuInfo, - WWindowListInfo, - LastInfo -} InfoType; - -#define MAX_SECTION_SIZE 4 -#define PATH_LEN 256 - -typedef struct _Panel { - WMBox *box; - char *sectionName; - - char *description; - - CallbackRec callbacks; - WMWidget *parent; - - WMFont *boldFont; - WMFont *normalFont; - WMColor *white; - WMColor *gray; - WMColor *black; - - WMPixmap *markerPix[LastInfo]; - - WMPopUpButton *typeP; - - WMWidget *itemPad[3]; - int currentPad; - - WEditMenu *menu; - char *menuPath; - - WMFrame *optionsF; - - WMFrame *commandF; - WMTextField *commandT; /* command to run */ - WMButton *browseB; - WMButton *xtermC; /* inside xterm? */ - - WMFrame *pathF; - WMTextField *pathT; - - WMFrame *pipeF; - WMTextField *pipeT; - WMButton *pipeCacheB; - - WMFrame *dpathF; - WMTextField *dpathT; - - WMFrame *dcommandF; - WMTextField *dcommandT; - - WMButton *dstripB; - - WMFrame *shortF; - WMTextField *shortT; - WMButton *sgrabB; - WMButton *sclearB; - - WMList *icommandL; - - WMFrame *paramF; - WMTextField *paramT; - - WMButton *quickB; - - Bool dontAsk; /* whether to comfirm submenu remove */ - Bool dontSave; - - Bool capturing; - - /* about the currently selected item */ - WEditMenuItem *currentItem; - InfoType currentType; - WMWidget *sections[LastInfo][MAX_SECTION_SIZE]; -} _Panel; +#include "KeyboardShortcuts.h" typedef struct { InfoType type; @@ -254,58 +168,6 @@ static void browseForFile(WMWidget * self, void *clientData) wfree(oldprog); } -static char *captureShortcut(Display * dpy, _Panel * panel) -{ - XEvent ev; - KeySym ksym; - char buffer[64]; - char *key = NULL; - - while (panel->capturing) { - XAllowEvents(dpy, AsyncKeyboard, CurrentTime); - WMNextEvent(dpy, &ev); - if (ev.type == KeyPress && ev.xkey.keycode != 0) { - ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); - if (!IsModifierKey(ksym)) { - key = XKeysymToString(ksym); - panel->capturing = 0; - break; - } - } - WMHandleEvent(&ev); - } - - if (!key) - return NULL; - - buffer[0] = 0; - - if (ev.xkey.state & ControlMask) { - strcat(buffer, "Control+"); - } - if (ev.xkey.state & ShiftMask) { - strcat(buffer, "Shift+"); - } - if (ev.xkey.state & Mod1Mask) { - strcat(buffer, "Mod1+"); - } - if (ev.xkey.state & Mod2Mask) { - strcat(buffer, "Mod2+"); - } - if (ev.xkey.state & Mod3Mask) { - strcat(buffer, "Mod3+"); - } - if (ev.xkey.state & Mod4Mask) { - strcat(buffer, "Mod4+"); - } - if (ev.xkey.state & Mod5Mask) { - strcat(buffer, "Mod5+"); - } - strcat(buffer, key); - - return wstrdup(buffer); -} - static void sgrabClicked(WMWidget * w, void *data) { _Panel *panel = (_Panel *) data; @@ -322,7 +184,7 @@ static void sgrabClicked(WMWidget * w, void *data) panel->capturing = 1; WMSetButtonText(w, _("Cancel")); XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime); - shortcut = captureShortcut(dpy, panel); + shortcut = captureShortcut(dpy, panel, 0); if (shortcut) { WMSetTextFieldText(panel->shortT, shortcut); updateMenuItem(panel, panel->currentItem, panel->shortT); -- 1.7.2.3 >From 853f675f4b78180a7777f450b0592bade9fad5d4 Mon Sep 17 00:00:00 2001 From: Rodolfo García Peñas (kix) <[email protected]> Date: Tue, 17 Jan 2012 19:32:44 +0100 Subject: [PATCH 2/2] WINGs: Removed proplist-compat.h The file proplist-compat.h is not needed to compile Window Maker and is not used by other applications (tested in Debian). Therefore the file should be removed. --- WINGs/WINGs/Makefile.am | 2 +- WINGs/WINGs/proplist-compat.h | 138 ----------------------------------------- 2 files changed, 1 insertions(+), 139 deletions(-) delete mode 100644 WINGs/WINGs/proplist-compat.h diff --git a/WINGs/WINGs/Makefile.am b/WINGs/WINGs/Makefile.am index b77333b..088f1fe 100644 --- a/WINGs/WINGs/Makefile.am +++ b/WINGs/WINGs/Makefile.am @@ -5,4 +5,4 @@ AUTOMAKE_OPTIONS = # is this a kluge? if so, how should i do it? includedir = @includedir@/WINGs -include_HEADERS = WINGs.h WUtil.h WINGsP.h proplist-compat.h +include_HEADERS = WINGs.h WUtil.h WINGsP.h diff --git a/WINGs/WINGs/proplist-compat.h b/WINGs/WINGs/proplist-compat.h deleted file mode 100644 index 18ec457..0000000 --- a/WINGs/WINGs/proplist-compat.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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_ -#define _PROPLIST_COMPAT_H_ - -#include <WINGs/WUtil.h> - - -typedef WMPropList* proplist_t; - - -#ifndef YES -#define YES True -#endif - -#ifndef NO -#define NO False -#endif - - -#define PLSetCaseSensitive(c) WMPLSetCaseSensitive(c) - -#define PLMakeString(bytes) WMCreatePLString(bytes) -#define PLMakeData(bytes, length) WMCreatePLDataWithBytes(bytes, length) -#define PLMakeArrayFromElements WMCreatePLArray -#define PLMakeDictionaryFromEntries WMCreatePLDictionary - -#define PLRetain(pl) WMRetainPropList(pl) -#define PLRelease(pl) WMReleasePropList(pl) - -#define PLInsertArrayElement(array, pl, pos) WMInsertInPLArray(array, pos, pl) -#define PLAppendArrayElement(array, pl) WMAddToPLArray(array, pl) -#define PLRemoveArrayElement(array, pos) WMDeleteFromPLArray(array, pos) -#define PLInsertDictionaryEntry(dict, key, value) WMPutInPLDictionary(dict, key, value) -#define PLRemoveDictionaryEntry(dict, key) WMRemoveFromPLDictionary(dict, key) -#define PLMergeDictionaries(dest, source) WMMergePLDictionaries(dest, source, False) - -#define PLGetNumberOfElements(pl) WMGetPropListItemCount(pl) - -#define PLIsString(pl) WMIsPLString(pl) -#define PLIsData(pl) WMIsPLData(pl) -#define PLIsArray(pl) WMIsPLArray(pl) -#define PLIsDictionary(pl) WMIsPLDictionary(pl) -#define PLIsSimple(pl) (WMIsPLString(pl) || WMIsPLData(pl)) -#define PLIsCompound(pl) (WMIsPLArray(pl) || WMIsPLDictionary(pl)) -#define PLIsEqual(pl1, pl2) WMIsPropListEqualTo(pl1, pl2) - -#define PLGetString(pl) WMGetFromPLString(pl) -#define PLGetDataBytes(pl) WMGetPLDataBytes(pl) -#define PLGetDataLength(pl) WMGetPLDataLength(pl) -#define PLGetArrayElement(pl, index) WMGetFromPLArray(pl, index) -#define PLGetDictionaryEntry(pl, key) WMGetFromPLDictionary(pl, key) -#define PLGetAllDictionaryKeys(pl) WMGetPLDictionaryKeys(pl) - -#define PLShallowCopy(pl) WMShallowCopyPropList(pl) -#define PLDeepCopy(pl) WMDeepCopyPropList(pl) - -#define PLGetProplistWithDescription(desc) WMCreatePropListFromDescription(desc) -#define PLGetDescriptionIndent(pl, level) WMGetPropListDescription(pl, True) -#define PLGetDescription(pl) WMGetPropListDescription(pl, False) -#define PLGetStringDescription(pl) WMGetPropListDescription(pl, False) -#define PLGetDataDescription(pl) WMGetPropListDescription(pl, False) - -#define PLGetProplistWithPath(file) WMReadPropListFromFile(file) -#define PLSave(pl, file, atm) WMWritePropListToFile(pl, file) - - -/* Unsupported functions. Do not ask for them. They're evil :P */ -#define PLSetStringCmpHook(fn) error_PLSetStringCmpHook_is_not_supported -#define PLDeepSynchronize(pl) error_PLDeepSynchronize_is_not_supported -#define PLSynchronize(pl) error_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) error_PLGetContainer_is_not_supported - -#define PLGetDomainNames error_PLGetDomainNames_is_not_supported -#define PLGetDomain(name) error_PLGetDomain_is_not_supported -#define PLSetDomain(name, value, kickme) error_PLSetDomain_is_not_supported -#define PLDeleteDomain(name, kickme) error_PLDeleteDomain_is_not_supported -#define PLRegister(name, callback) error_PLRegister_is_not_supported -#define PLUnregister(name) error_PLUnregister_is_not_supported - - -#endif -- 1.7.2.3
>From a1fd666180bcbd6738e8854ff128d57c25eb1f6d Mon Sep 17 00:00:00 2001 From: Rodolfo GarcÃa Peñas (kix) <[email protected]> Date: Tue, 17 Jan 2012 19:29:36 +0100 Subject: [PATCH 1/2] WPrefs.app: Removing duplicated code The code for the struct _Panel is the same in the files KeyboardShortcuts.c and Menu.c. The common code has been moved to KeyboardShortcuts.h and the name of some variables has been unified. The type of int was changed to Bool for one variable. The only difference is that the function captureShortcut had only two parameters, and in one case the panel text is changed to lowercase and not in the other. I add a parameter (boolean flag as int) to do it. Other difference is the function captureShortcut, now is not static. The new file KeyboardShortcuts.h is included in the Makefile.am file. --- WPrefs.app/KeyboardShortcuts.c | 170 ++++++++------------------------------ WPrefs.app/KeyboardShortcuts.h | 178 ++++++++++++++++++++++++++++++++++++++++ WPrefs.app/Makefile.am | 1 + WPrefs.app/Menu.c | 140 +------------------------------- 4 files changed, 217 insertions(+), 272 deletions(-) create mode 100644 WPrefs.app/KeyboardShortcuts.h diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 1d70854..f2ffda5 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -19,108 +19,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" /* for HAVE_XCONVERTCASE */ +#include "KeyboardShortcuts.h" -#include "WPrefs.h" -#include <ctype.h> - -#include <X11/keysym.h> - -typedef struct _Panel { - WMBox *box; - - char *sectionName; - - char *description; - - CallbackRec callbacks; - - WMWidget *parent; - - WMLabel *actL; - WMList *actLs; - - WMFrame *shoF; - WMTextField *shoT; - WMButton *cleB; - WMButton *defB; - - WMLabel *instructionsL; - - WMColor *white; - WMColor *black; - WMColor *gray; - WMFont *font; - - /**/ char capturing; - char **shortcuts; - int actionCount; -} _Panel; - -#define ICON_FILE "keyshortcuts" - -/* - * Must be in the same order as the corresponding items in - * "actions list" in createPanel() - */ -static char *keyOptions[] = { - "RootMenuKey", - "WindowListKey", - "WindowMenuKey", - "HideKey", - "HideOthersKey", - "MiniaturizeKey", - "MinimizeAllKey", - "CloseKey", - "MaximizeKey", - "VMaximizeKey", - "HMaximizeKey", - "LHMaximizeKey", - "RHMaximizeKey", - "MaximusKey", - "RaiseKey", - "LowerKey", - "RaiseLowerKey", - "ShadeKey", - "MoveResizeKey", - "SelectKey", - "FocusNextKey", - "FocusPrevKey", - "GroupNextKey", - "GroupPrevKey", - "NextWorkspaceKey", - "PrevWorkspaceKey", - "NextWorkspaceLayerKey", - "PrevWorkspaceLayerKey", - "Workspace1Key", - "Workspace2Key", - "Workspace3Key", - "Workspace4Key", - "Workspace5Key", - "Workspace6Key", - "Workspace7Key", - "Workspace8Key", - "Workspace9Key", - "Workspace10Key", - "WindowShortcut1Key", - "WindowShortcut2Key", - "WindowShortcut3Key", - "WindowShortcut4Key", - "WindowShortcut5Key", - "WindowShortcut6Key", - "WindowShortcut7Key", - "WindowShortcut8Key", - "WindowShortcut9Key", - "WindowShortcut10Key", - "ScreenSwitchKey", - "DockRaiseLowerKey", -#ifndef XKB_MODELOCK - "ClipRaiseLowerKey" -#else - "ClipRaiseLowerKey", - "ToggleKbdModeKey" -#endif /* XKB_MODELOCK */ -}; +#define ICON_FILE "keyshortcuts" #ifndef HAVE_XCONVERTCASE /* from Xlib */ @@ -230,7 +131,7 @@ static void XConvertCase(register KeySym sym, KeySym * lower, KeySym * upper) } #endif -static char *captureShortcut(Display * dpy, _Panel * panel) +char *captureShortcut(Display * dpy, _Panel * panel, int convertCase) { XEvent ev; KeySym ksym, lksym, uksym; @@ -243,7 +144,8 @@ static char *captureShortcut(Display * dpy, _Panel * panel) if (ev.type == KeyPress && ev.xkey.keycode != 0) { ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); if (!IsModifierKey(ksym)) { - XConvertCase(ksym, &lksym, &uksym); + if (convertCase) + XConvertCase(ksym, &lksym, &uksym); key = XKeysymToString(uksym); panel->capturing = 0; @@ -296,11 +198,11 @@ static void captureClick(WMWidget * w, void *data) WMSetLabelText(panel->instructionsL, _("Press the desired shortcut key(s) or click Cancel to stop capturing.")); XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime); - shortcut = captureShortcut(dpy, panel); + shortcut = captureShortcut(dpy, panel, 1); if (shortcut) { int row = WMGetListSelectedItemRow(panel->actLs); - WMSetTextFieldText(panel->shoT, shortcut); + WMSetTextFieldText(panel->shortT, shortcut); if (row >= 0) { if (panel->shortcuts[row]) wfree(panel->shortcuts[row]); @@ -323,7 +225,7 @@ static void clearShortcut(WMWidget * w, void *data) _Panel *panel = (_Panel *) data; int row = WMGetListSelectedItemRow(panel->actLs); - WMSetTextFieldText(panel->shoT, NULL); + WMSetTextFieldText(panel->shortT, NULL); if (row >= 0) { if (panel->shortcuts[row]) @@ -343,7 +245,7 @@ static void typedKeys(void *observerData, WMNotification * notification) if (panel->shortcuts[row]) wfree(panel->shortcuts[row]); - panel->shortcuts[row] = WMGetTextFieldText(panel->shoT); + panel->shortcuts[row] = WMGetTextFieldText(panel->shortT); if (strlen(panel->shortcuts[row]) == 0) { wfree(panel->shortcuts[row]); panel->shortcuts[row] = NULL; @@ -356,7 +258,7 @@ static void listClick(WMWidget * w, void *data) _Panel *panel = (_Panel *) data; int row = WMGetListSelectedItemRow(w); - WMSetTextFieldText(panel->shoT, panel->shortcuts[row]); + WMSetTextFieldText(panel->shortT, panel->shortcuts[row]); } static char *trimstr(char *str) @@ -423,7 +325,7 @@ static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int stat WMReleasePixmap(pix); } - WMDrawString(scr, d, panel->black, panel->font, x + 20, y, text, strlen(text)); + WMDrawString(scr, d, panel->black, panel->normalFont, x + 20, y, text, strlen(text)); } static void createPanel(Panel * p) @@ -438,7 +340,7 @@ static void createPanel(Panel * p) panel->white = WMWhiteColor(scr); panel->black = WMBlackColor(scr); panel->gray = WMGrayColor(scr); - panel->font = WMSystemFontOfSize(scr, 12); + panel->normalFont = WMSystemFontOfSize(scr, 12); panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); @@ -527,36 +429,36 @@ static void createPanel(Panel * p) /***************** Shortcut ****************/ - panel->shoF = WMCreateFrame(panel->box); - WMResizeWidget(panel->shoF, 190, 210); - WMMoveWidget(panel->shoF, 315, 10); - WMSetFrameTitle(panel->shoF, _("Shortcut")); - - panel->shoT = WMCreateTextField(panel->shoF); - WMResizeWidget(panel->shoT, 160, 20); - WMMoveWidget(panel->shoT, 15, 65); - WMAddNotificationObserver(typedKeys, panel, WMTextDidChangeNotification, panel->shoT); - - panel->cleB = WMCreateCommandButton(panel->shoF); - WMResizeWidget(panel->cleB, 75, 24); - WMMoveWidget(panel->cleB, 15, 95); - WMSetButtonText(panel->cleB, _("Clear")); - WMSetButtonAction(panel->cleB, clearShortcut, panel); - - panel->defB = WMCreateCommandButton(panel->shoF); - WMResizeWidget(panel->defB, 75, 24); - WMMoveWidget(panel->defB, 100, 95); - WMSetButtonText(panel->defB, _("Capture")); - WMSetButtonAction(panel->defB, captureClick, panel); - - panel->instructionsL = WMCreateLabel(panel->shoF); + panel->shortF = WMCreateFrame(panel->box); + WMResizeWidget(panel->shortF, 190, 210); + WMMoveWidget(panel->shortF, 315, 10); + WMSetFrameTitle(panel->shortF, _("Shortcut")); + + panel->shortT = WMCreateTextField(panel->shortF); + WMResizeWidget(panel->shortT, 160, 20); + WMMoveWidget(panel->shortT, 15, 65); + WMAddNotificationObserver(typedKeys, panel, WMTextDidChangeNotification, panel->shortT); + + panel->sclearB = WMCreateCommandButton(panel->shortF); + WMResizeWidget(panel->sclearB, 75, 24); + WMMoveWidget(panel->sclearB, 15, 95); + WMSetButtonText(panel->sclearB, _("Clear")); + WMSetButtonAction(panel->sclearB, clearShortcut, panel); + + panel->sgrabB = WMCreateCommandButton(panel->shortF); + WMResizeWidget(panel->sgrabB, 75, 24); + WMMoveWidget(panel->sgrabB, 100, 95); + WMSetButtonText(panel->sgrabB, _("Capture")); + WMSetButtonAction(panel->sgrabB, captureClick, panel); + + panel->instructionsL = WMCreateLabel(panel->shortF); WMResizeWidget(panel->instructionsL, 160, 55); WMMoveWidget(panel->instructionsL, 15, 140); WMSetLabelTextAlignment(panel->instructionsL, WACenter); WMSetLabelWraps(panel->instructionsL, True); WMSetLabelText(panel->instructionsL, _("Click on Capture to interactively define the shortcut key.")); - WMMapSubwidgets(panel->shoF); + WMMapSubwidgets(panel->shortF); WMReleaseFont(boldFont); diff --git a/WPrefs.app/KeyboardShortcuts.h b/WPrefs.app/KeyboardShortcuts.h new file mode 100644 index 0000000..9fb2ca8 --- /dev/null +++ b/WPrefs.app/KeyboardShortcuts.h @@ -0,0 +1,178 @@ +#include "config.h" /* for HAVE_XCONVERTCASE */ +#include "WPrefs.h" +#include <ctype.h> +#include <X11/keysym.h> +#include "editmenu.h" + +#define MAX_SECTION_SIZE 4 + +typedef enum { + NoInfo, + ExecInfo, + CommandInfo, + ExternalInfo, + PipeInfo, + DirectoryInfo, + WSMenuInfo, + WWindowListInfo, + LastInfo +} InfoType; + +typedef struct _Panel { + /* In Menu.c and KeyboardShortcuts.c */ + WMBox *box; + char *sectionName; + + char *description; + + CallbackRec callbacks; + WMWidget *parent; + + WMFont *boldFont; + WMFont *normalFont; + WMColor *white; + WMColor *gray; + WMColor *black; + + WMFrame *shortF; + WMTextField *shortT; + WMButton *sgrabB; + WMButton *sclearB; + + Bool capturing; + + /* KeyboardShortcuts.c */ + WMLabel *actL; + WMList *actLs; + WMLabel *instructionsL; + char **shortcuts; + int actionCount; + + /* Menu.c */ + WMPixmap *markerPix[LastInfo]; + WMPopUpButton *typeP; + + WMWidget *itemPad[3]; + int currentPad; + + WEditMenu *menu; + char *menuPath; + + WMFrame *optionsF; + + WMFrame *commandF; + WMTextField *commandT; /* command to run */ + WMButton *browseB; + WMButton *xtermC; /* inside xterm? */ + + WMFrame *pathF; + WMTextField *pathT; + + WMFrame *pipeF; + WMTextField *pipeT; + WMButton *pipeCacheB; + + WMFrame *dpathF; + WMTextField *dpathT; + + WMFrame *dcommandF; + WMTextField *dcommandT; + + WMButton *dstripB; + + WMList *icommandL; + + WMFrame *paramF; + WMTextField *paramT; + + WMButton *quickB; + + Bool dontAsk; /* whether to comfirm submenu remove */ + Bool dontSave; + + /* about the currently selected item */ + WEditMenuItem *currentItem; + InfoType currentType; + WMWidget *sections[LastInfo][MAX_SECTION_SIZE]; +} _Panel; + +/* + * Must be in the same order as the corresponding items in + * "actions list" in createPanel() + */ +static char *keyOptions[] = { + "RootMenuKey", + "WindowListKey", + "WindowMenuKey", + "HideKey", + "HideOthersKey", + "MiniaturizeKey", + "MinimizeAllKey", + "CloseKey", + "MaximizeKey", + "VMaximizeKey", + "HMaximizeKey", + "LHMaximizeKey", + "RHMaximizeKey", + "MaximusKey", + "RaiseKey", + "LowerKey", + "RaiseLowerKey", + "ShadeKey", + "MoveResizeKey", + "SelectKey", + "FocusNextKey", + "FocusPrevKey", + "GroupNextKey", + "GroupPrevKey", + "NextWorkspaceKey", + "PrevWorkspaceKey", + "NextWorkspaceLayerKey", + "PrevWorkspaceLayerKey", + "Workspace1Key", + "Workspace2Key", + "Workspace3Key", + "Workspace4Key", + "Workspace5Key", + "Workspace6Key", + "Workspace7Key", + "Workspace8Key", + "Workspace9Key", + "Workspace10Key", + "WindowShortcut1Key", + "WindowShortcut2Key", + "WindowShortcut3Key", + "WindowShortcut4Key", + "WindowShortcut5Key", + "WindowShortcut6Key", + "WindowShortcut7Key", + "WindowShortcut8Key", + "WindowShortcut9Key", + "WindowShortcut10Key", + "ScreenSwitchKey", + "DockRaiseLowerKey", +#ifndef XKB_MODELOCK + "ClipRaiseLowerKey" +#else + "ClipRaiseLowerKey", + "ToggleKbdModeKey" +#endif /* XKB_MODELOCK */ +}; + +char *captureShortcut(Display * dpy, _Panel * panel, int convertCase); /* No static now! */ + +static void captureClick(WMWidget * w, void *data); +static void clearShortcut(WMWidget * w, void *data); +static void typedKeys(void *observerData, WMNotification * notification); +static void listClick(WMWidget * w, void *data); +static char *trimstr(char *str); +static void showData(_Panel * panel); +static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect); +static void createPanel(Panel * p); +static void storeData(_Panel * panel); +Panel *InitKeyboardShortcuts(WMScreen * scr, WMWidget * parent); + +#ifndef HAVE_XCONVERTCASE +/* from Xlib */ +static void XConvertCase(register KeySym sym, KeySym * lower, KeySym * upper); +#endif diff --git a/WPrefs.app/Makefile.am b/WPrefs.app/Makefile.am index 654457f..7c40d2e 100644 --- a/WPrefs.app/Makefile.am +++ b/WPrefs.app/Makefile.am @@ -23,6 +23,7 @@ WPrefs_SOURCES = \ FontSimple.c \ Icons.c \ KeyboardSettings.c \ + KeyboardShortcuts.h \ KeyboardShortcuts.c \ Menu.c \ MenuPreferences.c \ diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index 21a9fe1..67ef654 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -25,93 +25,7 @@ #include <X11/keysym.h> #include <X11/cursorfont.h> - -#include "editmenu.h" - -typedef enum { - NoInfo, - ExecInfo, - CommandInfo, - ExternalInfo, - PipeInfo, - DirectoryInfo, - WSMenuInfo, - WWindowListInfo, - LastInfo -} InfoType; - -#define MAX_SECTION_SIZE 4 -#define PATH_LEN 256 - -typedef struct _Panel { - WMBox *box; - char *sectionName; - - char *description; - - CallbackRec callbacks; - WMWidget *parent; - - WMFont *boldFont; - WMFont *normalFont; - WMColor *white; - WMColor *gray; - WMColor *black; - - WMPixmap *markerPix[LastInfo]; - - WMPopUpButton *typeP; - - WMWidget *itemPad[3]; - int currentPad; - - WEditMenu *menu; - char *menuPath; - - WMFrame *optionsF; - - WMFrame *commandF; - WMTextField *commandT; /* command to run */ - WMButton *browseB; - WMButton *xtermC; /* inside xterm? */ - - WMFrame *pathF; - WMTextField *pathT; - - WMFrame *pipeF; - WMTextField *pipeT; - WMButton *pipeCacheB; - - WMFrame *dpathF; - WMTextField *dpathT; - - WMFrame *dcommandF; - WMTextField *dcommandT; - - WMButton *dstripB; - - WMFrame *shortF; - WMTextField *shortT; - WMButton *sgrabB; - WMButton *sclearB; - - WMList *icommandL; - - WMFrame *paramF; - WMTextField *paramT; - - WMButton *quickB; - - Bool dontAsk; /* whether to comfirm submenu remove */ - Bool dontSave; - - Bool capturing; - - /* about the currently selected item */ - WEditMenuItem *currentItem; - InfoType currentType; - WMWidget *sections[LastInfo][MAX_SECTION_SIZE]; -} _Panel; +#include "KeyboardShortcuts.h" typedef struct { InfoType type; @@ -254,58 +168,6 @@ static void browseForFile(WMWidget * self, void *clientData) wfree(oldprog); } -static char *captureShortcut(Display * dpy, _Panel * panel) -{ - XEvent ev; - KeySym ksym; - char buffer[64]; - char *key = NULL; - - while (panel->capturing) { - XAllowEvents(dpy, AsyncKeyboard, CurrentTime); - WMNextEvent(dpy, &ev); - if (ev.type == KeyPress && ev.xkey.keycode != 0) { - ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); - if (!IsModifierKey(ksym)) { - key = XKeysymToString(ksym); - panel->capturing = 0; - break; - } - } - WMHandleEvent(&ev); - } - - if (!key) - return NULL; - - buffer[0] = 0; - - if (ev.xkey.state & ControlMask) { - strcat(buffer, "Control+"); - } - if (ev.xkey.state & ShiftMask) { - strcat(buffer, "Shift+"); - } - if (ev.xkey.state & Mod1Mask) { - strcat(buffer, "Mod1+"); - } - if (ev.xkey.state & Mod2Mask) { - strcat(buffer, "Mod2+"); - } - if (ev.xkey.state & Mod3Mask) { - strcat(buffer, "Mod3+"); - } - if (ev.xkey.state & Mod4Mask) { - strcat(buffer, "Mod4+"); - } - if (ev.xkey.state & Mod5Mask) { - strcat(buffer, "Mod5+"); - } - strcat(buffer, key); - - return wstrdup(buffer); -} - static void sgrabClicked(WMWidget * w, void *data) { _Panel *panel = (_Panel *) data; @@ -322,7 +184,7 @@ static void sgrabClicked(WMWidget * w, void *data) panel->capturing = 1; WMSetButtonText(w, _("Cancel")); XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime); - shortcut = captureShortcut(dpy, panel); + shortcut = captureShortcut(dpy, panel, 0); if (shortcut) { WMSetTextFieldText(panel->shortT, shortcut); updateMenuItem(panel, panel->currentItem, panel->shortT); -- 1.7.2.3
>From 853f675f4b78180a7777f450b0592bade9fad5d4 Mon Sep 17 00:00:00 2001 From: Rodolfo GarcÃa Peñas (kix) <[email protected]> Date: Tue, 17 Jan 2012 19:32:44 +0100 Subject: [PATCH 2/2] WINGs: Removed proplist-compat.h The file proplist-compat.h is not needed to compile Window Maker and is not used by other applications (tested in Debian). Therefore the file should be removed. --- WINGs/WINGs/Makefile.am | 2 +- WINGs/WINGs/proplist-compat.h | 138 ----------------------------------------- 2 files changed, 1 insertions(+), 139 deletions(-) delete mode 100644 WINGs/WINGs/proplist-compat.h diff --git a/WINGs/WINGs/Makefile.am b/WINGs/WINGs/Makefile.am index b77333b..088f1fe 100644 --- a/WINGs/WINGs/Makefile.am +++ b/WINGs/WINGs/Makefile.am @@ -5,4 +5,4 @@ AUTOMAKE_OPTIONS = # is this a kluge? if so, how should i do it? includedir = @includedir@/WINGs -include_HEADERS = WINGs.h WUtil.h WINGsP.h proplist-compat.h +include_HEADERS = WINGs.h WUtil.h WINGsP.h diff --git a/WINGs/WINGs/proplist-compat.h b/WINGs/WINGs/proplist-compat.h deleted file mode 100644 index 18ec457..0000000 --- a/WINGs/WINGs/proplist-compat.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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_ -#define _PROPLIST_COMPAT_H_ - -#include <WINGs/WUtil.h> - - -typedef WMPropList* proplist_t; - - -#ifndef YES -#define YES True -#endif - -#ifndef NO -#define NO False -#endif - - -#define PLSetCaseSensitive(c) WMPLSetCaseSensitive(c) - -#define PLMakeString(bytes) WMCreatePLString(bytes) -#define PLMakeData(bytes, length) WMCreatePLDataWithBytes(bytes, length) -#define PLMakeArrayFromElements WMCreatePLArray -#define PLMakeDictionaryFromEntries WMCreatePLDictionary - -#define PLRetain(pl) WMRetainPropList(pl) -#define PLRelease(pl) WMReleasePropList(pl) - -#define PLInsertArrayElement(array, pl, pos) WMInsertInPLArray(array, pos, pl) -#define PLAppendArrayElement(array, pl) WMAddToPLArray(array, pl) -#define PLRemoveArrayElement(array, pos) WMDeleteFromPLArray(array, pos) -#define PLInsertDictionaryEntry(dict, key, value) WMPutInPLDictionary(dict, key, value) -#define PLRemoveDictionaryEntry(dict, key) WMRemoveFromPLDictionary(dict, key) -#define PLMergeDictionaries(dest, source) WMMergePLDictionaries(dest, source, False) - -#define PLGetNumberOfElements(pl) WMGetPropListItemCount(pl) - -#define PLIsString(pl) WMIsPLString(pl) -#define PLIsData(pl) WMIsPLData(pl) -#define PLIsArray(pl) WMIsPLArray(pl) -#define PLIsDictionary(pl) WMIsPLDictionary(pl) -#define PLIsSimple(pl) (WMIsPLString(pl) || WMIsPLData(pl)) -#define PLIsCompound(pl) (WMIsPLArray(pl) || WMIsPLDictionary(pl)) -#define PLIsEqual(pl1, pl2) WMIsPropListEqualTo(pl1, pl2) - -#define PLGetString(pl) WMGetFromPLString(pl) -#define PLGetDataBytes(pl) WMGetPLDataBytes(pl) -#define PLGetDataLength(pl) WMGetPLDataLength(pl) -#define PLGetArrayElement(pl, index) WMGetFromPLArray(pl, index) -#define PLGetDictionaryEntry(pl, key) WMGetFromPLDictionary(pl, key) -#define PLGetAllDictionaryKeys(pl) WMGetPLDictionaryKeys(pl) - -#define PLShallowCopy(pl) WMShallowCopyPropList(pl) -#define PLDeepCopy(pl) WMDeepCopyPropList(pl) - -#define PLGetProplistWithDescription(desc) WMCreatePropListFromDescription(desc) -#define PLGetDescriptionIndent(pl, level) WMGetPropListDescription(pl, True) -#define PLGetDescription(pl) WMGetPropListDescription(pl, False) -#define PLGetStringDescription(pl) WMGetPropListDescription(pl, False) -#define PLGetDataDescription(pl) WMGetPropListDescription(pl, False) - -#define PLGetProplistWithPath(file) WMReadPropListFromFile(file) -#define PLSave(pl, file, atm) WMWritePropListToFile(pl, file) - - -/* Unsupported functions. Do not ask for them. They're evil :P */ -#define PLSetStringCmpHook(fn) error_PLSetStringCmpHook_is_not_supported -#define PLDeepSynchronize(pl) error_PLDeepSynchronize_is_not_supported -#define PLSynchronize(pl) error_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) error_PLGetContainer_is_not_supported - -#define PLGetDomainNames error_PLGetDomainNames_is_not_supported -#define PLGetDomain(name) error_PLGetDomain_is_not_supported -#define PLSetDomain(name, value, kickme) error_PLSetDomain_is_not_supported -#define PLDeleteDomain(name, kickme) error_PLDeleteDomain_is_not_supported -#define PLRegister(name, callback) error_PLRegister_is_not_supported -#define PLUnregister(name) error_PLUnregister_is_not_supported - - -#endif -- 1.7.2.3
