/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ // guiEditResources.cpp.part5 // this needs to be saved for use in the resize callback widPrimersSubcloneFullPathnameForm_ = widPrimersSubcloneFullPathnameOfFileOfSequencesForScreeningForm; if ( !bStandAlone_ ) XtPopup( widPopupShell_, XtGrabNone ); delete pPleaseWait; createResourceArray(); waitUntilDialogIsVisible( widPopupShell_ ); windowCameUp(); bAllTheWayUp_ = true; } guiEditResources :: ~guiEditResources() { // segmentation fault without this because cbResize gets called // after popping down the window XtRemoveCallback( widClipWindow_, XmNresizeCallback, cbResize, this ); XtPopdown( widPopupShell_ ); XtDestroyWidget( widPopupShell_ ); if ( bStandAlone_ ) _exit( 0 ); } void guiEditResources :: userPushedSave() { checkEverything(); // open the appropriate file and check with the user that this // is really the one they want--put up a Motif file dialog box. FileName filToWrite; if ( XmToggleButtonGetState( widUserRadioButton_ ) == True ) { // thus we want to write to $HOME/.consedrc // translate $HOME char* pHOME = getenv( "HOME" ); if ( !pHOME ) { popupErrorMessage( "something is really screwed up because $HOME is not set. Thus no user-defined parameters can be set" ); return; } filToWrite = pHOME; filToWrite += "/.consedrc"; } else if ( XmToggleButtonGetState( widProjectRadioButton_ ) == True ) { const int nBigNumber = 1000; char szCurrentDirectory[ nBigNumber + 1 ]; getcwd( szCurrentDirectory, nBigNumber ); filToWrite = szCurrentDirectory; filToWrite += "/.consedrc"; } else if ( XmToggleButtonGetState( widAllUsersAllProjectsRadioButton_ ) ) { char* pConsedParameters = getenv( "CONSED_PARAMETERS" ); if ( !pConsedParameters ) { popupErrorMessage( "environment variable CONSED_PARAMETERS is not set so I don't know where to write the parameters: you will have to tell me" ); filToWrite = "./.consedrc"; } else { filToWrite = pConsedParameters; } } else assert( false ); int nArgs = 0; Arg aArg[50]; // XtSetArg( aArg[ nArgs ], XmNdialogTitle, xmsTitle ); ++nArgs; Widget widFileSelectionBox = XmCreateFileSelectionDialog( widPopupShell_, "Parameter Filename", NULL, 0 ); XtAddCallback( widFileSelectionBox, XmNokCallback, cbFileSelectionOK, this ); XtAddCallback( widFileSelectionBox, XmNcancelCallback, cbFileSelectionCancel, this ); XmString xmsTitle = XmStringCreateSimple( "Name of parameter file to write" ); RWCString soDirMask = filToWrite.soGetDirectory() + "*.*"; XmString xmsDirMask = XmStringCreateSimple( soDirMask.data() ); XmString xmsDirSpec = XmStringCreateSimple( filToWrite.data() ); XmString xmsDirectory = XmStringCreateSimple( filToWrite.soGetDirectory().data() ); XtVaSetValues( widFileSelectionBox, XmNdialogTitle, xmsTitle, XmNselectionLabelString, xmsTitle, XmNdirMask, xmsDirMask, XmNdirectory, xmsDirectory, NULL ); XtVaSetValues( widFileSelectionBox, XmNdirSpec, xmsDirSpec, NULL ); XtManageChild( widFileSelectionBox ); XmStringFree( xmsDirSpec ); XmStringFree( xmsTitle ); XmStringFree( xmsDirMask ); } void guiEditResources :: userChoseFileAndPushedOK( const Widget wid, XmFileSelectionBoxCallbackStruct* pCallbackStruct ) { char* szFullPath; assert( XmStringGetLtoR( pCallbackStruct->value, XmSTRING_DEFAULT_CHARSET, &szFullPath ) ); FileName filToWrite( szFullPath ); cerr << "user selected file" << filToWrite << endl; if ( filToWrite.bFileByThisNameExists() ) { bool bGoAhead = GuiApp::popupDecisionMessage( "File %s exists. Save anyway?", filToWrite.data() ); if ( !bGoAhead ) { return; } } // no more user input below here // this might throw an exception checkEverything(); // once more // since the user is satisfied with this file, we don't need the // file dialog box any longer: XtUnmanageChild( wid ); XtDestroyWidget( wid ); FILE* pFileToWrite = fopen( szFullPath, "w" ); // now write the changed resources // guiEditResources.cpp.part6