Gobby::FileChooser::Dialog::Dialog(Gobby::FileChooser& chooser, Gtk::Window& parent, const Glib::ustring& title, Gtk::FileChooserAction action): Gtk::FileChooserDialog(parent, title, action), m_chooser(chooser) { // Set defaults depending on action switch(action) { case Gtk::FILE_CHOOSER_ACTION_SAVE: add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); add_button(_("_Save"), Gtk::RESPONSE_ACCEPT); set_do_overwrite_confirmation(true); break; case Gtk::FILE_CHOOSER_ACTION_OPEN: add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); add_button(_("_Open"), Gtk::RESPONSE_ACCEPT); break; default: g_assert_not_reached(); break; } set_local_only(false); set_current_folder_uri(m_chooser.get_current_folder_uri()); }
filechooserDialog::filechooserDialog ( Gtk::Window& parent, const Glib::ustring& title, Gtk::FileChooserAction action, Glib::ustring currentFolder, bool multipleSelection, unsigned int mimeType ) : Gtk::FileChooserDialog (parent, title, action) { // append filechooser buttons and linked events add_button ( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ); add_button ( Gtk::Stock::OK, Gtk::RESPONSE_OK ); // set the path to folder of the application as current folder set_current_folder(currentFolder); // Allow the selection of several files set_select_multiple(multipleSelection); // ask confirmation before overwrite an existing file if (action == Gtk::FILE_CHOOSER_ACTION_SAVE) set_do_overwrite_confirmation(true); // mime type file filter setFilters(mimeType); // run the filechooser and grab the result response = run(); // alert dialog if (action != Gtk::FILE_CHOOSER_ACTION_SAVE) { if (response == Gtk::RESPONSE_OK and !genericFeatures::fileExists(get_filename())) { genericAlertWindow * AC = new genericAlertWindow ( *this, "File error" , "The file you are trying to open does not exist" ); delete AC; } } }