|
|
|
|
@ -5,12 +5,15 @@
|
|
|
|
|
|
|
|
|
|
std::string open_dialog(const std::string &title, |
|
|
|
|
const std::vector<std::pair<std::string, Gtk::ResponseType>> &buttons, |
|
|
|
|
Gtk::FileChooserAction gtk_options) { |
|
|
|
|
Gtk::FileChooserAction gtk_options, |
|
|
|
|
const std::string &file_name = "") { |
|
|
|
|
Gtk::FileChooserDialog dialog(title, gtk_options); |
|
|
|
|
if(Singleton::directories()->current_path!="") |
|
|
|
|
gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), Singleton::directories()->current_path.string().c_str()); |
|
|
|
|
else |
|
|
|
|
gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), boost::filesystem::current_path().string().c_str()); |
|
|
|
|
if (!file_name.empty()) |
|
|
|
|
gtk_file_chooser_set_filename((GtkFileChooser*)dialog.gobj(), file_name.c_str()); |
|
|
|
|
dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS); |
|
|
|
|
dialog.set_transient_for(*Singleton::window());
|
|
|
|
|
for (auto &button : buttons)
|
|
|
|
|
@ -45,6 +48,7 @@ std::string Dialog::select_file() {
|
|
|
|
|
std::string Dialog::save_file() { |
|
|
|
|
return open_dialog("Please choose a file", |
|
|
|
|
{std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Save", Gtk::RESPONSE_OK)}, |
|
|
|
|
Gtk::FILE_CHOOSER_ACTION_SAVE); |
|
|
|
|
Gtk::FILE_CHOOSER_ACTION_SAVE, |
|
|
|
|
Singleton::window()->notebook.get_current_view()->file_path.string()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|