Replace the last folder persister and the use of std::auto_ptr by a simple method using a lambda to bind a variable using the selection_changed signal.

This commit is contained in:
Adam Reichold
2015-12-25 19:48:20 +01:00
parent 547b969ed4
commit ff616eb473
11 changed files with 21 additions and 70 deletions

View File

@@ -1013,34 +1013,18 @@ bool MyFileChooserButton::on_scroll_event (GdkEventScroll* event)
return false;
}
FileChooserLastFolderPersister::FileChooserLastFolderPersister(
Gtk::FileChooser* chooser, Glib::ustring& folderVariable) :
chooser(chooser), folderVariable(folderVariable)
void bindCurrentFolder (Gtk::FileChooser& chooser, Glib::ustring& variable)
{
assert(chooser != NULL);
chooser.signal_selection_changed ().connect ([&]()
{
const auto current_folder = chooser.get_current_folder ();
selectionChangedConnetion = chooser->signal_selection_changed().connect(
sigc::mem_fun(*this,
&FileChooserLastFolderPersister::selectionChanged));
if (!folderVariable.empty()) {
chooser->set_current_folder(folderVariable);
}
}
FileChooserLastFolderPersister::~FileChooserLastFolderPersister()
{
}
void FileChooserLastFolderPersister::selectionChanged()
{
if (!chooser->get_current_folder().empty()) {
folderVariable = chooser->get_current_folder();
}
if (!current_folder.empty ())
variable = current_folder;
});
if (!variable.empty ())
chooser.set_current_folder (variable);
}
TextOrIcon::TextOrIcon (Glib::ustring fname, Glib::ustring labelTx, Glib::ustring tooltipTx, TOITypes type)