From: ishmal Date: Wed, 21 Mar 2007 22:58:45 +0000 (+0000) Subject: Do some cleanup X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e6e1b2e5f40dde0ce49b9cefe147181bb31c8837;p=inkscape.git Do some cleanup --- diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index cd5730a5c..c72d8cb29 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -1,47 +1,42 @@ -/* +/** * Implementation of the file dialog interfaces defined in filedialog.h * * Authors: * Bob Jamison * Other dudes from The Inkscape Organization * + * Copyright (C) 2004-2007 Bob Jamison * Copyright (C) 2006 Johan Engelen - * Copyright (C) 2004-2006 The Inkscape Organization + * Copyright (C) 2004-2007 The Inkscape Organization * * Released under GNU GPL, read the file 'COPYING' for more information */ + #ifdef HAVE_CONFIG_H # include #endif +//General includes +#include +#include +#include - +//Gtk includes +#include +#include +#include //Temporary ugly hack -//Remove these after the get_filter() calls in +//Remove this after the get_filter() calls in //show() on both classes are fixed #include - //Another hack #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + +//Inkscape includes #include "prefs-utils.h" #include #include @@ -56,6 +51,7 @@ #include "ui/widget/scalar-unit.h" +//Routines from file.cpp #undef INK_DUMP_FILENAME_CONV #ifdef INK_DUMP_FILENAME_CONV @@ -63,6 +59,9 @@ void dump_str( const gchar* str, const gchar* prefix ); void dump_ustr( const Glib::ustring& ustr ); #endif + + + namespace Inkscape { namespace UI @@ -240,6 +239,7 @@ bool SVGPreview::setDocument(SPDocument *doc) return true; } + bool SVGPreview::setFileName(Glib::ustring &theFileName) { Glib::ustring fileName = theFileName; @@ -332,7 +332,7 @@ void SVGPreview::showImage(Glib::ustring &theFileName) "\n" + "width=\"%d\" height=\"%d\">\n" //# VALUES HERE "\n" @@ -348,7 +348,7 @@ void SVGPreview::showImage(Glib::ustring &theFileName) " style=\"font-size:24.000000;font-style:normal;font-weight:normal;" " fill:#000000;fill-opacity:1.0000000;stroke:none;" " font-family:Bitstream Vera Sans\"\n" - " x=\"10\" y=\"26\">%d x %d\n" + " x=\"10\" y=\"26\">%d x %d\n" //# VALUES HERE "\n\n"; //if (!Glib::get_charset()) //If we are not utf8 @@ -388,7 +388,7 @@ void SVGPreview::showNoPreview() "\n" + "width=\"%d\" height=\"%d\">\n" //# VALUES HERE "\n" "%s\n" + "x=\"190\" y=\"240\">%s\n" //# VALUE HERE "\n\n"; //Fill in the template @@ -467,6 +467,11 @@ void SVGPreview::showNoPreview() } + +/** + * Inform the user that the svg file is too large to be displayed. + * This does not check for sizes of embedded images (yet) + */ void SVGPreview::showTooLarge(long fileLength) { @@ -480,7 +485,7 @@ void SVGPreview::showTooLarge(long fileLength) "\n" + "width=\"%d\" height=\"%d\">\n" //# VALUES HERE "\n" "%5.1f MB\n" + "x=\"170\" y=\"215\">%5.1f MB\n" //# VALUE HERE "%s\n" + "x=\"180\" y=\"245\">%s\n" //# VALUE HERE "\n\n"; //Fill in the template @@ -622,19 +627,22 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) return false; - gchar *fName = (gchar *)fileName.c_str(); - //g_message("fname:%s\n", fName); + g_message("fname:%s", fileName.c_str()); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) { + g_message("dir"); showNoPreview(); return false; } if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { + Glib::ustring fileNameUtf8 = Glib::filename_to_utf8(fileName); + gchar *fName = (gchar *)fileNameUtf8.c_str(); struct stat info; if (stat(fName, &info)) { + g_message("SVGPreview::set() : %s", strerror(errno)); return FALSE; } long fileLen = info.st_size; @@ -760,7 +768,10 @@ private: void FileDialogBase::internalSetup() { - bool enablePreview = (bool)prefs_get_int_attribute( preferenceBase.c_str(), "enable_preview", 1 ); + bool enablePreview = + (bool)prefs_get_int_attribute( preferenceBase.c_str(), + "enable_preview", 1 ); + previewCheckbox.set_label( Glib::ustring(_("Enable Preview")) ); previewCheckbox.set_active( enablePreview ); @@ -778,13 +789,15 @@ void FileDialogBase::internalSetup() } + void FileDialogBase::cleanup( bool showConfirmed ) { - if ( showConfirmed ) { - prefs_set_int_attribute( preferenceBase.c_str(), "enable_preview", previewCheckbox.get_active() ); - } + if ( showConfirmed ) + prefs_set_int_attribute( preferenceBase.c_str(), + "enable_preview", previewCheckbox.get_active() ); } + void FileDialogBase::_previewEnabledCB() { bool enabled = previewCheckbox.get_active(); @@ -795,12 +808,14 @@ void FileDialogBase::_previewEnabledCB() } + /** * Callback for checking if the preview needs to be redrawn */ void FileDialogBase::_updatePreviewCallback() { Glib::ustring fileName = get_preview_filename(); + #ifdef WITH_GNOME_VFS if (fileName.length() < 1) fileName = get_preview_uri(); @@ -810,8 +825,6 @@ void FileDialogBase::_updatePreviewCallback() return; svgPreview.set(fileName, dialogType); -// bool retval = svgPreview.set(fileName, dialogType); -// set_preview_widget_active(retval); }