void AP_Dialog_Options::_storeWindowData(void) { XAP_Prefs *pPrefs = m_pApp->getPrefs(); UT_return_if_fail (pPrefs); AP_FrameData *pFrameData = NULL; if(m_pFrame) { pFrameData = (AP_FrameData *)m_pFrame->getFrameData(); UT_return_if_fail (pFrameData); } XAP_PrefsScheme *pPrefsScheme = pPrefs->getCurrentScheme(); UT_return_if_fail (pPrefsScheme); // turn off all notification to PrefListeners via XAP_Prefs pPrefs->startBlockChange(); // before we continue to remember all the changed values, check to see if // we have turned OFF PrefsAutoSave. If so, toggle that value, then force // a prefs save, then update everything else // [email protected] if ( pPrefs->getAutoSavePrefs() == true && _gatherPrefsAutoSave() == false ) { pPrefs->setAutoSavePrefs( false ); pPrefs->savePrefsFile(); // TODO: check the results } else { // otherwise, just set the value pPrefs->setAutoSavePrefs( _gatherPrefsAutoSave() ); } // try again to make sure we've got an updatable scheme pPrefsScheme = pPrefs->getCurrentScheme(true); UT_return_if_fail (pPrefsScheme); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // save the values to the Prefs classes Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_AutoSpellCheck, _gatherSpellCheckAsType() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_AutoGrammarCheck, _gatherGrammarCheck() ); Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_SmartQuotesEnable, _gatherSmartQuotes() ); Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_CustomSmartQuotes, _gatherCustomSmartQuotes() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_SpellCheckCaps, _gatherSpellUppercase() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_SpellCheckNumbers, _gatherSpellNumbers() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_CursorBlink, _gatherViewCursorBlink() ); // Not implemented for UNIX or Win32. No need for it. #if !defined(TOOLKIT_GTK) && !defined(TOOLKIT_COCOA) && !defined (TOOLKIT_WIN) Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_RulerVisible, _gatherViewShowRuler() ); UT_uint32 i; for (i = 0; i < m_pApp->getToolbarFactory()->countToolbars(); i++) { Save_Pref_Bool( pPrefsScheme, m_pApp->getToolbarFactory()->prefKeyForToolbar(i), _gatherViewShowToolbar(i)); } Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_StatusBarVisible, _gatherViewShowStatusBar() ); #endif Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_ParaVisible, _gatherViewUnprintable() ); #if defined(TOOLKIT_GTK) Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_EnableSmoothScrolling, _gatherEnableSmoothScrolling() ); #endif Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_InsertModeToggle, _gatherEnableOverwrite() ); Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_AutoLoadPlugins, _gatherAutoLoadPlugins() ); Save_Pref_Bool( pPrefsScheme, AP_PREF_KEY_DefaultDirectionRtl, _gatherOtherDirectionRtl() ); Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_ChangeLanguageWithKeyboard, _gatherLanguageWithKeyboard() ); Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_DirMarkerAfterClosingParenthesis, _gatherDirMarkerAfterClosingParenthesis()); // JOAQUIN - fix this: Dom UT_DEBUGMSG(("Saving Auto Save File [%i]\n", _gatherAutoSaveFile())); Save_Pref_Bool( pPrefsScheme, XAP_PREF_KEY_AutoSaveFile, _gatherAutoSaveFile() ); UT_String stVal; _gatherAutoSaveFileExt(stVal); UT_DEBUGMSG(("Saving Auto Save File Ext [%s]\n", stVal.c_str())); pPrefsScheme->setValue(XAP_PREF_KEY_AutoSaveFileExt, stVal.c_str()); _gatherAutoSaveFilePeriod(stVal); UT_DEBUGMSG(("Saving Auto Save File with a period of [%s]\n", stVal.c_str())); pPrefsScheme->setValue(XAP_PREF_KEY_AutoSaveFilePeriod, stVal.c_str()); // Jordi: win32 specific for now _gatherUILanguage(stVal); if (stVal.length()) { UT_DEBUGMSG(("Setting default UI language to [%s]\n", stVal.c_str())); pPrefsScheme->setValue(AP_PREF_KEY_StringSet, stVal.c_str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // If we changed whether the ruler is to be visible // or hidden, then update the current window: // (If we didn't change anything, leave it alone) #if !defined(TOOLKIT_GTK) && !defined(TOOLKIT_COCOA) && !defined (TOOLKIT_WIN) if (pFrameData && _gatherViewShowRuler() != pFrameData->m_bShowRuler ) { pFrameData->m_bShowRuler = _gatherViewShowRuler() ; if (!pFrameData->m_bIsFullScreen) { m_pFrame->toggleRuler(pFrameData->m_bShowRuler); } } // Same for status bar if (pFrameData && _gatherViewShowStatusBar() != pFrameData->m_bShowStatusBar) { pFrameData->m_bShowStatusBar = _gatherViewShowStatusBar(); if (!pFrameData->m_bIsFullScreen) { m_pFrame->toggleStatusBar(pFrameData->m_bShowStatusBar); } } if(pFrameData) { for (i = 0; i < m_pApp->getToolbarFactory()->countToolbars(); i++) { if (_gatherViewShowToolbar(i) != pFrameData->m_bShowBar[i]) { pFrameData->m_bShowBar[i] = _gatherViewShowToolbar(i); if (!pFrameData->m_bIsFullScreen) { m_pFrame->toggleBar(i, pFrameData->m_bShowBar[i]); } } } } #endif if (pFrameData && _gatherViewUnprintable() != pFrameData->m_bShowPara ) { pFrameData->m_bShowPara = _gatherViewUnprintable() ; AV_View * pAVView = m_pFrame->getCurrentView(); UT_return_if_fail (pAVView); FV_View * pView = static_cast<FV_View *> (pAVView); pView->setShowPara(pFrameData->m_bShowPara); } #if defined(TOOLKIT_GTK) if ( _gatherEnableSmoothScrolling() != XAP_App::getApp()->isSmoothScrollingEnabled() ) { XAP_App::getApp()->setEnableSmoothScrolling(_gatherEnableSmoothScrolling()); } #endif // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // save ruler units value pPrefsScheme->setValue((gchar*)AP_PREF_KEY_RulerUnits, (gchar*)UT_dimensionName( _gatherViewRulerUnits()) ); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // save screen color pPrefsScheme->setValue((gchar*)XAP_PREF_KEY_ColorForTransparent, _gatherColorForTransparent() ); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // allow XAP_Prefs to notify all the listeners of changes // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // TODO: change to snprintf gchar szBuffer[40]; sprintf( szBuffer, "%i", _gatherNotebookPageNum() ); pPrefsScheme->setValue((gchar*)AP_PREF_KEY_OptionsTabNumber, (gchar*)szBuffer ); // allow the prefListeners to receive their calls pPrefs->endBlockChange(); // if we hit the Save button, then force a save after the gather if ( m_answer == a_SAVE ) { pPrefs->savePrefsFile(); // TODO: check the results } }
void AP_Dialog_Options::_populateWindowData(void) { bool b; gint n = 0; XAP_Prefs *pPrefs = 0; const gchar *pszBuffer = 0; m_bInitialPop = true; // TODO: move this logic when we get a PrefsListener API and turn this // dialog into an app-specific pPrefs = m_pApp->getPrefs(); UT_return_if_fail ( pPrefs ); // ------------ Spell if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_AutoSpellCheck,&b)) _setSpellCheckAsType (b); if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_SpellCheckCaps,&b)) _setSpellUppercase (b); if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_SpellCheckNumbers,&b)) _setSpellNumbers (b); if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_AutoGrammarCheck,&b)) _setGrammarCheck (b); // ------------ Smart Quotes if (pPrefs->getPrefsValueBool((gchar*)XAP_PREF_KEY_SmartQuotesEnable,&b)) _setSmartQuotes (b); if (pPrefs->getPrefsValueBool((gchar*)XAP_PREF_KEY_CustomSmartQuotes,&b)) _setCustomSmartQuotes (b); if (pPrefs->getPrefsValueInt((gchar*)XAP_PREF_KEY_OuterQuoteStyle, n)) _setOuterQuoteStyle(n); if (pPrefs->getPrefsValueInt((gchar*)XAP_PREF_KEY_InnerQuoteStyle, n)) _setInnerQuoteStyle(n); // ------------ Prefs _setPrefsAutoSave( pPrefs->getAutoSavePrefs() ); // ------------ View if (pPrefs->getPrefsValue((gchar*)AP_PREF_KEY_RulerUnits,&pszBuffer)) _setViewRulerUnits (UT_determineDimension(pszBuffer)); #if !defined(TOOLKIT_GTK) && !defined(TOOLKIT_COCOA) && !defined (TOOLKIT_WIN) if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_RulerVisible,&b)) _setViewShowRuler (b); UT_uint32 i; for (i = 0; i < m_pApp->getToolbarFactory()->countToolbars(); i++) { if (pPrefs->getPrefsValueBool((gchar*)m_pApp->getToolbarFactory()->prefKeyForToolbar(i),&b)) { _setViewShowToolbar (i, b); } } if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_StatusBarVisible,&b)) _setViewShowStatusBar (b); #endif if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_InsertModeToggle,&b)) _setEnableOverwrite (b); if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_ParaVisible,&b)) _setViewUnprintable (b); if (pPrefs->getPrefsValueBool((gchar*)AP_PREF_KEY_CursorBlink,&b)) _setViewCursorBlink (b); #if defined(TOOLKIT_GTK) if (pPrefs->getPrefsValueBool((gchar*)XAP_PREF_KEY_EnableSmoothScrolling,&b)) _setEnableSmoothScrolling(b); #endif if (pPrefs->getPrefsValueBool((gchar*)XAP_PREF_KEY_AutoLoadPlugins,&b)) _setAutoLoadPlugins(b); // TODO: JOAQUIN FIX THIS if (pPrefs->getPrefsValueBool((gchar*)XAP_PREF_KEY_AutoSaveFile,&b)) _setAutoSaveFile (b); UT_String stBuffer; if (pPrefs->getPrefsValue(XAP_PREF_KEY_AutoSaveFileExt, stBuffer)) _setAutoSaveFileExt(stBuffer); if (pPrefs->getPrefsValue(XAP_PREF_KEY_AutoSaveFilePeriod, stBuffer)) _setAutoSaveFilePeriod(stBuffer); //Just for win32 if (pPrefs->getPrefsValue(AP_PREF_KEY_StringSet, stBuffer)) _setUILanguage(stBuffer); // ------------ Screen Color const gchar * pszColorForTransparent = NULL; if (pPrefs->getPrefsValue(XAP_PREF_KEY_ColorForTransparent, &pszColorForTransparent)) _setColorForTransparent(pszColorForTransparent); // ------------ the page tab number int which = getInitialPageNum (); if ((which == -1) && pPrefs->getPrefsValue((gchar*)AP_PREF_KEY_OptionsTabNumber,&pszBuffer)) _setNotebookPageNum (atoi(pszBuffer)); else _setNotebookPageNum(which); //------------- other if (pPrefs->getPrefsValueBool(AP_PREF_KEY_DefaultDirectionRtl,&b)) _setOtherDirectionRtl (b); if (pPrefs->getPrefsValueBool(XAP_PREF_KEY_ChangeLanguageWithKeyboard,&b)) _setLanguageWithKeyboard (b); if (pPrefs->getPrefsValueBool(XAP_PREF_KEY_DirMarkerAfterClosingParenthesis,&b)) _setDirMarkerAfterClosingParenthesis (b); // enable/disable controls _initEnableControls(); m_bInitialPop = false; }