summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1e25a60)
raw | patch | inline | side by side (parent: 1e25a60)
author | tweenk <tweenk@users.sourceforge.net> | |
Sun, 7 Dec 2008 00:44:56 +0000 (00:44 +0000) | ||
committer | tweenk <tweenk@users.sourceforge.net> | |
Sun, 7 Dec 2008 00:44:56 +0000 (00:44 +0000) |
12 files changed:
diff --git a/build.xml b/build.xml
index a143876c9161843f958806d2c8a2373660f32e66..fee13acf36d9f7d8a0203a2c831a98752a3640d5 100644 (file)
--- a/build.xml
+++ b/build.xml
<include name="dir-util-test.h"/>
<include name="extract-uri-test.h"/>
<include name="mod360-test.h"/>
+ <include name="preferences-test.h"/>
<include name="round-test.h"/>
<include name="sp-gradient-test.h"/>
<include name="sp-style-elem-test.h"/>
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 4bef3dc5634734af4c314931eb15b33b8bf17017..1d2ba935227103b9fecf341f0c2d87edf7d51bf4 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
$(srcdir)/extract-uri-test.h \
$(srcdir)/mod360-test.h \
$(srcdir)/round-test.h \
+ $(srcdir)/preferences-test.h \
$(srcdir)/sp-gradient-test.h \
$(srcdir)/sp-style-elem-test.h \
$(srcdir)/style-test.h \
index 24c811778b963f668598fcbd75907beec09d79bb..c0501389fafd5f6d7934188c704be6792c2d61ac 100644 (file)
sp_object_type_register ("sodipodi:namedview", SP_TYPE_NAMEDVIEW);
sp_object_type_register ("sodipodi:guide", SP_TYPE_GUIDE);
- Inkscape::Preferences::load();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->load(true, false);
}
bool
index 9ac9fd9cf2e45598765aa882567a155ffcac4cd2..5994e19bd5e136ec8a75ef99e7bf56d33fbae96a 100644 (file)
display/nr-light-types.h
display_bezier_utils_test_SOURCES = display/bezier-utils-test.cpp
-display_bezier_utils_test_LDADD = libnr/libnr.a -lglib-2.0
+display_bezier_utils_test_LDADD = libnr/libnr.a -lglib-2.0 2geom/lib2geom.a
# Copy/paste from libnr
display/test-display-main.cpp: display/test-display.cpp
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 49b92394e48cb83ce6d0b1e06f1fb893c3b9cb79..2a7f31c3e92647b7c42e042fcd64ca60635ad2be 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
inkscape->argv0 = g_strdup(argv0);
/* Load the preferences and menus; Later menu layout should be merged into prefs */
- Inkscape::Preferences::use_gui = use_gui;
- Inkscape::Preferences::load();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->load(use_gui, false);
inkscape_load_menus(inkscape);
sp_input_load_from_preferences();
diff --git a/src/inkview.cpp b/src/inkview.cpp
index 873cacc31476fdd46f1893422c460d9bf7309803..d192449115ae2bbff40e5ec4a31752bfe92f80c7 100644 (file)
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
LIBXML_TEST_VERSION
Inkscape::GC::init();
- Inkscape::Preferences::use_gui = false;
- Inkscape::Preferences::load();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->load(false, true); // keep quiet about any failures
gtk_init (&argc, (char ***) &argv);
index b952939ed5f948be8935c821dfb8d93b80ba5d36..b4ff5851a81ce22f9397f60a2654a7e95ad88b39 100644 (file)
template<PIXEL_FORMAT resultFormat, PIXEL_FORMAT backgroundFormat, PIXEL_FORMAT foregroundFormat>
static void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha);
-template<> static void composePixel<R8G8B8, R8G8B8, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8, R8G8B8, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + alpha*s[3]*s[0], 255*255);
d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + alpha*s[3]*s[1], 255*255);
d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + alpha*s[3]*s[2], 255*255);
}
-template<> static void composePixel<R8G8B8, R8G8B8, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8, R8G8B8, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + 255*alpha*s[0], 255*255);
d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + 255*alpha*s[1], 255*255);
d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + 255*alpha*s[2], 255*255);
}
-template<> static void composePixel<R8G8B8A8N, EMPTY, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8N, EMPTY, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
unsigned int newa = 255*255 - (255*255 - alpha*s[3]);
d[0] = s[0];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[0], newa);
d[1] = s[1];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[1], newa);
d[3] = DIV_ROUND(newa, 255);
}
-template<> static void composePixel<R8G8B8A8N, EMPTY, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8N, EMPTY, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
unsigned int newa = 255*255 - (255*255 - alpha*s[3]);
d[0] = s[3] == 0 ? 0 : DIV_ROUND(255*s[0], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[0], newa);
d[1] = s[3] == 0 ? 0 : DIV_ROUND(255*s[1], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[1], newa);
d[3] = DIV_ROUND(newa, 255);
}
-template<> static void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
if ( d[3] == 0 ) {
composePixel<R8G8B8A8N, EMPTY, R8G8B8A8N>(d, s, alpha);
} else if ( alpha*s[3] == 0 ) {
}
}
-template<> static void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
if ( d[3] == 0 ) {
composePixel<R8G8B8A8N, EMPTY, R8G8B8A8P>(d, s, alpha);
} else if ( alpha*s[3] == 0 ) {
@@ -75,28 +75,28 @@ template<> static void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8P>(unsigned ch
}
}
-template<> static void composePixel<R8G8B8A8P, EMPTY, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8P, EMPTY, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
d[0] = DIV_ROUND(alpha*s[3]*s[0], 255*255);
d[1] = DIV_ROUND(alpha*s[3]*s[1], 255*255);
d[2] = DIV_ROUND(alpha*s[3]*s[2], 255*255);
d[3] = DIV_ROUND(255*255 - (255*255 - alpha*s[3]), 255);
}
-template<> static void composePixel<R8G8B8A8P, EMPTY, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8P, EMPTY, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
d[0] = DIV_ROUND(alpha*s[0], 255);
d[1] = DIV_ROUND(alpha*s[1], 255);
d[2] = DIV_ROUND(alpha*s[2], 255);
d[3] = DIV_ROUND(255*255 - (255*255 - alpha*s[3]), 255);
}
-template<> static void composePixel<R8G8B8A8P, R8G8B8A8P, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8P, R8G8B8A8P, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + alpha*s[3]*s[0], 255*255);
d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + alpha*s[3]*s[1], 255*255);
d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + alpha*s[3]*s[2], 255*255);
d[3] = DIV_ROUND(255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]), 255*255);
}
-template<> static void composePixel<R8G8B8A8P, R8G8B8A8P, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
+template<> void composePixel<R8G8B8A8P, R8G8B8A8P, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + 255 * alpha*s[0], 255*255);
d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + 255 * alpha*s[1], 255*255);
d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + 255 * alpha*s[2], 255*255);
index c409759200fe06bfcbb6349d984999190d1daa30..fe3ccd61fbc8f9fc6a6b1dd67d8711669dc454f0 100644 (file)
@@ -12,10 +12,10 @@ static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { ret
static inline unsigned char NR_PREMUL_111(unsigned int c, unsigned int a) { return static_cast<unsigned char>(DIV_ROUND(c*a, 255)); }
template<PIXEL_FORMAT format>
-static int IMGCMP(const unsigned char* a, const unsigned char* b, size_t n) { return memcmp(a, b, n); }
+int IMGCMP(const unsigned char* a, const unsigned char* b, size_t n) { return memcmp(a, b, n); }
template<>
-static int IMGCMP<R8G8B8A8N>(const unsigned char* a, const unsigned char* b, size_t n)
+int IMGCMP<R8G8B8A8N>(const unsigned char* a, const unsigned char* b, size_t n)
{
// If two pixels each have their alpha channel set to zero they're equivalent
// Note that this doesn't work for premultiplied values, as their color values should
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 8b8289849dc3ca42d14aaf400e9dadee2b3579de..76edc2f7c54c7d2ae9c3dbaa312166d154cc874a 100644 (file)
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
_prefs_basename(PREFERENCES_FILE_NAME),
_prefs_dir(""),
_prefs_filename(""),
- _writable(false),
- _prefs_doc(NULL)
+ _prefs_doc(NULL),
+ _use_gui(true),
+ _quiet(false),
+ _loaded(false),
+ _writable(false)
{
// profile_path essentailly returns the argument prefixed by the profile directory.
gchar *path = profile_path(NULL);
_prefs_filename = path;
g_free(path);
- _load();
+ _loadDefaults();
}
Preferences::~Preferences()
* Tries to load the user's preferences.xml file. If there is none, creates it.
* Displays dialog boxes on any errors.
*/
-void Preferences::_load()
-{
- _loadDefaults();
-
+void Preferences::load(bool use_gui, bool quiet)
+{
Glib::ustring const not_saved = _("Inkscape will run with default settings, "
"and new settings will not be saved. ");
+ _use_gui = use_gui;
+ _quiet = quiet;
+ _loaded = true;
// NOTE: After we upgrade to Glib 2.16, use Glib::ustring::compose
@@ -615,7 +619,8 @@ void Preferences::_keySplit(Glib::ustring const &pref_path, Glib::ustring &node_
void Preferences::_errorDialog(Glib::ustring const &msg, Glib::ustring const &secondary)
{
- if (Preferences::use_gui) {
+ if (_quiet) return;
+ if (_use_gui) {
Gtk::MessageDialog err(
msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
err.set_secondary_text(secondary);
@@ -631,7 +636,6 @@ Preferences::Entry const Preferences::_create_pref_value(Glib::ustring const &pa
return Entry(path, ptr);
}
-bool Preferences::use_gui = true;
Preferences *Preferences::_instance = NULL;
diff --git a/src/preferences.h b/src/preferences.h
index e39adc22878a15e155c19a690c9dde0a7e6a661a..2f2337b8131892f1dc6157cd8ad1970fc0e1f74b 100644 (file)
--- a/src/preferences.h
+++ b/src/preferences.h
// utility methods
/**
- * @name Save preferences to the disk.
+ * @name Load stored preferences and save them to the disk.
* @{
*/
+ /**
+ * @brief Load the preferences from the default location.
+ *
+ * Loads the stored user preferences and enables saving them. If there's
+ * no preferences file in the expected location, it creates it. Any changes
+ * made to the preferences before loading will be overridden by the stored
+ * prefs. Not calling load() is sometimes useful, e.g. for testing.
+ *
+ * @param use_gui Whether to use dialogs to notify about errors when
+ * loading the preferences. Set to false in console mode.
+ * @param quiet Whether to output any messages about preference loading.
+ * If this is true, the use_gui parameter is ignored.
+ */
+ void load(bool use_gui=true, bool quiet=false);
/**
* @brief Save all preferences to the hard disk.
*
/**
* @name Access and manipulate the Preferences object.
+ * @{
*/
/**
if (!_instance) _instance = new Preferences();
return _instance;
}
- /**
- * @brief Load the preferences.
- *
- * This method is automatically called from get(). It exists to supress
- * possible compiler warnings over unused variables.
- */
- static void load() {
- if (!_instance) _instance = new Preferences();
- }
/**
* @brief Unload all preferences and store them on the hard disk.
*
_instance = NULL;
}
}
-
- /**
- * @brief Whether to use GUI error notifications
- *
- * Set this to false when running Inkscape in command-line mode.
- * Preference-related warnings will be printed to the console.
- */
- static bool use_gui;
/*@}*/
protected:
private:
Preferences();
~Preferences();
- void _load();
void _loadDefaults();
void _getRawValue(Glib::ustring const &path, gchar const *&result);
void _setRawValue(Glib::ustring const &path, gchar const *value);
std::string _prefs_basename; ///< Basename of the prefs file
std::string _prefs_dir; ///< Directory in which to look for the prefs file
std::string _prefs_filename; ///< Full filename (with directory) of the prefs file
- bool _writable; ///< Will the preferences be saved at exit?
XML::Document *_prefs_doc; ///< XML document storing all the preferences
+ bool _use_gui; ///< Use GUI error notifications?
+ bool _quiet; ///< Display any messages about loading?
+ bool _loaded; ///< Was a load attempt made?
+ bool _writable; ///< Will the preferences be saved at exit?
/// Wrapper class for XML node observers
class PrefNodeObserver;
index 45a1a7db3dfb6770a52ddbf51ce447507f0f7305..6a6c7bcd2edc91706ce2402e80f84060bf26eec1 100644 (file)
--- a/src/svg/Makefile_insert
+++ b/src/svg/Makefile_insert
svg_libtest_svg_a_SOURCES = \
svg/test-svg.cpp \
+ preferences.cpp \
+ sp-object.cpp \
$(svg_test_svg_includes)
svg_libtest_stubs_a_SOURCES = \
$(svg_test_svg_includes)
svg_test_svg_LDADD = \
- svg/libspsvg.a \
+ svg/libspsvg.a \
svg/libtest-svg.a \
svg/libtest-stubs.a \
2geom/lib2geom.a \
- libnr/libnr.a \
+ libnr/libnr.a \
+ xml/libspxml.a \
+ util/libinkutil.a \
+ io/libio.a \
+ libinkpost.a \
+ debug/libinkdebug.a \
+ libcroco/libcroco.a \
$(INKSCAPE_LIBS)
diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp
index 1077f7e2fc928fc9e719a3614837904207c60732..1ff9776e5dbe5d95b3c09d831076e4bb7530431a 100644 (file)
--- a/src/svg/svg-affine.cpp
+++ b/src/svg/svg-affine.cpp
-#define __SP_SVG_AFFINE_C__
-
/*
* SVG data parser
*
sp_svg_transform_write(Geom::Matrix const *transform)
{
return sp_svg_transform_write(*transform);
-}
\ No newline at end of file
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :