~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

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