~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/ui/dialog/filedialog.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 * @brief Virtual base definitions for native file dialogs
 
3
 */
 
4
/* Authors:
 
5
 *   Bob Jamison <rwjj@earthlink.net>
 
6
 *   Joel Holdsworth
 
7
 *   Inkscape Guys
 
8
 *
 
9
 * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
 
10
 * Copyright (C) 2007-2008 Joel Holdsworth
 
11
 * Copyright (C) 2004-2008, Inkscape Authors
 
12
 *
 
13
 * Released under GNU GPL, read the file 'COPYING' for more information
 
14
 */
 
15
 
 
16
#ifndef __FILE_DIALOG_H__
 
17
#define __FILE_DIALOG_H__
 
18
 
 
19
#include <glibmm.h>
 
20
#include <vector>
 
21
#include <set>
 
22
#include <gtkmm.h>
 
23
 
 
24
namespace Inkscape {
 
25
namespace Extension {
 
26
class Extension;
 
27
class Output;
 
28
}
 
29
}
 
30
 
 
31
namespace Inkscape
 
32
{
 
33
namespace UI
 
34
{
 
35
namespace Dialog
 
36
{
 
37
 
 
38
/**
 
39
 * Used for setting filters and options, and
 
40
 * reading them back from user selections.
 
41
 */
 
42
typedef enum {
 
43
    SVG_TYPES,
 
44
    IMPORT_TYPES,
 
45
    EXPORT_TYPES
 
46
    } FileDialogType;
 
47
 
 
48
/**
 
49
 * Used for returning the type selected in a SaveAs
 
50
 */
 
51
typedef enum {
 
52
    SVG_NAMESPACE,
 
53
    SVG_NAMESPACE_WITH_EXTENSIONS
 
54
    } FileDialogSelectionType;
 
55
 
 
56
 
 
57
/**
 
58
 * Return true if the string ends with the given suffix
 
59
 */
 
60
bool hasSuffix(const Glib::ustring &str, const Glib::ustring &ext);
 
61
 
 
62
/**
 
63
 * Return true if the image is loadable by Gdk, else false
 
64
 */
 
65
bool isValidImageFile(const Glib::ustring &fileName);
 
66
 
 
67
/**
 
68
 * This class provides an implementation-independent API for
 
69
 * file "Open" dialogs.  Using a standard interface obviates the need
 
70
 * for ugly #ifdefs in file open code
 
71
 */
 
72
class FileOpenDialog
 
73
{
 
74
public:
 
75
 
 
76
 
 
77
    /**
 
78
     * Constructor ..  do not call directly
 
79
     * @param path the directory where to start searching
 
80
     * @param fileTypes one of FileDialogTypes
 
81
     * @param title the title of the dialog
 
82
     */
 
83
    FileOpenDialog()
 
84
        {};
 
85
 
 
86
    /**
 
87
     * Factory.
 
88
     * @param path the directory where to start searching
 
89
     * @param fileTypes one of FileDialogTypes
 
90
     * @param title the title of the dialog
 
91
     */
 
92
    static FileOpenDialog *create(Gtk::Window& parentWindow,
 
93
                                  const Glib::ustring &path,
 
94
                                  FileDialogType fileTypes,
 
95
                                  const char *title);
 
96
 
 
97
 
 
98
    /**
 
99
     * Destructor.
 
100
     * Perform any necessary cleanups.
 
101
     */
 
102
    virtual ~FileOpenDialog() {};
 
103
 
 
104
    /**
 
105
     * Show an OpenFile file selector.
 
106
     * @return the selected path if user selected one, else NULL
 
107
     */
 
108
    virtual bool show() = 0;
 
109
 
 
110
    /**
 
111
     * Return the 'key' (filetype) of the selection, if any
 
112
     * @return a pointer to a string if successful (which must
 
113
     * be later freed with g_free(), else NULL.
 
114
     */
 
115
    virtual Inkscape::Extension::Extension * getSelectionType() = 0;
 
116
 
 
117
    Glib::ustring getFilename();
 
118
 
 
119
    virtual std::vector<Glib::ustring> getFilenames() = 0;
 
120
 
 
121
    virtual Glib::ustring getCurrentDirectory() = 0;
 
122
 
 
123
protected:
 
124
    /**
 
125
     * Filename that was given
 
126
     */
 
127
    Glib::ustring myFilename;
 
128
 
 
129
}; //FileOpenDialog
 
130
 
 
131
 
 
132
 
 
133
 
 
134
 
 
135
 
 
136
/**
 
137
 * This class provides an implementation-independent API for
 
138
 * file "Save" dialogs.
 
139
 */
 
140
class FileSaveDialog
 
141
{
 
142
public:
 
143
 
 
144
    /**
 
145
     * Constructor.  Do not call directly .   Use the factory.
 
146
     * @param path the directory where to start searching
 
147
     * @param fileTypes one of FileDialogTypes
 
148
     * @param title the title of the dialog
 
149
     * @param key a list of file types from which the user can select
 
150
     */
 
151
    FileSaveDialog ()
 
152
        {};
 
153
 
 
154
    /**
 
155
     * Factory.
 
156
     * @param path the directory where to start searching
 
157
     * @param fileTypes one of FileDialogTypes
 
158
     * @param title the title of the dialog
 
159
     * @param key a list of file types from which the user can select
 
160
     */
 
161
    static FileSaveDialog *create(Gtk::Window& parentWindow,
 
162
                                  const Glib::ustring &path,
 
163
                                  FileDialogType fileTypes,
 
164
                                  const char *title,
 
165
                                  const Glib::ustring &default_key,
 
166
                                  const gchar *docTitle);
 
167
 
 
168
 
 
169
    /**
 
170
     * Destructor.
 
171
     * Perform any necessary cleanups.
 
172
     */
 
173
    virtual ~FileSaveDialog() {};
 
174
 
 
175
 
 
176
    /**
 
177
     * Show an SaveAs file selector.
 
178
     * @return the selected path if user selected one, else NULL
 
179
     */
 
180
    virtual bool show() =0;
 
181
 
 
182
    /**
 
183
     * Return the 'key' (filetype) of the selection, if any
 
184
     * @return a pointer to a string if successful (which must
 
185
     * be later freed with g_free(), else NULL.
 
186
     */
 
187
    virtual Inkscape::Extension::Extension * getSelectionType() = 0;
 
188
 
 
189
    virtual void setSelectionType( Inkscape::Extension::Extension * key ) = 0;
 
190
 
 
191
    /**
 
192
     * Get the file name chosen by the user.   Valid after an [OK]
 
193
     */
 
194
    Glib::ustring getFilename ();
 
195
 
 
196
    /**
 
197
     * Get the document title chosen by the user.   Valid after an [OK]
 
198
     */
 
199
    Glib::ustring getDocTitle ();
 
200
 
 
201
    virtual Glib::ustring getCurrentDirectory() = 0;
 
202
 
 
203
protected:
 
204
 
 
205
    /**
 
206
     * Filename that was given
 
207
     */
 
208
    Glib::ustring myFilename;
 
209
 
 
210
    /**
 
211
     * Doc Title that was given
 
212
     */
 
213
    Glib::ustring myDocTitle;
 
214
 
 
215
    /**
 
216
     * List of known file extensions.
 
217
     */
 
218
    std::set<Glib::ustring> knownExtensions;
 
219
 
 
220
 
 
221
    void appendExtension(Glib::ustring& path, Inkscape::Extension::Output* outputExtension);
 
222
 
 
223
}; //FileSaveDialog
 
224
 
 
225
 
 
226
 
 
227
 
 
228
/**
 
229
 * This class provides an implementation-independent API for
 
230
 * file "Export" dialogs.  Saving as these types will not affect
 
231
 * the original file.
 
232
 */
 
233
class FileExportDialog
 
234
{
 
235
public:
 
236
 
 
237
    typedef enum
 
238
        {
 
239
        SCOPE_DOCUMENT,
 
240
        SCOPE_PAGE,
 
241
        SCOPE_SELECTION,
 
242
        SCOPE_CUSTOM
 
243
        } ScopeType;
 
244
 
 
245
    /**
 
246
     * Constructor.  Do not call directly .   Use the factory.
 
247
     * @param path the directory where to start searching
 
248
     * @param fileTypes one of FileDialogTypes
 
249
     * @param title the title of the dialog
 
250
     * @param key a list of file types from which the user can select
 
251
     */
 
252
    FileExportDialog()
 
253
        {}
 
254
 
 
255
    /**
 
256
     * Factory.
 
257
     * @param path the directory where to start searching
 
258
     * @param fileTypes one of FileDialogTypes
 
259
     * @param title the title of the dialog
 
260
     * @param key a list of file types from which the user can select
 
261
     */
 
262
    static FileExportDialog *create(Gtk::Window& parentWindow,
 
263
                                    const Glib::ustring &path,
 
264
                                    FileDialogType fileTypes,
 
265
                                    const char *title,
 
266
                                    const Glib::ustring &default_key);
 
267
 
 
268
 
 
269
    /**
 
270
     * Destructor.
 
271
     * Perform any necessary cleanups.
 
272
     */
 
273
    virtual ~FileExportDialog () {};
 
274
 
 
275
 
 
276
    /**
 
277
     * Show an SaveAs file selector.
 
278
     * @return the selected path if user selected one, else NULL
 
279
     */
 
280
    virtual bool show() =0;
 
281
 
 
282
    /**
 
283
     * Return the 'key' (filetype) of the selection, if any
 
284
     * @return a pointer to a string if successful (which must
 
285
     * be later freed with g_free(), else NULL.
 
286
     */
 
287
    virtual Inkscape::Extension::Extension * getSelectionType() = 0;
 
288
 
 
289
    /**
 
290
     * Return the selected filename, if any.  If not, return ""
 
291
     */
 
292
    virtual Glib::ustring getFilename () =0;
 
293
 
 
294
    /**
 
295
     * Return the scope of the export.  One of the enumerated types
 
296
     * in ScopeType
 
297
     */
 
298
    virtual ScopeType getScope() = 0;
 
299
 
 
300
    /**
 
301
     * Return left side of the exported region
 
302
     */
 
303
    virtual double getSourceX() = 0;
 
304
 
 
305
    /**
 
306
     * Return the top of the exported region
 
307
     */
 
308
    virtual double getSourceY() = 0;
 
309
 
 
310
    /**
 
311
     * Return the width of the exported region
 
312
     */
 
313
    virtual double getSourceWidth() = 0;
 
314
 
 
315
    /**
 
316
     * Return the height of the exported region
 
317
     */
 
318
    virtual double getSourceHeight() = 0;
 
319
 
 
320
    /**
 
321
     * Return the units of the coordinates of exported region
 
322
     */
 
323
    virtual Glib::ustring getSourceUnits() = 0;
 
324
 
 
325
    /**
 
326
     * Return the width of the destination document
 
327
     */
 
328
    virtual double getDestinationWidth() = 0;
 
329
 
 
330
    /**
 
331
     * Return the height of the destination document
 
332
     */
 
333
    virtual double getDestinationHeight() = 0;
 
334
 
 
335
    /**
 
336
     * Return the height of the exported region
 
337
     */
 
338
    virtual Glib::ustring getDestinationUnits() = 0;
 
339
 
 
340
    /**
 
341
     * Return the destination DPI image resulution, if bitmap
 
342
     */
 
343
    virtual double getDestinationDPI() = 0;
 
344
 
 
345
    /**
 
346
     * Return whether we should use Cairo for rendering
 
347
     */
 
348
    virtual bool getUseCairo() = 0;
 
349
 
 
350
    /**
 
351
     * Return whether we should use antialiasing
 
352
     */
 
353
    virtual bool getUseAntialias() = 0;
 
354
 
 
355
    /**
 
356
     * Return the background color for exporting
 
357
     */
 
358
    virtual unsigned long getBackground() = 0;
 
359
 
 
360
 
 
361
 
 
362
}; //FileExportDialog
 
363
 
 
364
 
 
365
} //namespace Dialog
 
366
} //namespace UI
 
367
} //namespace Inkscape
 
368
 
 
369
 
 
370
#endif /* __FILE_DIALOG_H__ */
 
371
 
 
372
/*
 
373
  Local Variables:
 
374
  mode:c++
 
375
  c-file-style:"stroustrup"
 
376
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
377
  indent-tabs-mode:nil
 
378
  fill-column:99
 
379
  End:
 
380
*/
 
381
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :