Solved problem with opening windows on Mac
[sgc2.git] / praat_module / adaptPraat.patch
blob6c76cb3516b367cf7af742515d579513d8ae7ce1
1 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/stat/praat_Stat.cpp demo_praat_sources/stat/praat_Stat.cpp
2 --- praat_sources/stat/praat_Stat.cpp 2011-10-01 13:32:45.000000000 +0200
3 +++ demo_praat_sources/stat/praat_Stat.cpp 2011-11-18 08:55:32.000000000 +0100
4 @@ -406,7 +406,9 @@ DO
5 END
7 DIRECT (Table_edit)
8 +#ifndef DEMOAPP
9 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot edit a Table from batch.");
10 +#endif
11 LOOP {
12 iam (Table);
13 autoTableEditor editor = TableEditor_create (ID_AND_FULL_NAME, me);
14 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/praat_script.cpp demo_praat_sources/sys/praat_script.cpp
15 --- praat_sources/sys/praat_script.cpp 2011-09-02 13:53:33.000000000 +0200
16 +++ demo_praat_sources/sys/praat_script.cpp 2011-10-28 07:54:25.000000000 +0200
17 @@ -460,6 +460,7 @@ void praat_executeScriptFromText (wchar
18 autoInterpreter interpreter = Interpreter_create (NULL, NULL);
19 Interpreter_run (interpreter.peek(), text);
20 } catch (MelderError) {
21 + exit (0);
22 Melder_throw (L"Script not completed.");
25 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/Graphics_text.cpp demo_praat_sources/sys/Graphics_text.cpp
26 --- praat_sources/sys/Graphics_text.cpp 2011-09-29 12:27:01.000000000 +0200
27 +++ demo_praat_sources/sys/Graphics_text.cpp 2011-10-27 09:14:57.000000000 +0200
28 @@ -137,7 +137,7 @@ static HFONT loadFont (GraphicsScreen me
29 ipaInited = TRUE;
30 if (! charisAvailable && ! doulosAvailable) {
31 /* BUG: The next warning may cause reentry of drawing (on window exposure) and lead to crash. Some code must be non-reentrant !! */
32 - Melder_warning (L"The phonetic font is not available.\nSeveral characters will not look correct.\nSee www.praat.org");
33 + //Melder_warning (L"The phonetic font is not available.\nSeveral characters will not look correct.\nSee www.praat.org");
34 } else {
35 ipaAvailable = true;
37 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/praat.cpp demo_praat_sources/sys/praat.cpp
38 --- praat_sources/sys/praat.cpp 2012-10-15 10:41:10.000000000 +0200
39 +++ demo_praat_sources/sys/praat.cpp 2012-10-15 13:47:24.000000000 +0200
40 @@ -1085,9 +1085,9 @@ void praat_init (const char *title, unsi
41 * Make sure that the program's private directory exists.
43 #if defined (UNIX)
44 - swprintf (name, 256, L".%ls-dir", Melder_utf8ToWcs (programName)); /* For example .myProg-dir */
45 + swprintf (name, 256, L".%ls", Melder_utf8ToWcs (praatP.title)); /* For example .myProg-dir */
46 #elif defined (macintosh)
47 - swprintf (name, 256, L"%ls Prefs", Melder_utf8ToWcs (praatP.title)); /* For example MyProg Prefs */
48 + swprintf (name, 256, L"%ls", L"SpeakGoodChinese2"); /* For example MyProg Prefs */
49 #elif defined (_WIN32)
50 swprintf (name, 256, L"%ls", Melder_utf8ToWcs (praatP.title)); /* For example MyProg */
51 #endif
52 @@ -1164,6 +1164,12 @@ void praat_init (const char *title, unsi
54 GuiWindow raam = NULL;
55 if (Melder_batch) {
56 + #if defined (DEMOAPP) && gtk
57 + char objectWindowTitle [100];
58 + Machine_initLookAndFeel (argc, argv);
59 + sprintf (objectWindowTitle, "%s Objects", praatP.title);
60 + GuiWindow_create (0, 0, WINDOW_WIDTH, WINDOW_HEIGHT,Melder_peekUtf8ToWcs (objectWindowTitle), gui_cb_quit, NULL, 0);
61 + #endif
62 #if defined (UNIX) || defined (macintosh) || defined (_WIN32) && defined (CONSOLE_APPLICATION)
63 MelderString_empty (& theCurrentPraatApplication -> batchName);
64 for (unsigned int i = iarg_batchName; i < argc; i ++) {
65 @@ -1209,9 +1215,11 @@ void praat_init (const char *title, unsi
66 #if motif
67 GuiApp_setApplicationShell (theCurrentPraatApplication -> topShell -> d_xmShell);
68 #endif
69 +#ifndef DEMOAPP
70 trace ("before objects window shows locale %s", setlocale (LC_ALL, NULL));
71 raam -> f_show ();
72 trace ("after objects window shows locale %s", setlocale (LC_ALL, NULL));
73 +#endif
75 Thing_recognizeClassesByName (classCollection, classStrings, classManPages, classSortedSetOfString, NULL);
76 if (Melder_batch) {
77 @@ -1221,6 +1229,9 @@ void praat_init (const char *title, unsi
78 trace ("adding fixed buttons without GUI");
79 praat_addFixedButtons (NULL);
80 } else {
81 + #ifdef DEMOAPP
82 + Melder_backgrounding = true;
83 + #endif
85 #ifdef macintosh
86 MelderGui_create (raam); /* BUG: default Melder_assert would call printf recursively!!! */
87 @@ -1244,7 +1255,9 @@ void praat_init (const char *title, unsi
88 trace ("creating the dynamic menu in the Objects window");
89 praat_actions_createDynamicMenu (raam, 250);
90 trace ("showing the Objects window");
91 +#ifndef DEMOAPP
92 raam -> f_show ();
93 +#endif
94 //Melder_fatal ("stop");
95 #ifdef UNIX
96 try {
97 @@ -1269,7 +1282,12 @@ void praat_init (const char *title, unsi
99 trace ("creating the Picture window");
100 trace ("before picture window shows: locale is %s", setlocale (LC_ALL, NULL));
101 - if (! praatP.dontUsePictureWindow) praat_picture_init ();
102 + #ifdef DEMOAPP
103 + praat_picture_init ();
104 + praat_dontUsePictureWindow ();
105 + #else
106 + if (! praatP.dontUsePictureWindow) praat_picture_init ();
107 + #endif
108 trace ("after picture window shows: locale is %s", setlocale (LC_ALL, NULL));
111 @@ -1515,6 +1533,14 @@ void praat_run (void) {
112 Melder_flushError (NULL);
115 + else if (thePraatStandAloneScriptText != NULL) {
116 + try {
117 + praat_executeScriptFromText (thePraatStandAloneScriptText);
118 + praat_exit (0);
119 + } catch (MelderError) {
120 + Melder_flushError (NULL);
122 + };
123 #endif
124 for (;;) {
125 XEvent event;
126 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/praat_picture.cpp demo_praat_sources/sys/praat_picture.cpp
127 --- praat_sources/sys/praat_picture.cpp 2012-09-27 09:10:50.000000000 +0200
128 +++ demo_praat_sources/sys/praat_picture.cpp 2012-10-15 13:47:43.000000000 +0200
129 @@ -1669,7 +1669,9 @@ void praat_picture_init (void) {
130 width = height = resolution * 12;
131 scrollWindow = GuiScrolledWindow_createShown (dialog, margin, 0, Machine_getMenuBarHeight () + margin, 0, 1, 1, 0);
132 drawingArea = GuiDrawingArea_createShown (scrollWindow, width, height, NULL, NULL, NULL, NULL, NULL, 0);
133 +#ifndef DEMOAPP
134 dialog -> f_show ();
135 +#endif
138 // TODO: Paul: deze moet VOOR de update functies anders krijgen die void_me 0x0
139 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/fon/praat_TextGrid_init.cpp demo_praat_sources/fon/praat_TextGrid_init.cpp
140 --- praat_sources/fon/praat_TextGrid_init.cpp 2011-09-12 10:17:12.000000000 +0200
141 +++ demo_praat_sources/fon/praat_TextGrid_init.cpp 2011-09-12 10:59:25.000000000 +0200
142 @@ -825,7 +825,9 @@ static void cb_TextGridEditor_publicatio
145 DIRECT (TextGrid_edit)
146 +#ifndef DEMOAPP
147 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a TextGrid from batch.");
148 +#endif
149 Sound sound = NULL;
150 LOOP {
151 if (CLASS == classSound) sound = (Sound) OBJECT; // may stay NULL
152 @@ -839,7 +841,9 @@ DIRECT (TextGrid_edit)
155 DIRECT (TextGrid_LongSound_edit)
156 +#ifndef DEMOAPP
157 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a TextGrid from batch.");
158 +#endif
159 LongSound longSound = NULL;
160 int ilongSound = 0;
161 LOOP {
162 @@ -855,7 +859,9 @@ DIRECT (TextGrid_LongSound_edit)
165 DIRECT (TextGrid_SpellingChecker_edit)
166 +#ifndef DEMOAPP
167 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a TextGrid from batch.");
168 +#endif
169 SpellingChecker spellingChecker = NULL;
170 int ispellingChecker = 0;
171 Sound sound = NULL;
172 @@ -872,7 +878,9 @@ DIRECT (TextGrid_SpellingChecker_edit)
175 DIRECT (TextGrid_LongSound_SpellingChecker_edit)
176 +#ifndef DEMOAPP
177 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a TextGrid from batch.");
178 +#endif
179 LongSound longSound = NULL;
180 SpellingChecker spellingChecker = NULL;
181 int ilongSound = 0, ispellingChecker = 0;
182 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/fon/praat_Sound_init.cpp demo_praat_sources/fon/praat_Sound_init.cpp
183 --- praat_sources/fon/praat_Sound_init.cpp 2011-09-12 10:17:12.000000000 +0200
184 +++ demo_praat_sources/fon/praat_Sound_init.cpp 2011-09-12 11:03:24.000000000 +0200
185 @@ -172,7 +172,9 @@ DO
188 DIRECT (LongSound_view)
189 +#ifndef DEMOAPP
190 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a LongSound from batch.");
191 +#endif
192 LOOP {
193 iam (LongSound);
194 autoSoundEditor editor = SoundEditor_create (ID_AND_FULL_NAME, me);
195 @@ -703,7 +705,9 @@ static void cb_SoundEditor_publication (
198 DIRECT (Sound_edit)
199 +#ifndef DEMOAPP
200 if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a Sound from batch.");
201 +#endif
202 LOOP {
203 iam (Sound);
204 autoSoundEditor editor = SoundEditor_create (ID_AND_FULL_NAME, me);
205 @@ -1367,8 +1371,10 @@ static void cb_SoundRecorder_publication
206 praat_updateSelection ();
208 static void do_Sound_record (int numberOfChannels) {
209 +#ifndef DEMOAPP
210 if (theCurrentPraatApplication -> batch)
211 Melder_throw ("Cannot record a Sound from batch.");
212 +#endif
213 if (theSoundRecorder) {
214 if (numberOfChannels == thePreviousNumberOfChannels) {
215 theSoundRecorder -> raise ();
216 @@ -1418,10 +1424,21 @@ FORM (Sound_recordFixedTime, L"Record So
217 POSITIVE (L"Duration (seconds)", L"1.0")
220 +#if defined (_WIN32) && defined (DEMOAPP)
221 + UINT numberOfDevices = waveInGetNumDevs (), i;
222 + if(numberOfDevices > 0) {
223 +#endif
224 autoSound me = Sound_recordFixedTime (GET_INTEGER (L"Input source"),
225 GET_REAL (L"Gain"), GET_REAL (L"Balance"),
226 wcstod (GET_STRING (L"Sampling frequency"), NULL), GET_REAL (L"Duration"));
227 praat_new (me.transfer(), L"untitled");
228 +#if defined (_WIN32) && defined (DEMOAPP)
229 + } else {
230 + // Create an empty sound if no input is available
231 + autoSound me = Sound_createSimple (1, GET_REAL (L"Duration"), wcstod (GET_STRING (L"Sampling frequency"), NULL));
232 + praat_new (me.transfer(), L"untitled");
233 + };
234 +#endif
237 FORM (Sound_resample, L"Sound: Resample", L"Sound: Resample...")
238 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/UiPause.cpp demo_praat_sources/sys/UiPause.cpp
239 --- praat_sources/sys/UiPause.cpp 2012-09-27 09:10:50.000000000 +0200
240 +++ demo_praat_sources/sys/UiPause.cpp 2012-09-27 13:25:18.000000000 +0200
241 @@ -159,6 +159,7 @@ int UiPause_end (int numberOfContinueBut
242 { // scope
243 autoMelderSaveDefaultDir saveDir;
244 thePauseForm_clicked = 0;
245 + if(wcsnequ(continueText1, L"DESTROY WINDOW ", 15))thePauseForm_clicked = 1;
246 Melder_assert (theEventLoopDepth == 0);
247 theEventLoopDepth ++;
248 try {
249 @@ -168,24 +169,28 @@ int UiPause_end (int numberOfContinueBut
250 } while (! thePauseForm_clicked);
251 #elif cocoa
252 #elif motif
253 + if(wcsnequ(continueText1, L"DESTROY WINDOW ", 15) == 0){
254 do {
255 XEvent event;
256 GuiNextEvent (& event);
257 XtDispatchEvent (& event);
258 } while (! thePauseForm_clicked);
259 + };
260 #endif
261 } catch (MelderError) {
262 Melder_flushError ("An error made it to the outer level in a pause window; should not occur! Please write to paul.boersma@uva.nl");
264 theEventLoopDepth --;
266 + if(wcsnequ(continueText1, L"DESTROY WINDOW ", 15))forget(thePauseForm);
267 if (wasBackgrounding) praat_background ();
268 /* BUG: should also restore praatP. editor. */
269 thePauseForm = NULL; // undangle
270 thePauseFormRadio = NULL; // undangle
271 if (thePauseForm_clicked == -1) {
272 - Interpreter_stop (interpreter);
273 - Melder_throw ("You interrupted the script.");
274 + thePauseForm_clicked = cancelContinueButton;
275 + //Interpreter_stop (interpreter);
276 + //Melder_throw ("You interrupted the script.");
277 //Melder_flushError (NULL);
278 //Melder_clearError ();
279 } else {
280 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/makefiles/makefile.defs.linux demo_praat_sources/makefiles/makefile.defs.linux
281 --- praat_sources/makefiles/makefile.defs.linux 2011-09-12 10:17:12.000000000 +0200
282 +++ demo_praat_sources/makefiles/makefile.defs.linux 2011-09-12 13:28:59.000000000 +0200
283 @@ -7,7 +7,7 @@ CC = gcc -std=gnu99
285 CXX = g++
287 -CFLAGS = -DUNIX -Dlinux `pkg-config --cflags gtk+-2.0` -Werror=missing-prototypes -Werror=implicit -Wreturn-type -Wunused -Wunused-parameter -Wuninitialized -O1 -g1
288 +CFLAGS = -DUNIX -Dlinux `pkg-config --cflags gtk+-2.0` -Werror=missing-prototypes -Werror=implicit -Wreturn-type -Wunused -Wunused-parameter -Wuninitialized -DDEMOAPP -O1
290 CXXFLAGS = $(CFLAGS) -Wshadow
292 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/makefiles/makefile.defs.mingw32 demo_praat_sources/makefiles/makefile.defs.mingw32
293 --- praat_sources/makefiles/makefile.defs.mingw32 2011-09-19 12:26:39.000000000 +0200
294 +++ demo_praat_sources/makefiles/makefile.defs.mingw32 2011-09-19 15:33:55.000000000 +0200
295 @@ -7,7 +7,7 @@ CC = /mingw32/bin/gcc -std=gnu99 -isyste
297 CXX = /mingw32/bin/g++ -isystem /mingw32/include/c++/4.7.0 -isystem /mingw32/include -Wshadow
299 -CFLAGS = -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0500 -DUNICODE -Dmain=wingwmain -O1
300 +CFLAGS = -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0500 -DUNICODE -Dmain=wingwmain -O1 -DDEMOAPP
302 CXXFLAGS = $(CFLAGS)
304 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/makefiles/makefile.defs.mingw64 demo_praat_sources/makefiles/makefile.defs.mingw64--- praat_sources/makefiles/makefile.defs.mingw32 2011-09-19 12:26:39.000000000 +0200
305 --- praat_sources/makefiles/makefile.defs.mingw64 2011-09-19 12:26:39.000000000 +0200
306 +++ demo_praat_sources/makefiles/makefile.defs.mingw64 2011-09-19 15:33:37.000000000 +0200
307 @@ -7,7 +7,7 @@ CC = /mingw64/bin/gcc -std=gnu99 -isyste
309 CXX = /mingw64/bin/g++ -isystem /mingw64/include/c++/4.7.0 -isystem /mingw64/include -Wshadow -m64
311 -CFLAGS = -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0500 -DUNICODE -Dmain=wingwmain -O1
312 +CFLAGS = -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0500 -DUNICODE -Dmain=wingwmain -O1 -DDEMOAPP
314 CXXFLAGS = $(CFLAGS)
316 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/dwtools/Intensity_extensions.cpp demo_praat_sources/dwtools/Intensity_extensions.cpp
317 --- praat_sources/dwtools/Intensity_extensions.cpp 2011-09-20 11:40:46.000000000 +0200
318 +++ demo_praat_sources/dwtools/Intensity_extensions.cpp 2011-09-28 11:45:46.000000000 +0200
319 @@ -67,8 +67,8 @@ TextGrid Intensity_to_TextGrid_detectSil
320 Vector_getMinimumAndX (me, 0, 0, 1, NUM_PEAK_INTERPOLATE_PARABOLIC, &intensity_min_db, &xOfMinimum);
321 double intensity_dbRange = intensity_max_db - intensity_min_db;
323 - if (intensity_dbRange < 10) Melder_warning (L"The loudest and softest part in your sound only differ by ",
324 - Melder_double (intensity_dbRange), L" dB.");
325 + /*if (intensity_dbRange < 10) Melder_warning (L"The loudest and softest part in your sound only differ by ",
326 + Melder_double (intensity_dbRange), L" dB.");*/
328 double intensityThreshold = intensity_max_db - fabs (silenceThreshold_dB);
330 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/praat_objectMenus.cpp demo_praat_sources/sys/praat_objectMenus.cpp
331 --- praat_sources/sys/praat_objectMenus.cpp 2012-02-22 13:04:43.000000000 +0100
332 +++ demo_praat_sources/sys/praat_objectMenus.cpp 2012-02-22 13:48:24.000000000 +0100
333 @@ -465,8 +465,10 @@ FORM (SearchManual, L"Search manual", L"
334 TEXTFIELD (L"query", L"")
337 + #ifndef DEMOAPP
338 if (theCurrentPraatApplication -> batch)
339 Melder_throw (L"Cannot view a manual from batch.");
340 + #endif
341 Manual manPage = Manual_create (L"Intro", theCurrentPraatApplication -> manPages, false);
342 Manual_search (manPage, GET_STRING (L"query"));
344 @@ -477,8 +479,10 @@ FORM (GoToManualPage, L"Go to manual pag
345 LIST (L"Page", numberOfPages, pages, 1)}
348 + #ifndef DEMOAPP
349 if (theCurrentPraatApplication -> batch)
350 Melder_throw (L"Cannot view a manual from batch.");
351 + #endif
352 Manual manPage = Manual_create (L"Intro", theCurrentPraatApplication -> manPages, false);
353 HyperPage_goToPage_i (manPage, GET_INTEGER (L"Page"));
355 diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/GuiMenu.cpp demo_praat_sources/sys/GuiMenu.cpp
356 --- praat_sources/sys/GuiMenu.cpp 2012-09-27 09:10:50.000000000 +0200
357 +++ demo_praat_sources/sys/GuiMenu.cpp 2012-10-25 09:55:23.000000000 +0200
358 @@ -206,7 +206,9 @@ GuiMenu GuiMenu_createInWindow (GuiWindo
359 [my d_nsMenuButton setTitle: (NSString *) Melder_peekWcsToCfstring (title)];
361 #elif motif
362 + #ifndef DEMOAPP
363 if (window == NULL) {
364 + #endif
365 my d_xmMenuTitle = XmCreateCascadeButton (theGuiTopMenuBar, Melder_peekWcsToUtf8 (title), NULL, 0);
366 if (wcsequ (title, L"Help"))
367 XtVaSetValues (theGuiTopMenuBar, XmNmenuHelpWidget, my d_xmMenuTitle, NULL);
368 @@ -215,6 +217,7 @@ GuiMenu GuiMenu_createInWindow (GuiWindo
369 XtSetSensitive (my d_xmMenuTitle, False);
370 XtVaSetValues (my d_xmMenuTitle, XmNsubMenuId, my d_widget, NULL);
371 XtManageChild (my d_xmMenuTitle);
372 + #ifndef DEMOAPP
373 } else {
374 my d_xmMenuTitle = XmCreateCascadeButton (window -> d_xmMenuBar, Melder_peekWcsToUtf8 (title), NULL, 0);
375 if (wcsequ (title, L"Help"))
376 @@ -225,6 +228,7 @@ GuiMenu GuiMenu_createInWindow (GuiWindo
377 XtVaSetValues (my d_xmMenuTitle, XmNsubMenuId, my d_widget, NULL);
378 XtManageChild (my d_xmMenuTitle);
380 + #endif
381 _GuiObject_setUserData (my d_widget, me);
382 #endif