Fix file chooser entry not updating

Save file name while it is typed in the text entry.

Add placeholder text for Lensfun database directory to indicate
automatic detection if left blank.
This commit is contained in:
Lawrence Lee
2023-04-30 12:30:46 -07:00
parent f5dba61243
commit 45a3b36b3a
3 changed files with 23 additions and 2 deletions

View File

@@ -1548,13 +1548,18 @@ MyFileChooserEntry::MyFileChooserEntry(const Glib::ustring &title, Gtk::FileChoo
MyFileChooserWidget(title, action),
pimpl(new Impl())
{
const auto on_text_changed = [this]() {
set_filename(pimpl->entry.get_text());
};
pimpl->entry.get_buffer()->signal_deleted_text().connect([on_text_changed](guint, guint) { on_text_changed(); });
pimpl->entry.get_buffer()->signal_inserted_text().connect([on_text_changed](guint, const gchar *, guint) { on_text_changed(); });
pimpl->file_chooser_button.set_image(*Gtk::manage(make_folder_image().release()));
pimpl->file_chooser_button.signal_clicked().connect([this]() {
const auto &filename = pimpl->entry.get_text();
const auto &filename = get_filename();
if (Glib::file_test(filename, Glib::FILE_TEST_IS_DIR)) {
set_current_folder(filename);
}
set_filename(filename);
show_chooser(this);
});
@@ -1563,6 +1568,18 @@ MyFileChooserEntry::MyFileChooserEntry(const Glib::ustring &title, Gtk::FileChoo
}
Glib::ustring MyFileChooserEntry::get_placeholder_text() const
{
return pimpl->entry.get_placeholder_text();
}
void MyFileChooserEntry::set_placeholder_text(const Glib::ustring &text)
{
pimpl->entry.set_placeholder_text(text);
}
void MyFileChooserEntry::on_filename_set()
{
if (pimpl->entry.get_text() != get_filename()) {