22 #include <libgtkcrnmm_config.h>
28 using namespace GtkCRN;
37 pathdisplay.set_sensitive(
false);
38 pack_start(pathdisplay,
false,
true, 0);
40 Gtk::ScrolledWindow *sw = Gtk::manage(
new Gtk::ScrolledWindow);
42 pack_start(*sw,
true,
true, 0);
45 files = Gtk::ListStore::create(columns);
47 tv.append_column(
_(
"Filename"), columns.name);
48 Gtk::TreeView::Column *col = tv.get_column(0);
50 col->set_sort_column(columns.name);
51 tv.signal_row_activated().connect(sigc::mem_fun(
this, &FileSelecter::on_row_activated));
73 for (Gtk::TreeIter it : files->children())
75 if (it->get_value(columns.name).c_str() == p)
77 tv.get_selection()->select(it);
89 if (tv.get_selection()->count_selected_rows() == 0)
91 Gtk::TreeIter it(tv.get_selection()->get_selected());
92 return it->get_value(columns.name).c_str();
96 void FileSelecter::update_files()
98 pathdisplay.set_text(path.
CStr());
101 std::vector<crn::Path> dirfiles(dir.GetFiles());
104 Gtk::TreeIter it(files->append());
105 it->set_value(columns.name, Glib::ustring(file.GetFilename().CStr()));
107 tv.get_selection()->select(files->children()[0]);
111 void FileSelecter::on_selection_changed()
120 void FileSelecter::on_row_activated(
const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column)
crn::Path get_selection() const
Gets the selected file.
A handler to the content of a directory.
bool set_selection(const crn::Path &p)
Sets the selected file.
const char * CStr() const noexcept
Conversion to UTF8 cstring.
A convenience class for file paths.
FileSelecter(const crn::Path &p)
Constructor.
void set_path(const crn::Path &p)
Sets the path of the directory to display.
Path & ToLocal()
Converts the path to the local format.