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

« back to all changes in this revision

Viewing changes to src/extension/input.cpp

  • 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:
44
44
    extension = NULL;
45
45
    filetypename = NULL;
46
46
    filetypetooltip = NULL;
47
 
        output_extension = NULL;
 
47
    output_extension = NULL;
48
48
 
49
49
    if (repr != NULL) {
50
50
        Inkscape::XML::Node * child_repr;
94
94
}
95
95
 
96
96
/**
97
 
        \return  None
98
 
        \brief   Destroys an Input extension
 
97
    \return  None
 
98
    \brief   Destroys an Input extension
99
99
*/
100
100
Input::~Input (void)
101
101
{
103
103
    g_free(extension);
104
104
    g_free(filetypename);
105
105
    g_free(filetypetooltip);
106
 
        g_free(output_extension);
 
106
    g_free(output_extension);
107
107
    return;
108
108
}
109
109
 
110
110
/**
111
111
    \return  Whether this extension checks out
112
 
        \brief   Validate this extension
 
112
    \brief   Validate this extension
113
113
 
114
 
        This function checks to make sure that the input extension has
115
 
        a filename extension and a MIME type.  Then it calls the parent
116
 
        class' check function which also checks out the implmentation.
 
114
    This function checks to make sure that the input extension has
 
115
    a filename extension and a MIME type.  Then it calls the parent
 
116
    class' check function which also checks out the implmentation.
117
117
*/
118
118
bool
119
119
Input::check (void)
120
120
{
121
 
        if (extension == NULL)
122
 
                return FALSE;
123
 
        if (mimetype == NULL)
124
 
                return FALSE;
 
121
    if (extension == NULL)
 
122
        return FALSE;
 
123
    if (mimetype == NULL)
 
124
        return FALSE;
125
125
 
126
 
        return Extension::check();
 
126
    return Extension::check();
127
127
}
128
128
 
129
129
/**
130
130
    \return  A new document
131
 
        \brief   This function creates a document from a file
132
 
        \param   uri  The filename to create the document from
133
 
 
134
 
        This function acts as the first step in creating a new document
135
 
        from a file.  The first thing that this does is make sure that the
136
 
        file actually exists.  If it doesn't, a NULL is returned.  If the
137
 
        file exits, then it is opened using the implmentation of this extension.
138
 
 
139
 
        After opening the document the output_extension is set.  What this
140
 
        accomplishes is that save can try to use an extension that supports
141
 
        the same fileformat.  So something like opening and saveing an 
142
 
        Adobe Illustrator file can be transparent (not recommended, but
143
 
        transparent).  This is all done with undo being turned off.
 
131
    \brief   This function creates a document from a file
 
132
    \param   uri  The filename to create the document from
 
133
 
 
134
    This function acts as the first step in creating a new document
 
135
    from a file.  The first thing that this does is make sure that the
 
136
    file actually exists.  If it doesn't, a NULL is returned.  If the
 
137
    file exits, then it is opened using the implmentation of this extension.
 
138
 
 
139
    After opening the document the output_extension is set.  What this
 
140
    accomplishes is that save can try to use an extension that supports
 
141
    the same fileformat.  So something like opening and saveing an 
 
142
    Adobe Illustrator file can be transparent (not recommended, but
 
143
    transparent).  This is all done with undo being turned off.
144
144
*/
145
145
SPDocument *
146
146
Input::open (const gchar *uri)
153
153
    }
154
154
    timer->touch();
155
155
 
156
 
    SPDocument * doc = NULL;
157
 
 
158
 
#ifdef WITH_GNOME_VFS
159
 
    doc = imp->open(this, uri);
160
 
#else
161
 
    if (Inkscape::IO::file_test(uri, G_FILE_TEST_EXISTS)) {
162
 
        doc = imp->open(this, uri);
163
 
    }
164
 
#endif
165
 
    
 
156
    SPDocument *const doc = imp->open(this, uri);
166
157
    if (doc != NULL) {
167
158
        Inkscape::XML::Node * repr = sp_document_repr_root(doc);
168
 
        gboolean saved = sp_document_get_undo_sensitive(doc);
169
 
        sp_document_set_undo_sensitive (doc, FALSE);
 
159
        bool saved = sp_document_get_undo_sensitive(doc);
 
160
        sp_document_set_undo_sensitive (doc, false);
170
161
        repr->setAttribute("inkscape:output_extension", output_extension);
171
162
        sp_document_set_undo_sensitive (doc, saved);
172
163
    }
176
167
 
177
168
/**
178
169
    \return  IETF mime-type for the extension
179
 
        \brief   Get the mime-type that describes this extension
 
170
    \brief   Get the mime-type that describes this extension
180
171
*/
181
172
gchar *
182
173
Input::get_mimetype(void)
186
177
 
187
178
/**
188
179
    \return  Filename extension for the extension
189
 
        \brief   Get the filename extension for this extension
 
180
    \brief   Get the filename extension for this extension
190
181
*/
191
182
gchar *
192
183
Input::get_extension(void)
196
187
 
197
188
/**
198
189
    \return  The name of the filetype supported
199
 
        \brief   Get the name of the filetype supported
 
190
    \brief   Get the name of the filetype supported
200
191
*/
201
192
gchar *
202
193
Input::get_filetypename(void)
209
200
 
210
201
/**
211
202
    \return  Tooltip giving more information on the filetype
212
 
        \brief   Get the tooltip for more information on the filetype
 
203
    \brief   Get the tooltip for more information on the filetype
213
204
*/
214
205
gchar *
215
206
Input::get_filetypetooltip(void)
219
210
 
220
211
/**
221
212
    \return  A dialog to get settings for this extension
222
 
        \brief   Create a dialog for preference for this extension
 
213
    \brief   Create a dialog for preference for this extension
223
214
 
224
 
        Calls the implementation to get the preferences.
 
215
    Calls the implementation to get the preferences.
225
216
*/
226
217
bool
227
218
Input::prefs (const gchar *uri)
228
219
{
229
 
    if (!loaded())
 
220
    if (!loaded()) {
230
221
        set_state(Extension::STATE_LOADED);
231
 
    if (!loaded()) return false;
 
222
    }
 
223
    if (!loaded()) {
 
224
        return false;
 
225
    }
232
226
 
233
227
    Gtk::Widget * controls;
234
228
    controls = imp->prefs_input(this, uri);