From e131fadbb0f396098fb300283227bdf042c71d45 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 17 Apr 2012 15:27:21 +0200 Subject: [PATCH 1/1] Move FileNamePopUp to dialogs.c --- dialogs.c | 22 ++++++++++++++++++++++ menus.h | 3 +++ xboard.c | 24 ------------------------ xboard.h | 2 -- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/dialogs.c b/dialogs.c index 11c6c7a..046fbc6 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2296,4 +2296,26 @@ Browse (DialogClass dlg, char *label, char *proposed, char *ext, Boolean pathFla SetWidgetLabel(&browseOptions[9], FileTypes[j]); } +static char *openName; +FileProc fileProc; +char *fileOpenMode; +FILE *openFP; + +void +DelayedLoad () +{ + (void) (*fileProc)(openFP, 0, openName); +} + +void +FileNamePopUp (char *label, char *def, char *filter, FileProc proc, char *openMode) +{ + fileProc = proc; /* I can't see a way not */ + fileOpenMode = openMode; /* to use globals here */ + { // [HGM] use file-selector dialog stolen from Ghostview + // int index; // this is not supported yet + Browse(BoardWindow, label, (def[0] ? def : NULL), filter, False, openMode, &openName, &openFP); + } +} + diff --git a/menus.h b/menus.h index ddf942e..5ab748a 100644 --- a/menus.h +++ b/menus.h @@ -52,6 +52,7 @@ typedef void MenuProc P((void)); +typedef int (*FileProc) P((FILE *f, int n, char *title)); typedef struct { String string; @@ -167,6 +168,8 @@ void EngineOutputProc P((void)); void EvalGraphProc P((void)); int SaveGameListAsText P((FILE *f)); +void FileNamePopUp P((char *label, char *def, char *filter, + FileProc proc, char *openMode)); void AppendMenuItem P((char *text, int n)); MenuItem *MenuNameToItem P((char *menuName)); diff --git a/xboard.c b/xboard.c index 5877c3a..4935dea 100644 --- a/xboard.c +++ b/xboard.c @@ -256,8 +256,6 @@ void DrawPositionProc P((Widget w, XEvent *event, void CommentClick P((Widget w, XEvent * event, String * params, Cardinal * nParams)); void ICSInputBoxPopUp P((void)); -void FileNamePopUp P((char *label, char *def, char *filter, - FileProc proc, char *openMode)); void SelectCommand P((Widget w, XtPointer client_data, XtPointer call_data)); void KeyBindingProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void QuitWrapper P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); @@ -303,8 +301,6 @@ XFontStruct *coordFontStruct, *countFontStruct; XtAppContext appContext; char *layoutName; -FileProc fileProc; -char *fileOpenMode; char installDir[] = "."; // [HGM] UCI: needed for UCI; probably needs run-time initializtion Position commentX = -1, commentY = -1; @@ -2800,26 +2796,6 @@ CommentPopDown () PopDown(CommentDlg); } -static char *openName; -FILE *openFP; - -void -DelayedLoad () -{ - (void) (*fileProc)(openFP, 0, openName); -} - -void -FileNamePopUp (char *label, char *def, char *filter, FileProc proc, char *openMode) -{ - fileProc = proc; /* I can't see a way not */ - fileOpenMode = openMode; /* to use globals here */ - { // [HGM] use file-selector dialog stolen from Ghostview - // int index; // this is not supported yet - Browse(BoardWindow, label, (def[0] ? def : NULL), filter, False, openMode, &openName, &openFP); - } -} - /* Disable all user input other than deleting the window */ static int frozen = 0; diff --git a/xboard.h b/xboard.h index c9a68ce..b6709d7 100644 --- a/xboard.h +++ b/xboard.h @@ -130,8 +130,6 @@ typedef struct { #define SETTINGS_FILE SYSCONFDIR"/xboard.conf" #define COLOR_BKGD "white" -typedef int (*FileProc) P((FILE *f, int n, char *title)); - void NewTagsPopup P((char *text, char *msg)); int AppendText P((Option *opt, char *s)); void NewCommentPopup P((char *title, char *text, int index)); -- 1.7.0.4