filechooser.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(INCLUDED_GTKUTIL_FILECHOOSER_H)
00023 #define INCLUDED_GTKUTIL_FILECHOOSER_H
00024
00025 #include <string>
00026 #include "radiant_i18n.h"
00027
00030
00031 typedef struct _GtkWidget GtkWidget;
00032 const char* file_dialog (GtkWidget *parent, bool open, const std::string& title, const std::string& path = "",
00033 const std::string& pattern = "");
00034
00035 namespace gtkutil
00036 {
00037
00038 class FileChooser
00039 {
00040 public:
00049 class Preview
00050 {
00051 public:
00052
00053 virtual GtkWidget* getPreviewWidget () = 0;
00054
00060 virtual void onFileSelectionChanged (const std::string& newFileName, FileChooser& fileChooser) = 0;
00061 };
00062
00063 private:
00064
00065 GtkWidget* _parent;
00066
00067 GtkWidget* _dialog;
00068
00069
00070 std::string _title;
00071
00072 std::string _path;
00073 std::string _file;
00074
00075 std::string _pattern;
00076
00077 std::string _defaultExt;
00078
00079
00080 bool _open;
00081
00082
00083 Preview* _preview;
00084
00085 public:
00097 FileChooser (GtkWidget* parent, const std::string& title, bool open, bool browseFolders,
00098 const std::string& pattern = "", const std::string& defaultExt = "");
00099
00100 virtual ~FileChooser ();
00101
00102
00103 void setCurrentPath (const std::string& path);
00104
00105
00106 void setCurrentFile (const std::string& file);
00107
00113 void attachPreview (Preview* preview);
00114
00119 virtual std::string getSelectedFileName ();
00120
00127 virtual std::string display ();
00128
00129
00130
00131 void setPreviewActive (bool active);
00132
00133 private:
00134
00135 static void onUpdatePreview (GtkFileChooser* chooser, FileChooser* self);
00136 };
00137
00138 }
00139
00140
00141 #endif