~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/ui/dialog/ocaldialogs.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

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