91ee54bf8c5798c2d7ce53e03a9dde649f13d855
1 /**\r
2 * Implementation of the OCAL import/export dialogs\r
3 *\r
4 * Authors:\r
5 * Joel Holdsworth\r
6 * Bruno Dilly\r
7 * Other dudes from The Inkscape Organization\r
8 *\r
9 * Copyright (C) 2007 Bruno Dilly\r
10 *\r
11 * Released under GNU GPL, read the file 'COPYING' for more information\r
12 */
14 #include "filedialogimpl-gtkmm.h"\r
15 \r
16 namespace Inkscape\r
17 {\r
18 namespace UI\r
19 {\r
20 namespace Dialog\r
21 {
23 /*#########################################################################\r
24 ### F I L E D I A L O G O C A L B A S E C L A S S\r
25 #########################################################################*/\r
26 \r
27 /**\r
28 * This class is the base implementation for export to OCAL.\r
29 */\r
30 class FileDialogOCALBase : public Gtk::Dialog\r
31 {\r
32 public:\r
33 \r
34 /**\r
35 *\r
36 */\r
37 FileDialogOCALBase(const Glib::ustring &title) : Gtk::Dialog(title,true)\r
38 {}\r
39 /*\r
40 *\r
41 */\r
42 virtual ~FileDialogOCALBase()\r
43 {}\r
44 \r
45 protected:\r
46 void cleanup( bool showConfirmed );\r
47 \r
48 //Glib::ustring preferenceBase;\r
49 /**\r
50 * What type of 'open' are we? (open, import, place, etc)\r
51 */\r
52 FileDialogType dialogType;\r
53 };\r
56 //########################################################################\r
57 //# F I L E E X P O R T T O O C A L\r
58 //########################################################################\r
59 \r
60 /**\r
61 * Our implementation of the FileExportToOCALDialog interface.\r
62 */\r
63 class FileExportToOCALDialog : public FileDialogOCALBase\r
64 {\r
65 \r
66 public:\r
67 FileExportToOCALDialog(Gtk::Window& parentWindow, \r
68 const Glib::ustring &title,\r
69 const Glib::ustring &default_key);\r
71 /**
72 * Destructor.
73 * Perform any necessary cleanups.
74 */\r
75 virtual ~FileExportToOCALDialog();\r
76 \r
77 bool show();\r
79 /**
80 * Return the 'key' (filetype) of the selection, if any
81 * @return a pointer to a string if successful (which must
82 * be later freed with g_free(), else NULL.
83 */\r
84 Inkscape::Extension::Extension *getSelectionType();
85 \r
86 virtual void setSelectionType( Inkscape::Extension::Extension * key );\r
87 \r
88 Glib::ustring getFilename();\r
89 \r
90 Glib::ustring myFilename;\r
91 \r
92 void change_title(const Glib::ustring& title);\r
93 void updateNameAndExtension();\r
94 \r
95 private:\r
96 \r
97 /**\r
98 * Fix to allow the user to type the file name\r
99 */\r
100 Gtk::Entry *fileNameEntry;\r
101 \r
102 \r
103 /**\r
104 * Allow the specification of the output file type\r
105 */\r
106 Gtk::ComboBoxText fileTypeComboBox;\r
107 \r
108 \r
109 /**\r
110 * Data mirror of the combo box\r
111 */\r
112 std::vector<FileType> fileTypes;\r
113 \r
114 // Child widgets\r
115 Gtk::HBox childBox;\r
116 Gtk::VBox checksBox;\r
117 Gtk::HBox fileBox;\r
118 \r
119 Gtk::CheckButton fileTypeCheckbox;\r
120 \r
121 /**\r
122 * Callback for user input into fileNameEntry\r
123 */\r
124 void fileTypeChangedCallback();\r
125 \r
126 /**\r
127 * Create a filter menu for this type of dialog\r
128 */\r
129 void createFileTypeMenu();\r
130 \r
131 \r
132 /**\r
133 * The extension to use to write this file\r
134 */\r
135 Inkscape::Extension::Extension *extension;\r
136 \r
137 /**\r
138 * Callback for user input into fileNameEntry\r
139 */\r
140 void fileNameEntryChangedCallback();\r
141 \r
142 /**\r
143 * List of known file extensions.\r
144 */\r
145 std::set<Glib::ustring> knownExtensions;\r
146 };\r
147 \r
148 \r
149 //#########################################################################\r
150 //### F I L E I M P O R T F R O M O C A L\r
151 //#########################################################################\r
152 \r
153 /**\r
154 * Our implementation class for filesListView\r
155 */\r
156 class FileListViewText : public Gtk::ListViewText\r
157 {\r
158 public:\r
159 FileListViewText(guint columns_count, SVGPreview& filesPreview):ListViewText(columns_count)\r
160 {\r
161 myPreview = &filesPreview;\r
162 }\r
163 Glib::ustring getFilename();\r
164 protected:\r
165 void on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);\r
166 private:\r
167 Glib::ustring myFilename;\r
168 SVGPreview *myPreview;\r
169 };\r
170 \r
171 /**\r
172 * Our implementation class for the FileImportFromOCALDialog\r
173 */\r
174 class FileImportFromOCALDialog : public FileDialogOCALBase\r
175 {\r
176 public:\r
177 \r
178 FileImportFromOCALDialog(Gtk::Window& parentWindow,\r
179 const Glib::ustring &dir,\r
180 const Glib::ustring &title);\r
182 /**
183 * Destructor.
184 * Perform any necessary cleanups.
185 */\r
186 virtual ~FileImportFromOCALDialog();\r
188 /**
189 * Show an OpenFile file selector.
190 * @return the selected path if user selected one, else NULL
191 */\r
192 bool show();\r
194 /**
195 * Return the 'key' (filetype) of the selection, if any
196 * @return a pointer to a string if successful (which must
197 * be later freed with g_free(), else NULL.
198 */\r
199 Inkscape::Extension::Extension *getSelectionType();\r
200 \r
201 Glib::ustring getFilename();\r
202 \r
203 private:\r
204 \r
205 /**\r
206 * Allow the user to type the tag to be searched\r
207 */\r
208 Gtk::Entry *searchTagEntry;\r
209 FileListViewText *filesList;\r
210 SVGPreview *filesPreview;\r
211 Gtk::Label *notFoundLabel;\r
212 \r
213 // Child widgets\r
214 Gtk::HBox tagBox;\r
215 Gtk::HBox filesBox;\r
216 Gtk::HBox messageBox;\r
217 Gtk::ScrolledWindow listScrolledWindow;\r
218 Glib::RefPtr<Gtk::TreeSelection> selection;\r
219 \r
220 /**\r
221 * Callback for user input into searchTagEntry\r
222 */\r
223 void searchTagEntryChangedCallback();\r
224 \r
225 \r
226 /**\r
227 * Prints the names of the all the xml elements \r
228 * that are siblings or children of a given xml node\r
229 */\r
230 void print_xml_element_names(xmlNode * a_node);\r
231 \r
232 /**\r
233 * The extension to use to write this file\r
234 */\r
235 Inkscape::Extension::Extension *extension;\r
236 };\r
237 \r
238 }\r
239 }\r
240 }\r
241 \r
242 /*\r
243 Local Variables:\r
244 mode:c++\r
245 c-file-style:"stroustrup"\r
246 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
247 indent-tabs-mode:nil\r
248 fill-column:99\r
249 End:\r
250 */\r
251 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :