Code

454a356c7aa1faaa28827c36d632e70471b7f39c
[inkscape.git] / src / ui / dialog / filedialog.cpp
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) 2006 Johan Engelen <johan@shouraizou.nl>
9  * Copyright (C) 2004-2006 The Inkscape Organization
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
14 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
20 //Temporary ugly hack
21 //Remove these after the get_filter() calls in
22 //show() on both classes are fixed
23 #include <gtk/gtkfilechooser.h>
25 //Another hack
26 #include <gtk/gtkentry.h>
27 #include <gtk/gtkexpander.h>
29 #include <unistd.h>
30 #include <sys/stat.h>
31 #include <set>
32 #include <glibmm/i18n.h>
33 #include <gtkmm/box.h>
34 #include <gtkmm/colorbutton.h>
35 #include <gtkmm/frame.h>
36 #include <gtkmm/filechooserdialog.h>
37 #include <gtkmm/menubar.h>
38 #include <gtkmm/menu.h>
39 #include <gtkmm/entry.h>
40 #include <gtkmm/expander.h>
41 #include <gtkmm/comboboxtext.h>
42 #include <gtkmm/stock.h>
43 #include <gdkmm/pixbuf.h>
45 #include "prefs-utils.h"
46 #include <dialogs/dialog-events.h>
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 "filedialog.h"
53 #include "gc-core.h"
55 //For export dialog
56 #include "ui/widget/scalar-unit.h"
59 #undef INK_DUMP_FILENAME_CONV
61 #ifdef INK_DUMP_FILENAME_CONV
62 void dump_str( const gchar* str, const gchar* prefix );
63 void dump_ustr( const Glib::ustring& ustr );
64 #endif
66 namespace Inkscape
67 {
68 namespace UI
69 {
70 namespace Dialog
71 {
77 //########################################################################
78 //### U T I L I T Y
79 //########################################################################
81 /**
82     \brief  A quick function to turn a standard extension into a searchable
83             pattern for the file dialogs
84     \param  pattern  The patter that the extension should be written to
85     \param  in_file_extension  The C string that represents the extension
87     This function just goes through the string, and takes all characters
88     and puts a [<upper><lower>] so that both are searched and shown in
89     the file dialog.  This function edits the pattern string to make
90     this happen.
91 */
92 static void
93 fileDialogExtensionToPattern(Glib::ustring &pattern,
94                       Glib::ustring &extension)
95 {
96     for (unsigned int i = 0; i < extension.length(); i++ )
97         {
98         Glib::ustring::value_type ch = extension[i];
99         if ( Glib::Unicode::isalpha(ch) )
100             {
101             pattern += '[';
102             pattern += Glib::Unicode::toupper(ch);
103             pattern += Glib::Unicode::tolower(ch);
104             pattern += ']';
105             }
106         else
107             {
108             pattern += ch;
109             }
110         }
114 /**
115  *  Hack:  Find all entry widgets in a container
116  */
117 static void
118 findEntryWidgets(Gtk::Container *parent,
119                  std::vector<Gtk::Entry *> &result)
121     if (!parent)
122         return;
123     std::vector<Gtk::Widget *> children = parent->get_children();
124     for (unsigned int i=0; i<children.size() ; i++)
125         {
126         Gtk::Widget *child = children[i];
127         GtkWidget *wid = child->gobj();
128         if (GTK_IS_ENTRY(wid))
129            result.push_back((Gtk::Entry *)child);
130         else if (GTK_IS_CONTAINER(wid))
131             findEntryWidgets((Gtk::Container *)child, result);
132         }
139 /**
140  *  Hack:  Find all expander widgets in a container
141  */
142 static void
143 findExpanderWidgets(Gtk::Container *parent,
144                     std::vector<Gtk::Expander *> &result)
146     if (!parent)
147         return;
148     std::vector<Gtk::Widget *> children = parent->get_children();
149     for (unsigned int i=0; i<children.size() ; i++)
150         {
151         Gtk::Widget *child = children[i];
152         GtkWidget *wid = child->gobj();
153         if (GTK_IS_EXPANDER(wid))
154            result.push_back((Gtk::Expander *)child);
155         else if (GTK_IS_CONTAINER(wid))
156             findExpanderWidgets((Gtk::Container *)child, result);
157         }
162 /*#########################################################################
163 ### SVG Preview Widget
164 #########################################################################*/
166 /**
167  * Simple class for displaying an SVG file in the "preview widget."
168  * Currently, this is just a wrapper of the sp_svg_view Gtk widget.
169  * Hopefully we will eventually replace with a pure Gtkmm widget.
170  */
171 class SVGPreview : public Gtk::VBox
173 public:
175     SVGPreview();
177     ~SVGPreview();
179     bool setDocument(SPDocument *doc);
181     bool setFileName(Glib::ustring &fileName);
183     bool setFromMem(char const *xmlBuffer);
185     bool set(Glib::ustring &fileName, int dialogType);
187     bool setURI(URI &uri);
189     /**
190      * Show image embedded in SVG
191      */
192     void showImage(Glib::ustring &fileName);
194     /**
195      * Show the "No preview" image
196      */
197     void showNoPreview();
199     /**
200      * Show the "Too large" image
201      */
202     void showTooLarge(long fileLength);
204 private:
205     /**
206      * The svg document we are currently showing
207      */
208     SPDocument *document;
210     /**
211      * The sp_svg_view widget
212      */
213     GtkWidget *viewerGtk;
215     /**
216      * are we currently showing the "no preview" image?
217      */
218     bool showingNoPreview;
220 };
223 bool SVGPreview::setDocument(SPDocument *doc)
225     if (document)
226         sp_document_unref(document);
228     sp_document_ref(doc);
229     document = doc;
231     //This should remove it from the box, and free resources
232     if (viewerGtk)
233         gtk_widget_destroy(viewerGtk);
235     viewerGtk  = sp_svg_view_widget_new(doc);
236     GtkWidget *vbox = (GtkWidget *)gobj();
237     gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0);
238     gtk_widget_show(viewerGtk);
240     return true;
243 bool SVGPreview::setFileName(Glib::ustring &theFileName)
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;
264 bool SVGPreview::setFromMem(char const *xmlBuffer)
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;
287 void SVGPreview::showImage(Glib::ustring &theFileName)
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"
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"
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);
375 void SVGPreview::showNoPreview()
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"
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"
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;
470 void SVGPreview::showTooLarge(long fileLength)
473     //Arbitrary size of svg doc -- rather 'portrait' shaped
474     gint previewWidth  = 300;
475     gint previewHeight = 600;
477     //Our template.  Modify to taste
478     gchar const *xformat =
479           "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
480           "<svg\n"
481           "xmlns=\"http://www.w3.org/2000/svg\"\n"
482           "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
483           "width=\"%d\" height=\"%d\">\n"
484           "<g transform=\"translate(-170,24.27184)\" style=\"opacity:0.12\">\n"
485           "<path\n"
486           "style=\"font-size:12;fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.936193pt\"\n"
487           "d=\"M 397.64309 320.25301 L 280.39197 282.517 L 250.74227 124.83447 L 345.08225 "
488           "29.146783 L 393.59996 46.667064 L 483.89679 135.61619 L 397.64309 320.25301 z \"\n"
489           "id=\"whiteSpace\" />\n"
490           "<path\n"
491           "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
492           "d=\"M 476.95792 339.17168 C 495.78197 342.93607 499.54842 356.11361 495.78197 359.87802 "
493           "C 492.01856 363.6434 482.6065 367.40781 475.07663 361.76014 C 467.54478 "
494           "356.11361 467.54478 342.93607 476.95792 339.17168 z \"\n"
495           "id=\"droplet01\" />\n"
496           "<path\n"
497           "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
498           "d=\"M 286.46194 340.42914 C 284.6277 340.91835 269.30405 327.71337 257.16909 333.8338 "
499           "C 245.03722 339.95336 236.89276 353.65666 248.22676 359.27982 C 259.56184 364.90298 "
500           "267.66433 358.41867 277.60113 351.44119 C 287.53903 344.46477 "
501           "287.18046 343.1206 286.46194 340.42914 z \"\n"
502           "id=\"droplet02\" />\n"
503           "<path\n"
504           "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
505           "d=\"M 510.35756 306.92856 C 520.59494 304.36879 544.24333 306.92856 540.47688 321.98634 "
506           "C 536.71354 337.04806 504.71297 331.39827 484.00371 323.87156 C 482.12141 "
507           "308.81083 505.53237 308.13423 510.35756 306.92856 z \"\n"
508           "id=\"droplet03\" />\n"
509           "<path\n"
510           "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n"
511           "d=\"M 359.2403 21.362537 C 347.92693 21.362537 336.6347 25.683095 327.96556 34.35223 "
512           "L 173.87387 188.41466 C 165.37697 196.9114 161.1116 207.95813 160.94269 219.04577 "
513           "L 160.88418 219.04577 C 160.88418 219.08524 160.94076 219.12322 160.94269 219.16279 "
514           "C 160.94033 219.34888 160.88418 219.53256 160.88418 219.71865 L 161.14748 219.71865 "
515           "C 164.0966 230.93917 240.29699 245.24198 248.79866 253.74346 C 261.63771 266.58263 "
516           "199.5652 276.01151 212.4041 288.85074 C 225.24316 301.68979 289.99433 313.6933 302.8346 "
517           "326.53254 C 315.67368 339.37161 276.5961 353.04289 289.43532 365.88196 C 302.27439 "
518           "378.72118 345.40201 362.67257 337.5908 396.16198 C 354.92909 413.50026 391.10302 "
519           "405.2208 415.32417 387.88252 C 428.16323 375.04345 390.6948 376.17577 403.53397 "
520           "363.33668 C 416.37304 350.49745 448.78128 350.4282 476.08902 319.71589 C 465.09739 "
521           "302.62116 429.10801 295.34136 441.94719 282.50217 C 454.78625 269.66311 479.74708 "
522           "276.18423 533.60644 251.72479 C 559.89837 239.78398 557.72636 230.71459 557.62567 "
523           "219.71865 C 557.62356 219.48727 557.62567 219.27892 557.62567 219.04577 L 557.56716 "
524           "219.04577 C 557.3983 207.95812 553.10345 196.9114 544.60673 188.41466 L 390.54428 "
525           "34.35223 C 381.87515 25.683095 370.55366 21.362537 359.2403 21.362537 z M 357.92378 "
526           "41.402939 C 362.95327 41.533963 367.01541 45.368018 374.98006 50.530832 L 447.76915 "
527           "104.50827 C 448.56596 105.02498 449.32484 105.564 450.02187 106.11735 C 450.7189 106.67062 "
528           "451.3556 107.25745 451.95277 107.84347 C 452.54997 108.42842 453.09281 109.01553 453.59111 "
529           "109.62808 C 454.08837 110.24052 454.53956 110.86661 454.93688 111.50048 C 455.33532 112.13538 "
530           "455.69164 112.78029 455.9901 113.43137 C 456.28877 114.08363 456.52291 114.75639 456.7215 "
531           "115.42078 C 456.92126 116.08419 457.08982 116.73973 457.18961 117.41019 C 457.28949 "
532           "118.08184 457.33588 118.75535 457.33588 119.42886 L 414.21245 98.598549 L 409.9118 "
533           "131.16055 L 386.18512 120.04324 L 349.55654 144.50131 L 335.54288 96.1703 L 317.4919 "
534           "138.4453 L 267.08369 143.47735 L 267.63956 121.03795 C 267.63956 115.64823 296.69685 "
535           "77.915899 314.39075 68.932902 L 346.77721 45.674327 C 351.55594 42.576634 354.90608 "
536           "41.324327 357.92378 41.402939 z M 290.92738 261.61333 C 313.87149 267.56365 339.40299 "
537           "275.37038 359.88393 275.50997 L 360.76161 284.72563 C 343.2235 282.91785 306.11346 "
538           "274.45012 297.36372 269.98057 L 290.92738 261.61333 z \"\n"
539           "id=\"mountainDroplet\" />\n"
540           "</g>\n"
541           "<text xml:space=\"preserve\"\n"
542           "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;"
543           "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;"
544           "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
545           "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n"
546           "x=\"170\" y=\"215\">%5.1f MB</text>\n"
547           "<text xml:space=\"preserve\"\n"
548           "style=\"font-size:24.000000;font-style:normal;font-variant:normal;font-weight:bold;"
549           "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;"
550           "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;"
551           "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n"
552           "x=\"180\" y=\"245\">%s</text>\n"
553           "</svg>\n\n";
555     //Fill in the template
556     double floatFileLength = ((double)fileLength) / 1048576.0;
557     //printf("%ld %f\n", fileLength, floatFileLength);
558     gchar *xmlBuffer = g_strdup_printf(xformat,
559            previewWidth, previewHeight, floatFileLength,
560            _("too large for preview"));
562     //g_message("%s\n", xmlBuffer);
564     //now show it!
565     setFromMem(xmlBuffer);
566     g_free(xmlBuffer);
571 /**
572  * Return true if the string ends with the given suffix
573  */ 
574 static bool
575 hasSuffix(Glib::ustring &str, Glib::ustring &ext)
577     int strLen = str.length();
578     int extLen = ext.length();
579     if (extLen > strLen)
580         return false;
581     int strpos = strLen-1;
582     for (int extpos = extLen-1 ; extpos>=0 ; extpos--, strpos--)
583         {
584         Glib::ustring::value_type ch = str[strpos];
585         if (ch != ext[extpos])
586             {
587             if ( ((ch & 0xff80) != 0) ||
588                  static_cast<Glib::ustring::value_type>( g_ascii_tolower( static_cast<gchar>(0x07f & ch) ) ) != ext[extpos] )
589                 {
590                 return false;
591                 }
592             }
593         }
594     return true;
598 /**
599  * Return true if the image is loadable by Gdk, else false
600  */
601 static bool
602 isValidImageFile(Glib::ustring &fileName)
604     std::vector<Gdk::PixbufFormat>formats = Gdk::Pixbuf::get_formats();
605     for (unsigned int i=0; i<formats.size(); i++)
606         {
607         Gdk::PixbufFormat format = formats[i];
608         std::vector<Glib::ustring>extensions = format.get_extensions();
609         for (unsigned int j=0; j<extensions.size(); j++)
610             {
611             Glib::ustring ext = extensions[j];
612             if (hasSuffix(fileName, ext))
613                 return true;
614             }
615         }
616     return false;
619 bool SVGPreview::set(Glib::ustring &fileName, int dialogType)
622     if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS))
623         return false;
625     gchar *fName = (gchar *)fileName.c_str();
626     //g_message("fname:%s\n", fName);
628     if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
629         showNoPreview();
630         return false;
631     }
633     if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR))
634         {
635         struct stat info;
636         if (stat(fName, &info))
637             {
638             return FALSE;
639             }
640         long fileLen = info.st_size;
641         if (fileLen > 0x150000L)
642             {
643             showingNoPreview = false;
644             showTooLarge(fileLen);
645             return FALSE;
646             }
647         }
649     Glib::ustring svg = ".svg";
650     Glib::ustring svgz = ".svgz";
652     if ((dialogType == SVG_TYPES || dialogType == IMPORT_TYPES) &&
653            (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz)   )
654         ) {
655         bool retval = setFileName(fileName);
656         showingNoPreview = false;
657         return retval;
658     } else if (isValidImageFile(fileName)) {
659         showImage(fileName);
660         showingNoPreview = false;
661         return true;
662     } else {
663         showNoPreview();
664         return false;
665     }
669 SVGPreview::SVGPreview()
671     if (!INKSCAPE)
672         inkscape_application_init("",false);
673     document = NULL;
674     viewerGtk = NULL;
675     set_size_request(150,150);
676     showingNoPreview = false;
679 SVGPreview::~SVGPreview()
688 /*#########################################################################
689 ### F I L E     D I A L O G    B A S E    C L A S S
690 #########################################################################*/
692 /**
693  * This class is the base implementation for the others.  This
694  * reduces redundancies and bugs.
695  */
696 class FileDialogBase : public Gtk::FileChooserDialog
698 public:
700     /**
701      *
702      */
703     FileDialogBase(const Glib::ustring &title) :
704                         Gtk::FileChooserDialog(title)
705         {
706         }
708     /**
709      *
710      */
711     FileDialogBase(const Glib::ustring &title,
712                    Gtk::FileChooserAction dialogType) :
713                    Gtk::FileChooserDialog(title, dialogType)
714         {
715         }
717     /**
718      *
719      */
720     virtual ~FileDialogBase()
721         {}
723 };
727 /*#########################################################################
728 ### F I L E    O P E N
729 #########################################################################*/
731 /**
732  * Our implementation class for the FileOpenDialog interface..
733  */
734 class FileOpenDialogImpl : public FileOpenDialog, public FileDialogBase
736 public:
738     FileOpenDialogImpl(const Glib::ustring &dir,
739                        FileDialogType fileTypes,
740                        const Glib::ustring &title);
742     virtual ~FileOpenDialogImpl();
744     bool show();
746     Inkscape::Extension::Extension *getSelectionType();
748     Glib::ustring getFilename();
750     std::vector<Glib::ustring> getFilenames ();
752 protected:
756 private:
759     /**
760      * What type of 'open' are we? (open, import, place, etc)
761      */
762     FileDialogType dialogType;
764     /**
765      * Our svg preview widget
766      */
767     SVGPreview svgPreview;
769     /**
770      * Callback for seeing if the preview needs to be drawn
771      */
772     void updatePreviewCallback();
774     /**
775      *  Create a filter menu for this type of dialog
776      */
777     void createFilterMenu();
779     /**
780      * Filter name->extension lookup
781      */
782     std::map<Glib::ustring, Inkscape::Extension::Extension *> extensionMap;
784     /**
785      * The extension to use to write this file
786      */
787     Inkscape::Extension::Extension *extension;
789     /**
790      * Filename that was given
791      */
792     Glib::ustring myFilename;
794 };
800 /**
801  * Callback for checking if the preview needs to be redrawn
802  */
803 void FileOpenDialogImpl::updatePreviewCallback()
805     Glib::ustring fileName = get_preview_filename();
806 #ifdef WITH_GNOME_VFS
807     if (fileName.length() < 1)
808         fileName = get_preview_uri();
809 #endif
810     if (fileName.length() < 1)
811         return;
812     svgPreview.set(fileName, dialogType);
821 void FileOpenDialogImpl::createFilterMenu()
823     //patterns added dynamically below
824     Gtk::FileFilter allImageFilter;
825     allImageFilter.set_name(_("All Images"));
826     extensionMap[Glib::ustring(_("All Images"))]=NULL;
827     add_filter(allImageFilter);
829     Gtk::FileFilter allFilter;
830     allFilter.set_name(_("All Files"));
831     extensionMap[Glib::ustring(_("All Files"))]=NULL;
832     allFilter.add_pattern("*");
833     add_filter(allFilter);
835     //patterns added dynamically below
836     Gtk::FileFilter allInkscapeFilter;
837     allInkscapeFilter.set_name(_("All Inkscape Files"));
838     extensionMap[Glib::ustring(_("All Inkscape Files"))]=NULL;
839     add_filter(allInkscapeFilter);
841     Inkscape::Extension::DB::InputList extension_list;
842     Inkscape::Extension::db.get_input_list(extension_list);
844     for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin();
845          current_item != extension_list.end(); current_item++)
846     {
847         Inkscape::Extension::Input * imod = *current_item;
849         // FIXME: would be nice to grey them out instead of not listing them
850         if (imod->deactivated()) continue;
852         Glib::ustring upattern("*");
853         Glib::ustring extension = imod->get_extension();
854         fileDialogExtensionToPattern(upattern, extension);
856         Gtk::FileFilter filter;
857         Glib::ustring uname(_(imod->get_filetypename()));
858         filter.set_name(uname);
859         filter.add_pattern(upattern);
860         add_filter(filter);
861         extensionMap[uname] = imod;
863         //g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str());
864         allInkscapeFilter.add_pattern(upattern);
865         if ( strncmp("image", imod->get_mimetype(), 5)==0 )
866             allImageFilter.add_pattern(upattern);
867     }
869     return;
874 /**
875  * Constructor.  Not called directly.  Use the factory.
876  */
877 FileOpenDialogImpl::FileOpenDialogImpl(const Glib::ustring &dir,
878                                        FileDialogType fileTypes,
879                                        const Glib::ustring &title) :
880                                        FileDialogBase(title)
884     /* One file at a time */
885     /* And also Multiple Files */
886     set_select_multiple(true);
888 #ifdef WITH_GNOME_VFS
889     set_local_only(false);
890 #endif
892     /* Initalize to Autodetect */
893     extension = NULL;
894     /* No filename to start out with */
895     myFilename = "";
897     /* Set our dialog type (open, import, etc...)*/
898     dialogType = fileTypes;
901     /* Set the pwd and/or the filename */
902     if (dir.size() > 0)
903         {
904         Glib::ustring udir(dir);
905         Glib::ustring::size_type len = udir.length();
906         // leaving a trailing backslash on the directory name leads to the infamous
907         // double-directory bug on win32
908         if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
909         set_current_folder(udir.c_str());
910         }
912     //###### Add the file types menu
913     createFilterMenu();
915     //###### Add a preview widget
916     set_preview_widget(svgPreview);
917     set_preview_widget_active(true);
918     set_use_preview_label (false);
920     //Catch selection-changed events, so we can adjust the text widget
921     signal_update_preview().connect(
922          sigc::mem_fun(*this, &FileOpenDialogImpl::updatePreviewCallback) );
924     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
925     set_default(*add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK));
933 /**
934  * Public factory.  Called by file.cpp, among others.
935  */
936 FileOpenDialog *FileOpenDialog::create(const Glib::ustring &path,
937                                        FileDialogType fileTypes,
938                                        const Glib::ustring &title)
940     FileOpenDialog *dialog = new FileOpenDialogImpl(path, fileTypes, title);
941     return dialog;
947 /**
948  * Destructor
949  */
950 FileOpenDialogImpl::~FileOpenDialogImpl()
956 /**
957  * Show this dialog modally.  Return true if user hits [OK]
958  */
959 bool
960 FileOpenDialogImpl::show()
962     Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
963     if (s.length() == 0) 
964         s = getcwd (NULL, 0);
965     set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
966     set_modal (TRUE);                      //Window
967     sp_transientize((GtkWidget *)gobj());  //Make transient
968     gint b = run();                        //Dialog
969     svgPreview.showNoPreview();
970     hide();
972     if (b == Gtk::RESPONSE_OK)
973         {
974         //This is a hack, to avoid the warning messages that
975         //Gtk::FileChooser::get_filter() returns
976         //should be:  Gtk::FileFilter *filter = get_filter();
977         GtkFileChooser *gtkFileChooser = Gtk::FileChooser::gobj();
978         GtkFileFilter *filter = gtk_file_chooser_get_filter(gtkFileChooser);
979         if (filter)
980             {
981             //Get which extension was chosen, if any
982             extension = extensionMap[gtk_file_filter_get_name(filter)];
983             }
984         myFilename = get_filename();
985 #ifdef WITH_GNOME_VFS
986         if (myFilename.length() < 1)
987             myFilename = get_uri();
988 #endif
989         return TRUE;
990         }
991     else
992        {
993        return FALSE;
994        }
1000 /**
1001  * Get the file extension type that was selected by the user. Valid after an [OK]
1002  */
1003 Inkscape::Extension::Extension *
1004 FileOpenDialogImpl::getSelectionType()
1006     return extension;
1010 /**
1011  * Get the file name chosen by the user.   Valid after an [OK]
1012  */
1013 Glib::ustring
1014 FileOpenDialogImpl::getFilename (void)
1016     return g_strdup(myFilename.c_str());
1020 /**
1021  * To Get Multiple filenames selected at-once.
1022  */
1023 std::vector<Glib::ustring>FileOpenDialogImpl::getFilenames()
1024 {    
1025     std::vector<Glib::ustring> result = get_filenames();
1026 #ifdef WITH_GNOME_VFS
1027     if (result.empty())
1028         result = get_uris();
1029 #endif
1030     return result;
1038 //########################################################################
1039 //# F I L E    S A V E
1040 //########################################################################
1042 class FileType
1044     public:
1045     FileType() {}
1046     ~FileType() {}
1047     Glib::ustring name;
1048     Glib::ustring pattern;
1049     Inkscape::Extension::Extension *extension;
1050 };
1052 /**
1053  * Our implementation of the FileSaveDialog interface.
1054  */
1055 class FileSaveDialogImpl : public FileSaveDialog, public FileDialogBase
1058 public:
1059     FileSaveDialogImpl(const Glib::ustring &dir,
1060                        FileDialogType fileTypes,
1061                        const Glib::ustring &title,
1062                        const Glib::ustring &default_key);
1064     virtual ~FileSaveDialogImpl();
1066     bool show();
1068     Inkscape::Extension::Extension *getSelectionType();
1069     virtual void setSelectionType( Inkscape::Extension::Extension * key );
1071     Glib::ustring getFilename();
1073     void change_title(const Glib::ustring& title);
1074     void change_path(const Glib::ustring& path);
1075     void updateNameAndExtension();
1077 private:
1079     /**
1080      * What type of 'open' are we? (save, export, etc)
1081      */
1082     FileDialogType dialogType;
1084     /**
1085      * Our svg preview widget
1086      */
1087     SVGPreview svgPreview;
1089     /**
1090      * Fix to allow the user to type the file name
1091      */
1092     Gtk::Entry *fileNameEntry;
1094     /**
1095      * Callback for seeing if the preview needs to be drawn
1096      */
1097     void updatePreviewCallback();
1101     /**
1102      * Allow the specification of the output file type
1103      */
1104     Gtk::HBox fileTypeBox;
1106     /**
1107      * Allow the specification of the output file type
1108      */
1109     Gtk::ComboBoxText fileTypeComboBox;
1112     /**
1113      *  Data mirror of the combo box
1114      */
1115     std::vector<FileType> fileTypes;
1117     //# Child widgets
1118     Gtk::CheckButton fileTypeCheckbox;
1120     /**
1121      * Callback for user input into fileNameEntry
1122      */
1123     void fileTypeChangedCallback();
1125     /**
1126      *  Create a filter menu for this type of dialog
1127      */
1128     void createFileTypeMenu();
1131     /**
1132      * The extension to use to write this file
1133      */
1134     Inkscape::Extension::Extension *extension;
1136     /**
1137      * Callback for user input into fileNameEntry
1138      */
1139     void fileNameEntryChangedCallback();
1141     /**
1142      * Filename that was given
1143      */
1144     Glib::ustring myFilename;
1146     /**
1147      * List of known file extensions.
1148      */
1149     std::set<Glib::ustring> knownExtensions;
1150 };
1157 /**
1158  * Callback for checking if the preview needs to be redrawn
1159  */
1160 void FileSaveDialogImpl::updatePreviewCallback()
1162     Glib::ustring fileName = get_preview_filename();
1163 #ifdef WITH_GNOME_VFS
1164     if (fileName.length() < 1)
1165         fileName = get_preview_uri();
1166 #endif
1167     if (!fileName.c_str())
1168         return;
1169     bool retval = svgPreview.set(fileName, dialogType);
1170     set_preview_widget_active(retval);
1175 /**
1176  * Callback for fileNameEntry widget
1177  */
1178 void FileSaveDialogImpl::fileNameEntryChangedCallback()
1180     if (!fileNameEntry)
1181         return;
1183     Glib::ustring fileName = fileNameEntry->get_text();
1184     if (!Glib::get_charset()) //If we are not utf8
1185         fileName = Glib::filename_to_utf8(fileName);
1187     //g_message("User hit return.  Text is '%s'\n", fileName.c_str());
1189     if (!Glib::path_is_absolute(fileName)) {
1190         //try appending to the current path
1191         // not this way: fileName = get_current_folder() + "/" + fileName;
1192         std::vector<Glib::ustring> pathSegments;
1193         pathSegments.push_back( get_current_folder() );
1194         pathSegments.push_back( fileName );
1195         fileName = Glib::build_filename(pathSegments);
1196     }
1198     //g_message("path:'%s'\n", fileName.c_str());
1200     if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
1201         set_current_folder(fileName);
1202     } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) {
1203         //dialog with either (1) select a regular file or (2) cd to dir
1204         //simulate an 'OK'
1205         set_filename(fileName);
1206         response(Gtk::RESPONSE_OK);
1207     }
1212 /**
1213  * Callback for fileNameEntry widget
1214  */
1215 void FileSaveDialogImpl::fileTypeChangedCallback()
1217     int sel = fileTypeComboBox.get_active_row_number();
1218     if (sel<0 || sel >= (int)fileTypes.size())
1219         return;
1220     FileType type = fileTypes[sel];
1221     //g_message("selected: %s\n", type.name.c_str());
1223     extension = type.extension;
1224     Gtk::FileFilter filter;
1225     filter.add_pattern(type.pattern);
1226     set_filter(filter);
1228     updateNameAndExtension();
1233 void FileSaveDialogImpl::createFileTypeMenu()
1235     Inkscape::Extension::DB::OutputList extension_list;
1236     Inkscape::Extension::db.get_output_list(extension_list);
1237     knownExtensions.clear();
1239     for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
1240          current_item != extension_list.end(); current_item++)
1241     {
1242         Inkscape::Extension::Output * omod = *current_item;
1244         // FIXME: would be nice to grey them out instead of not listing them
1245         if (omod->deactivated()) continue;
1247         FileType type;
1248         type.name     = (_(omod->get_filetypename()));
1249         type.pattern  = "*";
1250         Glib::ustring extension = omod->get_extension();
1251         knownExtensions.insert( extension.casefold() );
1252         fileDialogExtensionToPattern (type.pattern, extension);
1253         type.extension= omod;
1254         fileTypeComboBox.append_text(type.name);
1255         fileTypes.push_back(type);
1256     }
1258     //#Let user choose
1259     FileType guessType;
1260     guessType.name = _("Guess from extension");
1261     guessType.pattern = "*";
1262     guessType.extension = NULL;
1263     fileTypeComboBox.append_text(guessType.name);
1264     fileTypes.push_back(guessType);
1267     fileTypeComboBox.set_active(0);
1268     fileTypeChangedCallback(); //call at least once to set the filter
1273 /**
1274  * Constructor
1275  */
1276 FileSaveDialogImpl::FileSaveDialogImpl(const Glib::ustring &dir,
1277             FileDialogType fileTypes,
1278             const Glib::ustring &title,
1279             const Glib::ustring &default_key) :
1280             FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE)
1282     /* One file at a time */
1283     set_select_multiple(false);
1285 #ifdef WITH_GNOME_VFS
1286     set_local_only(false);
1287 #endif
1289     /* Initalize to Autodetect */
1290     extension = NULL;
1291     /* No filename to start out with */
1292     myFilename = "";
1294     /* Set our dialog type (save, export, etc...)*/
1295     dialogType = fileTypes;
1297     /* Set the pwd and/or the filename */
1298     if (dir.size() > 0)
1299         {
1300         Glib::ustring udir(dir);
1301         Glib::ustring::size_type len = udir.length();
1302         // leaving a trailing backslash on the directory name leads to the infamous
1303         // double-directory bug on win32
1304         if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
1305         myFilename = udir;
1306         }
1308     //###### Add the file types menu
1309     //createFilterMenu();
1311     //###### Do we want the .xxx extension automatically added?
1312     fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
1313     fileTypeCheckbox.set_active( (bool)prefs_get_int_attribute("dialogs.save_as",
1314                                                                "append_extension", 1) );
1316     fileTypeBox.pack_start(fileTypeCheckbox);
1317     createFileTypeMenu();
1318     fileTypeComboBox.set_size_request(200,40);
1319     fileTypeComboBox.signal_changed().connect(
1320          sigc::mem_fun(*this, &FileSaveDialogImpl::fileTypeChangedCallback) );
1322     fileTypeBox.pack_start(fileTypeComboBox);
1324     set_extra_widget(fileTypeBox);
1325     //get_vbox()->pack_start(fileTypeBox, false, false, 0);
1326     //get_vbox()->reorder_child(fileTypeBox, 2);
1328     //###### Add a preview widget
1329     set_preview_widget(svgPreview);
1330     set_preview_widget_active(true);
1331     set_use_preview_label (false);
1333     //Catch selection-changed events, so we can adjust the text widget
1334     signal_update_preview().connect(
1335          sigc::mem_fun(*this, &FileSaveDialogImpl::updatePreviewCallback) );
1338     //Let's do some customization
1339     fileNameEntry = NULL;
1340     Gtk::Container *cont = get_toplevel();
1341     std::vector<Gtk::Entry *> entries;
1342     findEntryWidgets(cont, entries);
1343     //g_message("Found %d entry widgets\n", entries.size());
1344     if (entries.size() >=1 )
1345         {
1346         //Catch when user hits [return] on the text field
1347         fileNameEntry = entries[0];
1348         fileNameEntry->signal_activate().connect(
1349              sigc::mem_fun(*this, &FileSaveDialogImpl::fileNameEntryChangedCallback) );
1350         }
1352     //Let's do more customization
1353     std::vector<Gtk::Expander *> expanders;
1354     findExpanderWidgets(cont, expanders);
1355     //g_message("Found %d expander widgets\n", expanders.size());
1356     if (expanders.size() >=1 )
1357         {
1358         //Always show the file list
1359         Gtk::Expander *expander = expanders[0];
1360         expander->set_expanded(true);
1361         }
1364     //if (extension == NULL)
1365     //    checkbox.set_sensitive(FALSE);
1367     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1368     set_default(*add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK));
1370     show_all_children();
1375 /**
1376  * Public factory method.  Used in file.cpp
1377  */
1378 FileSaveDialog *FileSaveDialog::create(const Glib::ustring &path,
1379                                        FileDialogType fileTypes,
1380                                        const Glib::ustring &title,
1381                                        const Glib::ustring &default_key)
1383     FileSaveDialog *dialog = new FileSaveDialogImpl(path, fileTypes, title, default_key);
1384     return dialog;
1391 /**
1392  * Destructor
1393  */
1394 FileSaveDialogImpl::~FileSaveDialogImpl()
1400 /**
1401  * Show this dialog modally.  Return true if user hits [OK]
1402  */
1403 bool
1404 FileSaveDialogImpl::show()
1406     change_path(myFilename);
1407     set_modal (TRUE);                      //Window
1408     sp_transientize((GtkWidget *)gobj());  //Make transient
1409     gint b = run();                        //Dialog
1410     svgPreview.showNoPreview();
1411     hide();
1413     if (b == Gtk::RESPONSE_OK)
1414         {
1415         updateNameAndExtension();
1417         // Store changes of the "Append filename automatically" checkbox back to preferences.
1418         prefs_set_int_attribute("dialogs.save_as", "append_extension", fileTypeCheckbox.get_active());
1420         // Store the last used save-as filetype to preferences.
1421         prefs_set_string_attribute("dialogs.save_as", "default",
1422                                    ( extension != NULL ? extension->get_id() : "" ));
1424         return TRUE;
1425         }
1426     else
1427         {
1428         return FALSE;
1429         }
1433 /**
1434  * Get the file extension type that was selected by the user. Valid after an [OK]
1435  */
1436 Inkscape::Extension::Extension *
1437 FileSaveDialogImpl::getSelectionType()
1439     return extension;
1442 void FileSaveDialogImpl::setSelectionType( Inkscape::Extension::Extension * key )
1444     extension = key;
1446     // If no pointer to extension is passed in, look up based on filename extension.
1447     if ( !extension ) {
1448         // Not quite UTF-8 here.
1449         gchar *filenameLower = g_ascii_strdown(myFilename.c_str(), -1);
1450         for ( int i = 0; !extension && (i < (int)fileTypes.size()); i++ ) {
1451             Inkscape::Extension::Output *ext = dynamic_cast<Inkscape::Extension::Output*>(fileTypes[i].extension);
1452             if ( ext && ext->get_extension() ) {
1453                 gchar *extensionLower = g_ascii_strdown( ext->get_extension(), -1 );
1454                 if ( g_str_has_suffix(filenameLower, extensionLower) ) {
1455                     extension = fileTypes[i].extension;
1456                 }
1457                 g_free(extensionLower);
1458             }
1459         }
1460         g_free(filenameLower);
1461     }
1463     // Ensure the proper entry in the combo box is selected.
1464     if ( extension ) {
1465         gchar const * extensionID = extension->get_id();
1466         if ( extensionID ) {
1467             for ( int i = 0; i < (int)fileTypes.size(); i++ ) {
1468                 Inkscape::Extension::Extension *ext = fileTypes[i].extension;
1469                 if ( ext ) {
1470                     gchar const * id = ext->get_id();
1471                     if ( id && ( strcmp(extensionID, id) == 0) ) {
1472                         int oldSel = fileTypeComboBox.get_active_row_number();
1473                         if ( i != oldSel ) {
1474                             fileTypeComboBox.set_active(i);
1475                         }
1476                         break;
1477                     }
1478                 }
1479             }
1480         }
1481     }
1485 /**
1486  * Get the file name chosen by the user.   Valid after an [OK]
1487  */
1488 Glib::ustring
1489 FileSaveDialogImpl::getFilename()
1491     return myFilename;
1495 void 
1496 FileSaveDialogImpl::change_title(const Glib::ustring& title)
1498     this->set_title(title);
1501 /**
1502   * Change the default save path location.
1503   */
1504 void 
1505 FileSaveDialogImpl::change_path(const Glib::ustring& path)
1507     myFilename = path;
1508     if (Glib::file_test(myFilename, Glib::FILE_TEST_IS_DIR)) {
1509         //fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str());
1510         set_current_folder(myFilename);
1511     } else {
1512         //fprintf(stderr,"set_filename(%s)\n",myFilename.c_str());
1513         if ( Glib::file_test( myFilename, Glib::FILE_TEST_EXISTS ) ) {
1514             set_filename(myFilename);
1515         } else {
1516             std::string dirName = Glib::path_get_dirname( myFilename  );
1517             if ( dirName != get_current_folder() ) {
1518                 set_current_folder(dirName);
1519             }
1520         }
1521         Glib::ustring basename = Glib::path_get_basename(myFilename);
1522         //fprintf(stderr,"set_current_name(%s)\n",basename.c_str());
1523         try {
1524             set_current_name( Glib::filename_to_utf8(basename) );
1525         } catch ( Glib::ConvertError& e ) {
1526             g_warning( "Error converting save filename to UTF-8." );
1527             // try a fallback.
1528             set_current_name( basename );
1529         }
1530     }
1533 void FileSaveDialogImpl::updateNameAndExtension()
1535     // Pick up any changes the user has typed in.
1536     Glib::ustring tmp = get_filename();
1537 #ifdef WITH_GNOME_VFS
1538     if ( tmp.empty() ) {
1539         tmp = get_uri();
1540     }
1541 #endif
1542     if ( !tmp.empty() ) {
1543         myFilename = tmp;
1544     }
1546     Inkscape::Extension::Output* newOut = extension ? dynamic_cast<Inkscape::Extension::Output*>(extension) : 0;
1547     if ( fileTypeCheckbox.get_active() && newOut ) {
1548         try {
1549             bool appendExtension = true;
1550             Glib::ustring utf8Name = Glib::filename_to_utf8( myFilename );
1551             size_t pos = utf8Name.rfind('.');
1552             if ( pos != Glib::ustring::npos ) {
1553                 Glib::ustring trail = utf8Name.substr( pos );
1554                 Glib::ustring foldedTrail = trail.casefold();
1555                 if ( (trail == ".") 
1556                      | (foldedTrail != Glib::ustring( newOut->get_extension() ).casefold()
1557                         && ( knownExtensions.find(foldedTrail) != knownExtensions.end() ) ) ) {
1558                     utf8Name = utf8Name.erase( pos );
1559                 } else {
1560                     appendExtension = false;
1561                 }
1562             }
1564             if (appendExtension) {
1565                 utf8Name = utf8Name + newOut->get_extension();
1566                 myFilename = Glib::filename_from_utf8( utf8Name );
1567                 change_path(myFilename);
1568             }
1569         } catch ( Glib::ConvertError& e ) {
1570             // ignore
1571         }
1572     }
1577 //########################################################################
1578 //# F I L E     E X P O R T
1579 //########################################################################
1582 /**
1583  * Our implementation of the FileExportDialog interface.
1584  */
1585 class FileExportDialogImpl : public FileExportDialog, public FileDialogBase
1588 public:
1589     FileExportDialogImpl(const Glib::ustring &dir,
1590                        FileDialogType fileTypes,
1591                        const Glib::ustring &title,
1592                        const Glib::ustring &default_key);
1594     virtual ~FileExportDialogImpl();
1596     bool show();
1598     Inkscape::Extension::Extension *getSelectionType();
1600     Glib::ustring getFilename();
1603     /**
1604      * Return the scope of the export.  One of the enumerated types
1605      * in ScopeType     
1606      */
1607     ScopeType getScope()
1608         { 
1609         if (pageButton.get_active())
1610             return SCOPE_PAGE;
1611         else if (selectionButton.get_active())
1612             return SCOPE_SELECTION;
1613         else if (customButton.get_active())
1614             return SCOPE_CUSTOM;
1615         else
1616             return SCOPE_DOCUMENT;
1618         }
1619     
1620     /**
1621      * Return left side of the exported region
1622      */
1623     double getSourceX()
1624         { return sourceX0Spinner.getValue(); }
1625     
1626     /**
1627      * Return the top of the exported region
1628      */
1629     double getSourceY()
1630         { return sourceY1Spinner.getValue(); }
1631     
1632     /**
1633      * Return the width of the exported region
1634      */
1635     double getSourceWidth()
1636         { return sourceWidthSpinner.getValue(); }
1637     
1638     /**
1639      * Return the height of the exported region
1640      */
1641     double getSourceHeight()
1642         { return sourceHeightSpinner.getValue(); }
1644     /**
1645      * Return the units of the coordinates of exported region
1646      */
1647     Glib::ustring getSourceUnits()
1648         { return sourceUnitsSpinner.getUnitAbbr(); }
1650     /**
1651      * Return the width of the destination document
1652      */
1653     double getDestinationWidth()
1654         { return destWidthSpinner.getValue(); }
1656     /**
1657      * Return the height of the destination document
1658      */
1659     double getDestinationHeight()
1660         { return destHeightSpinner.getValue(); }
1662     /**
1663      * Return the height of the exported region
1664      */
1665     Glib::ustring getDestinationUnits()
1666         { return destUnitsSpinner.getUnitAbbr(); }
1668     /**
1669      * Return the destination DPI image resulution, if bitmap
1670      */
1671     double getDestinationDPI()
1672         { return destDPISpinner.getValue(); }
1674     /**
1675      * Return whether we should use Cairo for rendering
1676      */
1677     bool getUseCairo()
1678         { return cairoButton.get_active(); }
1680     /**
1681      * Return whether we should use antialiasing
1682      */
1683     bool getUseAntialias()
1684         { return antiAliasButton.get_active(); }
1686     /**
1687      * Return the background color for exporting
1688      */
1689     unsigned long getBackground()
1690         { return backgroundButton.get_color().get_pixel(); }
1692 private:
1694     /**
1695      * What type of 'open' are we? (save, export, etc)
1696      */
1697     FileDialogType dialogType;
1699     /**
1700      * Our svg preview widget
1701      */
1702     SVGPreview svgPreview;
1704     /**
1705      * Fix to allow the user to type the file name
1706      */
1707     Gtk::Entry *fileNameEntry;
1709     /**
1710      * Callback for seeing if the preview needs to be drawn
1711      */
1712     void updatePreviewCallback();
1714     //##########################################
1715     //# EXTRA WIDGET -- SOURCE SIDE
1716     //##########################################
1718     Gtk::Frame            sourceFrame;
1719     Gtk::VBox             sourceBox;
1721     Gtk::HBox             scopeBox;
1722     Gtk::RadioButtonGroup scopeGroup;
1723     Gtk::RadioButton      documentButton;
1724     Gtk::RadioButton      pageButton;
1725     Gtk::RadioButton      selectionButton;
1726     Gtk::RadioButton      customButton;
1728     Gtk::Table                      sourceTable;
1729     Inkscape::UI::Widget::Scalar    sourceX0Spinner;
1730     Inkscape::UI::Widget::Scalar    sourceY0Spinner;
1731     Inkscape::UI::Widget::Scalar    sourceX1Spinner;
1732     Inkscape::UI::Widget::Scalar    sourceY1Spinner;
1733     Inkscape::UI::Widget::Scalar    sourceWidthSpinner;
1734     Inkscape::UI::Widget::Scalar    sourceHeightSpinner;
1735     Inkscape::UI::Widget::UnitMenu  sourceUnitsSpinner;
1738     //##########################################
1739     //# EXTRA WIDGET -- DESTINATION SIDE
1740     //##########################################
1742     Gtk::Frame       destFrame;
1743     Gtk::VBox        destBox;
1745     Gtk::Table                      destTable;
1746     Inkscape::UI::Widget::Scalar    destWidthSpinner;
1747     Inkscape::UI::Widget::Scalar    destHeightSpinner;
1748     Inkscape::UI::Widget::Scalar    destDPISpinner;
1749     Inkscape::UI::Widget::UnitMenu  destUnitsSpinner;
1751     Gtk::HBox        otherOptionBox;
1752     Gtk::CheckButton cairoButton;
1753     Gtk::CheckButton antiAliasButton;
1754     Gtk::ColorButton backgroundButton;
1757     /**
1758      * 'Extra' widget that holds two boxes above
1759      */
1760     Gtk::HBox exportOptionsBox;
1763     //# Child widgets
1764     Gtk::CheckButton fileTypeCheckbox;
1766     /**
1767      * Allow the specification of the output file type
1768      */
1769     Gtk::ComboBoxText fileTypeComboBox;
1772     /**
1773      *  Data mirror of the combo box
1774      */
1775     std::vector<FileType> fileTypes;
1779     /**
1780      * Callback for user input into fileNameEntry
1781      */
1782     void fileTypeChangedCallback();
1784     /**
1785      *  Create a filter menu for this type of dialog
1786      */
1787     void createFileTypeMenu();
1790     bool append_extension;
1792     /**
1793      * The extension to use to write this file
1794      */
1795     Inkscape::Extension::Extension *extension;
1797     /**
1798      * Callback for user input into fileNameEntry
1799      */
1800     void fileNameEntryChangedCallback();
1802     /**
1803      * Filename that was given
1804      */
1805     Glib::ustring myFilename;
1806 };
1813 /**
1814  * Callback for checking if the preview needs to be redrawn
1815  */
1816 void FileExportDialogImpl::updatePreviewCallback()
1818     Glib::ustring fileName = get_preview_filename();
1819 #ifdef WITH_GNOME_VFS
1820     if (fileName.length() < 1)
1821         fileName = get_preview_uri();
1822 #endif
1823     if (!fileName.c_str())
1824         return;
1825     bool retval = svgPreview.set(fileName, dialogType);
1826     set_preview_widget_active(retval);
1831 /**
1832  * Callback for fileNameEntry widget
1833  */
1834 void FileExportDialogImpl::fileNameEntryChangedCallback()
1836     if (!fileNameEntry)
1837         return;
1839     Glib::ustring fileName = fileNameEntry->get_text();
1840     if (!Glib::get_charset()) //If we are not utf8
1841         fileName = Glib::filename_to_utf8(fileName);
1843     //g_message("User hit return.  Text is '%s'\n", fileName.c_str());
1845     if (!Glib::path_is_absolute(fileName)) {
1846         //try appending to the current path
1847         // not this way: fileName = get_current_folder() + "/" + fileName;
1848         std::vector<Glib::ustring> pathSegments;
1849         pathSegments.push_back( get_current_folder() );
1850         pathSegments.push_back( fileName );
1851         fileName = Glib::build_filename(pathSegments);
1852     }
1854     //g_message("path:'%s'\n", fileName.c_str());
1856     if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
1857         set_current_folder(fileName);
1858     } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) {
1859         //dialog with either (1) select a regular file or (2) cd to dir
1860         //simulate an 'OK'
1861         set_filename(fileName);
1862         response(Gtk::RESPONSE_OK);
1863     }
1868 /**
1869  * Callback for fileNameEntry widget
1870  */
1871 void FileExportDialogImpl::fileTypeChangedCallback()
1873     int sel = fileTypeComboBox.get_active_row_number();
1874     if (sel<0 || sel >= (int)fileTypes.size())
1875         return;
1876     FileType type = fileTypes[sel];
1877     //g_message("selected: %s\n", type.name.c_str());
1878     Gtk::FileFilter filter;
1879     filter.add_pattern(type.pattern);
1880     set_filter(filter);
1885 void FileExportDialogImpl::createFileTypeMenu()
1887     Inkscape::Extension::DB::OutputList extension_list;
1888     Inkscape::Extension::db.get_output_list(extension_list);
1890     for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
1891          current_item != extension_list.end(); current_item++)
1892     {
1893         Inkscape::Extension::Output * omod = *current_item;
1895         // FIXME: would be nice to grey them out instead of not listing them
1896         if (omod->deactivated()) continue;
1898         FileType type;
1899         type.name     = (_(omod->get_filetypename()));
1900         type.pattern  = "*";
1901         Glib::ustring extension = omod->get_extension();
1902         fileDialogExtensionToPattern (type.pattern, extension);
1903         type.extension= omod;
1904         fileTypeComboBox.append_text(type.name);
1905         fileTypes.push_back(type);
1906     }
1908     //#Let user choose
1909     FileType guessType;
1910     guessType.name = _("Guess from extension");
1911     guessType.pattern = "*";
1912     guessType.extension = NULL;
1913     fileTypeComboBox.append_text(guessType.name);
1914     fileTypes.push_back(guessType);
1917     fileTypeComboBox.set_active(0);
1918     fileTypeChangedCallback(); //call at least once to set the filter
1922 /**
1923  * Constructor
1924  */
1925 FileExportDialogImpl::FileExportDialogImpl(const Glib::ustring &dir,
1926             FileDialogType fileTypes,
1927             const Glib::ustring &title,
1928             const Glib::ustring &default_key) :
1929             FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE),
1930             sourceX0Spinner("X0",         _("Left edge of source")),
1931             sourceY0Spinner("Y0",         _("Top edge of source")),
1932             sourceX1Spinner("X1",         _("Right edge of source")),
1933             sourceY1Spinner("Y1",         _("Bottom edge of source")),
1934             sourceWidthSpinner("Width",   _("Source width")),
1935             sourceHeightSpinner("Height", _("Source height")),
1936             destWidthSpinner("Width",     _("Destination width")),
1937             destHeightSpinner("Height",   _("Destination height")),
1938             destDPISpinner("DPI",         _("Resolution (dots per inch)"))
1940     append_extension = (bool)prefs_get_int_attribute("dialogs.save_as", "append_extension", 1);
1942     /* One file at a time */
1943     set_select_multiple(false);
1945 #ifdef WITH_GNOME_VFS
1946     set_local_only(false);
1947 #endif
1949     /* Initalize to Autodetect */
1950     extension = NULL;
1951     /* No filename to start out with */
1952     myFilename = "";
1954     /* Set our dialog type (save, export, etc...)*/
1955     dialogType = fileTypes;
1957     /* Set the pwd and/or the filename */
1958     if (dir.size()>0)
1959         {
1960         Glib::ustring udir(dir);
1961         Glib::ustring::size_type len = udir.length();
1962         // leaving a trailing backslash on the directory name leads to the infamous
1963         // double-directory bug on win32
1964         if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
1965         set_current_folder(udir.c_str());
1966         }
1968     //#########################################
1969     //## EXTRA WIDGET -- SOURCE SIDE
1970     //#########################################
1972     //##### Export options buttons/spinners, etc
1973     documentButton.set_label(_("Document"));
1974     scopeBox.pack_start(documentButton);
1975     scopeGroup = documentButton.get_group();
1977     pageButton.set_label(_("Page"));
1978     pageButton.set_group(scopeGroup);
1979     scopeBox.pack_start(pageButton);
1981     selectionButton.set_label(_("Selection"));
1982     selectionButton.set_group(scopeGroup);
1983     scopeBox.pack_start(selectionButton);
1985     customButton.set_label(_("Custom"));
1986     customButton.set_group(scopeGroup);
1987     scopeBox.pack_start(customButton);
1989     sourceBox.pack_start(scopeBox);
1993     //dimension buttons
1994     sourceTable.resize(3,3);
1995     sourceTable.attach(sourceX0Spinner,     0,1,0,1);
1996     sourceTable.attach(sourceY0Spinner,     1,2,0,1);
1997     sourceUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR);
1998     sourceTable.attach(sourceUnitsSpinner,  2,3,0,1);
1999     sourceTable.attach(sourceX1Spinner,     0,1,1,2);
2000     sourceTable.attach(sourceY1Spinner,     1,2,1,2);
2001     sourceTable.attach(sourceWidthSpinner,  0,1,2,3);
2002     sourceTable.attach(sourceHeightSpinner, 1,2,2,3);
2004     sourceBox.pack_start(sourceTable);
2005     sourceFrame.set_label(_("Source"));
2006     sourceFrame.add(sourceBox);
2007     exportOptionsBox.pack_start(sourceFrame);
2010     //#########################################
2011     //## EXTRA WIDGET -- SOURCE SIDE
2012     //#########################################
2015     destTable.resize(3,3);
2016     destTable.attach(destWidthSpinner,    0,1,0,1);
2017     destTable.attach(destHeightSpinner,   1,2,0,1);
2018     destUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR);
2019     destTable.attach(destUnitsSpinner,    2,3,0,1);
2020     destTable.attach(destDPISpinner,      0,1,1,2);
2022     destBox.pack_start(destTable);
2025     cairoButton.set_label(_("Cairo"));
2026     otherOptionBox.pack_start(cairoButton);
2028     antiAliasButton.set_label(_("Antialias"));
2029     otherOptionBox.pack_start(antiAliasButton);
2031     backgroundButton.set_label(_("Background"));
2032     otherOptionBox.pack_start(backgroundButton);
2034     destBox.pack_start(otherOptionBox);
2040     //###### File options
2041     //###### Do we want the .xxx extension automatically added?
2042     fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
2043     fileTypeCheckbox.set_active(append_extension);
2044     destBox.pack_start(fileTypeCheckbox);
2046     //###### File type menu
2047     createFileTypeMenu();
2048     fileTypeComboBox.set_size_request(200,40);
2049     fileTypeComboBox.signal_changed().connect(
2050          sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback) );
2052     destBox.pack_start(fileTypeComboBox);
2054     destFrame.set_label(_("Destination"));
2055     destFrame.add(destBox);
2056     exportOptionsBox.pack_start(destFrame);
2058     //##### Put the two boxes and their parent onto the dialog    
2059     exportOptionsBox.pack_start(sourceFrame);
2060     exportOptionsBox.pack_start(destFrame);
2062     set_extra_widget(exportOptionsBox);
2067     //###### PREVIEW WIDGET
2068     set_preview_widget(svgPreview);
2069     set_preview_widget_active(true);
2070     set_use_preview_label (false);
2072     //Catch selection-changed events, so we can adjust the text widget
2073     signal_update_preview().connect(
2074          sigc::mem_fun(*this, &FileExportDialogImpl::updatePreviewCallback) );
2077     //Let's do some customization
2078     fileNameEntry = NULL;
2079     Gtk::Container *cont = get_toplevel();
2080     std::vector<Gtk::Entry *> entries;
2081     findEntryWidgets(cont, entries);
2082     //g_message("Found %d entry widgets\n", entries.size());
2083     if (entries.size() >=1 )
2084         {
2085         //Catch when user hits [return] on the text field
2086         fileNameEntry = entries[0];
2087         fileNameEntry->signal_activate().connect(
2088              sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback) );
2089         }
2091     //Let's do more customization
2092     std::vector<Gtk::Expander *> expanders;
2093     findExpanderWidgets(cont, expanders);
2094     //g_message("Found %d expander widgets\n", expanders.size());
2095     if (expanders.size() >=1 )
2096         {
2097         //Always show the file list
2098         Gtk::Expander *expander = expanders[0];
2099         expander->set_expanded(true);
2100         }
2103     //if (extension == NULL)
2104     //    checkbox.set_sensitive(FALSE);
2106     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2107     set_default(*add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK));
2109     show_all_children();
2114 /**
2115  * Public factory method.  Used in file.cpp
2116  */
2117 FileExportDialog *FileExportDialog::create(const Glib::ustring &path,
2118                                        FileDialogType fileTypes,
2119                                        const Glib::ustring &title,
2120                                        const Glib::ustring &default_key)
2122     FileExportDialog *dialog = new FileExportDialogImpl(path, fileTypes, title, default_key);
2123     return dialog;
2130 /**
2131  * Destructor
2132  */
2133 FileExportDialogImpl::~FileExportDialogImpl()
2139 /**
2140  * Show this dialog modally.  Return true if user hits [OK]
2141  */
2142 bool
2143 FileExportDialogImpl::show()
2145     Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
2146     if (s.length() == 0) 
2147         s = getcwd (NULL, 0);
2148     set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
2149     set_modal (TRUE);                      //Window
2150     sp_transientize((GtkWidget *)gobj());  //Make transient
2151     gint b = run();                        //Dialog
2152     svgPreview.showNoPreview();
2153     hide();
2155     if (b == Gtk::RESPONSE_OK)
2156         {
2157         int sel = fileTypeComboBox.get_active_row_number ();
2158         if (sel>=0 && sel< (int)fileTypes.size())
2159             {
2160             FileType &type = fileTypes[sel];
2161             extension = type.extension;
2162             }
2163         myFilename = get_filename();
2164 #ifdef WITH_GNOME_VFS
2165         if (myFilename.length() < 1)
2166             myFilename = get_uri();
2167 #endif
2169         /*
2171         // FIXME: Why do we have more code
2173         append_extension = checkbox.get_active();
2174         prefs_set_int_attribute("dialogs.save_as", "append_extension", append_extension);
2175         prefs_set_string_attribute("dialogs.save_as", "default",
2176                   ( extension != NULL ? extension->get_id() : "" ));
2177         */
2178         return TRUE;
2179         }
2180     else
2181         {
2182         return FALSE;
2183         }
2187 /**
2188  * Get the file extension type that was selected by the user. Valid after an [OK]
2189  */
2190 Inkscape::Extension::Extension *
2191 FileExportDialogImpl::getSelectionType()
2193     return extension;
2197 /**
2198  * Get the file name chosen by the user.   Valid after an [OK]
2199  */
2200 Glib::ustring
2201 FileExportDialogImpl::getFilename()
2203     return myFilename;
2209 } //namespace Dialog
2210 } //namespace UI
2211 } //namespace Inkscape
2214 /*
2215   Local Variables:
2216   mode:c++
2217   c-file-style:"stroustrup"
2218   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2219   indent-tabs-mode:nil
2220   fill-column:99
2221   End:
2222 */
2223 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :