filedialogimpl-gtkmm.cpp revision 52cad88e59adf0342e9294b9249b96bffe8fbe9e
830N/A * Other dudes from The Inkscape Organization 919N/A * Copyright (C) 2004-2007 Bob Jamison 830N/A * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> 919N/A * Copyright (C) 2007-2008 Joel Holdsworth 919N/A * Copyright (C) 2004-2007 The Inkscape Organization 919N/A * Released under GNU GPL, read the file 'COPYING' for more information 830N/A//######################################################################## 830N/A//######################################################################## 830N/A/*######################################################################### 830N/A#########################################################################*/ 830N/A // This should remove it from the box, and free resources 830N/A * I don't know why passing false to keepalive is bad. But it 830N/A * prevents the display of an svg with a non-ascii filename 830N/A /*##################################### 830N/A # LET'S HAVE SOME FUN WITH SVG! 830N/A # Instead of just loading an image, why 830N/A # don't we make a lovely little svg and 830N/A #####################################*/ 830N/A // Arbitrary size of svg doc -- rather 'portrait' shaped 830N/A // Get some image info. Smart pointer does not need to be deleted 830N/A // Find the minimum scale to fit the image inside the preview area 830N/A // Now get the resized values 830N/A // center the image on the area 830N/A // wrap a rectangle around the image 830N/A // Our template. Modify to taste 830N/A "width=\"%d\" height=\"%d\">\n" //# VALUES HERE 830N/A " style=\"fill:#eeeeee;stroke:none\"\n" 830N/A " x=\"-100\" y=\"-100\" width=\"4000\" height=\"4000\"/>\n" 830N/A "<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"\n" 830N/A "xlink:href=\"%s\"/>\n" 830N/A " stroke:#000000;stroke-width:1.0;" 830N/A " stroke-linejoin:miter;stroke-opacity:1.0000000;" 830N/A " stroke-miterlimit:4.0000000;stroke-dasharray:none\"\n" 830N/A " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/>\n" 830N/A " style=\"font-size:24.000000;font-style:normal;font-weight:normal;" 830N/A " fill:#000000;fill-opacity:1.0000000;stroke:none;" 830N/A " font-family:Sans\"\n" 830N/A " x=\"10\" y=\"26\">%d x %d</text>\n" //# VALUES HERE 830N/A // if (!Glib::get_charset()) //If we are not utf8 830N/A // Fill in the template 830N/A /* FIXME: Do proper XML quoting for fileName. */ 830N/A // g_message("%s\n", xmlBuffer); 830N/A // Are we already showing it? 830N/A // Arbitrary size of svg doc -- rather 'portrait' shaped 830N/A // Our template. Modify to taste 830N/A "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 830N/A "width=\"%d\" height=\"%d\">\n" //# VALUES HERE 830N/A "<g transform=\"translate(-190,24.27184)\" style=\"opacity:0.12\">\n" 830N/A "style=\"font-size:12;fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.936193pt\"\n" 830N/A "d=\"M 397.64309 320.25301 L 280.39197 282.517 L 250.74227 124.83447 L 345.08225 " 830N/A "29.146783 L 393.59996 46.667064 L 483.89679 135.61619 L 397.64309 320.25301 z \"\n" 830N/A "id=\"whiteSpace\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 476.95792 339.17168 C 495.78197 342.93607 499.54842 356.11361 495.78197 359.87802 " 830N/A "C 492.01856 363.6434 482.6065 367.40781 475.07663 361.76014 C 467.54478 " 830N/A "356.11361 467.54478 342.93607 476.95792 339.17168 z \"\n" 830N/A "id=\"droplet01\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 286.46194 340.42914 C 284.6277 340.91835 269.30405 327.71337 257.16909 333.8338 " 830N/A "C 245.03722 339.95336 236.89276 353.65666 248.22676 359.27982 C 259.56184 364.90298 " 830N/A "267.66433 358.41867 277.60113 351.44119 C 287.53903 344.46477 " 830N/A "287.18046 343.1206 286.46194 340.42914 z \"\n" 830N/A "id=\"droplet02\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 510.35756 306.92856 C 520.59494 304.36879 544.24333 306.92856 540.47688 321.98634 " 830N/A "C 536.71354 337.04806 504.71297 331.39827 484.00371 323.87156 C 482.12141 " 830N/A "308.81083 505.53237 308.13423 510.35756 306.92856 z \"\n" 830N/A "id=\"droplet03\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 359.2403 21.362537 C 347.92693 21.362537 336.6347 25.683095 327.96556 34.35223 " 830N/A "L 173.87387 188.41466 C 165.37697 196.9114 161.1116 207.95813 160.94269 219.04577 " 830N/A "L 160.88418 219.04577 C 160.88418 219.08524 160.94076 219.12322 160.94269 219.16279 " 830N/A "C 160.94033 219.34888 160.88418 219.53256 160.88418 219.71865 L 161.14748 219.71865 " 830N/A "C 164.0966 230.93917 240.29699 245.24198 248.79866 253.74346 C 261.63771 266.58263 " 830N/A "199.5652 276.01151 212.4041 288.85074 C 225.24316 301.68979 289.99433 313.6933 302.8346 " 830N/A "326.53254 C 315.67368 339.37161 276.5961 353.04289 289.43532 365.88196 C 302.27439 " 830N/A "378.72118 345.40201 362.67257 337.5908 396.16198 C 354.92909 413.50026 391.10302 " 830N/A "405.2208 415.32417 387.88252 C 428.16323 375.04345 390.6948 376.17577 403.53397 " 830N/A "363.33668 C 416.37304 350.49745 448.78128 350.4282 476.08902 319.71589 C 465.09739 " 830N/A "302.62116 429.10801 295.34136 441.94719 282.50217 C 454.78625 269.66311 479.74708 " 830N/A "276.18423 533.60644 251.72479 C 559.89837 239.78398 557.72636 230.71459 557.62567 " 830N/A "219.71865 C 557.62356 219.48727 557.62567 219.27892 557.62567 219.04577 L 557.56716 " 830N/A "219.04577 C 557.3983 207.95812 553.10345 196.9114 544.60673 188.41466 L 390.54428 " 830N/A "34.35223 C 381.87515 25.683095 370.55366 21.362537 359.2403 21.362537 z M 357.92378 " 830N/A "41.402939 C 362.95327 41.533963 367.01541 45.368018 374.98006 50.530832 L 447.76915 " 830N/A "104.50827 C 448.56596 105.02498 449.32484 105.564 450.02187 106.11735 C 450.7189 106.67062 " 830N/A "451.3556 107.25745 451.95277 107.84347 C 452.54997 108.42842 453.09281 109.01553 453.59111 " 830N/A "109.62808 C 454.08837 110.24052 454.53956 110.86661 454.93688 111.50048 C 455.33532 112.13538 " 830N/A "455.69164 112.78029 455.9901 113.43137 C 456.28877 114.08363 456.52291 114.75639 456.7215 " 830N/A "115.42078 C 456.92126 116.08419 457.08982 116.73973 457.18961 117.41019 C 457.28949 " 830N/A "118.08184 457.33588 118.75535 457.33588 119.42886 L 414.21245 98.598549 L 409.9118 " 830N/A "131.16055 L 386.18512 120.04324 L 349.55654 144.50131 L 335.54288 96.1703 L 317.4919 " 830N/A "138.4453 L 267.08369 143.47735 L 267.63956 121.03795 C 267.63956 115.64823 296.69685 " 830N/A "77.915899 314.39075 68.932902 L 346.77721 45.674327 C 351.55594 42.576634 354.90608 " 830N/A "41.324327 357.92378 41.402939 z M 290.92738 261.61333 C 313.87149 267.56365 339.40299 " 830N/A "275.37038 359.88393 275.50997 L 360.76161 284.72563 C 343.2235 282.91785 306.11346 " 830N/A "274.45012 297.36372 269.98057 L 290.92738 261.61333 z \"\n" 830N/A "id=\"mountainDroplet\" />\n" 830N/A "</g> <g transform=\"translate(-20,0)\">\n" 830N/A "<text xml:space=\"preserve\"\n" 830N/A "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;" 830N/A "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;" 830N/A "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;" 830N/A "font-family:Sans;text-anchor:middle;writing-mode:lr\"\n" 830N/A "x=\"190\" y=\"240\">%s</text></g>\n" //# VALUE HERE 830N/A // Fill in the template 830N/A // g_message("%s\n", xmlBuffer); 830N/A * Inform the user that the svg file is too large to be displayed. 830N/A * This does not check for sizes of embedded images (yet) 830N/A // Arbitrary size of svg doc -- rather 'portrait' shaped 830N/A // Our template. Modify to taste 830N/A "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 830N/A "width=\"%d\" height=\"%d\">\n" //# VALUES HERE 830N/A "<g transform=\"translate(-170,24.27184)\" style=\"opacity:0.12\">\n" 830N/A "style=\"font-size:12;fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.936193pt\"\n" 830N/A "d=\"M 397.64309 320.25301 L 280.39197 282.517 L 250.74227 124.83447 L 345.08225 " 830N/A "29.146783 L 393.59996 46.667064 L 483.89679 135.61619 L 397.64309 320.25301 z \"\n" 830N/A "id=\"whiteSpace\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 476.95792 339.17168 C 495.78197 342.93607 499.54842 356.11361 495.78197 359.87802 " 830N/A "C 492.01856 363.6434 482.6065 367.40781 475.07663 361.76014 C 467.54478 " 830N/A "356.11361 467.54478 342.93607 476.95792 339.17168 z \"\n" 830N/A "id=\"droplet01\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 286.46194 340.42914 C 284.6277 340.91835 269.30405 327.71337 257.16909 333.8338 " 830N/A "C 245.03722 339.95336 236.89276 353.65666 248.22676 359.27982 C 259.56184 364.90298 " 830N/A "267.66433 358.41867 277.60113 351.44119 C 287.53903 344.46477 " 830N/A "287.18046 343.1206 286.46194 340.42914 z \"\n" 830N/A "id=\"droplet02\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 510.35756 306.92856 C 520.59494 304.36879 544.24333 306.92856 540.47688 321.98634 " 830N/A "C 536.71354 337.04806 504.71297 331.39827 484.00371 323.87156 C 482.12141 " 830N/A "308.81083 505.53237 308.13423 510.35756 306.92856 z \"\n" 830N/A "id=\"droplet03\" />\n" 830N/A "style=\"font-size:12;fill-rule:evenodd;stroke-width:1pt;fill:#000000;fill-opacity:1\"\n" 830N/A "d=\"M 359.2403 21.362537 C 347.92693 21.362537 336.6347 25.683095 327.96556 34.35223 " 830N/A "L 173.87387 188.41466 C 165.37697 196.9114 161.1116 207.95813 160.94269 219.04577 " 830N/A "L 160.88418 219.04577 C 160.88418 219.08524 160.94076 219.12322 160.94269 219.16279 " 830N/A "C 160.94033 219.34888 160.88418 219.53256 160.88418 219.71865 L 161.14748 219.71865 " 830N/A "C 164.0966 230.93917 240.29699 245.24198 248.79866 253.74346 C 261.63771 266.58263 " 830N/A "199.5652 276.01151 212.4041 288.85074 C 225.24316 301.68979 289.99433 313.6933 302.8346 " 830N/A "326.53254 C 315.67368 339.37161 276.5961 353.04289 289.43532 365.88196 C 302.27439 " 830N/A "378.72118 345.40201 362.67257 337.5908 396.16198 C 354.92909 413.50026 391.10302 " 830N/A "405.2208 415.32417 387.88252 C 428.16323 375.04345 390.6948 376.17577 403.53397 " 830N/A "363.33668 C 416.37304 350.49745 448.78128 350.4282 476.08902 319.71589 C 465.09739 " 830N/A "302.62116 429.10801 295.34136 441.94719 282.50217 C 454.78625 269.66311 479.74708 " 830N/A "276.18423 533.60644 251.72479 C 559.89837 239.78398 557.72636 230.71459 557.62567 " 830N/A "219.71865 C 557.62356 219.48727 557.62567 219.27892 557.62567 219.04577 L 557.56716 " 830N/A "219.04577 C 557.3983 207.95812 553.10345 196.9114 544.60673 188.41466 L 390.54428 " 830N/A "34.35223 C 381.87515 25.683095 370.55366 21.362537 359.2403 21.362537 z M 357.92378 " 830N/A "41.402939 C 362.95327 41.533963 367.01541 45.368018 374.98006 50.530832 L 447.76915 " 830N/A "104.50827 C 448.56596 105.02498 449.32484 105.564 450.02187 106.11735 C 450.7189 106.67062 " 830N/A "451.3556 107.25745 451.95277 107.84347 C 452.54997 108.42842 453.09281 109.01553 453.59111 " 830N/A "109.62808 C 454.08837 110.24052 454.53956 110.86661 454.93688 111.50048 C 455.33532 112.13538 " 830N/A "455.69164 112.78029 455.9901 113.43137 C 456.28877 114.08363 456.52291 114.75639 456.7215 " 830N/A "115.42078 C 456.92126 116.08419 457.08982 116.73973 457.18961 117.41019 C 457.28949 " 830N/A "118.08184 457.33588 118.75535 457.33588 119.42886 L 414.21245 98.598549 L 409.9118 " 830N/A "131.16055 L 386.18512 120.04324 L 349.55654 144.50131 L 335.54288 96.1703 L 317.4919 " 830N/A "138.4453 L 267.08369 143.47735 L 267.63956 121.03795 C 267.63956 115.64823 296.69685 " 830N/A "77.915899 314.39075 68.932902 L 346.77721 45.674327 C 351.55594 42.576634 354.90608 " 830N/A "41.324327 357.92378 41.402939 z M 290.92738 261.61333 C 313.87149 267.56365 339.40299 " 830N/A "275.37038 359.88393 275.50997 L 360.76161 284.72563 C 343.2235 282.91785 306.11346 " 830N/A "274.45012 297.36372 269.98057 L 290.92738 261.61333 z \"\n" 830N/A "id=\"mountainDroplet\" />\n" 830N/A "<text xml:space=\"preserve\"\n" 830N/A "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;" 830N/A "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;" 830N/A "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;" 830N/A "font-family:Sans;text-anchor:middle;writing-mode:lr\"\n" 830N/A "x=\"170\" y=\"215\">%5.1f MB</text>\n" //# VALUE HERE 830N/A "<text xml:space=\"preserve\"\n" 830N/A "style=\"font-size:24.000000;font-style:normal;font-variant:normal;font-weight:bold;" 830N/A "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;" 830N/A "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;" 830N/A "font-family:Sans;text-anchor:middle;writing-mode:lr\"\n" 830N/A "x=\"180\" y=\"245\">%s</text>\n" //# VALUE HERE 830N/A // Fill in the template 830N/A // printf("%ld %f\n", fileLength, floatFileLength); 830N/A // g_message("%s\n", xmlBuffer); 830N/A/*######################################################################### 830N/A### F I L E D I A L O G B A S E C L A S S 830N/A#########################################################################*/ 830N/A // Open executable file dialogs don't need the preview panel 830N/A // Catch selection-changed events, so we can adjust the text widget 830N/A //###### Add a preview widget 830N/A // Clears out any current preview image. 830N/A * Callback for checking if the preview needs to be redrawn 830N/A/*######################################################################### 830N/A#########################################################################*/ 830N/A * Constructor. Not called directly. Use the factory. 830N/A /* One file at a time */ 830N/A /* And also Multiple Files */ 830N/A /* Initalize to Autodetect */ 830N/A /* No filename to start out with */ 830N/A /* Set our dialog type (open, import, etc...)*/ 830N/A // leaving a trailing backslash on the directory name leads to the infamous 830N/A // double-directory bug on win32 830N/A //###### Add the file types menu 830N/A //###### Allow easy access to our examples folder 830N/A // patterns added dynamically below 830N/A // FIXME: would be nice to grey them out instead of not listing them 830N/A// g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); 830N/A // uncomment this to find out all mime types supported by Inkscape import/open 830N/A // g_print ("%s\n", imod->get_mimetype()); 830N/A // I don't know of any other way to define "bitmap" formats other than by listing them 830N/A * Show this dialog modally. Return true if user hits [OK] 830N/A // This is a hack, to avoid the warning messages that 830N/A // Gtk::FileChooser::get_filter() returns 830N/A // should be: Gtk::FileFilter *filter = get_filter(); 830N/A // Get which extension was chosen, if any 830N/A * Get the file extension type that was selected by the user. Valid after an [OK] 830N/A * Get the file name chosen by the user. Valid after an [OK] 830N/A * To Get Multiple filenames selected at-once. 830N/A // Copy filenames to a vector of type Glib::ustring 830N/A//######################################################################## 830N/A//######################################################################## 830N/A /* One file at a time */ 830N/A /* Initalize to Autodetect */ 830N/A /* No filename to start out with */ 830N/A /* Set our dialog type (save, export, etc...)*/ 830N/A // leaving a trailing backslash on the directory name leads to the infamous 830N/A // double-directory bug on win32 830N/A //###### Add the file types menu 830N/A //###### Do we want the .xxx extension automatically added? 830N/A // Let's do some customization 830N/A // Catch when user hits [return] on the text field 830N/A // Let's do more customization 830N/A // Always show the file list 830N/A // allow easy access to the user's own templates folder 830N/A // if (extension == NULL) 830N/A * Callback for fileNameEntry widget 830N/A // try appending to the current path 830N/A // not this way: fileName = get_current_folder() + "/" + fileName; 830N/A }
else if (
/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/ 1) {
830N/A // dialog with either (1) select a regular file or (2) cd to dir 830N/A * Callback for fileNameEntry widget 830N/A // FIXME: would be nice to grey them out instead of not listing them 830N/A * Show this dialog modally. Return true if user hits [OK] 830N/A // Store changes of the "Append filename automatically" checkbox back to preferences. 830N/A * Get the file extension type that was selected by the user. Valid after an [OK] 830N/A // If no pointer to extension is passed in, look up based on filename extension. 830N/A // Not quite UTF-8 here. 830N/A // Ensure the proper entry in the combo box is selected. 830N/AFileSaveDialogImplGtk::change_title(const Glib::ustring& title) 830N/A * Change the default save path location. 830N/A // Pick up any changes the user has typed in. 830N/A // Append the file extension if it's not already present and display it in the file name entry field 830N/A//######################################################################## 830N/A//######################################################################## 830N/A * Callback for fileNameEntry widget 830N/A // try appending to the current path 830N/A // not this way: fileName = get_current_folder() + "/" + fileName; 830N/A }
else if (
/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/ 1) {
830N/A // dialog with either (1) select a regular file or (2) cd to dir 830N/A * Callback for fileNameEntry widget 830N/A // FIXME: would be nice to grey them out instead of not listing them 830N/A /* One file at a time */ 830N/A /* Initalize to Autodetect */ 830N/A /* No filename to start out with */ 830N/A /* Set our dialog type (save, export, etc...)*/ 830N/A // leaving a trailing backslash on the directory name leads to the infamous 830N/A // double-directory bug on win32 830N/A //######################################### 830N/A //## EXTRA WIDGET -- SOURCE SIDE 830N/A //######################################### 830N/A //######################################### 830N/A //## EXTRA WIDGET -- SOURCE SIDE 830N/A //######################################### 830N/A //###### Do we want the .xxx extension automatically added? 830N/A //###### File type menu 830N/A //##### Put the two boxes and their parent onto the dialog 830N/A // Let's do some customization 830N/A // Catch when user hits [return] on the text field 830N/A // Let's do more customization 830N/A // Always show the file list 830N/A // if (extension == NULL) 830N/A * Show this dialog modally. Return true if user hits [OK] 830N/A // FIXME: Why do we have more code 830N/A append_extension = checkbox.get_active(); 830N/A Inkscape::Preferences *prefs = Inkscape::Preferences::get(); 830N/A * Get the file extension type that was selected by the user. Valid after an [OK] 830N/A * Get the file name chosen by the user. Valid after an [OK] 830N/A#
endif // NEW_EXPORT_DIALOG 830N/A c-file-style:"stroustrup" 830N/A c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 830N/A// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :