Code

0cdd49477ef32b9cf9474333e3ac8c541d698080
[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, FileDialogType type, gchar const* preferenceBase) :
704         Gtk::FileChooserDialog(title),
705         preferenceBase(preferenceBase ? preferenceBase : "unknown"),
706         dialogType(type)
707     {
708         internalSetup();
709     }
711     /**
712      *
713      */
714     FileDialogBase(const Glib::ustring &title,
715                    Gtk::FileChooserAction dialogType, FileDialogType type, gchar const* preferenceBase) :
716         Gtk::FileChooserDialog(title, dialogType),
717         preferenceBase(preferenceBase ? preferenceBase : "unknown"),
718         dialogType(type)
719     {
720         internalSetup();
721     }
723     /**
724      *
725      */
726     virtual ~FileDialogBase()
727         {}
729 protected:
730     void cleanup( bool showConfirmed );
732     Glib::ustring preferenceBase;
733     /**
734      * What type of 'open' are we? (open, import, place, etc)
735      */
736     FileDialogType dialogType;
738     /**
739      * Our svg preview widget
740      */
741     SVGPreview svgPreview;
743     //# Child widgets
744     Gtk::CheckButton previewCheckbox;
746 private:
747     void internalSetup();
749     /**
750      * Callback for user changing preview checkbox
751      */
752     void _previewEnabledCB();
754     /**
755      * Callback for seeing if the preview needs to be drawn
756      */
757     void _updatePreviewCallback();
758 };
761 void FileDialogBase::internalSetup()
763     bool enablePreview = (bool)prefs_get_int_attribute( preferenceBase.c_str(), "enable_preview", 1 );
764     previewCheckbox.set_label( Glib::ustring(_("Enable Preview")) );
765     previewCheckbox.set_active( enablePreview );
767     previewCheckbox.signal_toggled().connect(
768         sigc::mem_fun(*this, &FileDialogBase::_previewEnabledCB) );
770     //Catch selection-changed events, so we can adjust the text widget
771     signal_update_preview().connect(
772          sigc::mem_fun(*this, &FileDialogBase::_updatePreviewCallback) );
774     //###### Add a preview widget
775     set_preview_widget(svgPreview);
776     set_preview_widget_active( enablePreview );
777     set_use_preview_label (false);
781 void FileDialogBase::cleanup( bool showConfirmed )
783     if ( showConfirmed ) {
784         prefs_set_int_attribute( preferenceBase.c_str(), "enable_preview", previewCheckbox.get_active() );
785     }
788 void FileDialogBase::_previewEnabledCB()
790     bool enabled = previewCheckbox.get_active();
791     set_preview_widget_active(enabled);
792     if ( enabled ) {
793         _updatePreviewCallback();
794     }
798 /**
799  * Callback for checking if the preview needs to be redrawn
800  */
801 void FileDialogBase::_updatePreviewCallback()
803     Glib::ustring fileName = get_preview_filename();
804 #ifdef WITH_GNOME_VFS
805     if (fileName.length() < 1)
806         fileName = get_preview_uri();
807 #endif
809     if (fileName.length() < 1)
810         return;
812     svgPreview.set(fileName, dialogType);
813 //         bool retval = svgPreview.set(fileName, dialogType);
814 //         set_preview_widget_active(retval);
818 /*#########################################################################
819 ### F I L E    O P E N
820 #########################################################################*/
822 /**
823  * Our implementation class for the FileOpenDialog interface..
824  */
825 class FileOpenDialogImpl : public FileOpenDialog, public FileDialogBase
827 public:
829     FileOpenDialogImpl(const Glib::ustring &dir,
830                        FileDialogType fileTypes,
831                        const Glib::ustring &title);
833     virtual ~FileOpenDialogImpl();
835     bool show();
837     Inkscape::Extension::Extension *getSelectionType();
839     Glib::ustring getFilename();
841     std::vector<Glib::ustring> getFilenames ();
843 private:
845     /**
846      *  Create a filter menu for this type of dialog
847      */
848     void createFilterMenu();
850     /**
851      * Filter name->extension lookup
852      */
853     std::map<Glib::ustring, Inkscape::Extension::Extension *> extensionMap;
855     /**
856      * The extension to use to write this file
857      */
858     Inkscape::Extension::Extension *extension;
860     /**
861      * Filename that was given
862      */
863     Glib::ustring myFilename;
865 };
873 void FileOpenDialogImpl::createFilterMenu()
875     //patterns added dynamically below
876     Gtk::FileFilter allImageFilter;
877     allImageFilter.set_name(_("All Images"));
878     extensionMap[Glib::ustring(_("All Images"))]=NULL;
879     add_filter(allImageFilter);
881     Gtk::FileFilter allFilter;
882     allFilter.set_name(_("All Files"));
883     extensionMap[Glib::ustring(_("All Files"))]=NULL;
884     allFilter.add_pattern("*");
885     add_filter(allFilter);
887     //patterns added dynamically below
888     Gtk::FileFilter allInkscapeFilter;
889     allInkscapeFilter.set_name(_("All Inkscape Files"));
890     extensionMap[Glib::ustring(_("All Inkscape Files"))]=NULL;
891     add_filter(allInkscapeFilter);
893     Inkscape::Extension::DB::InputList extension_list;
894     Inkscape::Extension::db.get_input_list(extension_list);
896     for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin();
897          current_item != extension_list.end(); current_item++)
898     {
899         Inkscape::Extension::Input * imod = *current_item;
901         // FIXME: would be nice to grey them out instead of not listing them
902         if (imod->deactivated()) continue;
904         Glib::ustring upattern("*");
905         Glib::ustring extension = imod->get_extension();
906         fileDialogExtensionToPattern(upattern, extension);
908         Gtk::FileFilter filter;
909         Glib::ustring uname(_(imod->get_filetypename()));
910         filter.set_name(uname);
911         filter.add_pattern(upattern);
912         add_filter(filter);
913         extensionMap[uname] = imod;
915         //g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str());
916         allInkscapeFilter.add_pattern(upattern);
917         if ( strncmp("image", imod->get_mimetype(), 5)==0 )
918             allImageFilter.add_pattern(upattern);
919     }
921     return;
926 /**
927  * Constructor.  Not called directly.  Use the factory.
928  */
929 FileOpenDialogImpl::FileOpenDialogImpl(const Glib::ustring &dir,
930                                        FileDialogType fileTypes,
931                                        const Glib::ustring &title) :
932     FileDialogBase(title, fileTypes, "dialogs.open")
936     /* One file at a time */
937     /* And also Multiple Files */
938     set_select_multiple(true);
940 #ifdef WITH_GNOME_VFS
941     set_local_only(false);
942 #endif
944     /* Initalize to Autodetect */
945     extension = NULL;
946     /* No filename to start out with */
947     myFilename = "";
949     /* Set our dialog type (open, import, etc...)*/
950     dialogType = fileTypes;
953     /* Set the pwd and/or the filename */
954     if (dir.size() > 0)
955         {
956         Glib::ustring udir(dir);
957         Glib::ustring::size_type len = udir.length();
958         // leaving a trailing backslash on the directory name leads to the infamous
959         // double-directory bug on win32
960         if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
961         set_current_folder(udir.c_str());
962         }
965     set_extra_widget( previewCheckbox );
968     //###### Add the file types menu
969     createFilterMenu();
972     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
973     set_default(*add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK));
980 /**
981  * Public factory.  Called by file.cpp, among others.
982  */
983 FileOpenDialog *FileOpenDialog::create(const Glib::ustring &path,
984                                        FileDialogType fileTypes,
985                                        const Glib::ustring &title)
987     FileOpenDialog *dialog = new FileOpenDialogImpl(path, fileTypes, title);
988     return dialog;
994 /**
995  * Destructor
996  */
997 FileOpenDialogImpl::~FileOpenDialogImpl()
1003 /**
1004  * Show this dialog modally.  Return true if user hits [OK]
1005  */
1006 bool
1007 FileOpenDialogImpl::show()
1009     Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
1010     if (s.length() == 0) 
1011         s = getcwd (NULL, 0);
1012     set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
1013     set_modal (TRUE);                      //Window
1014     sp_transientize((GtkWidget *)gobj());  //Make transient
1015     gint b = run();                        //Dialog
1016     svgPreview.showNoPreview();
1017     hide();
1019     if (b == Gtk::RESPONSE_OK)
1020         {
1021         //This is a hack, to avoid the warning messages that
1022         //Gtk::FileChooser::get_filter() returns
1023         //should be:  Gtk::FileFilter *filter = get_filter();
1024         GtkFileChooser *gtkFileChooser = Gtk::FileChooser::gobj();
1025         GtkFileFilter *filter = gtk_file_chooser_get_filter(gtkFileChooser);
1026         if (filter)
1027             {
1028             //Get which extension was chosen, if any
1029             extension = extensionMap[gtk_file_filter_get_name(filter)];
1030             }
1031         myFilename = get_filename();
1032 #ifdef WITH_GNOME_VFS
1033         if (myFilename.length() < 1)
1034             myFilename = get_uri();
1035 #endif
1036         cleanup( true );
1037         return TRUE;
1038         }
1039     else
1040        {
1041        cleanup( false );
1042        return FALSE;
1043        }
1049 /**
1050  * Get the file extension type that was selected by the user. Valid after an [OK]
1051  */
1052 Inkscape::Extension::Extension *
1053 FileOpenDialogImpl::getSelectionType()
1055     return extension;
1059 /**
1060  * Get the file name chosen by the user.   Valid after an [OK]
1061  */
1062 Glib::ustring
1063 FileOpenDialogImpl::getFilename (void)
1065     return g_strdup(myFilename.c_str());
1069 /**
1070  * To Get Multiple filenames selected at-once.
1071  */
1072 std::vector<Glib::ustring>FileOpenDialogImpl::getFilenames()
1073 {    
1074     std::vector<Glib::ustring> result = get_filenames();
1075 #ifdef WITH_GNOME_VFS
1076     if (result.empty())
1077         result = get_uris();
1078 #endif
1079     return result;
1087 //########################################################################
1088 //# F I L E    S A V E
1089 //########################################################################
1091 class FileType
1093     public:
1094     FileType() {}
1095     ~FileType() {}
1096     Glib::ustring name;
1097     Glib::ustring pattern;
1098     Inkscape::Extension::Extension *extension;
1099 };
1101 /**
1102  * Our implementation of the FileSaveDialog interface.
1103  */
1104 class FileSaveDialogImpl : public FileSaveDialog, public FileDialogBase
1107 public:
1108     FileSaveDialogImpl(const Glib::ustring &dir,
1109                        FileDialogType fileTypes,
1110                        const Glib::ustring &title,
1111                        const Glib::ustring &default_key);
1113     virtual ~FileSaveDialogImpl();
1115     bool show();
1117     Inkscape::Extension::Extension *getSelectionType();
1118     virtual void setSelectionType( Inkscape::Extension::Extension * key );
1120     Glib::ustring getFilename();
1122     void change_title(const Glib::ustring& title);
1123     void change_path(const Glib::ustring& path);
1124     void updateNameAndExtension();
1126 private:
1128     /**
1129      * Fix to allow the user to type the file name
1130      */
1131     Gtk::Entry *fileNameEntry;
1134     /**
1135      * Allow the specification of the output file type
1136      */
1137     Gtk::ComboBoxText fileTypeComboBox;
1140     /**
1141      *  Data mirror of the combo box
1142      */
1143     std::vector<FileType> fileTypes;
1145     //# Child widgets
1146     Gtk::HBox childBox;
1147     Gtk::VBox checksBox;
1149     Gtk::CheckButton fileTypeCheckbox;
1151     /**
1152      * Callback for user input into fileNameEntry
1153      */
1154     void fileTypeChangedCallback();
1156     /**
1157      *  Create a filter menu for this type of dialog
1158      */
1159     void createFileTypeMenu();
1162     /**
1163      * The extension to use to write this file
1164      */
1165     Inkscape::Extension::Extension *extension;
1167     /**
1168      * Callback for user input into fileNameEntry
1169      */
1170     void fileNameEntryChangedCallback();
1172     /**
1173      * Filename that was given
1174      */
1175     Glib::ustring myFilename;
1177     /**
1178      * List of known file extensions.
1179      */
1180     std::set<Glib::ustring> knownExtensions;
1181 };
1186 /**
1187  * Callback for fileNameEntry widget
1188  */
1189 void FileSaveDialogImpl::fileNameEntryChangedCallback()
1191     if (!fileNameEntry)
1192         return;
1194     Glib::ustring fileName = fileNameEntry->get_text();
1195     if (!Glib::get_charset()) //If we are not utf8
1196         fileName = Glib::filename_to_utf8(fileName);
1198     //g_message("User hit return.  Text is '%s'\n", fileName.c_str());
1200     if (!Glib::path_is_absolute(fileName)) {
1201         //try appending to the current path
1202         // not this way: fileName = get_current_folder() + "/" + fileName;
1203         std::vector<Glib::ustring> pathSegments;
1204         pathSegments.push_back( get_current_folder() );
1205         pathSegments.push_back( fileName );
1206         fileName = Glib::build_filename(pathSegments);
1207     }
1209     //g_message("path:'%s'\n", fileName.c_str());
1211     if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
1212         set_current_folder(fileName);
1213     } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) {
1214         //dialog with either (1) select a regular file or (2) cd to dir
1215         //simulate an 'OK'
1216         set_filename(fileName);
1217         response(Gtk::RESPONSE_OK);
1218     }
1223 /**
1224  * Callback for fileNameEntry widget
1225  */
1226 void FileSaveDialogImpl::fileTypeChangedCallback()
1228     int sel = fileTypeComboBox.get_active_row_number();
1229     if (sel<0 || sel >= (int)fileTypes.size())
1230         return;
1231     FileType type = fileTypes[sel];
1232     //g_message("selected: %s\n", type.name.c_str());
1234     extension = type.extension;
1235     Gtk::FileFilter filter;
1236     filter.add_pattern(type.pattern);
1237     set_filter(filter);
1239     updateNameAndExtension();
1244 void FileSaveDialogImpl::createFileTypeMenu()
1246     Inkscape::Extension::DB::OutputList extension_list;
1247     Inkscape::Extension::db.get_output_list(extension_list);
1248     knownExtensions.clear();
1250     for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
1251          current_item != extension_list.end(); current_item++)
1252     {
1253         Inkscape::Extension::Output * omod = *current_item;
1255         // FIXME: would be nice to grey them out instead of not listing them
1256         if (omod->deactivated()) continue;
1258         FileType type;
1259         type.name     = (_(omod->get_filetypename()));
1260         type.pattern  = "*";
1261         Glib::ustring extension = omod->get_extension();
1262         knownExtensions.insert( extension.casefold() );
1263         fileDialogExtensionToPattern (type.pattern, extension);
1264         type.extension= omod;
1265         fileTypeComboBox.append_text(type.name);
1266         fileTypes.push_back(type);
1267     }
1269     //#Let user choose
1270     FileType guessType;
1271     guessType.name = _("Guess from extension");
1272     guessType.pattern = "*";
1273     guessType.extension = NULL;
1274     fileTypeComboBox.append_text(guessType.name);
1275     fileTypes.push_back(guessType);
1278     fileTypeComboBox.set_active(0);
1279     fileTypeChangedCallback(); //call at least once to set the filter
1284 /**
1285  * Constructor
1286  */
1287 FileSaveDialogImpl::FileSaveDialogImpl(const Glib::ustring &dir,
1288             FileDialogType fileTypes,
1289             const Glib::ustring &title,
1290             const Glib::ustring &default_key) :
1291     FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
1293     /* One file at a time */
1294     set_select_multiple(false);
1296 #ifdef WITH_GNOME_VFS
1297     set_local_only(false);
1298 #endif
1300     /* Initalize to Autodetect */
1301     extension = NULL;
1302     /* No filename to start out with */
1303     myFilename = "";
1305     /* Set our dialog type (save, export, etc...)*/
1306     dialogType = fileTypes;
1308     /* Set the pwd and/or the filename */
1309     if (dir.size() > 0)
1310         {
1311         Glib::ustring udir(dir);
1312         Glib::ustring::size_type len = udir.length();
1313         // leaving a trailing backslash on the directory name leads to the infamous
1314         // double-directory bug on win32
1315         if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
1316         myFilename = udir;
1317         }
1319     //###### Add the file types menu
1320     //createFilterMenu();
1322     //###### Do we want the .xxx extension automatically added?
1323     fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
1324     fileTypeCheckbox.set_active( (bool)prefs_get_int_attribute("dialogs.save_as",
1325                                                                "append_extension", 1) );
1327     createFileTypeMenu();
1328     fileTypeComboBox.set_size_request(200,40);
1329     fileTypeComboBox.signal_changed().connect(
1330          sigc::mem_fun(*this, &FileSaveDialogImpl::fileTypeChangedCallback) );
1333     childBox.pack_start( checksBox );
1334     childBox.pack_end( fileTypeComboBox );
1335     checksBox.pack_start( fileTypeCheckbox );
1336     checksBox.pack_start( previewCheckbox );
1338     set_extra_widget( childBox );
1340     //Let's do some customization
1341     fileNameEntry = NULL;
1342     Gtk::Container *cont = get_toplevel();
1343     std::vector<Gtk::Entry *> entries;
1344     findEntryWidgets(cont, entries);
1345     //g_message("Found %d entry widgets\n", entries.size());
1346     if (entries.size() >=1 )
1347         {
1348         //Catch when user hits [return] on the text field
1349         fileNameEntry = entries[0];
1350         fileNameEntry->signal_activate().connect(
1351              sigc::mem_fun(*this, &FileSaveDialogImpl::fileNameEntryChangedCallback) );
1352         }
1354     //Let's do more customization
1355     std::vector<Gtk::Expander *> expanders;
1356     findExpanderWidgets(cont, expanders);
1357     //g_message("Found %d expander widgets\n", expanders.size());
1358     if (expanders.size() >=1 )
1359         {
1360         //Always show the file list
1361         Gtk::Expander *expander = expanders[0];
1362         expander->set_expanded(true);
1363         }
1366     //if (extension == NULL)
1367     //    checkbox.set_sensitive(FALSE);
1369     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1370     set_default(*add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK));
1372     show_all_children();
1377 /**
1378  * Public factory method.  Used in file.cpp
1379  */
1380 FileSaveDialog *FileSaveDialog::create(const Glib::ustring &path,
1381                                        FileDialogType fileTypes,
1382                                        const Glib::ustring &title,
1383                                        const Glib::ustring &default_key)
1385     FileSaveDialog *dialog = new FileSaveDialogImpl(path, fileTypes, title, default_key);
1386     return dialog;
1393 /**
1394  * Destructor
1395  */
1396 FileSaveDialogImpl::~FileSaveDialogImpl()
1402 /**
1403  * Show this dialog modally.  Return true if user hits [OK]
1404  */
1405 bool
1406 FileSaveDialogImpl::show()
1408     change_path(myFilename);
1409     set_modal (TRUE);                      //Window
1410     sp_transientize((GtkWidget *)gobj());  //Make transient
1411     gint b = run();                        //Dialog
1412     svgPreview.showNoPreview();
1413     hide();
1415     if (b == Gtk::RESPONSE_OK)
1416         {
1417         updateNameAndExtension();
1419         // Store changes of the "Append filename automatically" checkbox back to preferences.
1420         prefs_set_int_attribute("dialogs.save_as", "append_extension", fileTypeCheckbox.get_active());
1422         // Store the last used save-as filetype to preferences.
1423         prefs_set_string_attribute("dialogs.save_as", "default",
1424                                    ( extension != NULL ? extension->get_id() : "" ));
1426         cleanup( true );
1428         return TRUE;
1429         }
1430     else
1431         {
1432         cleanup( false );
1434         return FALSE;
1435         }
1439 /**
1440  * Get the file extension type that was selected by the user. Valid after an [OK]
1441  */
1442 Inkscape::Extension::Extension *
1443 FileSaveDialogImpl::getSelectionType()
1445     return extension;
1448 void FileSaveDialogImpl::setSelectionType( Inkscape::Extension::Extension * key )
1450     extension = key;
1452     // If no pointer to extension is passed in, look up based on filename extension.
1453     if ( !extension ) {
1454         // Not quite UTF-8 here.
1455         gchar *filenameLower = g_ascii_strdown(myFilename.c_str(), -1);
1456         for ( int i = 0; !extension && (i < (int)fileTypes.size()); i++ ) {
1457             Inkscape::Extension::Output *ext = dynamic_cast<Inkscape::Extension::Output*>(fileTypes[i].extension);
1458             if ( ext && ext->get_extension() ) {
1459                 gchar *extensionLower = g_ascii_strdown( ext->get_extension(), -1 );
1460                 if ( g_str_has_suffix(filenameLower, extensionLower) ) {
1461                     extension = fileTypes[i].extension;
1462                 }
1463                 g_free(extensionLower);
1464             }
1465         }
1466         g_free(filenameLower);
1467     }
1469     // Ensure the proper entry in the combo box is selected.
1470     if ( extension ) {
1471         gchar const * extensionID = extension->get_id();
1472         if ( extensionID ) {
1473             for ( int i = 0; i < (int)fileTypes.size(); i++ ) {
1474                 Inkscape::Extension::Extension *ext = fileTypes[i].extension;
1475                 if ( ext ) {
1476                     gchar const * id = ext->get_id();
1477                     if ( id && ( strcmp(extensionID, id) == 0) ) {
1478                         int oldSel = fileTypeComboBox.get_active_row_number();
1479                         if ( i != oldSel ) {
1480                             fileTypeComboBox.set_active(i);
1481                         }
1482                         break;
1483                     }
1484                 }
1485             }
1486         }
1487     }
1491 /**
1492  * Get the file name chosen by the user.   Valid after an [OK]
1493  */
1494 Glib::ustring
1495 FileSaveDialogImpl::getFilename()
1497     return myFilename;
1501 void 
1502 FileSaveDialogImpl::change_title(const Glib::ustring& title)
1504     this->set_title(title);
1507 /**
1508   * Change the default save path location.
1509   */
1510 void 
1511 FileSaveDialogImpl::change_path(const Glib::ustring& path)
1513     myFilename = path;
1514     if (Glib::file_test(myFilename, Glib::FILE_TEST_IS_DIR)) {
1515         //fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str());
1516         set_current_folder(myFilename);
1517     } else {
1518         //fprintf(stderr,"set_filename(%s)\n",myFilename.c_str());
1519         if ( Glib::file_test( myFilename, Glib::FILE_TEST_EXISTS ) ) {
1520             set_filename(myFilename);
1521         } else {
1522             std::string dirName = Glib::path_get_dirname( myFilename  );
1523             if ( dirName != get_current_folder() ) {
1524                 set_current_folder(dirName);
1525             }
1526         }
1527         Glib::ustring basename = Glib::path_get_basename(myFilename);
1528         //fprintf(stderr,"set_current_name(%s)\n",basename.c_str());
1529         try {
1530             set_current_name( Glib::filename_to_utf8(basename) );
1531         } catch ( Glib::ConvertError& e ) {
1532             g_warning( "Error converting save filename to UTF-8." );
1533             // try a fallback.
1534             set_current_name( basename );
1535         }
1536     }
1539 void FileSaveDialogImpl::updateNameAndExtension()
1541     // Pick up any changes the user has typed in.
1542     Glib::ustring tmp = get_filename();
1543 #ifdef WITH_GNOME_VFS
1544     if ( tmp.empty() ) {
1545         tmp = get_uri();
1546     }
1547 #endif
1548     if ( !tmp.empty() ) {
1549         myFilename = tmp;
1550     }
1552     Inkscape::Extension::Output* newOut = extension ? dynamic_cast<Inkscape::Extension::Output*>(extension) : 0;
1553     if ( fileTypeCheckbox.get_active() && newOut ) {
1554         try {
1555             bool appendExtension = true;
1556             Glib::ustring utf8Name = Glib::filename_to_utf8( myFilename );
1557             size_t pos = utf8Name.rfind('.');
1558             if ( pos != Glib::ustring::npos ) {
1559                 Glib::ustring trail = utf8Name.substr( pos );
1560                 Glib::ustring foldedTrail = trail.casefold();
1561                 if ( (trail == ".") 
1562                      | (foldedTrail != Glib::ustring( newOut->get_extension() ).casefold()
1563                         && ( knownExtensions.find(foldedTrail) != knownExtensions.end() ) ) ) {
1564                     utf8Name = utf8Name.erase( pos );
1565                 } else {
1566                     appendExtension = false;
1567                 }
1568             }
1570             if (appendExtension) {
1571                 utf8Name = utf8Name + newOut->get_extension();
1572                 myFilename = Glib::filename_from_utf8( utf8Name );
1573                 change_path(myFilename);
1574             }
1575         } catch ( Glib::ConvertError& e ) {
1576             // ignore
1577         }
1578     }
1583 //########################################################################
1584 //# F I L E     E X P O R T
1585 //########################################################################
1588 /**
1589  * Our implementation of the FileExportDialog interface.
1590  */
1591 class FileExportDialogImpl : public FileExportDialog, public FileDialogBase
1594 public:
1595     FileExportDialogImpl(const Glib::ustring &dir,
1596                        FileDialogType fileTypes,
1597                        const Glib::ustring &title,
1598                        const Glib::ustring &default_key);
1600     virtual ~FileExportDialogImpl();
1602     bool show();
1604     Inkscape::Extension::Extension *getSelectionType();
1606     Glib::ustring getFilename();
1609     /**
1610      * Return the scope of the export.  One of the enumerated types
1611      * in ScopeType     
1612      */
1613     ScopeType getScope()
1614         { 
1615         if (pageButton.get_active())
1616             return SCOPE_PAGE;
1617         else if (selectionButton.get_active())
1618             return SCOPE_SELECTION;
1619         else if (customButton.get_active())
1620             return SCOPE_CUSTOM;
1621         else
1622             return SCOPE_DOCUMENT;
1624         }
1625     
1626     /**
1627      * Return left side of the exported region
1628      */
1629     double getSourceX()
1630         { return sourceX0Spinner.getValue(); }
1631     
1632     /**
1633      * Return the top of the exported region
1634      */
1635     double getSourceY()
1636         { return sourceY1Spinner.getValue(); }
1637     
1638     /**
1639      * Return the width of the exported region
1640      */
1641     double getSourceWidth()
1642         { return sourceWidthSpinner.getValue(); }
1643     
1644     /**
1645      * Return the height of the exported region
1646      */
1647     double getSourceHeight()
1648         { return sourceHeightSpinner.getValue(); }
1650     /**
1651      * Return the units of the coordinates of exported region
1652      */
1653     Glib::ustring getSourceUnits()
1654         { return sourceUnitsSpinner.getUnitAbbr(); }
1656     /**
1657      * Return the width of the destination document
1658      */
1659     double getDestinationWidth()
1660         { return destWidthSpinner.getValue(); }
1662     /**
1663      * Return the height of the destination document
1664      */
1665     double getDestinationHeight()
1666         { return destHeightSpinner.getValue(); }
1668     /**
1669      * Return the height of the exported region
1670      */
1671     Glib::ustring getDestinationUnits()
1672         { return destUnitsSpinner.getUnitAbbr(); }
1674     /**
1675      * Return the destination DPI image resulution, if bitmap
1676      */
1677     double getDestinationDPI()
1678         { return destDPISpinner.getValue(); }
1680     /**
1681      * Return whether we should use Cairo for rendering
1682      */
1683     bool getUseCairo()
1684         { return cairoButton.get_active(); }
1686     /**
1687      * Return whether we should use antialiasing
1688      */
1689     bool getUseAntialias()
1690         { return antiAliasButton.get_active(); }
1692     /**
1693      * Return the background color for exporting
1694      */
1695     unsigned long getBackground()
1696         { return backgroundButton.get_color().get_pixel(); }
1698 private:
1700     /**
1701      * Fix to allow the user to type the file name
1702      */
1703     Gtk::Entry *fileNameEntry;
1705     //##########################################
1706     //# EXTRA WIDGET -- SOURCE SIDE
1707     //##########################################
1709     Gtk::Frame            sourceFrame;
1710     Gtk::VBox             sourceBox;
1712     Gtk::HBox             scopeBox;
1713     Gtk::RadioButtonGroup scopeGroup;
1714     Gtk::RadioButton      documentButton;
1715     Gtk::RadioButton      pageButton;
1716     Gtk::RadioButton      selectionButton;
1717     Gtk::RadioButton      customButton;
1719     Gtk::Table                      sourceTable;
1720     Inkscape::UI::Widget::Scalar    sourceX0Spinner;
1721     Inkscape::UI::Widget::Scalar    sourceY0Spinner;
1722     Inkscape::UI::Widget::Scalar    sourceX1Spinner;
1723     Inkscape::UI::Widget::Scalar    sourceY1Spinner;
1724     Inkscape::UI::Widget::Scalar    sourceWidthSpinner;
1725     Inkscape::UI::Widget::Scalar    sourceHeightSpinner;
1726     Inkscape::UI::Widget::UnitMenu  sourceUnitsSpinner;
1729     //##########################################
1730     //# EXTRA WIDGET -- DESTINATION SIDE
1731     //##########################################
1733     Gtk::Frame       destFrame;
1734     Gtk::VBox        destBox;
1736     Gtk::Table                      destTable;
1737     Inkscape::UI::Widget::Scalar    destWidthSpinner;
1738     Inkscape::UI::Widget::Scalar    destHeightSpinner;
1739     Inkscape::UI::Widget::Scalar    destDPISpinner;
1740     Inkscape::UI::Widget::UnitMenu  destUnitsSpinner;
1742     Gtk::HBox        otherOptionBox;
1743     Gtk::CheckButton cairoButton;
1744     Gtk::CheckButton antiAliasButton;
1745     Gtk::ColorButton backgroundButton;
1748     /**
1749      * 'Extra' widget that holds two boxes above
1750      */
1751     Gtk::HBox exportOptionsBox;
1754     //# Child widgets
1755     Gtk::CheckButton fileTypeCheckbox;
1757     /**
1758      * Allow the specification of the output file type
1759      */
1760     Gtk::ComboBoxText fileTypeComboBox;
1763     /**
1764      *  Data mirror of the combo box
1765      */
1766     std::vector<FileType> fileTypes;
1770     /**
1771      * Callback for user input into fileNameEntry
1772      */
1773     void fileTypeChangedCallback();
1775     /**
1776      *  Create a filter menu for this type of dialog
1777      */
1778     void createFileTypeMenu();
1781     bool append_extension;
1783     /**
1784      * The extension to use to write this file
1785      */
1786     Inkscape::Extension::Extension *extension;
1788     /**
1789      * Callback for user input into fileNameEntry
1790      */
1791     void fileNameEntryChangedCallback();
1793     /**
1794      * Filename that was given
1795      */
1796     Glib::ustring myFilename;
1797 };
1804 /**
1805  * Callback for fileNameEntry widget
1806  */
1807 void FileExportDialogImpl::fileNameEntryChangedCallback()
1809     if (!fileNameEntry)
1810         return;
1812     Glib::ustring fileName = fileNameEntry->get_text();
1813     if (!Glib::get_charset()) //If we are not utf8
1814         fileName = Glib::filename_to_utf8(fileName);
1816     //g_message("User hit return.  Text is '%s'\n", fileName.c_str());
1818     if (!Glib::path_is_absolute(fileName)) {
1819         //try appending to the current path
1820         // not this way: fileName = get_current_folder() + "/" + fileName;
1821         std::vector<Glib::ustring> pathSegments;
1822         pathSegments.push_back( get_current_folder() );
1823         pathSegments.push_back( fileName );
1824         fileName = Glib::build_filename(pathSegments);
1825     }
1827     //g_message("path:'%s'\n", fileName.c_str());
1829     if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) {
1830         set_current_folder(fileName);
1831     } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) {
1832         //dialog with either (1) select a regular file or (2) cd to dir
1833         //simulate an 'OK'
1834         set_filename(fileName);
1835         response(Gtk::RESPONSE_OK);
1836     }
1841 /**
1842  * Callback for fileNameEntry widget
1843  */
1844 void FileExportDialogImpl::fileTypeChangedCallback()
1846     int sel = fileTypeComboBox.get_active_row_number();
1847     if (sel<0 || sel >= (int)fileTypes.size())
1848         return;
1849     FileType type = fileTypes[sel];
1850     //g_message("selected: %s\n", type.name.c_str());
1851     Gtk::FileFilter filter;
1852     filter.add_pattern(type.pattern);
1853     set_filter(filter);
1858 void FileExportDialogImpl::createFileTypeMenu()
1860     Inkscape::Extension::DB::OutputList extension_list;
1861     Inkscape::Extension::db.get_output_list(extension_list);
1863     for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
1864          current_item != extension_list.end(); current_item++)
1865     {
1866         Inkscape::Extension::Output * omod = *current_item;
1868         // FIXME: would be nice to grey them out instead of not listing them
1869         if (omod->deactivated()) continue;
1871         FileType type;
1872         type.name     = (_(omod->get_filetypename()));
1873         type.pattern  = "*";
1874         Glib::ustring extension = omod->get_extension();
1875         fileDialogExtensionToPattern (type.pattern, extension);
1876         type.extension= omod;
1877         fileTypeComboBox.append_text(type.name);
1878         fileTypes.push_back(type);
1879     }
1881     //#Let user choose
1882     FileType guessType;
1883     guessType.name = _("Guess from extension");
1884     guessType.pattern = "*";
1885     guessType.extension = NULL;
1886     fileTypeComboBox.append_text(guessType.name);
1887     fileTypes.push_back(guessType);
1890     fileTypeComboBox.set_active(0);
1891     fileTypeChangedCallback(); //call at least once to set the filter
1895 /**
1896  * Constructor
1897  */
1898 FileExportDialogImpl::FileExportDialogImpl(const Glib::ustring &dir,
1899             FileDialogType fileTypes,
1900             const Glib::ustring &title,
1901             const Glib::ustring &default_key) :
1902             FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.export"),
1903             sourceX0Spinner("X0",         _("Left edge of source")),
1904             sourceY0Spinner("Y0",         _("Top edge of source")),
1905             sourceX1Spinner("X1",         _("Right edge of source")),
1906             sourceY1Spinner("Y1",         _("Bottom edge of source")),
1907             sourceWidthSpinner("Width",   _("Source width")),
1908             sourceHeightSpinner("Height", _("Source height")),
1909             destWidthSpinner("Width",     _("Destination width")),
1910             destHeightSpinner("Height",   _("Destination height")),
1911             destDPISpinner("DPI",         _("Resolution (dots per inch)"))
1913     append_extension = (bool)prefs_get_int_attribute("dialogs.save_as", "append_extension", 1);
1915     /* One file at a time */
1916     set_select_multiple(false);
1918 #ifdef WITH_GNOME_VFS
1919     set_local_only(false);
1920 #endif
1922     /* Initalize to Autodetect */
1923     extension = NULL;
1924     /* No filename to start out with */
1925     myFilename = "";
1927     /* Set our dialog type (save, export, etc...)*/
1928     dialogType = fileTypes;
1930     /* Set the pwd and/or the filename */
1931     if (dir.size()>0)
1932         {
1933         Glib::ustring udir(dir);
1934         Glib::ustring::size_type len = udir.length();
1935         // leaving a trailing backslash on the directory name leads to the infamous
1936         // double-directory bug on win32
1937         if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
1938         set_current_folder(udir.c_str());
1939         }
1941     //#########################################
1942     //## EXTRA WIDGET -- SOURCE SIDE
1943     //#########################################
1945     //##### Export options buttons/spinners, etc
1946     documentButton.set_label(_("Document"));
1947     scopeBox.pack_start(documentButton);
1948     scopeGroup = documentButton.get_group();
1950     pageButton.set_label(_("Page"));
1951     pageButton.set_group(scopeGroup);
1952     scopeBox.pack_start(pageButton);
1954     selectionButton.set_label(_("Selection"));
1955     selectionButton.set_group(scopeGroup);
1956     scopeBox.pack_start(selectionButton);
1958     customButton.set_label(_("Custom"));
1959     customButton.set_group(scopeGroup);
1960     scopeBox.pack_start(customButton);
1962     sourceBox.pack_start(scopeBox);
1966     //dimension buttons
1967     sourceTable.resize(3,3);
1968     sourceTable.attach(sourceX0Spinner,     0,1,0,1);
1969     sourceTable.attach(sourceY0Spinner,     1,2,0,1);
1970     sourceUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR);
1971     sourceTable.attach(sourceUnitsSpinner,  2,3,0,1);
1972     sourceTable.attach(sourceX1Spinner,     0,1,1,2);
1973     sourceTable.attach(sourceY1Spinner,     1,2,1,2);
1974     sourceTable.attach(sourceWidthSpinner,  0,1,2,3);
1975     sourceTable.attach(sourceHeightSpinner, 1,2,2,3);
1977     sourceBox.pack_start(sourceTable);
1978     sourceFrame.set_label(_("Source"));
1979     sourceFrame.add(sourceBox);
1980     exportOptionsBox.pack_start(sourceFrame);
1983     //#########################################
1984     //## EXTRA WIDGET -- SOURCE SIDE
1985     //#########################################
1988     destTable.resize(3,3);
1989     destTable.attach(destWidthSpinner,    0,1,0,1);
1990     destTable.attach(destHeightSpinner,   1,2,0,1);
1991     destUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR);
1992     destTable.attach(destUnitsSpinner,    2,3,0,1);
1993     destTable.attach(destDPISpinner,      0,1,1,2);
1995     destBox.pack_start(destTable);
1998     cairoButton.set_label(_("Cairo"));
1999     otherOptionBox.pack_start(cairoButton);
2001     antiAliasButton.set_label(_("Antialias"));
2002     otherOptionBox.pack_start(antiAliasButton);
2004     backgroundButton.set_label(_("Background"));
2005     otherOptionBox.pack_start(backgroundButton);
2007     destBox.pack_start(otherOptionBox);
2013     //###### File options
2014     //###### Do we want the .xxx extension automatically added?
2015     fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
2016     fileTypeCheckbox.set_active(append_extension);
2017     destBox.pack_start(fileTypeCheckbox);
2019     //###### File type menu
2020     createFileTypeMenu();
2021     fileTypeComboBox.set_size_request(200,40);
2022     fileTypeComboBox.signal_changed().connect(
2023          sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback) );
2025     destBox.pack_start(fileTypeComboBox);
2027     destFrame.set_label(_("Destination"));
2028     destFrame.add(destBox);
2029     exportOptionsBox.pack_start(destFrame);
2031     //##### Put the two boxes and their parent onto the dialog    
2032     exportOptionsBox.pack_start(sourceFrame);
2033     exportOptionsBox.pack_start(destFrame);
2035     set_extra_widget(exportOptionsBox);
2040     //Let's do some customization
2041     fileNameEntry = NULL;
2042     Gtk::Container *cont = get_toplevel();
2043     std::vector<Gtk::Entry *> entries;
2044     findEntryWidgets(cont, entries);
2045     //g_message("Found %d entry widgets\n", entries.size());
2046     if (entries.size() >=1 )
2047         {
2048         //Catch when user hits [return] on the text field
2049         fileNameEntry = entries[0];
2050         fileNameEntry->signal_activate().connect(
2051              sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback) );
2052         }
2054     //Let's do more customization
2055     std::vector<Gtk::Expander *> expanders;
2056     findExpanderWidgets(cont, expanders);
2057     //g_message("Found %d expander widgets\n", expanders.size());
2058     if (expanders.size() >=1 )
2059         {
2060         //Always show the file list
2061         Gtk::Expander *expander = expanders[0];
2062         expander->set_expanded(true);
2063         }
2066     //if (extension == NULL)
2067     //    checkbox.set_sensitive(FALSE);
2069     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2070     set_default(*add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_OK));
2072     show_all_children();
2077 /**
2078  * Public factory method.  Used in file.cpp
2079  */
2080 FileExportDialog *FileExportDialog::create(const Glib::ustring &path,
2081                                        FileDialogType fileTypes,
2082                                        const Glib::ustring &title,
2083                                        const Glib::ustring &default_key)
2085     FileExportDialog *dialog = new FileExportDialogImpl(path, fileTypes, title, default_key);
2086     return dialog;
2093 /**
2094  * Destructor
2095  */
2096 FileExportDialogImpl::~FileExportDialogImpl()
2102 /**
2103  * Show this dialog modally.  Return true if user hits [OK]
2104  */
2105 bool
2106 FileExportDialogImpl::show()
2108     Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
2109     if (s.length() == 0) 
2110         s = getcwd (NULL, 0);
2111     set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
2112     set_modal (TRUE);                      //Window
2113     sp_transientize((GtkWidget *)gobj());  //Make transient
2114     gint b = run();                        //Dialog
2115     svgPreview.showNoPreview();
2116     hide();
2118     if (b == Gtk::RESPONSE_OK)
2119         {
2120         int sel = fileTypeComboBox.get_active_row_number ();
2121         if (sel>=0 && sel< (int)fileTypes.size())
2122             {
2123             FileType &type = fileTypes[sel];
2124             extension = type.extension;
2125             }
2126         myFilename = get_filename();
2127 #ifdef WITH_GNOME_VFS
2128         if (myFilename.length() < 1)
2129             myFilename = get_uri();
2130 #endif
2132         /*
2134         // FIXME: Why do we have more code
2136         append_extension = checkbox.get_active();
2137         prefs_set_int_attribute("dialogs.save_as", "append_extension", append_extension);
2138         prefs_set_string_attribute("dialogs.save_as", "default",
2139                   ( extension != NULL ? extension->get_id() : "" ));
2140         */
2141         return TRUE;
2142         }
2143     else
2144         {
2145         return FALSE;
2146         }
2150 /**
2151  * Get the file extension type that was selected by the user. Valid after an [OK]
2152  */
2153 Inkscape::Extension::Extension *
2154 FileExportDialogImpl::getSelectionType()
2156     return extension;
2160 /**
2161  * Get the file name chosen by the user.   Valid after an [OK]
2162  */
2163 Glib::ustring
2164 FileExportDialogImpl::getFilename()
2166     return myFilename;
2172 } //namespace Dialog
2173 } //namespace UI
2174 } //namespace Inkscape
2177 /*
2178   Local Variables:
2179   mode:c++
2180   c-file-style:"stroustrup"
2181   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2182   indent-tabs-mode:nil
2183   fill-column:99
2184   End:
2185 */
2186 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :