| 1 |
/* |
| 2 |
Copyright (C) 2002/2004 Kai Sterker <[email protected]> |
| 3 |
Part of the Adonthell Project <http://adonthell.nongnu.org> |
| 4 |
|
| 5 |
Dlgedit is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 2 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
Dlgedit 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 General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with Dlgedit. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* @file common/gui_file.h |
| 21 |
* |
| 22 |
* @author Kai Sterker |
| 23 |
* @brief Wrapper for the GtkFileSelection widget |
| 24 |
*/ |
| 25 |
|
| 26 |
#include <string> |
| 27 |
#include "gui_modal_dialog.h" |
| 28 |
|
| 29 |
/** |
| 30 |
* A C++ interface to GTK's file selection dialog. |
| 31 |
*/ |
| 32 |
class GuiFile : public GuiModalDialog |
| 33 |
{ |
| 34 |
public: |
| 35 |
/** |
| 36 |
* Create a new file selection dialog. |
| 37 |
* @param parent the parent window for the dialog. |
| 38 |
* @param action type of file dialog. |
| 39 |
* @param file name of default file. |
| 40 |
* @param title the dialog title. |
| 41 |
*/ |
| 42 |
GuiFile (GtkWindow *parent, GtkFileChooserAction action, const std::string &file, const std::string &title); |
| 43 |
|
| 44 |
/** |
| 45 |
* Cleanup. |
| 46 |
*/ |
| 47 |
~GuiFile (); |
| 48 |
|
| 49 |
/** |
| 50 |
* Show the dialog. |
| 51 |
* @return true if closed with okay, false otherwise. |
| 52 |
*/ |
| 53 |
bool run (); |
| 54 |
|
| 55 |
/** |
| 56 |
* Add a filter to limit the files that will be visible and |
| 57 |
* selectable by the user. |
| 58 |
* @param pattern only show files matching the pattern. |
| 59 |
* @param name name of the filter. |
| 60 |
*/ |
| 61 |
void add_filter (const std::string & pattern, const std::string & name); |
| 62 |
|
| 63 |
/** |
| 64 |
* Add shortcut to the given directory to the file chooser. |
| 65 |
* @param shortcut the shortcut to add. |
| 66 |
*/ |
| 67 |
void add_shortcut (const std::string & shortcut); |
| 68 |
|
| 69 |
/** |
| 70 |
* Return the users selection. |
| 71 |
* @param the users selection. |
| 72 |
*/ |
| 73 |
std::string getSelection () const { return File; } |
| 74 |
|
| 75 |
private: |
| 76 |
/// the file the user has selected |
| 77 |
std::string File; |
| 78 |
}; |