void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ){ const char *filename = file_dialog( gtk_widget_get_toplevel( widget ), TRUE, "Choose File", gtk_entry_get_text( entry ) ); if ( filename != 0 ) { gtk_entry_set_text( entry, filename ); } }
void ProjectDialog(){ const char *filename; char buffer[NAME_MAX]; /* * Obtain the system directory name and * store it in buffer. */ strcpy( buffer, g_qeglobals.m_strHomeGame.GetBuffer() ); strcat( buffer, g_pGameDescription->mBaseGame.GetBuffer() ); strcat( buffer, "/scripts/" ); // Display the Open dialog box filename = file_dialog( NULL, TRUE, _( "Open File" ), buffer, "project" ); if ( filename == NULL ) { return; // canceled } // Open the file. // NOTE: QE_LoadProject takes care of saving prefs with new path to the project file if ( !QE_LoadProject( filename ) ) { Sys_Printf( "Failed to load project from file: %s\n", filename ); } else{ // FIXME TTimo QE_Init is probably broken if you don't call it during startup right now .. QE_Init(); } }
const char* misc_model_dialog(GtkWidget* parent) { StringOutputStream buffer(1024); buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; if(!file_readable(buffer.c_str())) { // just go to fsmain buffer.clear(); buffer << g_qeglobals.m_userGamePath.c_str() << "/"; } const char *filename = file_dialog (parent, TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name()); if (filename != 0) { // use VFS to get the correct relative path const char* relative = path_make_relative(filename, GlobalFileSystem().findRoot(filename)); if(relative == filename) { globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n"; } return relative; } return 0; }
void MainFrame::OpenReplay( wxCommandEvent& event ) { /** * Event handler opening a replay */ wxFileDialog file_dialog(this, wxT("Select a replay to open"), wxT(""), wxT(""), wxT("*.rep"), wxOPEN); file_dialog.ShowModal(); replayFilename = file_dialog.GetPath(); *text << "Opening replay " << replayFilename << "...\n"; if ( replay != NULL ) free(replay); replay = new Replay((char*)replayFilename.c_str()); *text << "Parsing Player List...\n"; playerSelection->Clear(); for(int i = 0; i < 8; i++) { if (replay->playerID[i] > -1 ) { playerSelection->Append(wxString(replay->playerName[i])); } } replayOpen = true; playerSelected = false; }
void analysis_export_dialog(void) { /* FIXME - dialog + model are linked */ if (sysenv.active_model) file_dialog("Export graph as text", NULL, FILE_SAVE, (gpointer) analysis_export, MD_ANALYSIS); }
void TOptions::on_m_find_app_clicked() { // As this is a slot that can be called by Qt code (in response to pushing the "Browse" // button in the options window, for example), we don't allow exceptions to go out // from here. So we use a "try" block. try { QDEBUG_METHOD_NAME QFileDialog file_dialog(this, tr("Select the viewer program"), "/"); file_dialog.setFileMode(QFileDialog::ExistingFile); // If the user accepts the dialog, get the path of the selected file if (file_dialog.exec() == QDialog::Accepted) { QTableWidgetItem *new_app_item = new QTableWidgetItem(QDir::toNativeSeparators((file_dialog.selectedFiles().first()))); m_exts_apps->setItem(m_exts_apps->currentRow(), 2, new_app_item); } } catch(std::exception &excep) { syst.exitBecauseException(excep); } catch(...) { syst.exitBecauseException(); } }
bool ADAK_ADD_PIXMAP_TO_BUTTON (QPushButton * push_button, QString * file_path, QWidget * parent) { QIcon icon = push_button->icon(); QFileDialog file_dialog (parent); QStringList file_extensions; file_dialog.setFileMode ( QFileDialog::AnyFile ); //Dikkat burdaki dosya uzantilari silinmeli dosya isminden. file_extensions << QObject::tr ("Image Files - Max. 512kb (*.png *.xpm *.jpg *.jpeg *.svg *.gif *.ico *.tiff)"); file_dialog.setNameFilters ( file_extensions ); file_dialog.setViewMode ( QFileDialog::Detail ); if ( file_dialog.exec() ) { QString pixmap_path = file_dialog.selectedFiles().at(0); /////////// Qt Image formatini otomatik tespit etmesi icin dosya formatina bakmasi engellenir. QPixmap pixmap; QImageReader * image_reader = new QImageReader(pixmap_path); image_reader->setDecideFormatFromContent(true); if (image_reader->canRead() EQ true) { QImage image = image_reader->read(); pixmap = QPixmap::fromImage(image); } /////////////////////// QFile file(pixmap_path); if ( file.size() > 512000) { //ADAK_WARNING (qApp->tr("Resim dosyaları 512kb büyük olamaz."),NULL, parent ); ADAK_WARNING (QObject::tr ("Image files must be smaller than 512KB."),NULL, parent ); return false; } if (icon.pixmap(32,32).toImage() EQ QIcon(pixmap).pixmap(32,32).toImage() AND file_path->isEmpty() EQ true) { *file_path = ""; return false; } *file_path = pixmap_path; //Button width ve height na gore setlenmesi her sette buttonun buyumesine neden olur. //Bu yuzden button widht ve height daha ufak bir deger girilmelidir. int w = push_button->width() - 20; int h = push_button->height() - 20; push_button->setIcon ( QIcon ( pixmap ) ); push_button->setText (""); push_button->setIconSize ( QSize ( w,h ) ); return true; } return false; }
GtkWidget* file_dialog_textentry(const char *title, GtkWidget* entry) { GtkWidget* filesel = file_dialog(title, GTK_SIGNAL_FUNC(file_dialog_ok_set_textentry), entry); const char* text = gtk_entry_get_text(GTK_ENTRY (entry)); if (text && *text) { gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), text); } return filesel; }
// Create various file dialogs static Widget create_file_dialog(Widget w, const _XtString name, FileSearchProc searchRemoteFiles = 0, FileSearchProc searchRemoteDirectories = 0, FileSearchProc searchLocalFiles = 0, FileSearchProc searchLocalDirectories = 0, XtCallbackProc openDone = 0) { if (remote_gdb()) return file_dialog(find_shell(w), name, searchRemoteFiles, searchRemoteDirectories, openDone); else if (app_data.filter_files) return file_dialog(find_shell(w), name, searchLocalFiles, searchLocalDirectories, openDone); else return file_dialog(find_shell(w), name, 0, 0, openDone); }
//Callback for node save x3d menu choice. void H3DViewerPopupMenus::OnTreeViewSaveSTL( wxCommandEvent& event ) { wxTreeItemId id = treeview_dialog->TreeViewTree->GetSelection(); H3DViewerTreeViewDialog::TreeIdMap::iterator ni = treeview_dialog->node_map.find( id.m_pItem ); if( ni == treeview_dialog->node_map.end() ) { wxMessageBox( wxT("Selected tree item is not a node"), wxT("Error"), wxOK | wxICON_EXCLAMATION); return; } else { X3DGeometryNode *geom = dynamic_cast< X3DGeometryNode * >( (*ni).second.get() ); if( !geom ) { wxMessageBox( wxT("Selected tree item is not a geometry node"), wxT("Error"), wxOK | wxICON_EXCLAMATION); return; } auto_ptr< wxFileDialog > file_dialog( new wxFileDialog ( this, wxT("File to save as.."), wxT(""), wxT(""), wxT("*.*"), wxFD_SAVE, wxDefaultPosition) ); if (file_dialog->ShowModal() == wxID_OK) { std::string filename(file_dialog->GetPath().mb_str()); std::ofstream os( filename.c_str() ); if( os.fail() ) { wxMessageBox( wxT("Unable to open selected file"), wxT("Error"), wxOK | wxICON_EXCLAMATION); } try { X3D::writeGeometryAsSTL( os, geom ); } catch (const Exception::H3DException &e) { stringstream s; s << e; wxMessageBox( wxString(s.str().c_str(),wxConvUTF8), wxT("Error"), wxOK | wxICON_EXCLAMATION); } os.close(); } } }
void MainFrame::SaveToAiscript( wxCommandEvent& event ) { /** * Event handler to save a replay to aiscript.bin */ if ( replayOpen && playerSelected ) { wxFileDialog file_dialog(this, wxT("Select location to save to"), wxT(""), wxT("aiscript.bin"), wxT("*.bin"), wxSAVE); file_dialog.ShowModal(); wxString filename = file_dialog.GetPath(); *text << "Saving AI as " << filename << "...\n"; rep2ai->saveToAiscript((char*)filename.c_str()); } }
// Callback for node save Png menu choice. void H3DViewerPopupMenus::OnTreeViewSavePng( wxCommandEvent& event ) { #ifdef HAVE_FREEIMAGE wxTreeItemId id = treeview_dialog->TreeViewTree->GetSelection(); H3DViewerTreeViewDialog::TreeIdMap::iterator ni = treeview_dialog->node_map.find( id.m_pItem ); if( ni == treeview_dialog->node_map.end() ) { wxMessageBox( wxT("Selected tree item is not a node"), wxT("Error"), wxOK | wxICON_EXCLAMATION); } else { auto_ptr< wxFileDialog > file_dialog ( new wxFileDialog ( this, wxT("File to save as.."), wxT(""), wxT(""), wxT("*.png"), wxFD_SAVE, wxDefaultPosition) ); if (file_dialog->ShowModal() == wxID_OK) { try { Node *n = (*ni).second.get(); Image *image = NULL; if( X3DTexture2DNode * tex = dynamic_cast< X3DTexture2DNode * >( n ) ) { image = tex->image->getValue(); } else if( X3DTexture3DNode * tex = dynamic_cast< X3DTexture3DNode * >( n ) ) { image = tex->image->getValue(); } if( !H3DUtil::saveFreeImagePNG( string(file_dialog->GetPath().mb_str()), *image ) ) { stringstream s; s << "Error saving png file"; wxMessageBox( wxString(s.str().c_str(),wxConvUTF8), wxT("Error"), wxOK | wxICON_EXCLAMATION); } } catch (const Exception::H3DException &e) { stringstream s; s << e; wxMessageBox( wxString(s.str().c_str(),wxConvUTF8), wxT("Error"), wxOK | wxICON_EXCLAMATION); } } } #endif }
WStringAutoPtr SelectFile ( WStringAutoPtr prompt ) { CWnd * parent_window = CWnd::FromHandle ( GetActiveWindow() ); CString filter = "All Files (*.*)|*.*||"; CFileDialog file_dialog ( TRUE, NULL, NULL, OFN_HIDEREADONLY, filter, parent_window, 0 ); file_dialog.m_ofn.lpstrTitle = prompt->c_str(); // if the user hasn't cancelled the dialog get the path to the file wchar_t path[MAX_PATH] = L""; if ( file_dialog.DoModal() == IDOK ) { CString file_path = file_dialog.GetPathName(); wcscpy_s ( path, (LPCTSTR)file_path ); } return WStringAutoPtr ( new wstring ( path ) ); } // SelectFile
void Gobby::BrowserContextCommands::on_open(InfBrowser* browser, InfBrowserIter iter) { m_watch.reset(new NodeWatch(browser, &iter)); m_watch->signal_node_removed().connect(sigc::mem_fun( *this, &BrowserContextCommands::on_dialog_node_removed)); std::auto_ptr<FileChooser::Dialog> file_dialog( new FileChooser::Dialog( m_file_chooser, m_parent, _("Choose a text file to open"), Gtk::FILE_CHOOSER_ACTION_OPEN)); file_dialog->signal_response().connect(sigc::bind( sigc::mem_fun(*this, &BrowserContextCommands::on_open_response), browser, iter)); file_dialog->set_select_multiple(true); m_dialog = file_dialog; m_dialog->present(); }
std::string file_dialog(const std::vector<std::pair<std::string, std::string>> &filetypes, bool save) { auto result = file_dialog(filetypes, save, false); return result.empty() ? "" : result.front(); }
void install_button_callback (GtkWidget *widget, gpointer data) { file_dialog(_("Select Script"), G_CALLBACK(install_file_dialog_ok_callback), NULL); }