Example #1
0
OpenFileDialog::OpenFileDialog(Gtk::Window& parent)
    : FileChooserNative{parent,
                        _("Open document"),
                        GTK_FILE_CHOOSER_ACTION_OPEN,
                        _("Open"),
                        _("Cancel")}
{
	set_select_multiple(false);
    add_filter(pdfFilter());
}
Example #2
0
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;
		}
	}
}