libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GtkCRNFileSelecter.h
Go to the documentation of this file.
1 /* Copyright 2010-2014 CoReNum, INSA-Lyon
2  *
3  * This file is part of libgtkcrnmm.
4  *
5  * libgtkcrnmm is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libgtkcrnmm is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libgtkcrnmm. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: GtkCRNFileSelecter.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef GtkCRNFileSelecter_HEADER
23 #define GtkCRNFileSelecter_HEADER
24 
25 #include <libgtkcrnmm_config.h>
26 #include <gtkmm.h>
27 #include <CRNIO/CRNPath.h>
28 
29 namespace GtkCRN
30 {
36  class FileSelecter: public Gtk::VBox
37  {
38  public:
40  FileSelecter(const crn::Path &p);
41  virtual ~FileSelecter() override {}
42 
44  void set_path(const crn::Path &p);
46  const crn::Path& get_path() const { return path; }
47 
49  bool set_selection(const crn::Path &p);
51  crn::Path get_selection() const;
52 
54  sigc::signal<void, crn::Path> signal_selection_changed() { return selection_changed; }
56  sigc::signal<void, crn::Path> signal_selection_activated() { return selection_activated; }
57 
58  private:
60  void update_files();
62  void on_selection_changed();
64  void on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
65 
66  Gtk::Entry pathdisplay;
68  class ModelColumns : public Gtk::TreeModelColumnRecord
69  {
70  public:
71  ModelColumns() { add(name); }
72  Gtk::TreeModelColumn<Glib::ustring> name;
73  };
74  ModelColumns columns;
75  Glib::RefPtr<Gtk::ListStore> files;
76  mutable Gtk::TreeView tv;
78  sigc::signal<void, crn::Path> selection_changed;
79  sigc::signal<void, crn::Path> selection_activated;
80  crn::Path path;
81  };
82 }
83 #endif
84 
const crn::Path & get_path() const
Gets the path of the displayed directory.
crn::Path get_selection() const
Gets the selected file.
bool set_selection(const crn::Path &p)
Sets the selected file.
virtual ~FileSelecter() override
sigc::signal< void, crn::Path > signal_selection_activated()
Signals when a file was double clicked. Connect to void on_double_click(crn::Path relative_filename) ...
A convenience class for file paths.
Definition: CRNPath.h:39
FileSelecter(const crn::Path &p)
Constructor.
A widget that displays the files in a directory and allows to select one.
void set_path(const crn::Path &p)
Sets the path of the directory to display.
sigc::signal< void, crn::Path > signal_selection_changed()
Signals when a file was selected. Connect to void on_new_file_selected(crn::Path relative_filename) ...