From: H.G. Muller Date: Sat, 23 Jan 2010 21:24:20 +0000 (+0100) Subject: Allow to apply filter in XB GameList filter edit X-Git-Tag: master-20100206~31 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=369d80a758a3b9f552874f26909d79864a902731;p=xboard.git Allow to apply filter in XB GameList filter edit Apply a translation to intercept the key. Set focus back to the list display afterwards. --- diff --git a/xboard.c b/xboard.c index d4f6569..a9f8991 100644 --- a/xboard.c +++ b/xboard.c @@ -850,6 +850,7 @@ XtActionsRec boardActions[] = { { "LoadNextGameProc", LoadNextGameProc }, { "LoadPrevGameProc", LoadPrevGameProc }, { "LoadSelectedProc", LoadSelectedProc }, + { "SetFilterProc", SetFilterProc }, { "ReloadGameProc", ReloadGameProc }, { "LoadPositionProc", LoadPositionProc }, { "LoadNextPositionProc", LoadNextPositionProc }, diff --git a/xgamelist.c b/xgamelist.c index 258eb39..3a04f3f 100644 --- a/xgamelist.c +++ b/xgamelist.c @@ -106,6 +106,8 @@ static int listLength; char gameListTranslations[] = "(2): LoadSelectedProc() \n \ Return: LoadSelectedProc() \n"; +char filterTranslations[] = + "Return: SetFilterProc() \n"; typedef struct { Widget shell; @@ -254,6 +256,8 @@ GameListCreate(name, callback, client_data) filterText = XtCreateManagedWidget(_("filtertext"), asciiTextWidgetClass, form, args, j); XtAddEventHandler(filterText, ButtonPressMask, False, SetFocus, (XtPointer) shell); + XtOverrideTranslations(filterText, + XtParseTranslationTable(filterTranslations)); j = 0; XtSetArg(args[j], XtNfromVert, viewport); j++; @@ -535,6 +539,29 @@ LoadSelectedProc(w, event, prms, nprms) } void +SetFilterProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + Arg args[16]; + String name; + Widget list; + int j = 0; + XtSetArg(args[j], XtNstring, &name); j++; + XtGetValues(filterText, args, j); + strcpy(filterString, name); + if(GameListPrepare()) GameListReplace(); // crashes on empty list... + list = XtNameToWidget(glc->shell, "*form.viewport.list"); + XawListHighlight(list, 0); + j = 0; + XtSetArg(args[j], XtNdisplayCaret, False); j++; + XtSetValues(filterText, args, j); + XtSetKeyboardFocus(glc->shell, list); +} + +void GameListPopDown() { Arg args[16]; diff --git a/xgamelist.h b/xgamelist.h index 21340aa..0c3fdf8 100644 --- a/xgamelist.h +++ b/xgamelist.h @@ -27,6 +27,8 @@ void ShowGameListProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void LoadSelectedProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void SetFilterProc P((Widget w, XEvent *event, + String *prms, Cardinal *nprms)); extern Widget gameListShell; #endif /* _XGAMEL_H */