1 /** @file
2 * @brief Open Clip Art Library integration dialogs
3 */
4 /* Authors:
5 * Bruno Dilly <bruno.dilly@gmail.com>
6 * Inkscape Guys
7 *
8 * Copyright (C) 2007 Bruno Dilly <bruno.dilly@gmail.com>
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifndef __OCAL_DIALOG_H__
13 #define __OCAL_DIALOG_H__
15 #include <glibmm.h>
16 #include <vector>
17 #include <gtkmm.h>
18 #include "filedialogimpl-gtkmm.h"
20 //General includes
21 #include <unistd.h>
22 #include <sys/stat.h>
23 #include <errno.h>
24 #include <set>
25 #include <libxml/parser.h>
26 #include <libxml/tree.h>
29 //Gtk includes
30 #include <glibmm/i18n.h>
31 #include <glib/gstdio.h>
33 //Temporary ugly hack
34 //Remove this after the get_filter() calls in
35 //show() on both classes are fixed
36 #include <gtk/gtkfilechooser.h>
38 //Another hack
39 #include <gtk/gtkentry.h>
40 #include <gtk/gtkexpander.h>
41 #ifdef WITH_GNOME_VFS
42 #include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized
43 #include<libgnomevfs/gnome-vfs.h>
44 #endif
46 //Inkscape includes
47 #include <extension/input.h>
48 #include <extension/output.h>
49 #include <extension/db.h>
50 #include "inkscape.h"
51 #include "svg-view-widget.h"
52 #include "gc-core.h"
54 //For export dialog
55 #include "ui/widget/scalar-unit.h"
58 namespace Inkscape
59 {
60 namespace UI
61 {
62 namespace Dialog
63 {
65 /*#########################################################################
66 ### F I L E D I A L O G O C A L B A S E C L A S S
67 #########################################################################*/
69 /**
70 * This class is the base implementation for export to OCAL.
71 */
72 class FileDialogOCALBase : public Gtk::Dialog
73 {
74 public:
76 /**
77 * Constructor
78 */
79 FileDialogOCALBase(const Glib::ustring &title, Gtk::Window& parent) : Gtk::Dialog(title, parent, true)
80 {}
82 /*
83 * Destructor
84 */
85 virtual ~FileDialogOCALBase()
86 {}
88 protected:
89 void cleanup( bool showConfirmed );
91 /**
92 * What type of 'open' are we? (open, import, place, etc)
93 */
94 FileDialogType dialogType;
95 };
100 //########################################################################
101 //# F I L E E X P O R T T O O C A L
102 //########################################################################
105 /**
106 * Our implementation of the FileExportToOCALDialog interface.
107 */
108 /*
109 class FileExportToOCALDialog : public FileDialogOCALBase
110 {
112 public:
113 */
114 /**
115 * Constructor
116 * @param fileTypes one of FileDialogTypes
117 * @param title the title of the dialog
118 * @param key a list of file types from which the user can select
119 */
120 /*
121 FileExportToOCALDialog(Gtk::Window& parentWindow,
122 FileDialogType fileTypes,
123 const Glib::ustring &title);
124 */
125 /**
126 * Destructor.
127 * Perform any necessary cleanups.
128 */
129 /*
130 ~FileExportToOCALDialog();
131 */
132 /**
133 * Show an SaveAs file selector.
134 * @return the selected path if user selected one, else NULL
135 */
136 /*
137 bool show();
139 Glib::ustring getFilename();
141 Glib::ustring myFilename;
142 */
143 /**
144 * Change the window title.
145 */
146 /*
147 void change_title(const Glib::ustring& title);
149 private:
150 */
151 /**
152 * Fix to allow the user to type the file name
153 */
154 /*
155 Gtk::Entry *fileNameEntry;
156 */
157 /**
158 * Data mirror of the combo box
159 */
160 /*
161 std::vector<FileType> fileTypes;
163 // Child widgets
164 Gtk::HBox childBox;
165 Gtk::VBox checksBox;
166 Gtk::HBox fileBox;
167 */
168 /**
169 * The extension to use to write this file
170 */
171 /*
172 Inkscape::Extension::Extension *extension;
173 */
174 /**
175 * Callback for user input into fileNameEntry
176 */
177 /*
178 void fileNameEntryChangedCallback();
179 */
180 /**
181 * List of known file extensions.
182 */
183 /*
184 std::set<Glib::ustring> knownExtensions;
186 }; //FileExportToOCAL
187 */
189 //########################################################################
190 //# F I L E E X P O R T T O O C A L P A S S W O R D
191 //########################################################################
194 /**
195 * Our implementation of the FileExportToOCALPasswordDialog interface.
196 */
197 /*
198 class FileExportToOCALPasswordDialog : public FileDialogOCALBase
199 {
201 public:
202 */
203 /**
204 * Constructor
205 * @param title the title of the dialog
206 */
207 /*
208 FileExportToOCALPasswordDialog(Gtk::Window& parentWindow,
209 const Glib::ustring &title);
210 */
211 /**
212 * Destructor.
213 * Perform any necessary cleanups.
214 */
215 /*
216 ~FileExportToOCALPasswordDialog();
217 */
219 /**
220 * Show 2 entry to input username and password.
221 */
222 /*
223 bool show();
225 Glib::ustring getUsername();
226 Glib::ustring getPassword();
227 */
228 /**
229 * Change the window title.
230 */
231 /*
232 void change_title(const Glib::ustring& title);
234 Glib::ustring myUsername;
235 Glib::ustring myPassword;
237 private:
238 */
239 /**
240 * Fix to allow the user to type the file name
241 */
242 /*
243 Gtk::Entry *usernameEntry;
244 Gtk::Entry *passwordEntry;
246 // Child widgets
247 Gtk::VBox entriesBox;
248 Gtk::HBox userBox;
249 Gtk::HBox passBox;
251 }; //FileExportToOCALPassword
252 */
255 //#########################################################################
256 //### F I L E I M P O R T F R O M O C A L
257 //#########################################################################
259 /**
260 * Our implementation class for filesListView
261 */
262 class FileListViewText : public Gtk::ListViewText
263 {
264 public:
265 FileListViewText(guint columns_count, SVGPreview& filesPreview, Gtk::Label& description, Gtk::Button& okButton)
266 :ListViewText(columns_count)
267 {
268 myPreview = &filesPreview;
269 myLabel = &description;
270 myButton = &okButton;
271 }
272 Glib::ustring getFilename();
273 protected:
274 void on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
275 void on_cursor_changed();
276 private:
277 Glib::ustring myFilename;
278 SVGPreview *myPreview;
279 Gtk::Label *myLabel;
280 Gtk::Button *myButton;
281 };
283 /**
284 * Our implementation class for the FileImportFromOCALDialog interface..
285 */
286 class FileImportFromOCALDialog : public FileDialogOCALBase
287 {
288 public:
289 /**
290 * Constructor
291 * @param path the directory where to start searching
292 * @param fileTypes one of FileDialogTypes
293 * @param title the title of the dialog
294 */
295 FileImportFromOCALDialog(Gtk::Window& parentWindow,
296 const Glib::ustring &dir,
297 FileDialogType fileTypes,
298 const Glib::ustring &title);
300 /**
301 * Destructor.
302 * Perform any necessary cleanups.
303 */
304 ~FileImportFromOCALDialog();
306 /**
307 * Show an OpenFile file selector.
308 * @return the selected path if user selected one, else NULL
309 */
310 bool show();
312 /**
313 * Return the 'key' (filetype) of the selection, if any
314 * @return a pointer to a string if successful (which must
315 * be later freed with g_free(), else NULL.
316 */
317 Inkscape::Extension::Extension *getSelectionType();
319 Glib::ustring getFilename();
321 private:
323 /**
324 * Allow the user to type the tag to be searched
325 */
326 Gtk::Entry *searchTagEntry;
327 FileListViewText *filesList;
328 SVGPreview *filesPreview;
329 Gtk::Label *notFoundLabel;
330 Gtk::Label *descriptionLabel;
331 Gtk::Button *searchButton;
332 Gtk::Button *okButton;
334 // Child widgets
335 Gtk::HBox tagBox;
336 Gtk::HBox filesBox;
337 Gtk::HBox messageBox;
338 Gtk::HBox descriptionBox;
339 Gtk::ScrolledWindow listScrolledWindow;
340 Glib::RefPtr<Gtk::TreeSelection> selection;
342 /**
343 * Callback for user input into searchTagEntry
344 */
345 void searchTagEntryChangedCallback();
348 /**
349 * Prints the names of the all the xml elements
350 * that are siblings or children of a given xml node
351 */
352 void print_xml_element_names(xmlNode * a_node);
354 /**
355 * The extension to use to write this file
356 */
357 Inkscape::Extension::Extension *extension;
359 }; //FileImportFromOCALDialog
362 } //namespace Dialog
363 } //namespace UI
364 } //namespace Inkscape
367 #endif /* __OCAL_DIALOG_H__ */
369 /*
370 Local Variables:
371 mode:c++
372 c-file-style:"stroustrup"
373 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
374 indent-tabs-mode:nil
375 fill-column:99
376 End:
377 */
378 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :