Example #1
0
static void cb_ERPWindow_publication (Editor /* editor */, autoDaata publication) {
	/*
	 * Keep the gate for error handling.
	 */
	try {
		bool isaSpectralSlice = Thing_isa (publication.get(), classSpectrum) && str32equ (Thing_getName (publication.get()), U"slice");
		praat_new (publication.move());
		praat_updateSelection ();
		if (isaSpectralSlice) {
			int IOBJECT;
			LOOP {
				iam (Spectrum);
				autoSpectrumEditor editor2 = SpectrumEditor_create (ID_AND_FULL_NAME, me);
				praat_installEditor (editor2.get(), IOBJECT);
				editor2.releaseToUser();
			}
		}
	} catch (MelderError) {
		Melder_flushError ();
	}
}
Example #2
0
END

static void cb_ERPWindow_publication (Editor editor, void *closure, Data publication) {
	(void) editor;
	(void) closure;
	/*
	 * Keep the gate for error handling.
	 */
	try {
		praat_new (publication, NULL);
		praat_updateSelection ();
		if (Thing_member (publication, classSpectrum) && wcsequ (Thing_getName (publication), L"slice")) {
			int IOBJECT;
			LOOP {
				iam (Spectrum);
				autoSpectrumEditor editor2 = SpectrumEditor_create (ID_AND_FULL_NAME, me);
				praat_installEditor (editor2.transfer(), IOBJECT);
			}
		}
	} catch (MelderError) {
		Melder_flushError (NULL);
	}
}
Example #3
0
int structButtonEditor :: v_goToPage (const char32 *title) {
	if (! title || ! title [0]) return 0;
	if (str32equ (title, U"Buttons")) return 1;
	switch (title [0]) {
		case 'a': {   // toggle visibility of action
			long i = Melder_atoi (& title [1]);
			Praat_Command action = praat_getAction (i);
			if (! action) return 0;
			if (action -> hidden)
				praat_showAction (action -> class1, action -> class2, action -> class3, action -> title);
			else
				praat_hideAction (action -> class1, action -> class2, action -> class3, action -> title);
		} break;
		case 'm': {   // toggle visibility of menu command
			long i = Melder_atoi (& title [1]);
			Praat_Command menuCommand = praat_getMenuCommand (i);
			if (! menuCommand) return 0;
			if (menuCommand -> hidden)
				praat_showMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title);
			else
				praat_hideMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title);
		} break;
		case 'e': {   // execute action
			long i = Melder_atoi (& title [1]);
			Praat_Command action = praat_getAction (i);
			if (! action || ! action -> callback) return 0;
			if (action -> title) {
				UiHistory_write (U"\n");
				UiHistory_write_colonize (action -> title);
			}
			if (action -> script) {
				try {
					DO_RunTheScriptFromAnyAddedMenuCommand (nullptr, 0, nullptr, action -> script, nullptr, nullptr, false, nullptr);
				} catch (MelderError) {
					Melder_flushError (U"Command not executed.");
				}
			} else {
				try {
					action -> callback (nullptr, 0, nullptr, nullptr, nullptr, nullptr, false, nullptr);
				} catch (MelderError) {
					Melder_flushError (U"Command not executed.");
				}
			}
			praat_updateSelection ();
		} break;
		case 'p': {   // perform menu command
			long i = Melder_atoi (& title [1]);
			Praat_Command menuCommand = praat_getMenuCommand (i);
			if (! menuCommand || ! menuCommand -> callback) return 0;
			if (menuCommand -> title) {
				UiHistory_write (U"\n");
				UiHistory_write_colonize (menuCommand -> title);
			}
			if (menuCommand -> script) {
				try {
					DO_RunTheScriptFromAnyAddedMenuCommand (nullptr, 0, nullptr, menuCommand -> script, nullptr, nullptr, false, nullptr);
				} catch (MelderError) {
					Melder_flushError (U"Command not executed.");
				}
			} else {
				try {
					menuCommand -> callback (nullptr, 0, nullptr, nullptr, nullptr, nullptr, false, nullptr);
				} catch (MelderError) {
					Melder_flushError (U"Command not executed.");
				}
			}
			praat_updateSelection ();
		} break;
		default: break;
	}
	return 0;
}
Example #4
0
int ButtonEditor::goToPage (const wchar_t *title) {
    if (! title || ! title [0]) return 0;
    if (wcsequ (title, L"Buttons")) return 1;
    switch (title [0]) {
    case 'a': {   /* Toggle visibility of action.*/
        long i = wcstol (& title [1], NULL, 10);
        praat_Command action = praat_getAction (i);
        if (! action) return 0;
        if (action -> hidden)
            praat_showAction (action -> class1, action -> class2, action -> class3, action -> title);
        else
            praat_hideAction (action -> class1, action -> class2, action -> class3, action -> title);
    }
    break;
    case 'm': {   /* Toggle visibility of menu command. */
        long i = wcstol (& title [1], NULL, 10);
        praat_Command menuCommand = praat_getMenuCommand (i);
        if (! menuCommand) return 0;
        if (menuCommand -> hidden)
            praat_showMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title);
        else
            praat_hideMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title);
    }
    break;
    case 'e': {   /* Execute action. */
        long i = wcstol (& title [1], NULL, 10);
        praat_Command action = praat_getAction (i);
        if (! action || ! action -> callback) return 0;
        if (action -> title) {
            UiForm::history.write (L"\n");
            UiForm::history.write (action -> title);
        }
        if (action -> script) {
            if (! DO_RunTheScriptFromAnyAddedMenuCommand (NULL, action -> script, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed.");
        } else {
            if (! action -> callback (NULL, NULL, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed.");
        }
        praat_updateSelection ();
    }
    break;
    case 'p': {   /* Perform menu command. */
        long i = wcstol (& title [1], NULL, 10);
        praat_Command menuCommand = praat_getMenuCommand (i);
        if (! menuCommand || ! menuCommand -> callback) return 0;
        if (menuCommand -> title) {
            UiForm::history.write (L"\n");
            UiForm::history.write (menuCommand -> title);
        }
        if (menuCommand -> script) {
            if (! DO_RunTheScriptFromAnyAddedMenuCommand (NULL, menuCommand -> script, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed.");
        } else {
            if (! menuCommand -> callback (NULL, NULL, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed.");
        }
        praat_updateSelection ();
    }
    break;
    default:
        break;
    }
    return 0;
}