void XAP_UnixDialog_FileOpenSaveAs::fileTypeChanged(GtkWidget * w) { if (!m_bSave) return; UT_sint32 nFileType = XAP_comboBoxGetActiveInt(GTK_COMBO_BOX(w)); UT_DEBUGMSG(("File type widget is %p filetype number is %d \n",w,nFileType)); // I have no idea for 0, but XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO // definitely means "skip this" if((nFileType == 0) || (nFileType == XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO)) { return; } gchar * filename = gtk_file_chooser_get_filename(m_FC); UT_String sFileName = filename; FREEP(filename); UT_String sSuffix = m_szSuffixes[nFileType-1]; sSuffix = sSuffix.substr(1,sSuffix.length()-1); UT_sint32 i = 0; bool bFoundComma = false; for(i=0; i< static_cast<UT_sint32>(sSuffix.length()); i++) { if(sSuffix[i] == ';') { bFoundComma = true; break; } } if(bFoundComma) { sSuffix = sSuffix.substr(0,i); } // // Hard code a suffix // if(strstr(sSuffix.c_str(),"gz") != NULL) { sSuffix = ".zabw"; } bool bFoundSuffix = false; for(i= sFileName.length()-1; i> 0; i--) { if(sFileName[i] == '.') { bFoundSuffix = true; break; } } if(!bFoundSuffix) { return; } sFileName = sFileName.substr(0,i); sFileName += sSuffix; gtk_file_chooser_set_current_name(m_FC, UT_basename(sFileName.c_str())); }
// we strip any path components static char * strippath(char *fname) { const char * fn = UT_basename(fname); // be sure terminating '\0' is copied and // use ansi memcpy equivalent that handles overlapping regions memmove(fname, fn, strlen(fn) + 1 ); return fname; }
BOOL AP_Win32Dialog_New::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) { m_hThisDlg = hWnd; XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp); UT_return_val_if_fail (app,1); const XAP_StringSet * pSS = m_pApp->getStringSet(); _win32Dialog.setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_NEW_Title)); // localize controls _DSX(NEW_BTN_OK, DLG_OK); _DSX(NEW_BTN_CANCEL, DLG_Cancel); _DS(NEW_RDO_TEMPLATE, DLG_NEW_Create); _DS(NEW_RDO_EXISTING, DLG_NEW_Open); _DS(NEW_BTN_EXISTING, DLG_NEW_Choose); // set initial state _win32Dialog.setControlText(AP_RID_DIALOG_NEW_EBX_EXISTING, pSS->getValue(AP_STRING_ID_DLG_NEW_NoFile)); HWND hControl = GetDlgItem(hWnd, AP_RID_DIALOG_NEW_LBX_TEMPLATE); long findtag; struct _finddata_t cfile; UT_String templateName, searchDir; templateName = XAP_App::getApp()->getUserPrivateDirectory(); searchDir = XAP_App::getApp()->getUserPrivateDirectory(); searchDir += "\\templates\\*.awt"; findtag = _findfirst( searchDir.c_str(), &cfile ); if( findtag != -1 ) { do { templateName = XAP_App::getApp()->getUserPrivateDirectory(); templateName += "\\templates\\"; templateName += cfile.name; if(!strstr(templateName.c_str(), "normal.awt-")) // don't truncate localized template names templateName = templateName.substr ( 0, templateName.size () - 4 ) ; UT_Win32LocaleString str; str.fromASCII (templateName.c_str()); char *uri = UT_go_filename_to_uri(str.utf8_str().utf8_str()); UT_continue_if_fail(uri); UT_sint32 nIndex = SendMessageW( hControl, LB_ADDSTRING, 0, (LPARAM) UT_basename( uri ) ); SendMessageW( hControl, LB_SETITEMDATA, (WPARAM) nIndex, (LPARAM) 0 ); g_free(uri); } while( _findnext( findtag, &cfile ) == 0 ); } _findclose( findtag ); templateName = XAP_App::getApp()->getAbiSuiteLibDir(); searchDir = XAP_App::getApp()->getAbiSuiteLibDir(); searchDir += "\\templates\\*.awt"; findtag = _findfirst( searchDir.c_str(), &cfile ); if( findtag != -1 ) { do { templateName = XAP_App::getApp()->getAbiSuiteLibDir(); templateName += "\\templates\\"; templateName += cfile.name; if(!strstr(templateName.c_str(), "normal.awt-")) // don't truncate localized template names templateName = templateName.substr ( 0, templateName.size () - 4 ) ; UT_Win32LocaleString str; str.fromASCII (templateName.c_str()); char *uri = UT_go_filename_to_uri(str.utf8_str().utf8_str()); UT_continue_if_fail(uri); UT_sint32 nIndex = SendMessageW( hControl, LB_ADDSTRING, 0, (LPARAM) UT_basename( uri ) ); SendMessageW( hControl, LB_SETITEMDATA, (WPARAM) nIndex, (LPARAM) 1 ); g_free(uri); } while( _findnext( findtag, &cfile ) == 0 ); } _findclose( findtag ); XAP_Win32DialogHelper::s_centerDialog(hWnd); _updateControls(); return 1; // 1 == we did not call SetFocus() }