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:
parent
f5dba61243
commit
45a3b36b3a
@ -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()) {
|
||||
|
@ -463,6 +463,9 @@ class MyFileChooserEntry : public Gtk::Box, public MyFileChooserWidget
|
||||
public:
|
||||
explicit MyFileChooserEntry(const Glib::ustring &title, Gtk::FileChooserAction action = Gtk::FILE_CHOOSER_ACTION_OPEN);
|
||||
|
||||
Glib::ustring get_placeholder_text() const;
|
||||
void set_placeholder_text(const Glib::ustring &text);
|
||||
|
||||
protected:
|
||||
void on_filename_set() override;
|
||||
|
||||
|
@ -671,6 +671,7 @@ Gtk::Widget* Preferences::getImageProcessingPanel ()
|
||||
Gtk::Label *lensfunDbDirLabel = Gtk::manage(new Gtk::Label(M("PREFERENCES_LENSFUNDBDIR") + ":"));
|
||||
setExpandAlignProperties(lensfunDbDirLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
|
||||
lensfunDbDir = Gtk::manage(new MyFileChooserEntry(M("PREFERENCES_LENSFUNDBDIR"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
|
||||
lensfunDbDir->set_placeholder_text(Glib::ustring::compose("(%1)", M("GENERAL_AUTO")));
|
||||
setExpandAlignProperties(lensfunDbDir, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER);
|
||||
Gtk::Label* lensfunDbDirRestartNeededLabel = Gtk::manage(new Gtk::Label(Glib::ustring(" (") + M("PREFERENCES_APPLNEXTSTARTUP") + ")"));
|
||||
setExpandAlignProperties(lensfunDbDirRestartNeededLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
|
||||
|
Loading…
x
Reference in New Issue
Block a user