25390d56fa20e6e8f0571be763d240bdc94f48ea
1 /**
2 * Implementation of the file dialog interfaces defined in filedialog.h
3 *
4 * Authors:
5 * Bob Jamison
6 * Other dudes from The Inkscape Organization
7 *
8 * Copyright (C) 2004-2007 Bob Jamison
9 * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
10 * Copyright (C) 2004-2007 The Inkscape Organization
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
16 #ifdef HAVE_CONFIG_H
17 # include <config.h>
18 #endif
20 //General includes
21 #include <unistd.h>
22 #include <sys/stat.h>
23 #include <set>
25 //Gtk includes
26 #include <gtkmm.h>
27 #include <glibmm/i18n.h>
28 #include <glib/gstdio.h>
29 //Temporary ugly hack
30 //Remove this after the get_filter() calls in
31 //show() on both classes are fixed
32 #include <gtk/gtkfilechooser.h>
33 //Another hack
34 #include <gtk/gtkentry.h>
35 #include <gtk/gtkexpander.h>
39 //Inkscape includes
40 #include "prefs-utils.h"
41 #include <dialogs/dialog-events.h>
42 #include <extension/input.h>
43 #include <extension/output.h>
44 #include <extension/db.h>
45 #include "inkscape.h"
46 #include "svg-view-widget.h"
47 #include "filedialog.h"
48 #include "gc-core.h"
50 //For export dialog
51 #include "ui/widget/scalar-unit.h"
54 //Routines from file.cpp
55 #undef INK_DUMP_FILENAME_CONV
57 #ifdef INK_DUMP_FILENAME_CONV
58 void dump_str( const gchar* str, const gchar* prefix );
59 void dump_ustr( const Glib::ustring& ustr );
60 #endif
62 extern int errno;
65 namespace Inkscape
66 {
67 namespace UI
68 {
69 namespace Dialog
70 {
76 //########################################################################
77 //### U T I L I T Y
78 //########################################################################
80 /**
81 \brief A quick function to turn a standard extension into a searchable
82 pattern for the file dialogs
83 \param pattern The patter that the extension should be written to
84 \param in_file_extension The C string that represents the extension
86 This function just goes through the string, and takes all characters
87 and puts a [<upper><lower>] so that both are searched and shown in
88 the file dialog. This function edits the pattern string to make
89 this happen.
90 */
91 static void
92 fileDialogExtensionToPattern(Glib::ustring &pattern,
93 Glib::ustring &extension)
94 {
95 for (unsigned int i = 0; i < extension.length(); i++ )
96 {
97 Glib::ustring::value_type ch = extension[i];
98 if ( Glib::Unicode::isalpha(ch) )
99 {
100 pattern += '[';
101 pattern += Glib::Unicode::toupper(ch);
102 pattern += Glib::Unicode::tolower(ch);
103 pattern += ']';
104 }
105 else
106 {
107 pattern += ch;
108 }
109 }
110 }
113 /**
114 * Hack: Find all entry widgets in a container
115 */
116 static void
117 findEntryWidgets(Gtk::Container *parent,
118 std::vector<Gtk::Entry *> &result)
119 {
120 if (!parent)
121 return;
122 std::vector<Gtk::Widget *> children = parent->get_children();
123 for (unsigned int i=0; i<children.size() ; i++)
124 {
125 Gtk::Widget *child = children[i];
126 GtkWidget *wid = child->gobj();
127 if (GTK_IS_ENTRY(wid))
128 result.push_back((Gtk::Entry *)child);
129 else if (GTK_IS_CONTAINER(wid))
130 findEntryWidgets((Gtk::Container *)child, result);
131 }
133 }
138 /**
139 * Hack: Find all expander widgets in a container
140 */
141 static void
142 findExpanderWidgets(Gtk::Container *parent,
143 std::vector<Gtk::Expander *> &result)
144 {
145 if (!parent)
146 return;
147 std::vector<Gtk::Widget *> children = parent->get_children();
148 for (unsigned int i=0; i<children.size() ; i++)
149 {
150 Gtk::Widget *child = children[i];
151 GtkWidget *wid = child->gobj();
152 if (GTK_IS_EXPANDER(wid))
153 result.push_back((Gtk::Expander *)child);
154 else if (GTK_IS_CONTAINER(wid))
155 findExpanderWidgets((Gtk::Container *)child, result);
156 }
158 }
161 /*#########################################################################
162 ### SVG Preview Widget
163 #########################################################################*/
165 /**
166 * Simple class for displaying an SVG file in the "preview widget."
167 * Currently, this is just a wrapper of the sp_svg_view Gtk widget.
168 * Hopefully we will eventually replace with a pure Gtkmm widget.
169 */
170 class SVGPreview : public Gtk::VBox
171 {
172 public:
174 SVGPreview();
176 ~SVGPreview();
178 bool setDocument(SPDocument *doc);
180 bool setFileName(Glib::ustring &fileName);
182 bool setFromMem(char const *xmlBuffer);
184 bool set(Glib::ustring &fileName, int dialogType);
186 bool setURI(URI &uri);
188 /**
189 * Show image embedded in SVG
190 */
191 void showImage(Glib::ustring &fileName);
193 /**
194 * Show the "No preview" image
195 */
196 void showNoPreview();
198 /**
199 * Show the "Too large" image
200 */
201 void showTooLarge(long fileLength);
203 private:
204 /**
205 * The svg document we are currently showing
206 */
207 SPDocument *document;
209 /**
210 * The sp_svg_view widget
211 */
212 GtkWidget *viewerGtk;
214 /**
215 * are we currently showing the "no preview" image?
216 */
217 bool showingNoPreview;
219 };
222 bool SVGPreview::setDocument(SPDocument *doc)
223 {
224 if (document)
225 sp_document_unref(document);
227 sp_document_ref(doc);
228 document = doc;
230 //This should remove it from the box, and free resources
231 if (viewerGtk)
232 gtk_widget_destroy(viewerGtk);
234 viewerGtk = sp_svg_view_widget_new(doc);
235 GtkWidget *vbox = (GtkWidget *)gobj();
236 gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0);
237 gtk_widget_show(viewerGtk);
239 return true;
240 }
243 bool SVGPreview::setFileName(Glib::ustring &theFileName)
244 {
245 Glib::ustring fileName = theFileName;
247 fileName = Glib::filename_to_utf8(fileName);
249 SPDocument *doc = sp_document_new (fileName.c_str(), 0);
250 if (!doc) {
251 g_warning("SVGView: error loading document '%s'\n", fileName.c_str());
252 return false;
253 }
255 setDocument(doc);
257 sp_document_unref(doc);
259 return true;
260 }
264 bool SVGPreview::setFromMem(char const *xmlBuffer)
265 {
266 if (!xmlBuffer)
267 return false;
269 gint len = (gint)strlen(xmlBuffer);
270 SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0);
271 if (!doc) {
272 g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer);
273 return false;
274 }
276 setDocument(doc);
278 sp_document_unref(doc);
280 Inkscape::GC::request_early_collection();
282 return true;
283 }
287 void SVGPreview::showImage(Glib::ustring &theFileName)
288 {
289 Glib::ustring fileName = theFileName;
292 /*#####################################
293 # LET'S HAVE SOME FUN WITH SVG!
294 # Instead of just loading an image, why
295 # don't we make a lovely little svg and
296 # display it nicely?
297 #####################################*/
299 //Arbitrary size of svg doc -- rather 'portrait' shaped
300 gint previewWidth = 400;
301 gint previewHeight = 600;
303 //Get some image info. Smart pointer does not need to be deleted
304 Glib::RefPtr<Gdk::Pixbuf> img = Gdk::Pixbuf::create_from_file(fileName);
305 gint imgWidth = img->get_width();
306 gint imgHeight = img->get_height();
308 //Find the minimum scale to fit the image inside the preview area
309 double scaleFactorX = (0.9 *(double)previewWidth) / ((double)imgWidth);
310 double scaleFactorY = (0.9 *(double)previewHeight) / ((double)imgHeight);
311 double scaleFactor = scaleFactorX;
312 if (scaleFactorX > scaleFactorY)
313 scaleFactor = scaleFactorY;
315 //Now get the resized values
316 gint scaledImgWidth = (int) (scaleFactor * (double)imgWidth);
317 gint scaledImgHeight = (int) (scaleFactor * (double)imgHeight);
319 //center the image on the area
320 gint imgX = (previewWidth - scaledImgWidth) / 2;
321 gint imgY = (previewHeight - scaledImgHeight) / 2;
323 //wrap a rectangle around the image
324 gint rectX = imgX-1;
325 gint rectY = imgY-1;
326 gint rectWidth = scaledImgWidth +2;
327 gint rectHeight = scaledImgHeight+2;
329 //Our template. Modify to taste
330 gchar const *xformat =
331 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
332 "<svg\n"
333 "xmlns=\"http://www.w3.org/2000/svg\"\n"
334 "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
335 "width=\"%d\" height=\"%d\">\n" //# VALUES HERE
336 "<rect\n"
337 " style=\"fill:#eeeeee;stroke:none\"\n"
338 " x=\"-100\" y=\"-100\" width=\"4000\" height=\"4000\"/>\n"
339 "<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"\n"
340 "xlink:href=\"%s\"/>\n"
341 "<rect\n"
342 " style=\"fill:none;"
343 " stroke:#000000;stroke-width:1.0;"
344 " stroke-linejoin:miter;stroke-opacity:1.0000000;"
345 " stroke-miterlimit:4.0000000;stroke-dasharray:none\"\n"
346 " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/>\n"
347 "<text\n"
348 " style=\"font-size:24.000000;font-style:normal;font-weight:normal;"
349 " fill:#000000;fill-opacity:1.0000000;stroke:none;"
350 " font-family:Bitstream Vera Sans\"\n"
351 " x=\"10\" y=\"26\">%d x %d</text>\n" //# VALUES HERE
352 "</svg>\n\n";
354 //if (!Glib::get_charset()) //If we are not utf8
355 fileName = Glib::filename_to_utf8(fileName);
357 //Fill in the template
358 /* FIXME: Do proper XML quoting for fileName. */
359 gchar *xmlBuffer = g_strdup_printf(xformat,
360 previewWidth, previewHeight,
361 imgX, imgY, scaledImgWidth, scaledImgHeight,
362 fileName.c_str(),
363 rectX, rectY, rectWidth, rectHeight,
364 imgWidth, imgHeight);
366 //g_message("%s\n", xmlBuffer);
368 //now show it!
369 setFromMem(xmlBuffer);
370 g_free(xmlBuffer);
371 }
375 void SVGPreview::showNoPreview()
376 {
377 //Are we already showing it?
378 if (showingNoPreview)
379 return;
381 //Arbitrary size of svg doc -- rather 'portrait' shaped
382 gint previewWidth = 300;
383 gint previewHeight = 600;
385 //Our template. Modify to taste
386 gchar const *xformat =
387 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
388 "<svg\n"
389 "xmlns=\"http://www.w3.org/2000/svg\"\n"
390 "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
391 "width=\"%d\" height=\"%d\">\n" //# VALUES HERE
392 "<g transform=\"translate(-190,24.27184)\" style=\"opacity:0.12\">\n"
393 "<path\n"
394 "style=\"font-size:12;fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.936193pt\"\n"
395 "d=\"M 397.64309 320.25301 L 280.39197 282.517 L 250.74227 124.83447 L 345.08225 "
396 "29.146783 L 393.59996 46.667064 L 483.89679 135.61619 L 397.64309 320.25301 z \"\n"
397 "id=\"whiteSpace\" />\n"
398 "<path\n"
399 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
400 "d=\"M 476.95792 339.17168 C 495.78197 342.93607 499.54842 356.11361 495.78197 359.87802 "
401 "C 492.01856 363.6434 482.6065 367.40781 475.07663 361.76014 C 467.54478 "
402 "356.11361 467.54478 342.93607 476.95792 339.17168 z \"\n"
403 "id=\"droplet01\" />\n"
404 "<path\n"
405 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
406 "d=\"M 286.46194 340.42914 C 284.6277 340.91835 269.30405 327.71337 257.16909 333.8338 "
407 "C 245.03722 339.95336 236.89276 353.65666 248.22676 359.27982 C 259.56184 364.90298 "
408 "267.66433 358.41867 277.60113 351.44119 C 287.53903 344.46477 "
409 "287.18046 343.1206 286.46194 340.42914 z \"\n"
410 "id=\"droplet02\" />\n"
411 "<path\n"
412 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
413 "d=\"M 510.35756 306.92856 C 520.59494 304.36879 544.24333 306.92856 540.47688 321.98634 "
414 "C 536.71354 337.04806 504.71297 331.39827 484.00371 323.87156 C 482.12141 "
415 "308.81083 505.53237 308.13423 510.35756 306.92856 z \"\n"
416 "id=\"droplet03\" />\n"
417 "<path\n"
418 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
419 "d=\"M 359.2403 21.362537 C 347.92693 21.362537 336.6347 25.683095 327.96556 34.35223 "
420 "L 173.87387 188.41466 C 165.37697 196.9114 161.1116 207.95813 160.94269 219.04577 "
421 "L 160.88418 219.04577 C 160.88418 219.08524 160.94076 219.12322 160.94269 219.16279 "
422 "C 160.94033 219.34888 160.88418 219.53256 160.88418 219.71865 L 161.14748 219.71865 "
423 "C 164.0966 230.93917 240.29699 245.24198 248.79866 253.74346 C 261.63771 266.58263 "
424 "199.5652 276.01151 212.4041 288.85074 C 225.24316 301.68979 289.99433 313.6933 302.8346 "
425 "326.53254 C 315.67368 339.37161 276.5961 353.04289 289.43532 365.88196 C 302.27439 "
426 "378.72118 345.40201 362.67257 337.5908 396.16198 C 354.92909 413.50026 391.10302 "
427 "405.2208 415.32417 387.88252 C 428.16323 375.04345 390.6948 376.17577 403.53397 "
428 "363.33668 C 416.37304 350.49745 448.78128 350.4282 476.08902 319.71589 C 465.09739 "
429 "302.62116 429.10801 295.34136 441.94719 282.50217 C 454.78625 269.66311 479.74708 "
430 "276.18423 533.60644 251.72479 C 559.89837 239.78398 557.72636 230.71459 557.62567 "
431 "219.71865 C 557.62356 219.48727 557.62567 219.27892 557.62567 219.04577 L 557.56716 "
432 "219.04577 C 557.3983 207.95812 553.10345 196.9114 544.60673 188.41466 L 390.54428 "
433 "34.35223 C 381.87515 25.683095 370.55366 21.362537 359.2403 21.362537 z M 357.92378 "
434 "41.402939 C 362.95327 41.533963 367.01541 45.368018 374.98006 50.530832 L 447.76915 "
435 "104.50827 C 448.56596 105.02498 449.32484 105.564 450.02187 106.11735 C 450.7189 106.67062 "
436 "451.3556 107.25745 451.95277 107.84347 C 452.54997 108.42842 453.09281 109.01553 453.59111 "
437 "109.62808 C 454.08837 110.24052 454.53956 110.86661 454.93688 111.50048 C 455.33532 112.13538 "
438 "455.69164 112.78029 455.9901 113.43137 C 456.28877 114.08363 456.52291 114.75639 456.7215 "
439 "115.42078 C 456.92126 116.08419 457.08982 116.73973 457.18961 117.41019 C 457.28949 "
440 "118.08184 457.33588 118.75535 457.33588 119.42886 L 414.21245 98.598549 L 409.9118 "
441 "131.16055 L 386.18512 120.04324 L 349.55654 144.50131 L 335.54288 96.1703 L 317.4919 "
442 "138.4453 L 267.08369 143.47735 L 267.63956 121.03795 C 267.63956 115.64823 296.69685 "
443 "77.915899 314.39075 68.932902 L 346.77721 45.674327 C 351.55594 42.576634 354.90608 "
444 "41.324327 357.92378 41.402939 z M 290.92738 261.61333 C 313.87149 267.56365 339.40299 "
445 "275.37038 359.88393 275.50997 L 360.76161 284.72563 C 343.2235 282.91785 306.11346 "
446 "274.45012 297.36372 269.98057 L 290.92738 261.61333 z \"\n"
447 "id=\"mountainDroplet\" />\n"
448 "</g> <g transform=\"translate(-20,0)\">\n"
449 "<text xml:space=\"preserve\"\n"
450 "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;"
451 "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;"
452 "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
453 "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n"
454 "x=\"190\" y=\"240\">%s</text></g>\n" //# VALUE HERE
455 "</svg>\n\n";
457 //Fill in the template
458 gchar *xmlBuffer = g_strdup_printf(xformat,
459 previewWidth, previewHeight, _("No preview"));
461 //g_message("%s\n", xmlBuffer);
463 //now show it!
464 setFromMem(xmlBuffer);
465 g_free(xmlBuffer);
466 showingNoPreview = true;
468 }
471 /**
472 * Inform the user that the svg file is too large to be displayed.
473 * This does not check for sizes of embedded images (yet)
474 */
475 void SVGPreview::showTooLarge(long fileLength)
476 {
478 //Arbitrary size of svg doc -- rather 'portrait' shaped
479 gint previewWidth = 300;
480 gint previewHeight = 600;
482 //Our template. Modify to taste
483 gchar const *xformat =
484 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
485 "<svg\n"
486 "xmlns=\"http://www.w3.org/2000/svg\"\n"
487 "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
488 "width=\"%d\" height=\"%d\">\n" //# VALUES HERE
489 "<g transform=\"translate(-170,24.27184)\" style=\"opacity:0.12\">\n"
490 "<path\n"
491 "style=\"font-size:12;fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.936193pt\"\n"
492 "d=\"M 397.64309 320.25301 L 280.39197 282.517 L 250.74227 124.83447 L 345.08225 "
493 "29.146783 L 393.59996 46.667064 L 483.89679 135.61619 L 397.64309 320.25301 z \"\n"
494 "id=\"whiteSpace\" />\n"
495 "<path\n"
496 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
497 "d=\"M 476.95792 339.17168 C 495.78197 342.93607 499.54842 356.11361 495.78197 359.87802 "
498 "C 492.01856 363.6434 482.6065 367.40781 475.07663 361.76014 C 467.54478 "
499 "356.11361 467.54478 342.93607 476.95792 339.17168 z \"\n"
500 "id=\"droplet01\" />\n"
501 "<path\n"
502 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
503 "d=\"M 286.46194 340.42914 C 284.6277 340.91835 269.30405 327.71337 257.16909 333.8338 "
504 "C 245.03722 339.95336 236.89276 353.65666 248.22676 359.27982 C 259.56184 364.90298 "
505 "267.66433 358.41867 277.60113 351.44119 C 287.53903 344.46477 "
506 "287.18046 343.1206 286.46194 340.42914 z \"\n"
507 "id=\"droplet02\" />\n"
508 "<path\n"
509 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
510 "d=\"M 510.35756 306.92856 C 520.59494 304.36879 544.24333 306.92856 540.47688 321.98634 "
511 "C 536.71354 337.04806 504.71297 331.39827 484.00371 323.87156 C 482.12141 "
512 "308.81083 505.53237 308.13423 510.35756 306.92856 z \"\n"
513 "id=\"droplet03\" />\n"
514 "<path\n"
515 "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
516 "d=\"M 359.2403 21.362537 C 347.92693 21.362537 336.6347 25.683095 327.96556 34.35223 "
517 "L 173.87387 188.41466 C 165.37697 196.9114 161.1116 207.95813 160.94269 219.04577 "
518 "L 160.88418 219.04577 C 160.88418 219.08524 160.94076 219.12322 160.94269 219.16279 "
519 "C 160.94033 219.34888 160.88418 219.53256 160.88418 219.71865 L 161.14748 219.71865 "
520 "C 164.0966 230.93917 240.29699 245.24198 248.79866 253.74346 C 261.63771 266.58263 "
521 "199.5652 276.01151 212.4041 288.85074 C 225.24316 301.68979 289.99433 313.6933 302.8346 "
522 "326.53254 C 315.67368 339.37161 276.5961 353.04289 289.43532 365.88196 C 302.27439 "
523 "378.72118 345.40201 362.67257 337.5908 396.16198 C 354.92909 413.50026 391.10302 "
524 "405.2208 415.32417 387.88252 C 428.16323 375.04345 390.6948 376.17577 403.53397 "
525 "363.33668 C 416.37304 350.49745 448.78128 350.4282 476.08902 319.71589 C 465.09739 "
526 "302.62116 429.10801 295.34136 441.94719 282.50217 C 454.78625 269.66311 479.74708 "
527 "276.18423 533.60644 251.72479 C 559.89837 239.78398 557.72636 230.71459 557.62567 "
528 "219.71865 C 557.62356 219.48727 557.62567 219.27892 557.62567 219.04577 L 557.56716 "
529 "219.04577 C 557.3983 207.95812 553.10345 196.9114 544.60673 188.41466 L 390.54428 "
530 "34.35223 C 381.87515 25.683095 370.55366 21.362537 359.2403 21.362537 z M 357.92378 "
531 "41.402939 C 362.95327 41.533963 367.01541 45.368018 374.98006 50.530832 L 447.76915 "
532 "104.50827 C 448.56596 105.02498 449.32484 105.564 450.02187 106.11735 C 450.7189 106.67062 "
533 "451.3556 107.25745 451.95277 107.84347 C 452.54997 108.42842 453.09281 109.01553 453.59111 "
534 "109.62808 C 454.08837 110.24052 454.53956 110.86661 454.93688 111.50048 C 455.33532 112.13538 "
535 "455.69164 112.78029 455.9901 113.43137 C 456.28877 114.08363 456.52291 114.75639 456.7215 "
536 "115.42078 C 456.92126 116.08419 457.08982 116.73973 457.18961 117.41019 C 457.28949 "
537 "118.08184 457.33588 118.75535 457.33588 119.42886 L 414.21245 98.598549 L 409.9118 "
538 "131.16055 L 386.18512 120.04324 L 349.55654 144.50131 L 335.54288 96.1703 L 317.4919 "
539 "138.4453 L 267.08369 143.47735 L 267.63956 121.03795 C 267.63956 115.64823 296.69685 "
540 "77.915899 314.39075 68.932902 L 346.77721 45.674327 C 351.55594 42.576634 354.90608 "
541 "41.324327 357.92378 41.402939 z M 290.92738 261.61333 C 313.87149 267.56365 339.40299 "
542 "275.37038 359.88393 275.50997 L 360.76161 284.72563 C 343.2235 282.91785 306.11346 "
543 "274.45012 297.36372 269.98057 L 290.92738 261.61333 z \"\n"
544 "id=\"mountainDroplet\" />\n"
545 "</g>\n"
546 "<text xml:space=\"preserve\"\n"
547 "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;"
548 "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;"
549 "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
550 "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n"
551 "x=\"170\" y=\"215\">%5.1f MB</text>\n" //# VALUE HERE
552 "<text xml:space=\"preserve\"\n"
553 "style=\"font-size:24.000000;font-style:normal;font-variant:normal;font-weight:bold;"
554 "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;"
555 "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
556 "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n"
557 "x=\"180\" y=\"245\">%s</text>\n" //# VALUE HERE
558 "</svg>\n\n";
560 //Fill in the template
561 double floatFileLength = ((double)fileLength) / 1048576.0;
562 //printf("%ld %f\n", fileLength, floatFileLength);
563 gchar *xmlBuffer = g_strdup_printf(xformat,
564 previewWidth, previewHeight, floatFileLength,
565 _("too large for preview"));
567 //g_message("%s\n", xmlBuffer);
569 //now show it!
570 setFromMem(xmlBuffer);
571 g_free(xmlBuffer);
573 }
576 /**
577 * Return true if the string ends with the given suffix
578 */
579 static bool
580 hasSuffix(Glib::ustring &str, Glib::ustring &ext)
581 {
582 int strLen = str.length();
583 int extLen = ext.length();
584 if (extLen > strLen)
585 return false;
586 int strpos = strLen-1;
587 for (int extpos = extLen-1 ; extpos>=0 ; extpos--, strpos--)
588 {
589 Glib::ustring::value_type ch = str[strpos];
590 if (ch != ext[extpos])
591 {
592 if ( ((ch & 0xff80) != 0) ||
593 static_cast<Glib::ustring::value_type>( g_ascii_tolower( static_cast<gchar>(0x07f & ch) ) ) != ext[extpos] )
594 {
595 return false;
596 }
597 }
598 }
599 return true;
600 }
603 /**
604 * Return true if the image is loadable by Gdk, else false
605 */
606 static bool
607 isValidImageFile(Glib::ustring &fileName)
608 {
609 std::vector<Gdk::PixbufFormat>formats = Gdk::Pixbuf::get_formats();
610 for (unsigned int i=0; i<formats.size(); i++)
611 {
612 Gdk::PixbufFormat format = formats[i];
613 std::vector<Glib::ustring>extensions = format.get_extensions();
614 for (unsigned int j=0; j<extensions.size(); j++)
615 {
616 Glib::ustring ext = extensions[j];
617 if (hasSuffix(fileName, ext))
618 return true;
619 }
620 }
621 return false;
622 }
624 bool SVGPreview::set(Glib::ustring &fileName, int dialogType)
625 {
627 if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS))
628 return false;
630 g_message("fname:%s", fileName.c_str());
632 if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
633 showNoPreview();
634 return false;
635 }
637 if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR))
638 {
639 Glib::ustring fileNameUtf8 = Glib::filename_to_utf8(fileName);
640 gchar *fName = (gchar *)fileNameUtf8.c_str();
641 struct stat info;
642 if (g_stat(fName, &info))
643 {
644 g_warning("SVGPreview::set() : %s : %s",
645 fName, strerror(errno));
646 return FALSE;
647 }
648 long fileLen = info.st_size;
649 if (fileLen > 0x150000L)
650 {
651 showingNoPreview = false;
652 showTooLarge(fileLen);
653 return FALSE;
654 }
655 }
657 Glib::ustring svg = ".svg";
658 Glib::ustring svgz = ".svgz";
660 if ((dialogType == SVG_TYPES || dialogType == IMPORT_TYPES) &&
661 (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz) )
662 ) {
663 bool retval = setFileName(fileName);
664 showingNoPreview = false;
665 return retval;
666 } else if (isValidImageFile(fileName)) {
667 showImage(fileName);
668 showingNoPreview = false;
669 return true;
670 } else {
671 showNoPreview();
672 return false;
673 }
674 }
677 SVGPreview::SVGPreview()
678 {
679 if (!INKSCAPE)
680 inkscape_application_init("",false);
681 document = NULL;
682 viewerGtk = NULL;
683 set_size_request(150,150);
684 showingNoPreview = false;
685 }
687 SVGPreview::~SVGPreview()
688 {
690 }
696 /*#########################################################################
697 ### F I L E D I A L O G B A S E C L A S S
698 #########################################################################*/
700 /**
701 * This class is the base implementation for the others. This
702 * reduces redundancies and bugs.
703 */
704 class FileDialogBase : public Gtk::FileChooserDialog
705 {
706 public:
708 /**
709 *
710 */
711 FileDialogBase(const Glib::ustring &title, FileDialogType type, gchar const* preferenceBase) :
712 Gtk::FileChooserDialog(title),
713 preferenceBase(preferenceBase ? preferenceBase : "unknown"),
714 dialogType(type)
715 {
716 internalSetup();
717 }
719 /**
720 *
721 */
722 FileDialogBase(const Glib::ustring &title,
723 Gtk::FileChooserAction dialogType, FileDialogType type, gchar const* preferenceBase) :
724 Gtk::FileChooserDialog(title, dialogType),
725 preferenceBase(preferenceBase ? preferenceBase : "unknown"),
726 dialogType(type)
727 {
728 internalSetup();
729 }
731 /**
732 *
733 */
734 virtual ~FileDialogBase()
735 {}
737 protected:
738 void cleanup( bool showConfirmed );
740 Glib::ustring preferenceBase;
741 /**
742 * What type of 'open' are we? (open, import, place, etc)
743 */
744 FileDialogType dialogType;
746 /**
747 * Our svg preview widget
748 */
749 SVGPreview svgPreview;
751 //# Child widgets
752 Gtk::CheckButton previewCheckbox;
754 private:
755 void internalSetup();
757 /**
758 * Callback for user changing preview checkbox
759 */
760 void _previewEnabledCB();
762 /**
763 * Callback for seeing if the preview needs to be drawn
764 */
765 void _updatePreviewCallback();
766 };
769 void FileDialogBase::internalSetup()
770 {
771 bool enablePreview =
772 (bool)prefs_get_int_attribute( preferenceBase.c_str(),
773 "enable_preview", 1 );
775 previewCheckbox.set_label( Glib::ustring(_("Enable Preview")) );
776 previewCheckbox.set_active( enablePreview );
778 previewCheckbox.signal_toggled().connect(
779 sigc::mem_fun(*this, &FileDialogBase::_previewEnabledCB) );
781 //Catch selection-changed events, so we can adjust the text widget
782 signal_update_preview().connect(
783 sigc::mem_fun(*this, &FileDialogBase::_updatePreviewCallback) );
785 //###### Add a preview widget
786 set_preview_widget(svgPreview);
787 set_preview_widget_active( enablePreview );
788 set_use_preview_label (false);
790 }
793 void FileDialogBase::cleanup( bool showConfirmed )
794 {
795 if ( showConfirmed )
796 prefs_set_int_attribute( preferenceBase.c_str(),
797 "enable_preview", previewCheckbox.get_active() );
798 }
801 void FileDialogBase::_previewEnabledCB()
802 {
803 bool enabled = previewCheckbox.get_active();
804 set_preview_widget_active(enabled);
805 if ( enabled ) {
806 _updatePreviewCallback();
807 }
808 }
812 /**
813 * Callback for checking if the preview needs to be redrawn
814 */
815 void FileDialogBase::_updatePreviewCallback()
816 {
817 Glib::ustring fileName = get_preview_filename();
819 #ifdef WITH_GNOME_VFS
820 if (fileName.length() < 1)
821 fileName = get_preview_uri();
822 #endif
824 if (fileName.length() < 1)
825 return;
827 svgPreview.set(fileName, dialogType);
828 }
831 /*#########################################################################
832 ### F I L E O P E N
833 #########################################################################*/
835 /**
836 * Our implementation class for the FileOpenDialog interface..
837 */
838 class FileOpenDialogImpl : public FileOpenDialog, public FileDialogBase
839 {
840 public:
842 FileOpenDialogImpl(const Glib::ustring &dir,
843 FileDialogType fileTypes,
844 const Glib::ustring &title);
846 virtual ~FileOpenDialogImpl();
848 bool show();
850 Inkscape::Extension::Extension *getSelectionType();
852 Glib::ustring getFilename();
854 std::vector<Glib::ustring> getFilenames ();
856 private:
858 /**
859 * Create a filter menu for this type of dialog
860 */
861 void createFilterMenu();
863 /**
864 * Filter name->extension lookup
865 */
866 std::map<Glib::ustring, Inkscape::Extension::Extension *> extensionMap;
868 /**
869 * The extension to use to write this file
870 */
871 Inkscape::Extension::Extension *extension;
873 /**
874 * Filename that was given
875 */
876 Glib::ustring myFilename;
878 };
886 void FileOpenDialogImpl::createFilterMenu()
887 {
888 //patterns added dynamically below
889 Gtk::FileFilter allImageFilter;
890 allImageFilter.set_name(_("All Images"));
891 extensionMap[Glib::ustring(_("All Images"))]=NULL;
892 add_filter(allImageFilter);
894 Gtk::FileFilter allFilter;
895 allFilter.set_name(_("All Files"));
896 extensionMap[Glib::ustring(_("All Files"))]=NULL;
897 allFilter.add_pattern("*");
898 add_filter(allFilter);
900 //patterns added dynamically below
901 Gtk::FileFilter allInkscapeFilter;
902 allInkscapeFilter.set_name(_("All Inkscape Files"));
903 extensionMap[Glib::ustring(_("All Inkscape Files"))]=NULL;
904 add_filter(allInkscapeFilter);
906 Inkscape::Extension::DB::InputList extension_list;
907 Inkscape::Extension::db.get_input_list(extension_list);
909 for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin();
910 current_item != extension_list.end(); current_item++)
911 {
912 Inkscape::Extension::Input * imod = *current_item;
914 // FIXME: would be nice to grey them out instead of not listing them
915 if (imod->deactivated()) continue;
917 Glib::ustring upattern("*");
918 Glib::ustring extension = imod->get_extension();
919 fileDialogExtensionToPattern(upattern, extension);
921 Gtk::FileFilter filter;
922 Glib::ustring uname(_(imod->get_filetypename()));
923 filter.set_name(uname);
924 filter.add_pattern(upattern);
925 add_filter(filter);
926 extensionMap[uname] = imod;
928 //g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str());
929 allInkscapeFilter.add_pattern(upattern);
930 if ( strncmp("image", imod->get_mimetype(), 5)==0 )
931 allImageFilter.add_pattern(upattern);
932 }
934 return;
935 }
939 /**
940 * Constructor. Not called directly. Use the factory.
941 */
942 FileOpenDialogImpl::FileOpenDialogImpl(const Glib::ustring &dir,
943 FileDialogType fileTypes,
944 const Glib::ustring &title) :
945 FileDialogBase(title, fileTypes, "dialogs.open")
946 {
949 /* One file at a time */
950 /* And also Multiple Files */
951 set_select_multiple(true);
953 #ifdef WITH_GNOME_VFS
954 set_local_only(false);
955 #endif
957 /* Initalize to Autodetect */
958 extension = NULL;
959 /* No filename to start out with */
960 myFilename = "";
962 /* Set our dialog type (open, import, etc...)*/
963 dialogType = fileTypes;
966 /* Set the pwd and/or the filename */
967 if (dir.size() > 0)
968 {
969 Glib::ustring udir(dir);
970 Glib::ustring::size_type len = udir.length();
971 // leaving a trailing backslash on the directory name leads to the infamous
972 // double-directory bug on win32
973 if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
974 set_current_folder(udir.c_str());
975 }
978 set_extra_widget( previewCheckbox );
981 //###### Add the file types menu
982 createFilterMenu();
985 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
986 set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK));
987 }
993 /**
994 * Public factory. Called by file.cpp, among others.
995 */
996 FileOpenDialog *FileOpenDialog::create(const Glib::ustring &path,
997 FileDialogType fileTypes,
998 const Glib::ustring &title)
999 {
1000 FileOpenDialog *dialog = new FileOpenDialogImpl(path, fileTypes, title);
1001 return dialog;
1002 }
1007 /**
1008 * Destructor
1009 */
1010 FileOpenDialogImpl::~FileOpenDialogImpl()
1011 {
1013 }
1016 /**
1017 * Show this dialog modally. Return true if user hits [OK]
1018 */
1019 bool
1020 FileOpenDialogImpl::show()
1021 {
1022 Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
1023 if (s.length() == 0)
1024 s = getcwd (NULL, 0);
1025 set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
1026 set_modal (TRUE); //Window
1027 sp_transientize((GtkWidget *)gobj()); //Make transient
1028 gint b = run(); //Dialog
1029 svgPreview.showNoPreview();
1030 hide();
1032 if (b == Gtk::RESPONSE_OK)
1033 {
1034 //This is a hack, to avoid the warning messages that
1035 //Gtk::FileChooser::get_filter() returns
1036 //should be: Gtk::FileFilter *filter = get_filter();
1037 GtkFileChooser *gtkFileChooser = Gtk::FileChooser::gobj();
1038 GtkFileFilter *filter = gtk_file_chooser_get_filter(gtkFileChooser);
1039 if (filter)
1040 {
1041 //Get which extension was chosen, if any
1042 extension = extensionMap[gtk_file_filter_get_name(filter)];
1043 }
1044 myFilename = get_filename();
1045 #ifdef WITH_GNOME_VFS
1046 if (myFilename.length() < 1)
1047 myFilename = get_uri();
1048 #endif
1049 cleanup( true );
1050 return TRUE;
1051 }
1052 else
1053 {
1054 cleanup( false );
1055 return FALSE;
1056 }
1057 }
1062 /**
1063 * Get the file extension type that was selected by the user. Valid after an [OK]
1064 */
1065 Inkscape::Extension::Extension *
1066 FileOpenDialogImpl::getSelectionType()
1067 {
1068 return extension;
1069 }
1072 /**
1073 * Get the file name chosen by the user. Valid after an [OK]
1074 */
1075 Glib::ustring
1076 FileOpenDialogImpl::getFilename (void)
1077 {
1078 return g_strdup(myFilename.c_str());
1079 }
1082 /**
1083 * To Get Multiple filenames selected at-once.
1084 */
1085 std::vector<Glib::ustring>FileOpenDialogImpl::getFilenames()
1086 {
1087 std::vector<Glib::ustring> result = get_filenames();
1088 #ifdef WITH_GNOME_VFS
1089 if (result.empty())
1090 result = get_uris();
1091 #endif
1092 return result;
1093 }
1100 //########################################################################
1101 //# F I L E S A V E
1102 //########################################################################
1104 class FileType
1105 {
1106 public:
1107 FileType() {}
1108 ~FileType() {}
1109 Glib::ustring name;
1110 Glib::ustring pattern;
1111 Inkscape::Extension::Extension *extension;
1112 };
1114 /**
1115 * Our implementation of the FileSaveDialog interface.
1116 */
1117 class FileSaveDialogImpl : public FileSaveDialog, public FileDialogBase
1118 {
1120 public:
1121 FileSaveDialogImpl(const Glib::ustring &dir,
1122 FileDialogType fileTypes,
1123 const Glib::ustring &title,
1124 const Glib::ustring &default_key);
1126 virtual ~FileSaveDialogImpl();
1128 bool show();
1130 Inkscape::Extension::Extension *getSelectionType();
1131 virtual void setSelectionType( Inkscape::Extension::Extension * key );
1133 Glib::ustring getFilename();
1135 void change_title(const Glib::ustring& title);
1136 void change_path(const Glib::ustring& path);
1137 void updateNameAndExtension();
1139 private:
1141 /**
1142 * Fix to allow the user to type the file name
1143 */
1144 Gtk::Entry *fileNameEntry;
1147 /**
1148 * Allow the specification of the output file type
1149 */
1150 Gtk::ComboBoxText fileTypeComboBox;
1153 /**
1154 * Data mirror of the combo box
1155 */
1156 std::vector<FileType> fileTypes;
1158 //# Child widgets
1159 Gtk::HBox childBox;
1160 Gtk::VBox checksBox;
1162 Gtk::CheckButton fileTypeCheckbox;
1164 /**
1165 * Callback for user input into fileNameEntry
1166 */
1167 void fileTypeChangedCallback();
1169 /**
1170 * Create a filter menu for this type of dialog
1171 */
1172 void createFileTypeMenu();
1175 /**
1176 * The extension to use to write this file
1177 */
1178 Inkscape::Extension::Extension *extension;
1180 /**
1181 * Callback for user input into fileNameEntry
1182 */
1183 void fileNameEntryChangedCallback();
1185 /**
1186 * Filename that was given
1187 */
1188 Glib::ustring myFilename;
1190 /**
1191 * List of known file extensions.
1192 */
1193 std::set<Glib::ustring> knownExtensions;
1194 };
1199 /**
1200 * Callback for fileNameEntry widget
1201 */
1202 void FileSaveDialogImpl::fileNameEntryChangedCallback()
1203 {
1204 if (!fileNameEntry)
1205 return;
1207 Glib::ustring fileName = fileNameEntry->get_text();
1208 if (!Glib::get_charset()) //If we are not utf8
1209 fileName = Glib::filename_to_utf8(fileName);
1211 //g_message("User hit return. Text is '%s'\n", fileName.c_str());
1213 if (!Glib::path_is_absolute(fileName)) {
1214 //try appending to the current path
1215 // not this way: fileName = get_current_folder() + "/" + fileName;
1216 std::vector<Glib::ustring> pathSegments;
1217 pathSegments.push_back( get_current_folder() );
1218 pathSegments.push_back( fileName );
1219 fileName = Glib::build_filename(pathSegments);
1220 }
1222 //g_message("path:'%s'\n", fileName.c_str());
1224 if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
1225 set_current_folder(fileName);
1226 } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) {
1227 //dialog with either (1) select a regular file or (2) cd to dir
1228 //simulate an 'OK'
1229 set_filename(fileName);
1230 response(Gtk::RESPONSE_OK);
1231 }
1232 }
1236 /**
1237 * Callback for fileNameEntry widget
1238 */
1239 void FileSaveDialogImpl::fileTypeChangedCallback()
1240 {
1241 int sel = fileTypeComboBox.get_active_row_number();
1242 if (sel<0 || sel >= (int)fileTypes.size())
1243 return;
1244 FileType type = fileTypes[sel];
1245 //g_message("selected: %s\n", type.name.c_str());
1247 extension = type.extension;
1248 Gtk::FileFilter filter;
1249 filter.add_pattern(type.pattern);
1250 set_filter(filter);
1252 updateNameAndExtension();
1253 }
1257 void FileSaveDialogImpl::createFileTypeMenu()
1258 {
1259 Inkscape::Extension::DB::OutputList extension_list;
1260 Inkscape::Extension::db.get_output_list(extension_list);
1261 knownExtensions.clear();
1263 for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
1264 current_item != extension_list.end(); current_item++)
1265 {
1266 Inkscape::Extension::Output * omod = *current_item;
1268 // FIXME: would be nice to grey them out instead of not listing them
1269 if (omod->deactivated()) continue;
1271 FileType type;
1272 type.name = (_(omod->get_filetypename()));
1273 type.pattern = "*";
1274 Glib::ustring extension = omod->get_extension();
1275 knownExtensions.insert( extension.casefold() );
1276 fileDialogExtensionToPattern (type.pattern, extension);
1277 type.extension= omod;
1278 fileTypeComboBox.append_text(type.name);
1279 fileTypes.push_back(type);
1280 }
1282 //#Let user choose
1283 FileType guessType;
1284 guessType.name = _("Guess from extension");
1285 guessType.pattern = "*";
1286 guessType.extension = NULL;
1287 fileTypeComboBox.append_text(guessType.name);
1288 fileTypes.push_back(guessType);
1291 fileTypeComboBox.set_active(0);
1292 fileTypeChangedCallback(); //call at least once to set the filter
1293 }
1297 /**
1298 * Constructor
1299 */
1300 FileSaveDialogImpl::FileSaveDialogImpl(const Glib::ustring &dir,
1301 FileDialogType fileTypes,
1302 const Glib::ustring &title,
1303 const Glib::ustring &default_key) :
1304 FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
1305 {
1306 /* One file at a time */
1307 set_select_multiple(false);
1309 #ifdef WITH_GNOME_VFS
1310 set_local_only(false);
1311 #endif
1313 /* Initalize to Autodetect */
1314 extension = NULL;
1315 /* No filename to start out with */
1316 myFilename = "";
1318 /* Set our dialog type (save, export, etc...)*/
1319 dialogType = fileTypes;
1321 /* Set the pwd and/or the filename */
1322 if (dir.size() > 0)
1323 {
1324 Glib::ustring udir(dir);
1325 Glib::ustring::size_type len = udir.length();
1326 // leaving a trailing backslash on the directory name leads to the infamous
1327 // double-directory bug on win32
1328 if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
1329 myFilename = udir;
1330 }
1332 //###### Add the file types menu
1333 //createFilterMenu();
1335 //###### Do we want the .xxx extension automatically added?
1336 fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
1337 fileTypeCheckbox.set_active( (bool)prefs_get_int_attribute("dialogs.save_as",
1338 "append_extension", 1) );
1340 createFileTypeMenu();
1341 fileTypeComboBox.set_size_request(200,40);
1342 fileTypeComboBox.signal_changed().connect(
1343 sigc::mem_fun(*this, &FileSaveDialogImpl::fileTypeChangedCallback) );
1346 childBox.pack_start( checksBox );
1347 childBox.pack_end( fileTypeComboBox );
1348 checksBox.pack_start( fileTypeCheckbox );
1349 checksBox.pack_start( previewCheckbox );
1351 set_extra_widget( childBox );
1353 //Let's do some customization
1354 fileNameEntry = NULL;
1355 Gtk::Container *cont = get_toplevel();
1356 std::vector<Gtk::Entry *> entries;
1357 findEntryWidgets(cont, entries);
1358 //g_message("Found %d entry widgets\n", entries.size());
1359 if (entries.size() >=1 )
1360 {
1361 //Catch when user hits [return] on the text field
1362 fileNameEntry = entries[0];
1363 fileNameEntry->signal_activate().connect(
1364 sigc::mem_fun(*this, &FileSaveDialogImpl::fileNameEntryChangedCallback) );
1365 }
1367 //Let's do more customization
1368 std::vector<Gtk::Expander *> expanders;
1369 findExpanderWidgets(cont, expanders);
1370 //g_message("Found %d expander widgets\n", expanders.size());
1371 if (expanders.size() >=1 )
1372 {
1373 //Always show the file list
1374 Gtk::Expander *expander = expanders[0];
1375 expander->set_expanded(true);
1376 }
1379 //if (extension == NULL)
1380 // checkbox.set_sensitive(FALSE);
1382 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1383 set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK));
1385 show_all_children();
1386 }
1390 /**
1391 * Public factory method. Used in file.cpp
1392 */
1393 FileSaveDialog *FileSaveDialog::create(const Glib::ustring &path,
1394 FileDialogType fileTypes,
1395 const Glib::ustring &title,
1396 const Glib::ustring &default_key)
1397 {
1398 FileSaveDialog *dialog = new FileSaveDialogImpl(path, fileTypes, title, default_key);
1399 return dialog;
1400 }
1406 /**
1407 * Destructor
1408 */
1409 FileSaveDialogImpl::~FileSaveDialogImpl()
1410 {
1411 }
1415 /**
1416 * Show this dialog modally. Return true if user hits [OK]
1417 */
1418 bool
1419 FileSaveDialogImpl::show()
1420 {
1421 change_path(myFilename);
1422 set_modal (TRUE); //Window
1423 sp_transientize((GtkWidget *)gobj()); //Make transient
1424 gint b = run(); //Dialog
1425 svgPreview.showNoPreview();
1426 hide();
1428 if (b == Gtk::RESPONSE_OK)
1429 {
1430 updateNameAndExtension();
1432 // Store changes of the "Append filename automatically" checkbox back to preferences.
1433 prefs_set_int_attribute("dialogs.save_as", "append_extension", fileTypeCheckbox.get_active());
1435 // Store the last used save-as filetype to preferences.
1436 prefs_set_string_attribute("dialogs.save_as", "default",
1437 ( extension != NULL ? extension->get_id() : "" ));
1439 cleanup( true );
1441 return TRUE;
1442 }
1443 else
1444 {
1445 cleanup( false );
1447 return FALSE;
1448 }
1449 }
1452 /**
1453 * Get the file extension type that was selected by the user. Valid after an [OK]
1454 */
1455 Inkscape::Extension::Extension *
1456 FileSaveDialogImpl::getSelectionType()
1457 {
1458 return extension;
1459 }
1461 void FileSaveDialogImpl::setSelectionType( Inkscape::Extension::Extension * key )
1462 {
1463 extension = key;
1465 // If no pointer to extension is passed in, look up based on filename extension.
1466 if ( !extension ) {
1467 // Not quite UTF-8 here.
1468 gchar *filenameLower = g_ascii_strdown(myFilename.c_str(), -1);
1469 for ( int i = 0; !extension && (i < (int)fileTypes.size()); i++ ) {
1470 Inkscape::Extension::Output *ext = dynamic_cast<Inkscape::Extension::Output*>(fileTypes[i].extension);
1471 if ( ext && ext->get_extension() ) {
1472 gchar *extensionLower = g_ascii_strdown( ext->get_extension(), -1 );
1473 if ( g_str_has_suffix(filenameLower, extensionLower) ) {
1474 extension = fileTypes[i].extension;
1475 }
1476 g_free(extensionLower);
1477 }
1478 }
1479 g_free(filenameLower);
1480 }
1482 // Ensure the proper entry in the combo box is selected.
1483 if ( extension ) {
1484 gchar const * extensionID = extension->get_id();
1485 if ( extensionID ) {
1486 for ( int i = 0; i < (int)fileTypes.size(); i++ ) {
1487 Inkscape::Extension::Extension *ext = fileTypes[i].extension;
1488 if ( ext ) {
1489 gchar const * id = ext->get_id();
1490 if ( id && ( strcmp(extensionID, id) == 0) ) {
1491 int oldSel = fileTypeComboBox.get_active_row_number();
1492 if ( i != oldSel ) {
1493 fileTypeComboBox.set_active(i);
1494 }
1495 break;
1496 }
1497 }
1498 }
1499 }
1500 }
1501 }
1504 /**
1505 * Get the file name chosen by the user. Valid after an [OK]
1506 */
1507 Glib::ustring
1508 FileSaveDialogImpl::getFilename()
1509 {
1510 return myFilename;
1511 }
1514 void
1515 FileSaveDialogImpl::change_title(const Glib::ustring& title)
1516 {
1517 this->set_title(title);
1518 }
1520 /**
1521 * Change the default save path location.
1522 */
1523 void
1524 FileSaveDialogImpl::change_path(const Glib::ustring& path)
1525 {
1526 myFilename = path;
1527 if (Glib::file_test(myFilename, Glib::FILE_TEST_IS_DIR)) {
1528 //fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str());
1529 set_current_folder(myFilename);
1530 } else {
1531 //fprintf(stderr,"set_filename(%s)\n",myFilename.c_str());
1532 if ( Glib::file_test( myFilename, Glib::FILE_TEST_EXISTS ) ) {
1533 set_filename(myFilename);
1534 } else {
1535 std::string dirName = Glib::path_get_dirname( myFilename );
1536 if ( dirName != get_current_folder() ) {
1537 set_current_folder(dirName);
1538 }
1539 }
1540 Glib::ustring basename = Glib::path_get_basename(myFilename);
1541 //fprintf(stderr,"set_current_name(%s)\n",basename.c_str());
1542 try {
1543 set_current_name( Glib::filename_to_utf8(basename) );
1544 } catch ( Glib::ConvertError& e ) {
1545 g_warning( "Error converting save filename to UTF-8." );
1546 // try a fallback.
1547 set_current_name( basename );
1548 }
1549 }
1550 }
1552 void FileSaveDialogImpl::updateNameAndExtension()
1553 {
1554 // Pick up any changes the user has typed in.
1555 Glib::ustring tmp = get_filename();
1556 #ifdef WITH_GNOME_VFS
1557 if ( tmp.empty() ) {
1558 tmp = get_uri();
1559 }
1560 #endif
1561 if ( !tmp.empty() ) {
1562 myFilename = tmp;
1563 }
1565 Inkscape::Extension::Output* newOut = extension ? dynamic_cast<Inkscape::Extension::Output*>(extension) : 0;
1566 if ( fileTypeCheckbox.get_active() && newOut ) {
1567 try {
1568 bool appendExtension = true;
1569 Glib::ustring utf8Name = Glib::filename_to_utf8( myFilename );
1570 Glib::ustring::size_type pos = utf8Name.rfind('.');
1571 if ( pos != Glib::ustring::npos ) {
1572 Glib::ustring trail = utf8Name.substr( pos );
1573 Glib::ustring foldedTrail = trail.casefold();
1574 if ( (trail == ".")
1575 | (foldedTrail != Glib::ustring( newOut->get_extension() ).casefold()
1576 && ( knownExtensions.find(foldedTrail) != knownExtensions.end() ) ) ) {
1577 utf8Name = utf8Name.erase( pos );
1578 } else {
1579 appendExtension = false;
1580 }
1581 }
1583 if (appendExtension) {
1584 utf8Name = utf8Name + newOut->get_extension();
1585 myFilename = Glib::filename_from_utf8( utf8Name );
1586 change_path(myFilename);
1587 }
1588 } catch ( Glib::ConvertError& e ) {
1589 // ignore
1590 }
1591 }
1592 }
1596 //########################################################################
1597 //# F I L E E X P O R T
1598 //########################################################################
1601 /**
1602 * Our implementation of the FileExportDialog interface.
1603 */
1604 class FileExportDialogImpl : public FileExportDialog, public FileDialogBase
1605 {
1607 public:
1608 FileExportDialogImpl(const Glib::ustring &dir,
1609 FileDialogType fileTypes,
1610 const Glib::ustring &title,
1611 const Glib::ustring &default_key);
1613 virtual ~FileExportDialogImpl();
1615 bool show();
1617 Inkscape::Extension::Extension *getSelectionType();
1619 Glib::ustring getFilename();
1622 /**
1623 * Return the scope of the export. One of the enumerated types
1624 * in ScopeType
1625 */
1626 ScopeType getScope()
1627 {
1628 if (pageButton.get_active())
1629 return SCOPE_PAGE;
1630 else if (selectionButton.get_active())
1631 return SCOPE_SELECTION;
1632 else if (customButton.get_active())
1633 return SCOPE_CUSTOM;
1634 else
1635 return SCOPE_DOCUMENT;
1637 }
1639 /**
1640 * Return left side of the exported region
1641 */
1642 double getSourceX()
1643 { return sourceX0Spinner.getValue(); }
1645 /**
1646 * Return the top of the exported region
1647 */
1648 double getSourceY()
1649 { return sourceY1Spinner.getValue(); }
1651 /**
1652 * Return the width of the exported region
1653 */
1654 double getSourceWidth()
1655 { return sourceWidthSpinner.getValue(); }
1657 /**
1658 * Return the height of the exported region
1659 */
1660 double getSourceHeight()
1661 { return sourceHeightSpinner.getValue(); }
1663 /**
1664 * Return the units of the coordinates of exported region
1665 */
1666 Glib::ustring getSourceUnits()
1667 { return sourceUnitsSpinner.getUnitAbbr(); }
1669 /**
1670 * Return the width of the destination document
1671 */
1672 double getDestinationWidth()
1673 { return destWidthSpinner.getValue(); }
1675 /**
1676 * Return the height of the destination document
1677 */
1678 double getDestinationHeight()
1679 { return destHeightSpinner.getValue(); }
1681 /**
1682 * Return the height of the exported region
1683 */
1684 Glib::ustring getDestinationUnits()
1685 { return destUnitsSpinner.getUnitAbbr(); }
1687 /**
1688 * Return the destination DPI image resulution, if bitmap
1689 */
1690 double getDestinationDPI()
1691 { return destDPISpinner.getValue(); }
1693 /**
1694 * Return whether we should use Cairo for rendering
1695 */
1696 bool getUseCairo()
1697 { return cairoButton.get_active(); }
1699 /**
1700 * Return whether we should use antialiasing
1701 */
1702 bool getUseAntialias()
1703 { return antiAliasButton.get_active(); }
1705 /**
1706 * Return the background color for exporting
1707 */
1708 unsigned long getBackground()
1709 { return backgroundButton.get_color().get_pixel(); }
1711 private:
1713 /**
1714 * Fix to allow the user to type the file name
1715 */
1716 Gtk::Entry *fileNameEntry;
1718 //##########################################
1719 //# EXTRA WIDGET -- SOURCE SIDE
1720 //##########################################
1722 Gtk::Frame sourceFrame;
1723 Gtk::VBox sourceBox;
1725 Gtk::HBox scopeBox;
1726 Gtk::RadioButtonGroup scopeGroup;
1727 Gtk::RadioButton documentButton;
1728 Gtk::RadioButton pageButton;
1729 Gtk::RadioButton selectionButton;
1730 Gtk::RadioButton customButton;
1732 Gtk::Table sourceTable;
1733 Inkscape::UI::Widget::Scalar sourceX0Spinner;
1734 Inkscape::UI::Widget::Scalar sourceY0Spinner;
1735 Inkscape::UI::Widget::Scalar sourceX1Spinner;
1736 Inkscape::UI::Widget::Scalar sourceY1Spinner;
1737 Inkscape::UI::Widget::Scalar sourceWidthSpinner;
1738 Inkscape::UI::Widget::Scalar sourceHeightSpinner;
1739 Inkscape::UI::Widget::UnitMenu sourceUnitsSpinner;
1742 //##########################################
1743 //# EXTRA WIDGET -- DESTINATION SIDE
1744 //##########################################
1746 Gtk::Frame destFrame;
1747 Gtk::VBox destBox;
1749 Gtk::Table destTable;
1750 Inkscape::UI::Widget::Scalar destWidthSpinner;
1751 Inkscape::UI::Widget::Scalar destHeightSpinner;
1752 Inkscape::UI::Widget::Scalar destDPISpinner;
1753 Inkscape::UI::Widget::UnitMenu destUnitsSpinner;
1755 Gtk::HBox otherOptionBox;
1756 Gtk::CheckButton cairoButton;
1757 Gtk::CheckButton antiAliasButton;
1758 Gtk::ColorButton backgroundButton;
1761 /**
1762 * 'Extra' widget that holds two boxes above
1763 */
1764 Gtk::HBox exportOptionsBox;
1767 //# Child widgets
1768 Gtk::CheckButton fileTypeCheckbox;
1770 /**
1771 * Allow the specification of the output file type
1772 */
1773 Gtk::ComboBoxText fileTypeComboBox;
1776 /**
1777 * Data mirror of the combo box
1778 */
1779 std::vector<FileType> fileTypes;
1783 /**
1784 * Callback for user input into fileNameEntry
1785 */
1786 void fileTypeChangedCallback();
1788 /**
1789 * Create a filter menu for this type of dialog
1790 */
1791 void createFileTypeMenu();
1794 bool append_extension;
1796 /**
1797 * The extension to use to write this file
1798 */
1799 Inkscape::Extension::Extension *extension;
1801 /**
1802 * Callback for user input into fileNameEntry
1803 */
1804 void fileNameEntryChangedCallback();
1806 /**
1807 * Filename that was given
1808 */
1809 Glib::ustring myFilename;
1810 };
1817 /**
1818 * Callback for fileNameEntry widget
1819 */
1820 void FileExportDialogImpl::fileNameEntryChangedCallback()
1821 {
1822 if (!fileNameEntry)
1823 return;
1825 Glib::ustring fileName = fileNameEntry->get_text();
1826 if (!Glib::get_charset()) //If we are not utf8
1827 fileName = Glib::filename_to_utf8(fileName);
1829 //g_message("User hit return. Text is '%s'\n", fileName.c_str());
1831 if (!Glib::path_is_absolute(fileName)) {
1832 //try appending to the current path
1833 // not this way: fileName = get_current_folder() + "/" + fileName;
1834 std::vector<Glib::ustring> pathSegments;
1835 pathSegments.push_back( get_current_folder() );
1836 pathSegments.push_back( fileName );
1837 fileName = Glib::build_filename(pathSegments);
1838 }
1840 //g_message("path:'%s'\n", fileName.c_str());
1842 if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
1843 set_current_folder(fileName);
1844 } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) {
1845 //dialog with either (1) select a regular file or (2) cd to dir
1846 //simulate an 'OK'
1847 set_filename(fileName);
1848 response(Gtk::RESPONSE_OK);
1849 }
1850 }
1854 /**
1855 * Callback for fileNameEntry widget
1856 */
1857 void FileExportDialogImpl::fileTypeChangedCallback()
1858 {
1859 int sel = fileTypeComboBox.get_active_row_number();
1860 if (sel<0 || sel >= (int)fileTypes.size())
1861 return;
1862 FileType type = fileTypes[sel];
1863 //g_message("selected: %s\n", type.name.c_str());
1864 Gtk::FileFilter filter;
1865 filter.add_pattern(type.pattern);
1866 set_filter(filter);
1867 }
1871 void FileExportDialogImpl::createFileTypeMenu()
1872 {
1873 Inkscape::Extension::DB::OutputList extension_list;
1874 Inkscape::Extension::db.get_output_list(extension_list);
1876 for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
1877 current_item != extension_list.end(); current_item++)
1878 {
1879 Inkscape::Extension::Output * omod = *current_item;
1881 // FIXME: would be nice to grey them out instead of not listing them
1882 if (omod->deactivated()) continue;
1884 FileType type;
1885 type.name = (_(omod->get_filetypename()));
1886 type.pattern = "*";
1887 Glib::ustring extension = omod->get_extension();
1888 fileDialogExtensionToPattern (type.pattern, extension);
1889 type.extension= omod;
1890 fileTypeComboBox.append_text(type.name);
1891 fileTypes.push_back(type);
1892 }
1894 //#Let user choose
1895 FileType guessType;
1896 guessType.name = _("Guess from extension");
1897 guessType.pattern = "*";
1898 guessType.extension = NULL;
1899 fileTypeComboBox.append_text(guessType.name);
1900 fileTypes.push_back(guessType);
1903 fileTypeComboBox.set_active(0);
1904 fileTypeChangedCallback(); //call at least once to set the filter
1905 }
1908 /**
1909 * Constructor
1910 */
1911 FileExportDialogImpl::FileExportDialogImpl(const Glib::ustring &dir,
1912 FileDialogType fileTypes,
1913 const Glib::ustring &title,
1914 const Glib::ustring &default_key) :
1915 FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.export"),
1916 sourceX0Spinner("X0", _("Left edge of source")),
1917 sourceY0Spinner("Y0", _("Top edge of source")),
1918 sourceX1Spinner("X1", _("Right edge of source")),
1919 sourceY1Spinner("Y1", _("Bottom edge of source")),
1920 sourceWidthSpinner("Width", _("Source width")),
1921 sourceHeightSpinner("Height", _("Source height")),
1922 destWidthSpinner("Width", _("Destination width")),
1923 destHeightSpinner("Height", _("Destination height")),
1924 destDPISpinner("DPI", _("Resolution (dots per inch)"))
1925 {
1926 append_extension = (bool)prefs_get_int_attribute("dialogs.save_as", "append_extension", 1);
1928 /* One file at a time */
1929 set_select_multiple(false);
1931 #ifdef WITH_GNOME_VFS
1932 set_local_only(false);
1933 #endif
1935 /* Initalize to Autodetect */
1936 extension = NULL;
1937 /* No filename to start out with */
1938 myFilename = "";
1940 /* Set our dialog type (save, export, etc...)*/
1941 dialogType = fileTypes;
1943 /* Set the pwd and/or the filename */
1944 if (dir.size()>0)
1945 {
1946 Glib::ustring udir(dir);
1947 Glib::ustring::size_type len = udir.length();
1948 // leaving a trailing backslash on the directory name leads to the infamous
1949 // double-directory bug on win32
1950 if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
1951 set_current_folder(udir.c_str());
1952 }
1954 //#########################################
1955 //## EXTRA WIDGET -- SOURCE SIDE
1956 //#########################################
1958 //##### Export options buttons/spinners, etc
1959 documentButton.set_label(_("Document"));
1960 scopeBox.pack_start(documentButton);
1961 scopeGroup = documentButton.get_group();
1963 pageButton.set_label(_("Page"));
1964 pageButton.set_group(scopeGroup);
1965 scopeBox.pack_start(pageButton);
1967 selectionButton.set_label(_("Selection"));
1968 selectionButton.set_group(scopeGroup);
1969 scopeBox.pack_start(selectionButton);
1971 customButton.set_label(_("Custom"));
1972 customButton.set_group(scopeGroup);
1973 scopeBox.pack_start(customButton);
1975 sourceBox.pack_start(scopeBox);
1979 //dimension buttons
1980 sourceTable.resize(3,3);
1981 sourceTable.attach(sourceX0Spinner, 0,1,0,1);
1982 sourceTable.attach(sourceY0Spinner, 1,2,0,1);
1983 sourceUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR);
1984 sourceTable.attach(sourceUnitsSpinner, 2,3,0,1);
1985 sourceTable.attach(sourceX1Spinner, 0,1,1,2);
1986 sourceTable.attach(sourceY1Spinner, 1,2,1,2);
1987 sourceTable.attach(sourceWidthSpinner, 0,1,2,3);
1988 sourceTable.attach(sourceHeightSpinner, 1,2,2,3);
1990 sourceBox.pack_start(sourceTable);
1991 sourceFrame.set_label(_("Source"));
1992 sourceFrame.add(sourceBox);
1993 exportOptionsBox.pack_start(sourceFrame);
1996 //#########################################
1997 //## EXTRA WIDGET -- SOURCE SIDE
1998 //#########################################
2001 destTable.resize(3,3);
2002 destTable.attach(destWidthSpinner, 0,1,0,1);
2003 destTable.attach(destHeightSpinner, 1,2,0,1);
2004 destUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR);
2005 destTable.attach(destUnitsSpinner, 2,3,0,1);
2006 destTable.attach(destDPISpinner, 0,1,1,2);
2008 destBox.pack_start(destTable);
2011 cairoButton.set_label(_("Cairo"));
2012 otherOptionBox.pack_start(cairoButton);
2014 antiAliasButton.set_label(_("Antialias"));
2015 otherOptionBox.pack_start(antiAliasButton);
2017 backgroundButton.set_label(_("Background"));
2018 otherOptionBox.pack_start(backgroundButton);
2020 destBox.pack_start(otherOptionBox);
2026 //###### File options
2027 //###### Do we want the .xxx extension automatically added?
2028 fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
2029 fileTypeCheckbox.set_active(append_extension);
2030 destBox.pack_start(fileTypeCheckbox);
2032 //###### File type menu
2033 createFileTypeMenu();
2034 fileTypeComboBox.set_size_request(200,40);
2035 fileTypeComboBox.signal_changed().connect(
2036 sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback) );
2038 destBox.pack_start(fileTypeComboBox);
2040 destFrame.set_label(_("Destination"));
2041 destFrame.add(destBox);
2042 exportOptionsBox.pack_start(destFrame);
2044 //##### Put the two boxes and their parent onto the dialog
2045 exportOptionsBox.pack_start(sourceFrame);
2046 exportOptionsBox.pack_start(destFrame);
2048 set_extra_widget(exportOptionsBox);
2053 //Let's do some customization
2054 fileNameEntry = NULL;
2055 Gtk::Container *cont = get_toplevel();
2056 std::vector<Gtk::Entry *> entries;
2057 findEntryWidgets(cont, entries);
2058 //g_message("Found %d entry widgets\n", entries.size());
2059 if (entries.size() >=1 )
2060 {
2061 //Catch when user hits [return] on the text field
2062 fileNameEntry = entries[0];
2063 fileNameEntry->signal_activate().connect(
2064 sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback) );
2065 }
2067 //Let's do more customization
2068 std::vector<Gtk::Expander *> expanders;
2069 findExpanderWidgets(cont, expanders);
2070 //g_message("Found %d expander widgets\n", expanders.size());
2071 if (expanders.size() >=1 )
2072 {
2073 //Always show the file list
2074 Gtk::Expander *expander = expanders[0];
2075 expander->set_expanded(true);
2076 }
2079 //if (extension == NULL)
2080 // checkbox.set_sensitive(FALSE);
2082 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2083 set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK));
2085 show_all_children();
2086 }
2090 /**
2091 * Public factory method. Used in file.cpp
2092 */
2093 FileExportDialog *FileExportDialog::create(const Glib::ustring &path,
2094 FileDialogType fileTypes,
2095 const Glib::ustring &title,
2096 const Glib::ustring &default_key)
2097 {
2098 FileExportDialog *dialog = new FileExportDialogImpl(path, fileTypes, title, default_key);
2099 return dialog;
2100 }
2106 /**
2107 * Destructor
2108 */
2109 FileExportDialogImpl::~FileExportDialogImpl()
2110 {
2111 }
2115 /**
2116 * Show this dialog modally. Return true if user hits [OK]
2117 */
2118 bool
2119 FileExportDialogImpl::show()
2120 {
2121 Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
2122 if (s.length() == 0)
2123 s = getcwd (NULL, 0);
2124 set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
2125 set_modal (TRUE); //Window
2126 sp_transientize((GtkWidget *)gobj()); //Make transient
2127 gint b = run(); //Dialog
2128 svgPreview.showNoPreview();
2129 hide();
2131 if (b == Gtk::RESPONSE_OK)
2132 {
2133 int sel = fileTypeComboBox.get_active_row_number ();
2134 if (sel>=0 && sel< (int)fileTypes.size())
2135 {
2136 FileType &type = fileTypes[sel];
2137 extension = type.extension;
2138 }
2139 myFilename = get_filename();
2140 #ifdef WITH_GNOME_VFS
2141 if (myFilename.length() < 1)
2142 myFilename = get_uri();
2143 #endif
2145 /*
2147 // FIXME: Why do we have more code
2149 append_extension = checkbox.get_active();
2150 prefs_set_int_attribute("dialogs.save_as", "append_extension", append_extension);
2151 prefs_set_string_attribute("dialogs.save_as", "default",
2152 ( extension != NULL ? extension->get_id() : "" ));
2153 */
2154 return TRUE;
2155 }
2156 else
2157 {
2158 return FALSE;
2159 }
2160 }
2163 /**
2164 * Get the file extension type that was selected by the user. Valid after an [OK]
2165 */
2166 Inkscape::Extension::Extension *
2167 FileExportDialogImpl::getSelectionType()
2168 {
2169 return extension;
2170 }
2173 /**
2174 * Get the file name chosen by the user. Valid after an [OK]
2175 */
2176 Glib::ustring
2177 FileExportDialogImpl::getFilename()
2178 {
2179 return myFilename;
2180 }
2185 } //namespace Dialog
2186 } //namespace UI
2187 } //namespace Inkscape
2190 /*
2191 Local Variables:
2192 mode:c++
2193 c-file-style:"stroustrup"
2194 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2195 indent-tabs-mode:nil
2196 fill-column:99
2197 End:
2198 */
2199 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :