summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ff86396)
raw | patch | inline | side by side (parent: ff86396)
author | tweenk <tweenk@users.sourceforge.net> | |
Tue, 16 Sep 2008 17:15:22 +0000 (17:15 +0000) | ||
committer | tweenk <tweenk@users.sourceforge.net> | |
Tue, 16 Sep 2008 17:15:22 +0000 (17:15 +0000) |
the Inkscape::Preferences class. Removed all use of
prefs_get_string_attribute(), pref_path_get_nth_child() and
create_pref() in favor of the new API. Replaced some "0 or 1" integer
preferences with booleans.
prefs_get_string_attribute(), pref_path_get_nth_child() and
create_pref() in favor of the new API. Replaced some "0 or 1" integer
preferences with booleans.
40 files changed:
index 4b1ea03df5f91ffb5e6e713206f772383b925bde..c7aa28971f7a033e063087709f50de3f37abddaa 100644 (file)
if (argv != NULL) {
_argv = argv; // TODO: Is this correct?
}
-
- Inkscape::Preferences::loadSkeleton();
+
if (new_gui) {
_gtk_main = new Gtk::Main(argc, argv, true);
*/
if (_gtk_main != NULL) {
g_assert(_app_impl != NULL);
-
- Inkscape::Preferences::load();
g_warning("Running main window");
Gtk::Window *win = static_cast<Gtk::Window*>(_app_impl->getWindow());
g_assert(win != NULL);
void
Application::exit()
{
- Inkscape::Preferences::save();
+ Inkscape::Preferences::unload();
if (_gtk_main != NULL) {
_gtk_main->quit();
index 8f9638f82f40555caad580524ee5d711893be7a1..0b8ac263e64ca21db7b0458482257edd5b67de3b 100644 (file)
{
//emit shutdown signal so that dialogs could remember layout
_shutdown_signal.emit();
- Inkscape::Preferences::save();
+ Inkscape::Preferences::unload();
}
//==================================================================
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index 0086d110158d6681e03fe3482c7cd8265f47d2ab..cdeb001ebe113a27b1e7384700e185db7b7f8c83 100644 (file)
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
#include "inkscape.h"
#include "persp3d.h"
#include "box3d-context.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "desktop-style.h"
#include "box3d.h"
void
box3d_side_apply_style (Box3DSide *side) {
Inkscape::XML::Node *repr_face = SP_OBJECT_REPR(SP_OBJECT(side));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gchar *descr = g_strconcat ("desktop.", box3d_side_axes_string (side), NULL);
- const gchar * cur_style = prefs_get_string_attribute(descr, "style");
- g_free (descr);
+ Glib::ustring descr = "desktop.";
+ descr += box3d_side_axes_string(side);
+ Glib::ustring cur_style = prefs->getString(descr, "style");
SPDesktop *desktop = inkscape_active_desktop();
- bool use_current = prefs_get_int_attribute("tools.shapes.3dbox", "usecurrent", 0);
- if (use_current && cur_style !=NULL) {
+ bool use_current = prefs->getBool("tools.shapes.3dbox", "usecurrent", false);
+ if (use_current && !cur_style.empty()) {
/* use last used style */
- repr_face->setAttribute("style", cur_style);
+ repr_face->setAttribute("style", cur_style.data());
} else {
/* use default style */
GString *pstring = g_string_new("");
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index 876280f298555f394b90c9413a5dd2f604e32283..583145c806a3dc596fd3f1ba7675f9f4745052d1 100644 (file)
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
#include "attributes.h"
#include "inkscape.h"
#include "document.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "dom/uri.h"
#include "dom/util/digest.h"
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
- gint dump = prefs_get_int_attribute_limited("options.scislac", #key, 0, 0, 1);\
- gint dumpD = prefs_get_int_attribute_limited("options.scislac", #key"D", 0, 0, 1);\
- gint dumpD2 = prefs_get_int_attribute_limited("options.scislac", #key"D2", 0, 0, 1);\
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();\
+ bool dump = prefs->getBool("options.scislac", #key);\
+ bool dumpD = prefs->getBool("options.scislac", #key"D");\
+ bool dumpD2 = prefs->getBool("options.scislac", #key"D2");\
dumpD &= ( (update_in_progress == 0) || dumpD2 );\
if ( dump )\
{\
cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle()
{
static cmsHPROFILE theOne = 0;
- static std::string lastURI;
+ static Glib::ustring lastURI;
static bool init = false;
if ( !init ) {
init = true;
}
- gchar const * uri = prefs_get_string_attribute("options.displayprofile", "uri");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring uri = prefs->getString("options.displayprofile", "uri");
- if ( uri && *uri ) {
- if ( lastURI != std::string(uri) ) {
+ if ( !uri.empty() ) {
+ if ( uri != lastURI ) {
lastURI.clear();
if ( theOne ) {
cmsCloseProfile( theOne );
cmsDeleteTransform( transf );
transf = 0;
}
- theOne = cmsOpenProfileFromFile( uri, "r" );
+ theOne = cmsOpenProfileFromFile( uri.data(), "r" );
if ( theOne ) {
// a display profile must have the proper stuff
icColorSpaceSignature space = cmsGetColorSpace(theOne);
cmsHPROFILE Inkscape::colorprofile_get_proof_profile_handle()
{
static cmsHPROFILE theOne = 0;
- static std::string lastURI;
+ static Glib::ustring lastURI;
static bool init = false;
if ( !init ) {
init = true;
}
- long long int which = prefs_get_int_attribute_limited( "options.softproof", "enable", 0, 0, 1 );
- gchar const * uri = prefs_get_string_attribute("options.softproof", "uri");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool which = prefs->getBool( "options.softproof", "enable");
+ Glib::ustring uri = prefs->getString("options.softproof", "uri");
- if ( which && uri && *uri ) {
- if ( lastURI != std::string(uri) ) {
+ if ( which && !uri.empty() ) {
+ if ( lastURI != uri ) {
lastURI.clear();
if ( theOne ) {
cmsCloseProfile( theOne );
cmsDeleteTransform( transf );
transf = 0;
}
- theOne = cmsOpenProfileFromFile( uri, "r" );
+ theOne = cmsOpenProfileFromFile( uri.data(), "r" );
if ( theOne ) {
// a display profile must have the proper stuff
icColorSpaceSignature space = cmsGetColorSpace(theOne);
cmsHTRANSFORM Inkscape::colorprofile_get_display_transform()
{
- long long int fromDisplay = prefs_get_int_attribute_limited( "options.displayprofile", "from_display", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool fromDisplay = prefs->getBool( "options.displayprofile", "from_display");
if ( fromDisplay ) {
if ( transf ) {
cmsDeleteTransform(transf);
return 0;
}
- bool warn = prefs_get_int_attribute_limited( "options.softproof", "gamutwarn", 0, 0, 1 );
- int intent = prefs_get_int_attribute_limited( "options.displayprofile", "intent", 0, 0, 3 );
- int proofIntent = prefs_get_int_attribute_limited( "options.softproof", "intent", 0, 0, 3 );
- bool bpc = prefs_get_int_attribute_limited( "options.softproof", "bpc", 0, 0, 1 );
+ bool warn = prefs->getBool( "options.softproof", "gamutwarn");
+ int intent = prefs->getIntLimited( "options.displayprofile", "intent", 0, 0, 3 );
+ int proofIntent = prefs->getIntLimited( "options.softproof", "intent", 0, 0, 3 );
+ bool bpc = prefs->getBool( "options.softproof", "bpc");
#if defined(cmsFLAGS_PRESERVEBLACK)
- bool preserveBlack = prefs_get_int_attribute_limited( "options.softproof", "preserveblack", 0, 0, 1 );
+ bool preserveBlack = prefs->getBool( "options.softproof", "preserveblack");
#endif //defined(cmsFLAGS_PRESERVEBLACK)
- gchar const* colorStr = prefs_get_string_attribute("options.softproof", "gamutcolor");
- Gdk::Color gamutColor( (colorStr && colorStr[0]) ? colorStr : "#808080");
+ Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor");
+ Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr );
if ( (warn != gamutWarn)
|| (lastIntent != intent)
@@ -958,21 +962,22 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_per( Glib::ustring const& id )
return 0;
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool found = false;
for ( std::vector< std::vector<MemProfile> >::iterator it = perMonitorProfiles.begin(); it != perMonitorProfiles.end() && !found; ++it ) {
for ( std::vector<MemProfile>::iterator it2 = it->begin(); it2 != it->end() && !found; ++it2 ) {
if ( id == it2->id ) {
MemProfile& item = *it2;
- bool warn = prefs_get_int_attribute_limited( "options.softproof", "gamutwarn", 0, 0, 1 );
- int intent = prefs_get_int_attribute_limited( "options.displayprofile", "intent", 0, 0, 3 );
- int proofIntent = prefs_get_int_attribute_limited( "options.softproof", "intent", 0, 0, 3 );
- bool bpc = prefs_get_int_attribute_limited( "options.softproof", "bpc", 0, 0, 1 );
+ bool warn = prefs->getBool( "options.softproof", "gamutwarn");
+ int intent = prefs->getIntLimited( "options.displayprofile", "intent", 0, 0, 3 );
+ int proofIntent = prefs->getIntLimited( "options.softproof", "intent", 0, 0, 3 );
+ bool bpc = prefs->getBool( "options.softproof", "bpc");
#if defined(cmsFLAGS_PRESERVEBLACK)
- bool preserveBlack = prefs_get_int_attribute_limited( "options.softproof", "preserveblack", 0, 0, 1 );
+ bool preserveBlack = prefs->getBool( "options.softproof", "preserveblack");
#endif //defined(cmsFLAGS_PRESERVEBLACK)
- gchar const* colorStr = prefs_get_string_attribute("options.softproof", "gamutcolor");
- Gdk::Color gamutColor( (colorStr && colorStr[0]) ? colorStr : "#808080");
+ Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor");
+ Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr );
if ( (warn != gamutWarn)
|| (lastIntent != intent)
index 9da7e057123536238d0c1b132a1bcbc17d8e77b7..b15dfe5f459001021a162e4bd5433a2fa3f96ed9 100644 (file)
#include "helper/units.h"
#include "widgets/icon.h"
#include "../inkscape.h"
-#include "../prefs-utils.h"
+#include "preferences.h"
#include "dialog-events.h"
#include "../macros.h"
#include "../verbs.h"
@@ -124,10 +124,11 @@ clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path, "x", x);
+ prefs->setInt(prefs_path, "y", y);
+ prefs->setInt(prefs_path, "w", w);
+ prefs->setInt(prefs_path, "h", h);
return FALSE; // which means, go ahead and destroy it
is_updating = true;
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, prefs_path);
gchar c[32];
sp_svg_write_color(c, sizeof(c), rgba);
- repr->setAttribute("initial_color", c);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(prefs_path, "initial_color", c);
is_updating = false;
}
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL)
return;
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::Selection *selection = sp_desktop_selection(desktop);
// check if something is selected
clonetiler_remove (NULL, NULL, false);
- double shiftx_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shiftx_per_i", 0, -10000, 10000);
- double shifty_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shifty_per_i", 0, -10000, 10000);
- double shiftx_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shiftx_per_j", 0, -10000, 10000);
- double shifty_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shifty_per_j", 0, -10000, 10000);
- double shiftx_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shiftx_rand", 0, 0, 1000);
- double shifty_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "shifty_rand", 0, 0, 1000);
- double shiftx_exp = prefs_get_double_attribute_limited (prefs_path, "shiftx_exp", 1, 0, 10);
- double shifty_exp = prefs_get_double_attribute_limited (prefs_path, "shifty_exp", 1, 0, 10);
- int shiftx_alternate = prefs_get_int_attribute (prefs_path, "shiftx_alternate", 0);
- int shifty_alternate = prefs_get_int_attribute (prefs_path, "shifty_alternate", 0);
- int shiftx_cumulate = prefs_get_int_attribute (prefs_path, "shiftx_cumulate", 0);
- int shifty_cumulate = prefs_get_int_attribute (prefs_path, "shifty_cumulate", 0);
- int shiftx_excludew = prefs_get_int_attribute (prefs_path, "shiftx_excludew", 0);
- int shifty_excludeh = prefs_get_int_attribute (prefs_path, "shifty_excludeh", 0);
-
- double scalex_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scalex_per_i", 0, -100, 1000);
- double scaley_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scaley_per_i", 0, -100, 1000);
- double scalex_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scalex_per_j", 0, -100, 1000);
- double scaley_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scaley_per_j", 0, -100, 1000);
- double scalex_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scalex_rand", 0, 0, 1000);
- double scaley_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "scaley_rand", 0, 0, 1000);
- double scalex_exp = prefs_get_double_attribute_limited (prefs_path, "scalex_exp", 1, 0, 10);
- double scaley_exp = prefs_get_double_attribute_limited (prefs_path, "scaley_exp", 1, 0, 10);
- double scalex_log = prefs_get_double_attribute_limited (prefs_path, "scalex_log", 0, 0, 10);
- double scaley_log = prefs_get_double_attribute_limited (prefs_path, "scaley_log", 0, 0, 10);
- int scalex_alternate = prefs_get_int_attribute (prefs_path, "scalex_alternate", 0);
- int scaley_alternate = prefs_get_int_attribute (prefs_path, "scaley_alternate", 0);
- int scalex_cumulate = prefs_get_int_attribute (prefs_path, "scalex_cumulate", 0);
- int scaley_cumulate = prefs_get_int_attribute (prefs_path, "scaley_cumulate", 0);
-
- double rotate_per_i = prefs_get_double_attribute_limited (prefs_path, "rotate_per_i", 0, -180, 180);
- double rotate_per_j = prefs_get_double_attribute_limited (prefs_path, "rotate_per_j", 0, -180, 180);
- double rotate_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rotate_rand", 0, 0, 100);
- int rotate_alternatei = prefs_get_int_attribute (prefs_path, "rotate_alternatei", 0);
- int rotate_alternatej = prefs_get_int_attribute (prefs_path, "rotate_alternatej", 0);
- int rotate_cumulatei = prefs_get_int_attribute (prefs_path, "rotate_cumulatei", 0);
- int rotate_cumulatej = prefs_get_int_attribute (prefs_path, "rotate_cumulatej", 0);
-
- double blur_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "blur_per_i", 0, 0, 100);
- double blur_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "blur_per_j", 0, 0, 100);
- int blur_alternatei = prefs_get_int_attribute (prefs_path, "blur_alternatei", 0);
- int blur_alternatej = prefs_get_int_attribute (prefs_path, "blur_alternatej", 0);
- double blur_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "blur_rand", 0, 0, 100);
-
- double opacity_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "opacity_per_i", 0, 0, 100);
- double opacity_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "opacity_per_j", 0, 0, 100);
- int opacity_alternatei = prefs_get_int_attribute (prefs_path, "opacity_alternatei", 0);
- int opacity_alternatej = prefs_get_int_attribute (prefs_path, "opacity_alternatej", 0);
- double opacity_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "opacity_rand", 0, 0, 100);
-
- const gchar *initial_color = prefs_get_string_attribute (prefs_path, "initial_color");
- double hue_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "hue_per_j", 0, -100, 100);
- double hue_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "hue_per_i", 0, -100, 100);
- double hue_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "hue_rand", 0, 0, 100);
- double saturation_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "saturation_per_j", 0, -100, 100);
- double saturation_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "saturation_per_i", 0, -100, 100);
- double saturation_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "saturation_rand", 0, 0, 100);
- double lightness_per_j = 0.01 * prefs_get_double_attribute_limited (prefs_path, "lightness_per_j", 0, -100, 100);
- double lightness_per_i = 0.01 * prefs_get_double_attribute_limited (prefs_path, "lightness_per_i", 0, -100, 100);
- double lightness_rand = 0.01 * prefs_get_double_attribute_limited (prefs_path, "lightness_rand", 0, 0, 100);
- int color_alternatej = prefs_get_int_attribute (prefs_path, "color_alternatej", 0);
- int color_alternatei = prefs_get_int_attribute (prefs_path, "color_alternatei", 0);
-
- int type = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
-
- int keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
-
- int imax = prefs_get_int_attribute (prefs_path, "imax", 2);
- int jmax = prefs_get_int_attribute (prefs_path, "jmax", 2);
-
- int fillrect = prefs_get_int_attribute (prefs_path, "fillrect", 0);
- double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 1e6);
- double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 1e6);
-
- int dotrace = prefs_get_int_attribute (prefs_path, "dotrace", 0);
- int pick = prefs_get_int_attribute (prefs_path, "pick", 0);
- int pick_to_presence = prefs_get_int_attribute (prefs_path, "pick_to_presence", 0);
- int pick_to_size = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
- int pick_to_color = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
- int pick_to_opacity = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
- double rand_picked = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_picked", 0, 0, 100);
- int invert_picked = prefs_get_int_attribute (prefs_path, "invert_picked", 0);
- double gamma_picked = prefs_get_double_attribute_limited (prefs_path, "gamma_picked", 0, -10, 10);
+ double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "shiftx_per_i", 0, -10000, 10000);
+ double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "shifty_per_i", 0, -10000, 10000);
+ double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "shiftx_per_j", 0, -10000, 10000);
+ double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "shifty_per_j", 0, -10000, 10000);
+ double shiftx_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "shiftx_rand", 0, 0, 1000);
+ double shifty_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "shifty_rand", 0, 0, 1000);
+ double shiftx_exp = prefs->getDoubleLimited(prefs_path, "shiftx_exp", 1, 0, 10);
+ double shifty_exp = prefs->getDoubleLimited(prefs_path, "shifty_exp", 1, 0, 10);
+ bool shiftx_alternate = prefs->getBool(prefs_path, "shiftx_alternate");
+ bool shifty_alternate = prefs->getBool(prefs_path, "shifty_alternate");
+ bool shiftx_cumulate = prefs->getBool(prefs_path, "shiftx_cumulate");
+ bool shifty_cumulate = prefs->getBool(prefs_path, "shifty_cumulate");
+ bool shiftx_excludew = prefs->getBool(prefs_path, "shiftx_excludew");
+ bool shifty_excludeh = prefs->getBool(prefs_path, "shifty_excludeh");
+
+ double scalex_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "scalex_per_i", 0, -100, 1000);
+ double scaley_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "scaley_per_i", 0, -100, 1000);
+ double scalex_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "scalex_per_j", 0, -100, 1000);
+ double scaley_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "scaley_per_j", 0, -100, 1000);
+ double scalex_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "scalex_rand", 0, 0, 1000);
+ double scaley_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "scaley_rand", 0, 0, 1000);
+ double scalex_exp = prefs->getDoubleLimited(prefs_path, "scalex_exp", 1, 0, 10);
+ double scaley_exp = prefs->getDoubleLimited(prefs_path, "scaley_exp", 1, 0, 10);
+ double scalex_log = prefs->getDoubleLimited(prefs_path, "scalex_log", 0, 0, 10);
+ double scaley_log = prefs->getDoubleLimited(prefs_path, "scaley_log", 0, 0, 10);
+ bool scalex_alternate = prefs->getBool(prefs_path, "scalex_alternate");
+ bool scaley_alternate = prefs->getBool(prefs_path, "scaley_alternate");
+ bool scalex_cumulate = prefs->getBool(prefs_path, "scalex_cumulate");
+ bool scaley_cumulate = prefs->getBool(prefs_path, "scaley_cumulate");
+
+ double rotate_per_i = prefs->getDoubleLimited(prefs_path, "rotate_per_i", 0, -180, 180);
+ double rotate_per_j = prefs->getDoubleLimited(prefs_path, "rotate_per_j", 0, -180, 180);
+ double rotate_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "rotate_rand", 0, 0, 100);
+ bool rotate_alternatei = prefs->getBool(prefs_path, "rotate_alternatei");
+ bool rotate_alternatej = prefs->getBool(prefs_path, "rotate_alternatej");
+ bool rotate_cumulatei = prefs->getBool(prefs_path, "rotate_cumulatei");
+ bool rotate_cumulatej = prefs->getBool(prefs_path, "rotate_cumulatej");
+
+ double blur_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "blur_per_i", 0, 0, 100);
+ double blur_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "blur_per_j", 0, 0, 100);
+ bool blur_alternatei = prefs->getBool(prefs_path, "blur_alternatei");
+ bool blur_alternatej = prefs->getBool(prefs_path, "blur_alternatej");
+ double blur_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "blur_rand", 0, 0, 100);
+
+ double opacity_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "opacity_per_i", 0, 0, 100);
+ double opacity_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "opacity_per_j", 0, 0, 100);
+ bool opacity_alternatei = prefs->getBool(prefs_path, "opacity_alternatei");
+ bool opacity_alternatej = prefs->getBool(prefs_path, "opacity_alternatej");
+ double opacity_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "opacity_rand", 0, 0, 100);
+
+ Glib::ustring initial_color = prefs->getString(prefs_path, "initial_color");
+ double hue_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "hue_per_j", 0, -100, 100);
+ double hue_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "hue_per_i", 0, -100, 100);
+ double hue_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "hue_rand", 0, 0, 100);
+ double saturation_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "saturation_per_j", 0, -100, 100);
+ double saturation_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "saturation_per_i", 0, -100, 100);
+ double saturation_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "saturation_rand", 0, 0, 100);
+ double lightness_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "lightness_per_j", 0, -100, 100);
+ double lightness_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "lightness_per_i", 0, -100, 100);
+ double lightness_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "lightness_rand", 0, 0, 100);
+ bool color_alternatej = prefs->getBool(prefs_path, "color_alternatej");
+ bool color_alternatei = prefs->getBool(prefs_path, "color_alternatei");
+
+ int type = prefs->getInt(prefs_path, "symmetrygroup", 0);
+
+ bool keepbbox = prefs->getBool(prefs_path, "keepbbox", true);
+
+ int imax = prefs->getInt(prefs_path, "imax", 2);
+ int jmax = prefs->getInt(prefs_path, "jmax", 2);
+
+ bool fillrect = prefs->getBool(prefs_path, "fillrect");
+ double fillwidth = prefs->getDoubleLimited(prefs_path, "fillwidth", 50, 0, 1e6);
+ double fillheight = prefs->getDoubleLimited(prefs_path, "fillheight", 50, 0, 1e6);
+
+ bool dotrace = prefs->getBool(prefs_path, "dotrace");
+ int pick = prefs->getInt(prefs_path, "pick");
+ bool pick_to_presence = prefs->getBool(prefs_path, "pick_to_presence");
+ bool pick_to_size = prefs->getBool(prefs_path, "pick_to_size");
+ bool pick_to_color = prefs->getBool(prefs_path, "pick_to_color");
+ bool pick_to_opacity = prefs->getBool(prefs_path, "pick_to_opacity");
+ double rand_picked = 0.01 * prefs->getDoubleLimited(prefs_path, "rand_picked", 0, 0, 100);
+ bool invert_picked = prefs->getBool(prefs_path, "invert_picked");
+ double gamma_picked = prefs->getDoubleLimited(prefs_path, "gamma_picked", 0, -10, 10);
if (dotrace) {
clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj));
x0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-x0", 0);
y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0);
} else {
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
- SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
- SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ bool prefs_bbox = prefs->getBool("tools", "bounding_box", false);
+ SPItem::BBoxType bbox_type = ( prefs_bbox ?
+ SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX );
boost::optional<NR::Rect> r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)),
bbox_type);
if (r) {
gchar color_string[32]; *color_string = 0;
// Color tab
- if (initial_color) {
- guint32 rgba = sp_svg_read_color (initial_color, 0x000000ff);
+ if (!initial_color.empty()) {
+ guint32 rgba = sp_svg_read_color (initial_color.data(), 0x000000ff);
float hsl[3];
sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba));
clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data)
{
const gchar *attr = (const gchar *) data;
- prefs_set_int_attribute (prefs_path, attr, gtk_toggle_button_get_active (tb));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path, attr, gtk_toggle_button_get_active(tb));
}
static GtkWidget *
GtkWidget *b = gtk_check_button_new ();
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL);
- int value = prefs_get_int_attribute (prefs_path, attr, 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool value = prefs->getBool(prefs_path, attr);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
static void
clonetiler_value_changed (GtkAdjustment *adj, gpointer data)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
const gchar *pref = (const gchar *) data;
- prefs_set_double_attribute (prefs_path, pref, adj->value);
+ prefs->setDouble(prefs_path, pref, adj->value);
}
static GtkWidget *
@@ -1597,7 +1601,8 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l
gtk_entry_set_width_chars (GTK_ENTRY (sb), 4);
gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN);
- double value = prefs_get_double_attribute_limited (prefs_path, attr, exponent? 1 : 0, lower, upper);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double value = prefs->getDoubleLimited(prefs_path, attr, exponent? 1.0 : 0.0, lower, upper);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
gtk_signal_connect(GTK_OBJECT(a), "value_changed",
GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr);
@@ -1621,28 +1626,32 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l
static void
clonetiler_symgroup_changed( GtkMenuItem */*item*/, gpointer data )
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint group_new = GPOINTER_TO_INT (data);
- prefs_set_int_attribute ( prefs_path, "symmetrygroup", group_new );
+ prefs->setInt(prefs_path, "symmetrygroup", group_new);
}
static void
clonetiler_xy_changed (GtkAdjustment *adj, gpointer data)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
const gchar *pref = (const gchar *) data;
- prefs_set_int_attribute (prefs_path, pref, (int) floor(adj->value + 0.5));
+ prefs->setInt(prefs_path, pref, (int) floor(adj->value + 0.5));
}
static void
clonetiler_keep_bbox_toggled( GtkToggleButton *tb, gpointer /*data*/ )
{
- prefs_set_int_attribute (prefs_path, "keepbbox", gtk_toggle_button_get_active (tb));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path, "keepbbox", gtk_toggle_button_get_active(tb));
}
static void
clonetiler_pick_to (GtkToggleButton *tb, gpointer data)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
const gchar *pref = (const gchar *) data;
- prefs_set_int_attribute (prefs_path, pref, gtk_toggle_button_get_active (tb));
+ prefs->setBool(prefs_path, pref, gtk_toggle_button_get_active(tb));
}
static void
clonetiler_pick_switched( GtkToggleButton */*tb*/, gpointer data )
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint v = GPOINTER_TO_INT (data);
- prefs_set_int_attribute (prefs_path, "pick", v);
+ prefs->setInt(prefs_path, "pick", v);
}
gtk_widget_set_sensitive (widthheight, FALSE);
}
- prefs_set_int_attribute (prefs_path, "fillrect", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path, "fillrect", false);
}
gtk_widget_set_sensitive (widthheight, TRUE);
}
- prefs_set_int_attribute (prefs_path, "fillrect", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path, "fillrect", true);
}
SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
- prefs_set_double_attribute (prefs_path, "fillwidth", pixels);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(prefs_path, "fillwidth", pixels);
}
static void
SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
- prefs_set_double_attribute (prefs_path, "fillheight", pixels);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(prefs_path, "fillheight", pixels);
}
{
GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
- prefs_set_int_attribute (prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
if (vvb)
gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
void
clonetiler_dialog (void)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (!dlg)
{
gchar title[500];
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", -1000);
- y = prefs_get_int_attribute (prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path, "x", -1000);
+ y = prefs->getInt(prefs_path, "y", -1000);
}
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path, "w", 0);
+ h = prefs->getInt(prefs_path, "h", 0);
}
// if (x<0) x=0;
gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN);
GtkWidget *m = gtk_menu_new ();
- int current = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
+ int current = prefs->getInt(prefs_path, "symmetrygroup", 0);
struct SymGroups {
int group;
GtkWidget *l = gtk_label_new (_("Initial color: "));
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
- guint32 rgba = 0x000000ff | sp_svg_read_color (prefs_get_string_attribute(prefs_path, "initial_color"), 0x000000ff);
+ guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path, "initial_color").data(), 0x000000ff);
color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke)")), rgba, false);
_color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));
g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
- gint old = prefs_get_int_attribute (prefs_path, "dotrace", 0);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+ bool old = prefs->getBool(prefs_path, "dotrace");
+ gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"), NULL);
gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
clonetiler_table_attach (table, radio, 0.0, 1, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_COLOR);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_COLOR);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
clonetiler_table_attach (table, radio, 0.0, 2, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_OPACITY);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_OPACITY);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R"));
clonetiler_table_attach (table, radio, 0.0, 1, 2);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_R);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_R);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G"));
clonetiler_table_attach (table, radio, 0.0, 2, 2);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_G);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_G);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B"));
clonetiler_table_attach (table, radio, 0.0, 3, 2);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_B);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_B);
}
{
//TRANSLATORS: only translate "string" in "context|string".
clonetiler_table_attach (table, radio, 0.0, 1, 3);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_H);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_H);
}
{
//TRANSLATORS: only translate "string" in "context|string".
clonetiler_table_attach (table, radio, 0.0, 2, 3);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_S);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_S);
}
{
//TRANSLATORS: only translate "string" in "context|string".
clonetiler_table_attach (table, radio, 0.0, 3, 3);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_L);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_L);
}
}
{
GtkWidget *b = gtk_check_button_new_with_label (_("Presence"));
- gint old = prefs_get_int_attribute (prefs_path, "pick_to_presence", 1);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+ bool old = prefs->getBool(prefs_path, "pick_to_presence", true);
+ gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
clonetiler_table_attach (table, b, 0.0, 1, 1);
gtk_signal_connect(GTK_OBJECT(b), "toggled",
{
GtkWidget *b = gtk_check_button_new_with_label (_("Size"));
- gint old = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+ bool old = prefs->getBool(prefs_path, "pick_to_size");
+ gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
clonetiler_table_attach (table, b, 0.0, 2, 1);
gtk_signal_connect(GTK_OBJECT(b), "toggled",
{
GtkWidget *b = gtk_check_button_new_with_label (_("Color"));
- gint old = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+ bool old = prefs->getBool(prefs_path, "pick_to_color", 0);
+ gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"), NULL);
clonetiler_table_attach (table, b, 0.0, 1, 2);
gtk_signal_connect(GTK_OBJECT(b), "toggled",
{
GtkWidget *b = gtk_check_button_new_with_label (_("Opacity"));
- gint old = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
+ bool old = prefs->getBool(prefs_path, "pick_to_opacity", 0);
+ gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
clonetiler_table_attach (table, b, 0.0, 2, 2);
gtk_signal_connect(GTK_OBJECT(b), "toggled",
GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity");
}
}
- gtk_widget_set_sensitive (vvb, prefs_get_int_attribute (prefs_path, "dotrace", 0));
+ gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path, "dotrace"));
}
}
{
GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
- int value = prefs_get_int_attribute (prefs_path, "jmax", 2);
+ int value = prefs->getInt(prefs_path, "jmax", 2);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL);
{
GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
- int value = prefs_get_int_attribute (prefs_path, "imax", 2);
+ int value = prefs->getInt(prefs_path, "imax", 2);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL);
GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0);
sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
- double value = prefs_get_double_attribute (prefs_path, "fillwidth", 50);
+ double value = prefs->getDouble(prefs_path, "fillwidth", 50.0);
SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
gdouble const units = sp_pixels_get_units (value, unit);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0);
sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
- double value = prefs_get_double_attribute (prefs_path, "fillheight", 50);
+ double value = prefs->getDouble(prefs_path, "fillheight", 50.0);
SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
gdouble const units = sp_pixels_get_units (value, unit);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
clonetiler_table_attach (table, radio, 0.0, 1, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
}
- if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 0) {
+ if (!prefs->getBool(prefs_path, "fillrect")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
}
clonetiler_table_attach (table, radio, 0.0, 2, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
}
- if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 1) {
+ if (prefs->getBool(prefs_path, "fillrect")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
}
gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile"));
- gint keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox != 0);
+ bool keepbbox = prefs->getBool(prefs_path, "keepbbox", true);
+ gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size"), NULL);
gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index ddf62f371f84c811ccc2055017b3cc4e7d0b71d8..382e956efbd6bdb9934f1195c6e100ddbe19e6a1 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
#include "selection-chemistry.h"
#include "dialog-events.h"
-#include "../prefs-utils.h"
-#include "../verbs.h"
-#include "../interface.h"
+#include "preferences.h"
+#include "verbs.h"
+#include "interface.h"
#include "extension/output.h"
#include "extension/db.h"
@@ -169,11 +169,12 @@ sp_export_dialog_delete ( GtkObject */*object*/, GdkEvent */*event*/, gpointer /
if (x<0) x=0;
if (y<0) y=0;
-
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path, "x", x);
+ prefs->setInt(prefs_path, "y", y);
+ prefs->setInt(prefs_path, "w", w);
+ prefs->setInt(prefs_path, "h", h);
return FALSE; // which means, go ahead and destroy it
void
sp_export_dialog (void)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (!dlg) {
gchar title[500];
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", 0);
- y = prefs_get_int_attribute (prefs_path, "y", 0);
+ x = prefs->getInt(prefs_path, "x", 0);
+ y = prefs->getInt(prefs_path, "y", 0);
}
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path, "w", 0);
+ h = prefs->getInt(prefs_path, "h", 0);
}
// if (x<0) x=0;
dlg );
sp_export_spinbutton_new ( "xdpi",
- prefs_get_double_attribute
- ( "dialogs.export.defaultxdpi",
- "value", DPI_BASE),
+ prefs->getDouble("dialogs.export.defaultxdpi", "value", DPI_BASE),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 0,
NULL, _("dp_i"), 2, 1,
G_CALLBACK (sp_export_xdpi_value_changed),
* Needs fixing: there's no way to set ydpi currently, so we use
* the defaultxdpi value here, too...
*/
- sp_export_spinbutton_new ( "ydpi", prefs_get_double_attribute
- ( "dialogs.export.defaultxdpi",
- "value", DPI_BASE),
+ sp_export_spinbutton_new ( "ydpi", prefs->getDouble("dialogs.export.defaultxdpi", "value", DPI_BASE),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 1,
NULL, _("dpi"), 2, 0, NULL, dlg );
/* Try using the preferences */
if (key == SELECTION_NUMBER_OF) {
- const gchar *what = NULL;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int i = SELECTION_NUMBER_OF;
- what = prefs_get_string_attribute ("dialogs.export.exportarea", "value");
+ Glib::ustring what = prefs->getString("dialogs.export.exportarea", "value");
- if (what != NULL) {
+ if (!what.empty()) {
for (i = 0; i < SELECTION_NUMBER_OF; i++) {
- if (!strcmp (what, selection_names[i])) {
+ if (what == selection_names[i]) {
break;
}
}
} // switch
// remember area setting
- prefs_set_string_attribute ( "dialogs.export.exportarea",
- "value", selection_names[key]);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("dialogs.export.exportarea", "value", selection_names[key]);
if ( key != SELECTION_CUSTOM && bbox ) {
sp_export_set_area (base, bbox->min()[NR::X],
xdpi = sp_export_value_get (base, "xdpi");
// remember xdpi setting
- prefs_set_double_attribute ("dialogs.export.defaultxdpi", "value", xdpi);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("dialogs.export.defaultxdpi", "value", xdpi);
bmwidth = (x1 - x0) * xdpi / DPI_BASE;
index 21889179f7d7e01a5d70ded0cf2e89aa589a9176..5d76cc8f6dcc70d61da43214606dd2acb061b0b0 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
#include "path-prefix.h"
#include "swatches.h"
#include "sp-item.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "eek-preview.h"
if ( !possible.empty() ) {
JustForNow* first = 0;
- gchar const* targetName = 0;
+ Glib::ustring targetName;
if ( _prefs_path ) {
- targetName = prefs_get_string_attribute( _prefs_path, "palette" );
- if ( targetName ) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ targetName = prefs->getString(_prefs_path, "palette");
+ if (!targetName.empty()) {
for ( std::vector<JustForNow*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
if ( (*iter)->_name == targetName ) {
first = *iter;
JustForNow* curr = possible[itemId];
if ( _prefs_path ) {
- prefs_set_string_attribute( _prefs_path, "palette", curr->_name.c_str() );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path, "palette", curr->_name);
}
if ( curr->_prefWidth > 0 ) {
index 0294f74206d744b44512d057810360b27429203a..7aecfb0b558a289b11fb2398de1ab7f9a4b14e7e 100644 (file)
#include "desktop.h"
#include "document.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params
@@ -193,17 +193,18 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
: CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC)
{
- gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.axonom", "units") );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.axonom", "units").data() );
if (!gridunit)
gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
- origin[NR::X] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.axonom", "origin_x", 0.0), *(gridunit) );
- origin[NR::Y] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.axonom", "origin_y", 0.0), *(gridunit) );
- color = prefs_get_int_attribute("options.grids.axonom", "color", 0x0000ff20);
- empcolor = prefs_get_int_attribute("options.grids.axonom", "empcolor", 0x0000ff40);
- empspacing = prefs_get_int_attribute("options.grids.axonom", "empspacing", 5);
- lengthy = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.axonom", "spacing_y", 1.0), *(gridunit) );
- angle_deg[X] = prefs_get_double_attribute ("options.grids.axonom", "angle_x", 30.0);
- angle_deg[Z] = prefs_get_double_attribute ("options.grids.axonom", "angle_z", 30.0);
+ origin[NR::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit );
+ origin[NR::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit );
+ color = prefs->getInt("options.grids.axonom", "color", 0x0000ff20);
+ empcolor = prefs->getInt("options.grids.axonom", "empcolor", 0x0000ff40);
+ empspacing = prefs->getInt("options.grids.axonom", "empspacing", 5);
+ lengthy = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "spacing_y", 1.0), *gridunit );
+ angle_deg[X] = prefs->getDouble("options.grids.axonom", "angle_x", 30.0);
+ angle_deg[Z] = prefs->getDouble("options.grids.axonom", "angle_z", 30.0);
angle_deg[Y] = 0;
angle_rad[X] = deg_to_rad(angle_deg[X]);
CanvasAxonomGrid::Render (SPCanvasBuf *buf)
{
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint32 _empcolor;
- bool preference = prefs_get_int_attribute ("options.grids", "no_emphasize_when_zoomedout", 0) == 1;
+ bool preference = prefs->getBool("options.grids", "no_emphasize_when_zoomedout", false);
if( scaled && preference ) {
_empcolor = color;
} else {
index 6d6b5d89f17790f82a24a251f1d911412b77ee81..27f7030e448698a127a76c240fee4abfb81e6a02 100644 (file)
#include "desktop.h"
#include "../document.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "canvas-grid.h"
#include "canvas-axonomgrid.h"
@@ -415,17 +415,18 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
: CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR)
{
- gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.xy", "units") );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.xy", "units").data() );
if (!gridunit)
gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
- origin[NR::X] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "origin_x", 0.0), *(gridunit) );
- origin[NR::Y] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "origin_y", 0.0), *(gridunit) );
- color = prefs_get_int_attribute("options.grids.xy", "color", 0x0000ff20);
- empcolor = prefs_get_int_attribute("options.grids.xy", "empcolor", 0x0000ff40);
- empspacing = prefs_get_int_attribute("options.grids.xy", "empspacing", 5);
- spacing[NR::X] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "spacing_x", 0.0), *(gridunit) );
- spacing[NR::Y] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "spacing_y", 0.0), *(gridunit) );
- render_dotted = prefs_get_int_attribute ("options.grids.xy", "dotted", 0) == 1;
+ origin[NR::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_x", 0.0), *gridunit);
+ origin[NR::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_y", 0.0), *gridunit);
+ color = prefs->getInt("options.grids.xy", "color", 0x0000ff20);
+ empcolor = prefs->getInt("options.grids.xy", "empcolor", 0x0000ff40);
+ empspacing = prefs->getInt("options.grids.xy", "empspacing", 5);
+ spacing[NR::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_x", 0.0), *gridunit);
+ spacing[NR::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_y", 0.0), *gridunit);
+ render_dotted = prefs->getBool("options.grids.xy", "dotted", false);
snapper = new CanvasXYGridSnapper(this, &namedview->snap_manager, 0);
gint const ylinestart = (gint) Inkscape::round((syg - ow[NR::Y]) / sw[NR::Y]);
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint32 _empcolor;
- bool no_emp_when_zoomed_out = prefs_get_int_attribute ("options.grids", "no_emphasize_when_zoomedout", 0) == 1;
+ bool no_emp_when_zoomed_out = prefs->getBool("options.grids", "no_emphasize_when_zoomedout", false);
if( (scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out ) {
_empcolor = color;
} else {
index 7955d90ffb3864dfc9aa4f6fd17427587bd90087..1f6d973c33e8b065d3f4415239b275ab974bc5af 100644 (file)
#include "selection.h"
#include "sp-namedview.h"
#include "io/sys.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "../system.h"
#include "extension/effect.h"
#include "extension/output.h"
interpName = interp->defaultval;
// 1. Check preferences
- gchar const *prefInterp = prefs_get_string_attribute("extensions", interp->prefstring);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring prefInterp = prefs->getString("extensions", interp->prefstring);
- if (prefInterp) {
+ if (!prefInterp.empty()) {
interpName = prefInterp;
return interpName;
}
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 940726df58e095386c212b1d0b2790f5d92b65d6..9a5aea86cd1a343bbdf2ee521d31334e2042988e 100644 (file)
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
#ifdef WITH_LIBWPG
#include "internal/wpg-input.h"
#endif
-#include "prefs-utils.h"
+#include "preferences.h"
#include "io/sys.h"
#ifdef WITH_IMAGE_MAGICK
update_pref(gchar const *pref_path, gchar const *pref_attr,
gchar const *pref_default) // , GSList *extension_family)
{
- gchar const *pref = prefs_get_string_attribute(pref_path,pref_attr);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring pref = prefs->getString(pref_path, pref_attr);
/*
gboolean missing=TRUE;
for (GSList *list = extension_family; list; list = g_slist_next(list)) {
if (!strcmp(extension->get_id(),pref)) missing=FALSE;
}
*/
- if (!Inkscape::Extension::db.get( pref ) /*missing*/) {
- prefs_set_string_attribute(pref_path, pref_attr, pref_default);
+ if (!Inkscape::Extension::db.get( pref.data() ) /*missing*/) {
+ prefs->setString(pref_path, pref_attr, pref_default);
}
}
void
init()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
/* TODO: Change to Internal */
Internal::Svg::init();
Internal::Svgz::init();
//Internal::EpsOutput::init(); // disabled, to be deleted, replaced by CairoEpsOutput
Internal::PrintPS::init();
#ifdef HAVE_CAIRO_PDF
- if (prefs_get_int_attribute("options.useoldpdfexporter", "value", 1) == 1) {
+ if (prefs->getInt("options.useoldpdfexporter", "value", 1) == 1) {
//g_print ("Using CairoPdfOutput: old pdf exporter\n");
Internal::CairoPdfOutput::init();
Internal::PrintCairoPDF::init();
index 845a048242285b4506f06f4b6a4b4c24d497ac29..555461bc71189794545839864dcd8d08de551e4a 100644 (file)
#include <color.h>
#include "widgets/sp-color-selector.h"
#include "widgets/sp-color-notebook.h"
+#include "preferences.h"
namespace Inkscape {
gchar * prefname = this->pref_name();
std::string value;
string(value);
- prefs_set_string_attribute(PREF_DIR, prefname, value.c_str());
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(PREF_DIR, prefname, value);
g_free(prefname);
return _value;
@@ -62,11 +65,12 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar *
defaulthex = sp_repr_children(xml)->content();
gchar * pref_name = this->pref_name();
- const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
g_free(pref_name);
- if (paramval != NULL)
- defaulthex = paramval;
+ if (!paramval.empty())
+ defaulthex = paramval.data();
_value = atoi(defaulthex);
index 89db25d0381d6d8e5e96b143e6e06b960cc6ca49..33c1534341c5a71cb147ff962a2014cb29768fe0 100644 (file)
#include <sp-object.h>
#include "enum.h"
+#include "preferences.h"
/** \brief The root directory in the preferences database for extension
related parameters. */
@@ -104,13 +105,14 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
defaultval = sp_repr_children(xml)->attribute("value");
gchar * pref_name = this->pref_name();
- const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
g_free(pref_name);
- if (paramval != NULL)
- defaultval = paramval;
+ if (!paramval.empty())
+ defaultval = paramval.data();
if (defaultval != NULL)
- _value = g_strdup(defaultval); // allocate space for _value
+ _value = g_strdup(defaultval);
return;
}
if (_value != NULL) g_free(_value);
_value = g_strdup(settext->c_str());
gchar * prefname = this->pref_name();
- prefs_set_string_attribute(PREF_DIR, prefname, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(PREF_DIR, prefname, _value);
g_free(prefname);
}
index 1a2623fbfc1536112192ccb6545fc92a8dfef6e1..bce6bc3d0672f47a179f5afccbdcc8c20aaeb3d1 100644 (file)
#include <xml/node.h>
#include <extension/extension.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "document-private.h"
#include "sp-object.h"
@@ -263,11 +263,12 @@ ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const g
}
gchar * pref_name = this->pref_name();
- const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
g_free(pref_name);
- if (paramval != NULL)
- defaultval = paramval;
+ if (!paramval.empty())
+ defaultval = paramval.data();
if (defaultval != NULL)
_value = g_strdup(defaultval); // allocate space for _value
index 76c3506af0fbf94400341b9537ed84cc87c6db26..c05191b58823323e47af06afeb3975f90af368e3 100644 (file)
#include <xml/node.h>
#include <extension/extension.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "document-private.h"
#include "sp-object.h"
defaultval = ((optionentry*) choices->data)->value->c_str();
gchar * pref_name = this->pref_name();
- const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
g_free(pref_name);
- if (paramval != NULL)
- defaultval = paramval;
+ if (!paramval.empty())
+ defaultval = paramval.data();
if (defaultval != NULL)
_value = g_strdup(defaultval); // allocate space for _value
@@ -165,7 +166,8 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No
if (_value != NULL) g_free(_value);
_value = g_strdup(settext->c_str());
gchar * prefname = this->pref_name();
- prefs_set_string_attribute(PREF_DIR, prefname, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(PREF_DIR, prefname, _value);
g_free(prefname);
}
index 3dd2a23282bfd66c04612a6f90272ffda0de7f02..56ceeaad5dd8b31b4a0ebb5ad689f841b194b2a5 100644 (file)
#include <extension/extension.h>
#include "string.h"
+#include "preferences.h"
namespace Inkscape {
namespace Extension {
_value = g_strdup(in);
gchar * prefname = this->pref_name();
- prefs_set_string_attribute(PREF_DIR, prefname, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(PREF_DIR, prefname, _value);
g_free(prefname);
return _value;
@@ -77,11 +79,12 @@ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar
defaultval = sp_repr_children(xml)->content();
gchar * pref_name = this->pref_name();
- const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
g_free(pref_name);
- if (paramval != NULL)
- defaultval = paramval;
+ if (!paramval.empty())
+ defaultval = paramval.data();
if (defaultval != NULL)
_value = g_strdup(defaultval);
index c35ffed92cb5004c76a2d6be917b2996c2f9c416..9d3abae762e4f7138c43fb13a58179d43817537a 100644 (file)
#include "inkscape.h"
#include "desktop.h"
-#include "preferences.h"
#include "effect.h"
#include "implementation/implementation.h"
diff --git a/src/file.cpp b/src/file.cpp
index ac8c0a40e1a5285c513e45ad9e3c2b4af1c6623d..dbd62a5fa46f8879bc6e0b77688992e45ed55b0d 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
#include "message-stack.h"
#include "ui/dialog/filedialog.h"
#include "ui/dialog/ocaldialogs.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "path-prefix.h"
#include "sp-namedview.h"
@@ -382,12 +382,12 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
{
//# Get the current directory for finding files
static Glib::ustring open_path;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if(open_path.empty())
{
- gchar const *attr = prefs_get_string_attribute("dialogs.open", "path");
- if (attr)
- open_path = attr;
+ Glib::ustring attr = prefs->getString("dialogs.open", "path");
+ if (!attr.empty()) open_path = attr;
}
//# Test if the open_path directory exists
@@ -498,7 +498,7 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
open_path = Glib::path_get_dirname (fileName);
open_path.append(G_DIR_SEPARATOR_S);
- prefs_set_string_attribute("dialogs.open", "path", open_path.c_str());
+ prefs->setString("dialogs.open", "path", open_path);
sp_file_open(fileName, selection);
}
{
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
-
Inkscape::Extension::Output *extension = 0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
//# Get the default extension name
Glib::ustring default_extension;
char *attr = (char *)repr->attribute("inkscape:output_extension");
- if (!attr)
- attr = (char *)prefs_get_string_attribute("dialogs.save_as", "default");
- if (attr)
+ if (!attr) {
+ Glib::ustring attr2 = prefs->getString("dialogs.save_as", "default");
+ if(!attr2.empty()) default_extension = attr2;
+ } else {
default_extension = attr;
+ }
//g_message("%s: extension name: '%s'", __FUNCTION__, default_extension);
Glib::ustring save_path;
if (extension)
filename_extension = extension->get_extension();
- attr = (char *)prefs_get_string_attribute("dialogs.save_as", "path");
- if (attr)
- save_path = attr;
+ Glib::ustring attr3 = prefs->getString("dialogs.save_as", "path");
+ if (!attr3.empty())
+ save_path = attr3;
if (!Inkscape::IO::file_test(save_path.c_str(),
(GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
save_path = Glib::path_get_dirname(fileName);
- prefs_set_string_attribute("dialogs.save_as", "path", save_path.c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("dialogs.save_as", "path", save_path);
return success;
}
// To move the imported object, we must temporarily set the "transform pattern with
// object" option.
{
- int const saved_pref = prefs_get_int_attribute("options.transform", "pattern", 1);
- prefs_set_int_attribute("options.transform", "pattern", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool const saved_pref = prefs->getBool("options.transform", "pattern", true);
+ prefs->setBool("options.transform", "pattern", true);
sp_document_ensure_up_to_date(sp_desktop_document(desktop));
boost::optional<NR::Rect> sel_bbox = selection->bounds();
if (sel_bbox) {
NR::Point m( desktop->point() - sel_bbox->midpoint() );
sp_selection_move_relative(selection, m);
}
- prefs_set_int_attribute("options.transform", "pattern", saved_pref);
+ prefs->setBool("options.transform", "pattern", saved_pref);
}
}
Glib::ustring export_loc;
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::Extension::Output *extension;
//# Get the default extension name
Glib::ustring default_extension;
char *attr = (char *)repr->attribute("inkscape:output_extension");
- if (!attr)
- attr = (char *)prefs_get_string_attribute("dialogs.save_as", "default");
- if (attr)
+ if (!attr) {
+ Glib::ustring attr2 = prefs->getString("dialogs.save_as", "default");
+ if(!attr2.empty()) default_extension = attr2;
+ } else {
default_extension = attr;
+ }
//g_message("%s: extension name: '%s'", __FUNCTION__, default_extension);
if (doc->uri == NULL)
if (extension)
filename_extension = extension->get_extension();
- attr = (char *)prefs_get_string_attribute("dialogs.save_as", "path");
- if (attr)
- export_path = attr;
+ Glib::ustring attr3 = prefs->getString("dialogs.save_as", "path");
+ if (!attr3.empty())
+ export_path = attr3;
if (!Inkscape::IO::file_test(export_path.c_str(),
(GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
export_path = fileName;
- prefs_set_string_attribute("dialogs.save_as", "path", export_path.c_str());
+ prefs->setString("dialogs.save_as", "path", export_path);
return success;
}
// Start now the submition
// Create the uri
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring uri = "dav://";
- char *username = (char *)prefs_get_string_attribute("options.ocalusername", "str");
- char *password = (char *)prefs_get_string_attribute("options.ocalpassword", "str");
- if ((username == NULL) || (!strcmp(username, "")) || (password == NULL) || (!strcmp(password, "")))
+ Glib::ustring username = prefs->getString("options.ocalusername", "str");
+ Glib::ustring password = prefs->getString("options.ocalpassword", "str");
+ if (username.empty() || password.empty())
{
if(!gotSuccess)
{
if (!success)
return success;
}
- username = (char *)exportPasswordDialogInstance->getUsername().c_str();
- password = (char *)exportPasswordDialogInstance->getPassword().c_str();
+ username = exportPasswordDialogInstance->getUsername();
+ password = exportPasswordDialogInstance->getPassword();
}
uri.append(username);
uri.append(":");
uri.append(password);
uri.append("@");
- uri.append(prefs_get_string_attribute("options.ocalurl", "str"));
+ uri.append(prefs->getString("options.ocalurl", "str"));
uri.append("/dav.php/");
uri.append(Glib::path_get_basename(fileName));
index 60cdab8146c6490e07e810a1ca915e8385a0a243..ef8eaa68051be861faa92370d74690617d6f9a21 100644 (file)
#include "libavoid/geomtypes.h"
#include "libcola/cola.h"
#include "libvpsc/generate-constraints.h"
-#include "prefs-utils.h"
+#include "preferences.h"
using namespace std;
using namespace cola;
}
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SimpleConstraints scx,scy;
- double ideal_connector_length = prefs_get_double_attribute("tools.connector","length",100);
+ double ideal_connector_length = prefs->getDouble("tools.connector", "length", 100.0);
double directed_edge_height_modifier = 1.0;
- gchar const *directed_str = NULL, *overlaps_str = NULL;
- directed_str = prefs_get_string_attribute("tools.connector",
- "directedlayout");
- overlaps_str = prefs_get_string_attribute("tools.connector",
- "avoidoverlaplayout");
- bool avoid_overlaps = false;
- bool directed = false;
- if (directed_str && !strcmp(directed_str, "true")) {
- directed = true;
- }
- if (overlaps_str && !strcmp(overlaps_str, "true")) {
- avoid_overlaps = true;
- }
+
+ bool directed = prefs->getBool("tools.connector", "directedlayout");
+ bool avoid_overlaps = prefs->getBool("tools.connector", "avoidoverlaplayout");
for (list<SPItem *>::iterator i(selected.begin());
i != selected.end();
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 10857e94a797f598087b6220a7610adda41308de..6486204eb866765cf3b6af52bcb007c7c85d4b18 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
#include <cstring>
#include "helper/sp-marshal.h"
#include "dialogs/debugdialog.h"
+#include "dialogs/input.h"
#include "application/application.h"
#include "application/editor.h"
-#include "preferences.h"
#include "document.h"
#include "selection.h"
#include "event-context.h"
#include "inkscape-private.h"
-#include "prefs-utils.h"
#include "xml/repr.h"
+#include "preferences.h"
#include "io/sys.h"
#include "message-stack.h"
static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop);
static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop);
-static bool inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, const gchar *skeleton,
- unsigned int skel_size,
- const gchar *e_mkdir,
- const gchar *e_notdir,
- const gchar *e_ccf,
- const gchar *e_cwf,
- const gchar *warn);
-
struct Inkscape::Application {
GObject object;
Inkscape::XML::Document *menus;
if (!inkscape->documents) { // nothing to autosave
return TRUE;
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Use UID for separating autosave-documents between users if directory is multiuser
uid_t uid = getuid();
Glib::ustring autosave_dir;
{
- gchar const* tmp = prefs_get_string_attribute("options.autosave", "path");
- if ( tmp ) {
+ Glib::ustring tmp = prefs->getString("options.autosave", "path");
+ if (!tmp.empty()) {
autosave_dir = tmp;
} else {
autosave_dir = Glib::get_tmp_dir();
gchar sptstr[256];
strftime(sptstr, 256, "%Y_%m_%d_%H_%M_%S", sptm);
- gint autosave_max = prefs_get_int_attribute("options.autosave", "max", 10);
+ gint autosave_max = prefs->getInt("options.autosave", "max", 10);
gint docnum = 0;
void inkscape_autosave_init()
{
static guint32 autosave_timeout_id = 0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Turn off any previously initiated timeouts
if ( autosave_timeout_id ) {
autosave_timeout_id = 0;
}
- // g_debug("options.autosave.enable = %lld", prefs_get_int_attribute_limited("options.autosave", "enable", 1, 0, 1));
+ // g_debug("options.autosave.enable = %d", prefs->getBool("options.autosave", "enable", true));
// Is autosave enabled?
- if( prefs_get_int_attribute_limited("options.autosave", "enable", 1, 0, 1) != 1 ){
+ if (!prefs->getBool("options.autosave", "enable", true)){
autosave_timeout_id = 0;
} else {
// Turn on autosave
- guint32 timeout = prefs_get_int_attribute("options.autosave", "interval", 10) * 60;
- // g_debug("options.autosave.interval = %lld", prefs_get_int_attribute("options.autosave", "interval", 10));
+ guint32 timeout = prefs->getInt("options.autosave", "interval", 10) * 60;
+ // g_debug("options.autosave.interval = %d", prefs->getInt("options.autosave", "interval", 10));
#if GLIB_CHECK_VERSION(2,14,0)
autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL);
#else
g_assert (!inkscape->desktops);
- Inkscape::Preferences::save();
+ Inkscape::Preferences::unload();
if (inkscape->menus) {
/* fixme: This is not the best place */
}
}
- Inkscape::Preferences::save();
+ Inkscape::Preferences::unload();
fprintf (stderr, "Emergency save completed. Inkscape will close now.\n");
fprintf (stderr, "If you can reproduce this crash, please file a bug at www.inkscape.org\n");
inkscape->use_gui = use_gui;
inkscape->argv0 = g_strdup(argv0);
- /* Attempt to load the preferences, and set the save_preferences flag to TRUE
- if we could, or FALSE if we couldn't */
+ /* 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();
inkscape_load_menus(inkscape);
+ sp_input_load_from_preferences();
/* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON.
* Use only if use_gui is enabled
#define DEFAULT_LOG_REDIRECT false
#endif
- if (use_gui == TRUE && prefs_get_int_attribute("dialogs.debug", "redirect", DEFAULT_LOG_REDIRECT))
+ if (use_gui == TRUE && prefs->getBool("dialogs.debug", "redirect", DEFAULT_LOG_REDIRECT))
{
Inkscape::UI::Dialogs::DebugDialog::getInstance()->captureLogMessages();
}
/* Check for global remapping of Alt key */
if(use_gui)
{
- inkscape_mapalt(guint(prefs_get_int_attribute("options.mapalt","value",0)));
+ inkscape_mapalt(guint(prefs->getInt("options.mapalt", "value", 0)));
}
/* Initialize the extensions */
return app->use_gui;
}
-/**
- * Preference management
- * We use '.' as separator
- *
- * Returns TRUE if the config file was successfully loaded, FALSE if not.
- */
-bool
-inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton,
- unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml,
- const gchar *e_notsp, const gchar *warn)
-{
- gchar *fn = profile_path(filename);
- if (!Inkscape::IO::file_test(fn, G_FILE_TEST_EXISTS)) {
- bool result;
- /* No such file */
- result = inkscape_init_config (config, filename, skeleton,
- skel_size,
- _("Cannot create directory %s.\n%s"),
- _("%s is not a valid directory.\n%s"),
- _("Cannot create file %s.\n%s"),
- _("Cannot write file %s.\n%s"),
- _("Although Inkscape will run, it will use default settings,\n"
- "and any changes made in preferences will not be saved."));
- g_free (fn);
- return result;
- }
-
- if (!Inkscape::IO::file_test(fn, G_FILE_TEST_IS_REGULAR)) {
- /* Not a regular file */
- gchar *safeFn = Inkscape::IO::sanitizeString(fn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_notreg, safeFn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- g_free(safeFn);
- g_free (fn);
- return false;
- }
-
- Inkscape::XML::Document *doc = sp_repr_read_file (fn, NULL);
- if (doc == NULL) {
- /* Not an valid xml file */
- gchar *safeFn = Inkscape::IO::sanitizeString(fn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_notxml, safeFn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- g_free(safeFn);
- g_free (fn);
- return false;
- }
-
- Inkscape::XML::Node *root = doc->root();
- if (strcmp (root->name(), "inkscape")) {
- gchar *safeFn = Inkscape::IO::sanitizeString(fn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_notsp, safeFn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- Inkscape::GC::release(doc);
- g_free(safeFn);
- g_free (fn);
- return false;
- }
-
- /** \todo this is a hack, need to figure out how to get
- * a reasonable merge working with the menus.xml file */
- if (skel_size == MENUS_SKELETON_SIZE) {
- if (INKSCAPE)
- INKSCAPE->menus = doc;
- doc = config;
- } else {
- config->root()->mergeFrom(doc->root(), "id");
- }
-
- Inkscape::GC::release(doc);
- g_free (fn);
- return true;
-}
-
/**
* Menus management
*
inkscape_load_menus (Inkscape::Application *inkscape)
{
gchar *fn = profile_path(MENUS_FILE);
- bool retval = false;
- if (Inkscape::IO::file_test(fn, G_FILE_TEST_EXISTS)) {
- retval = inkscape_load_config (MENUS_FILE,
- inkscape->menus,
- menus_skeleton,
- MENUS_SKELETON_SIZE,
- _("%s is not a regular file.\n%s"),
- _("%s not a valid XML file, or\n"
- "you don't have read permissions on it.\n%s"),
- _("%s is not a valid menus file.\n%s"),
- _("Inkscape will run with default menus.\n"
- "New menus will not be saved."));
- } else {
- INKSCAPE->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL);
- if (INKSCAPE->menus != NULL)
- retval = true;
- }
- g_free(fn);
- return retval;
+ gchar *menus_xml = NULL; gsize len = 0;
+
+ if (g_file_get_contents(fn, &menus_xml, &len, NULL)) {
+ // load the menus_xml file
+ INKSCAPE->menus = sp_repr_read_mem(menus_xml, len, NULL);
+ g_free(menus_xml);
+ if (INKSCAPE->menus) return true;
+ }
+ INKSCAPE->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL);
+ if (INKSCAPE->menus) return true;
+ return false;
}
/**
- * We use '.' as separator
- * \param inkscape Unused
+ * @deprecated Use the Preferences class instead, and try not to use _getNode
*/
Inkscape::XML::Node *
inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key)
{
- if ( (key == NULL) || (inkscape == NULL) ) {
- return NULL;
- }
-
- Inkscape::XML::Node *prefs = Inkscape::Preferences::get();
- if ( !prefs ) {
- return NULL;
- }
-
- Inkscape::XML::Node *repr = prefs->root();
- if (!repr) return NULL;
- g_assert (!(strcmp (repr->name(), "inkscape")));
-
- gchar const *s = key;
- while ((s) && (*s)) {
-
- /* Find next name */
- gchar const *e = strchr (s, '.');
- guint len;
- if (e) {
- len = e++ - s;
- } else {
- len = strlen (s);
- }
-
- Inkscape::XML::Node* child;
- for (child = repr->firstChild(); child != NULL; child = child->next()) {
- gchar const *id = child->attribute("id");
- if ((id) && (strlen (id) == len) && (!strncmp (id, s, len)))
- {
- break;
- }
- }
- if (child == NULL) {
- return NULL;
- }
-
- repr = child;
- s = e;
- }
- return repr;
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->_getNode(key);
}
-
void
inkscape_selection_modified (Inkscape::Selection *selection, guint flags)
{
# HELPERS
#####################*/
-static bool
-inkscape_init_config (Inkscape::XML::Document */*doc*/, const gchar *config_name, const gchar *skeleton,
- unsigned int skel_size,
- const gchar *e_mkdir,
- const gchar *e_notdir,
- const gchar *e_ccf,
- const gchar *e_cwf,
- const gchar *warn)
-{
- gchar *dn = profile_path(NULL);
- bool use_gui = (Inkscape::NSApplication::Application::getNewGui())? Inkscape::NSApplication::Application::getUseGui() : inkscape->use_gui;
- if (!Inkscape::IO::file_test(dn, G_FILE_TEST_EXISTS)) {
- if (Inkscape::IO::mkdir_utf8name(dn))
- {
- if (use_gui) {
- // Cannot create directory
- gchar *safeDn = Inkscape::IO::sanitizeString(dn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_mkdir, safeDn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- g_free(safeDn);
- g_free (dn);
- return false;
- } else {
- g_warning(e_mkdir, dn, warn);
- g_free (dn);
- return false;
- }
- }
-
- // Also create (empty for now) subdirectories for the user's stuff
- {
- gchar *temp_dn = profile_path("templates");
- Inkscape::IO::mkdir_utf8name(temp_dn);
- }
- {
- gchar *temp_dn = profile_path("keys");
- Inkscape::IO::mkdir_utf8name(temp_dn);
- }
- {
- gchar *temp_dn = profile_path("icons");
- Inkscape::IO::mkdir_utf8name(temp_dn);
- }
- {
- gchar *temp_dn = profile_path("extensions");
- Inkscape::IO::mkdir_utf8name(temp_dn);
- }
- {
- gchar *temp_dn = profile_path("palettes");
- Inkscape::IO::mkdir_utf8name(temp_dn);
- }
-
- } else if (!Inkscape::IO::file_test(dn, G_FILE_TEST_IS_DIR)) {
- if (use_gui) {
- // Not a directory
- gchar *safeDn = Inkscape::IO::sanitizeString(dn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_notdir, safeDn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- g_free( safeDn );
- g_free (dn);
- return false;
- } else {
- g_warning(e_notdir, dn, warn);
- g_free(dn);
- return false;
- }
- }
- g_free (dn);
-
- gchar *fn = profile_path(config_name);
-
- Inkscape::IO::dump_fopen_call(fn, "H");
- FILE *fh = Inkscape::IO::fopen_utf8name(fn, "w");
- if (!fh) {
- if (use_gui) {
- /* Cannot create file */
- gchar *safeFn = Inkscape::IO::sanitizeString(fn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_ccf, safeFn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- g_free(safeFn);
- g_free (fn);
- return false;
- } else {
- g_warning(e_ccf, fn, warn);
- g_free(fn);
- return false;
- }
- }
- if ( fwrite(skeleton, 1, skel_size, fh) != skel_size ) {
- if (use_gui) {
- /* Cannot create file */
- gchar *safeFn = Inkscape::IO::sanitizeString(fn);
- GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_cwf, safeFn, warn);
- gtk_dialog_run (GTK_DIALOG (w));
- gtk_widget_destroy (w);
- g_free(safeFn);
- g_free (fn);
- fclose(fh);
- return false;
- } else {
- g_warning(e_cwf, fn, warn);
- g_free(fn);
- fclose(fh);
- return false;
- }
- }
-
- g_free(fn);
- fclose(fh);
- return true;
-}
-
void
inkscape_refresh_display (Inkscape::Application *inkscape)
{
//emit shutdown signal so that dialogs could remember layout
g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0);
- Inkscape::Preferences::save();
+ Inkscape::Preferences::unload();
gtk_main_quit ();
}
-gchar *
+char *
homedir_path(const char *filename)
{
static const gchar *homedir = NULL;
if (!homedir) {
homedir = g_get_home_dir();
- gchar* utf8Path = g_filename_to_utf8( homedir, -1, NULL, NULL, NULL );
- if ( utf8Path )
- {
- homedir = utf8Path;
- if (!g_utf8_validate(homedir, -1, NULL)) {
- g_warning( "g_get_home_dir() post A IS NOT UTF-8" );
- }
- }
}
if (!homedir) {
gchar * path = g_path_get_dirname(INKSCAPE->argv0);
- gchar* utf8Path = g_filename_to_utf8( path, -1, NULL, NULL, NULL );
- g_free(path);
- if ( utf8Path )
- {
- homedir = utf8Path;
- if (!g_utf8_validate(homedir, -1, NULL)) {
- g_warning( "g_get_home_dir() post B IS NOT UTF-8" );
- }
- }
}
return g_build_filename(homedir, filename, NULL);
}
diff --git a/src/inkview.cpp b/src/inkview.cpp
index ade2b6d427d39f43ead661870e785dbd7f98e6a3..fee18612dbab581d113cf25fad3785f90742b703 100644 (file)
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
LIBXML_TEST_VERSION
Inkscape::GC::init();
- Inkscape::Preferences::loadSkeleton();
+ Inkscape::Preferences::use_gui = false;
+ Inkscape::Preferences::load();
gtk_init (&argc, (char ***) &argv);
ss.fullscreen = false;
inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL);
- Inkscape::Preferences::load();
// starting at where the commandline options stopped parsing because
// we want all the files to be in the list
diff --git a/src/preferences.cpp b/src/preferences.cpp
index fedfa85680007bdf4e25f0a6a469c39cf3cfb311..8bac7cf9d808380b9bd6b8f5fa9e31eabb38dfb9 100644 (file)
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
-/** \file
- * \brief Prefs handling implementation
+/** @file
+ * @brief Singleton class to access the preferences file - implementation
*
* Authors:
- * Ralf Stephan <ralf@ark.in-berlin.de>
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
- * Copyright (C) 2005 Authors
+ * Copyright (C) 2008 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <glibmm/i18n.h>
-
+#include "preferences.h"
#include "preferences-skeleton.h"
-#include "xml/repr.h"
-#include "dialogs/input.h"
#include "inkscape.h"
-#include "preferences.h"
-
-#define PREFERENCES_FILE "preferences.xml"
+#include "xml/repr.h"
+#include "xml/node-observer.h"
+#include <glibmm/fileutils.h>
+#include <glibmm/i18n.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <gtkmm/messagedialog.h>
-static Inkscape::XML::Document *_preferences;
-static bool _save_preferences;
+#define PREFERENCES_FILE_NAME "preferences.xml"
namespace Inkscape {
-void
-Preferences::loadSkeleton()
+Preferences::Preferences() :
+ _prefs_basename(PREFERENCES_FILE_NAME),
+ _prefs_dir(""),
+ _prefs_filename(""),
+ _writable(false),
+ _prefs_doc(NULL)
{
- _preferences = sp_repr_read_mem (preferences_skeleton, PREFERENCES_SKELETON_SIZE, 0);
+ // profile_path essentailly returns the argument prefixed by the profile directory.
+ gchar *path = profile_path(NULL);
+ _prefs_dir = path;
+ g_free(path);
+
+ path = profile_path(_prefs_basename.data());
+ _prefs_filename = path;
+ g_free(path);
+
+ _load();
}
-Inkscape::XML::Document*
-Preferences::get()
+Preferences::~Preferences()
{
- return _preferences;
+ // when the preferences are unloaded, save them
+ save();
+ Inkscape::GC::release(_prefs_doc);
}
/**
- * Attempts to load the preferences file indicated by the global PREFERENCES_FILE
- * parameter. If it cannot load it, the default preferences_skeleton will be used
- * instead.
+ * @brief Load internal defaults
+ *
+ * In the future this will try to load the system-wide file before falling
+ * back to the internal defaults.
*/
-void
-Preferences::load()
+void Preferences::_loadDefaults()
{
- /// \todo this still uses old Gtk+ code which should be somewhere else
- if (inkscape_load_config (PREFERENCES_FILE,
- _preferences,
- preferences_skeleton,
- PREFERENCES_SKELETON_SIZE,
- _("%s is not a regular file.\n%s"),
- _("%s not a valid XML file, or\n"
- "you don't have read permissions on it.\n%s"),
- _("%s is not a valid preferences file.\n%s"),
- _("Inkscape will run with default settings.\n"
- "New settings will not be saved.")))
- {
- sp_input_load_from_preferences();
- _save_preferences = true;
- } else
- _save_preferences = false;
+ _prefs_doc = sp_repr_read_mem(preferences_skeleton, PREFERENCES_SKELETON_SIZE, NULL);
}
-void
-Preferences::save()
+/**
+ * @brief Load the user's customized 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()
{
- if (!_preferences || ! _save_preferences)
+ _loadDefaults();
+
+ Glib::ustring not_saved = _("Inkscape will run with default settings, "
+ "and new settings will not be saved. ");
+
+ // 1. Does the file exist?
+ if (!g_file_test(_prefs_filename.data(), G_FILE_TEST_EXISTS)) {
+ // No - we need to create one.
+ // Does the profile directory exist?
+ if (!g_file_test(_prefs_dir.data(), G_FILE_TEST_EXISTS)) {
+ // No - create the profile directory
+ if (g_mkdir(_prefs_dir.data(), 0755)) {
+ // the creation failed
+ _errorDialog(Glib::ustring::compose(_("Cannot create profile directory %1."),
+ Glib::filename_to_utf8(_prefs_dir)), not_saved);
+ return;
+ }
+ // create some subdirectories for user stuff
+ char const *user_dirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
+ for(int i=0; user_dirs[i]; ++i) {
+ char *dir = profile_path(user_dirs[i]);
+ g_mkdir(dir, 0755);
+ g_free(dir);
+ }
+
+ } else if (!g_file_test(_prefs_dir.data(), G_FILE_TEST_IS_DIR)) {
+ // The profile dir is not actually a directory
+ _errorDialog(Glib::ustring::compose(_("%1 is not a valid directory."),
+ Glib::filename_to_utf8(_prefs_dir)), not_saved);
+ return;
+ }
+ // The profile dir exists and is valid.
+ if (!g_file_set_contents(_prefs_filename.data(), preferences_skeleton, PREFERENCES_SKELETON_SIZE, NULL)) {
+ // The write failed.
+ _errorDialog(Glib::ustring::compose(_("Failed to create the preferences file %1."),
+ Glib::filename_to_utf8(_prefs_filename)), not_saved);
+ return;
+ }
+
+ // The prefs file was just created.
+ // We can return now and skip the rest of the load process.
+ _writable = true;
+ return;
+ }
+
+ // Yes, the pref file exists.
+ // 2. Is it a regular file?
+ if (!g_file_test(_prefs_filename.data(), G_FILE_TEST_IS_REGULAR)) {
+ _errorDialog(Glib::ustring::compose(_("The preferences file %1 is not a regular file."),
+ Glib::filename_to_utf8(_prefs_filename)), not_saved);
+ return;
+ }
+
+ // 3. Is the file readable?
+ gchar *prefs_xml = NULL; gsize len = 0;
+ if (!g_file_get_contents(_prefs_filename.data(), &prefs_xml, &len, NULL)) {
+ _errorDialog(Glib::ustring::compose(_("The preferences file %1 could not be read."),
+ Glib::filename_to_utf8(_prefs_filename)), not_saved);
return;
+ }
+ // 4. Is it valid XML?
+ Inkscape::XML::Document *prefs_read = sp_repr_read_mem(prefs_xml, len, NULL);
+ g_free(prefs_xml);
+ if (!prefs_read) {
+ _errorDialog(Glib::ustring::compose(_("The preferences file %1 is not a valid XML document."),
+ Glib::filename_to_utf8(_prefs_filename)), not_saved);
+ return;
+ }
+ // 5. Basic sanity check: does the root element have a correct name?
+ if (strcmp(prefs_read->root()->name(), "inkscape")) {
+ _errorDialog(Glib::ustring::compose(_("The file %1 is not a valid Inkscape preferences file."),
+ Glib::filename_to_utf8(_prefs_filename)), not_saved);
+ Inkscape::GC::release(prefs_read);
+ return;
+ }
+
+ // Merge the loaded prefs with defaults.
+ _prefs_doc->root()->mergeFrom(prefs_read->root(), "id");
+ Inkscape::GC::release(prefs_read);
+ _writable = true;
+}
+
+/**
+ * @brief Flush all pref changes to the XML file
+ */
+void Preferences::save()
+{
+ if (!_writable) return; // no-op if the prefs file is not writable
+
+ // sp_repr_save_file uses utf-8 instead of the glib filename encoding.
+ // I don't know why filenames are kept in utf-8 in Inkscape and then
+ // converted to filename encoding when necessary through sepcial functions
+ // - wouldn't it be easier to keep things in the encoding they are supposed
+ // to be in?
+ Glib::ustring utf8name = Glib::filename_from_utf8(_prefs_filename);
+ if (utf8name.empty()) return;
+ sp_repr_save_file(_prefs_doc, utf8name.data());
+}
- gchar *fn = profile_path (PREFERENCES_FILE);
- (void) sp_repr_save_file (_preferences, fn);
- g_free (fn);
+void Preferences::addPrefsObserver(Inkscape::XML::NodeObserver *observer)
+{
+ _prefs_doc->addSubtreeObserver(*observer);
}
-} // namespace Inkscape
+// Now for the meat.
+// Most of the logic is similar to former prefs-utils.cpp
+
+
+/**
+ * @brief Check for the existence of a given pref key
+ * @param pref_key Preference key to check
+ * @return True if the key exists, false otherwise
+ */
+bool Preferences::exists(Glib::ustring const &pref_key)
+{
+ return _getNode(pref_key) != NULL;
+}
+
+/**
+ * @brief Get the number of sub-preferences of a given pref
+ * @param pref_key Preference key to check
+ * @return Number of sub-preferences
+ *
+ * Note: This does not count attributes, only child preferences.
+ */
+unsigned int Preferences::childCount(Glib::ustring const &pref_key)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key);
+ return ( node ? node->childCount() : 0 );
+}
+
+/**
+ * @brief Get the key of the n-th sub-preference of the specified pref
+ * @param father_key Parent key
+ * @param n The zero-based index of the pref key to retrieve
+ * @return The key of the n-th sub-preference
+ */
+Glib::ustring Preferences::getNthChild(Glib::ustring const &father_key, unsigned int n)
+{
+ Inkscape::XML::Node *node = _getNode(father_key), *child;
+ if (!node) return "";
+ child = node->nthChild(n);
+ if (!child) return "";
+ if (child->attribute("id")) {
+ Glib::ustring child_key = father_key;
+ child_key += '.';
+ child_key += child->attribute("id");
+ return child_key;
+ }
+ return "";
+}
+
+
+/**
+ * @brief Create the preference with the specified key
+ * @return True if the node was created, false if it already existed
+ *
+ * This method is redundant, because the setters automatically create prefs
+ * if they don't already exist. It is only left to accomodate some legacy code
+ * which manipulates the DOM of the preferences file directly.
+ */
+bool Preferences::create(Glib::ustring const &pref_key)
+{
+ if (_getNode(pref_key)) return false;
+ _getNode(pref_key, true);
+ return true;
+}
+
+// getter methods
+
+/**
+ * @brief Get a boolean attribute of a preference
+ * @param pref_key Key of he preference to retrieve
+ * @param attr Attribute to retrieve
+ * @param def The default value to return if the preference is not set
+ * @return The retrieved value
+ */
+bool Preferences::getBool(Glib::ustring const &pref_key, Glib::ustring const &attr, bool def)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key);
+ if (!node) return def;
+ gchar const *rawstr = node->attribute(attr.data());
+ if(!rawstr || !rawstr[0]) return def;
+ Glib::ustring str = rawstr;
+
+ // This is to handle legacy preferences using ints as booleans
+ if (str == "true" || str == "1") return true;
+ return false;
+}
+
+
+/**
+ * @brief Get an integer attribute of a preference
+ * @param pref_key Key of he preference to retrieve
+ * @param attr Attribute to retrieve
+ * @param def The default value to return if the preference is not set
+ * @return The retrieved value
+ */
+int Preferences::getInt(Glib::ustring const &pref_key, Glib::ustring const &attr, int def)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key);
+ if (!node) return def;
+ gchar const *rawstr = node->attribute(attr.data());
+ if (!rawstr || !rawstr[0]) return def;
+ Glib::ustring str = rawstr;
+ // Protection against leftover getInt calls when the value is in fact a boolean
+ if (str == "true") return 1;
+ if (str == "false") return 0;
+ return atoi(str.data());
+}
+
+int Preferences::getIntLimited(Glib::ustring const &pref_key, Glib::ustring const &attr, int def, int min, int max)
+{
+ int value = getInt(pref_key, attr, def);
+ return ( value >= min && value <= max ? value : def);
+}
+
+/**
+ * @brief Get a floating point attribute of a preference
+ * @param pref_key Key of he preference to retrieve
+ * @param attr Attribute to retrieve
+ * @param def The default value to return if the preference is not set
+ * @return The retrieved value
+ */
+double Preferences::getDouble(Glib::ustring const &pref_key, Glib::ustring const &attr, double def)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key);
+ if (!node) return def;
+ gchar const *str = node->attribute(attr.data());
+ if (!str) return def;
+ return g_ascii_strtod(str, NULL);
+}
+
+double Preferences::getDoubleLimited(Glib::ustring const &pref_key, Glib::ustring const &attr, double def, double min, double max)
+{
+ double value = getDouble(pref_key, attr, def);
+ return ( value >= min && value <= max ? value : def);
+}
+
+/**
+ * @brief Get a string attribute of a preference
+ * @param pref_key Key of he preference to retrieve
+ * @param attr Attribute to retrieve
+ * @param def The default value to return if the preference is not set
+ * @return The retrieved value
+ */
+Glib::ustring Preferences::getString(Glib::ustring const &pref_key, Glib::ustring const &attr)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key);
+ if (!node) return "";
+ gchar const *str = node->attribute(attr.data());
+ if (!str) return "";
+ return Glib::ustring(str);
+}
+
+
+// setter methods
+
+/**
+ * @brief Set a boolean attribute of a preference
+ * @param pref_key Key of the preference to modify
+ * @param attr Attribute to set
+ * @param value The new value of the pref attribute
+ */
+void Preferences::setBool(Glib::ustring const &pref_key, Glib::ustring const &attr, bool value)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key, true);
+ node->setAttribute(attr.data(), ( value ? "true" : "false" ));
+}
+
+/**
+ * @brief Set an integer attribute of a preference
+ * @param pref_key Key of the preference to modify
+ * @param attr Attribute to set
+ * @param value The new value of the pref attribute
+ */
+void Preferences::setInt(Glib::ustring const &pref_key, Glib::ustring const &attr, int value)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key, true);
+ gchar intstr[32];
+ g_snprintf(intstr, 32, "%d", value);
+ node->setAttribute(attr.data(), intstr);
+}
+
+/**
+ * @brief Set a floating point attribute of a preference
+ * @param pref_key Key of the preference to modify
+ * @param attr Attribute to set
+ * @param value The new value of the pref attribute
+ */
+void Preferences::setDouble(Glib::ustring const &pref_key, Glib::ustring const &attr, double value)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key, true);
+ sp_repr_set_svg_double(node, attr.data(), value);
+ /*
+ gchar dblstr[32];
+ g_snprintf(dblstr, 32, "%g", value);
+ node->setAttribute(attr, dblstr);
+ */
+}
+
+/**
+ * @brief Set a string attribute of a preference
+ * @param pref_key Key of the preference to modify
+ * @param attr Attribute to set
+ * @param value The new value of the pref attribute
+ */
+void Preferences::setString(Glib::ustring const &pref_key, Glib::ustring const &attr, Glib::ustring const &value)
+{
+ Inkscape::XML::Node *node = _getNode(pref_key, true);
+ node->setAttribute(attr.data(), value.data());
+}
+
+/**
+ * @brief Get the XML node corresponding to the given pref key
+ * @param pref_key Preference key (path) to get
+ * @param create Whether to create the corresponding node if it doesn't exist
+ * @return XML node corresponding to the specified key
+ *
+ * The separator for key components is '.' (a dot). Derived from former
+ * inkscape_get_repr().
+ */
+Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool create)
+{
+ Inkscape::XML::Node *node = _prefs_doc->root(), *child = NULL;
+ gchar **splits = g_strsplit(pref_key.data(), ".", 0);
+ int part_i = 0;
+
+ while(splits[part_i]) {
+ for (child = node->firstChild(); child; child = child->next())
+ if (!strcmp(splits[part_i], child->attribute("id"))) break;
+
+ // If the previous loop found a matching key, child now contains the node
+ // matching the processed key part. If no node was found then it is NULL.
+ if (!child) {
+ if (create) {
+ // create the rest of the key
+ while(splits[part_i]) {
+ child = node->document()->createElement("group");
+ child->setAttribute("id", splits[part_i]);
+ node->appendChild(child);
+
+ ++part_i;
+ node = child;
+ }
+ g_strfreev(splits);
+ return node;
+ } else {
+ return NULL;
+ }
+ }
+
+ ++part_i;
+ node = child;
+ }
+ g_strfreev(splits);
+ return node;
+}
+
+
+void Preferences::_errorDialog(Glib::ustring const &msg, Glib::ustring const &secondary)
+{
+ if (Preferences::use_gui) {
+ Gtk::MessageDialog err(
+ msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
+ err.set_secondary_text(secondary);
+ err.run();
+ } else {
+ g_message("%s", msg.data());
+ g_message("%s", secondary.data());
+ }
+}
+
+bool Preferences::use_gui = true;
+Preferences *Preferences::_instance = NULL;
+
+
+} // namespace Inkscape
+
/*
Local Variables:
mode:c++
diff --git a/src/preferences.h b/src/preferences.h
index 4a765958615a8f34af80e845388f44e49eafa68b..90b2f518ede644ee0c0d3795457051faaa7b0f4b 100644 (file)
--- a/src/preferences.h
+++ b/src/preferences.h
-/** \file
- * \brief Static class where all preferences handling happens.
+/** @file
+ * @brief Singleton class to access the preferences file in a convenient way.
*
* Authors:
- * Ralf Stephan <ralf@ark.in-berlin.de>
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
- * Copyright (C) 2005 Authors
+ * Copyright (C) 2008 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
-#ifndef INKSCAPE_PREFERENCES_H
-#define INKSCAPE_PREFERENCES_H
+#ifndef INKSCAPE_PREFSTORE_H
+#define INKSCAPE_PREFSTORE_H
+
+#include <glibmm/ustring.h>
+#include <string>
+#include <climits>
+#include <cfloat>
namespace Inkscape {
- namespace XML {
- class Document;
- }
+namespace XML {
+ class Node;
+ class Document;
+ class NodeObserver;
+} // namespace XML
-class Preferences
-{
+/**
+ * @brief Preference storage class
+ *
+ * This is a singleton that allows one to access the user preferences stored in
+ * the preferences.xml file. The preferences are stored in a tree hierarchy.
+ * Each preference is identified by its key, and sections of the key
+ * corresponding to the levels of the hierarchy are delimited with dots.
+ * Preferences are generally typeless - it's up to the programmer to ensure
+ * that a given preference is always accessed as the correct type.
+ *
+ * All preferences are loaded when the first singleton pointer is requested,
+ * or when the static load() method is called. Before loading, the static
+ * variable @c use_gui should be set accordingly. To save the preferences,
+ * the method save() or the static function unload() can be used.
+ *
+ * In future, this could be a virtual base from which specific backends
+ * derive (e.g. GConf, Windows registry, flat XML file...)
+ */
+class Preferences {
public:
- static XML::Document *get();
- static void load();
- static void save();
- static void loadSkeleton();
-
+ // utility methods
+ void save();
+ bool isWritable() { return _writable; }
+
+ // some helpers
+ bool exists(Glib::ustring const &pref_key);
+ unsigned int childCount(Glib::ustring const &pref_key);
+ Glib::ustring getNthChild(Glib::ustring const &father_path, unsigned int n);
+ bool create(Glib::ustring const &pref_key);
+
+ // getter methods
+ // Note that default values supplied as arguments are last-chance,
+ // and are overridden by those in preferences-defaults.h
+ bool getBool(Glib::ustring const &pref_path, Glib::ustring const &attr, bool def=false);
+ int getInt(Glib::ustring const &pref_path, Glib::ustring const &attr, int def=0);
+ int getIntLimited(Glib::ustring const &pref_path, Glib::ustring const &attr, int def=0, int min=INT_MIN, int max=INT_MAX);
+ double getDouble(Glib::ustring const &pref_path, Glib::ustring const &attr, double def=0.0);
+ double getDoubleLimited(Glib::ustring const &pref_path, Glib::ustring const &attr, double def=0.0, double min=DBL_MIN, double max=DBL_MAX);
+ Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &attr);
+
+ // setter methods
+ void setBool(Glib::ustring const &pref_path, Glib::ustring const &attr, bool value);
+ void setInt(Glib::ustring const &pref_path, Glib::ustring const &attr, int value);
+ void setDouble(Glib::ustring const &pref_path, Glib::ustring const &attr, double value);
+ void setString(Glib::ustring const &pref_path, Glib::ustring const &attr, Glib::ustring const &value);
+
+ // do not use this - it is only temporarily public to ease porting old code to this class
+ XML::Node *_getNode(Glib::ustring const &pref_path, bool create=false);
+
+ // used for some obscure purpose in sp_desktop_widget_init
+ void addPrefsObserver(XML::NodeObserver *observer);
+
+ // singleton accessor
+ static Preferences *get() {
+ if (!_instance) _instance = new Preferences();
+ return _instance;
+ }
+ static void load() {
+ if (!_instance) _instance = new Preferences();
+ }
+ static void unload() {
+ if(_instance)
+ {
+ delete _instance;
+ _instance = NULL;
+ }
+ }
+ // this is a static member to reduce dependency bloat for this class
+ static bool use_gui; ///< Whether to use GUI error notifications
+
private:
+ Preferences();
+ ~Preferences();
+ void _load();
+ void _loadDefaults();
+ void _errorDialog(Glib::ustring const &, Glib::ustring const &);
+
+ // disable copying
+ Preferences(Preferences const &);
+ Preferences operator=(Preferences const &);
+
+ 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
+
+ static Preferences *_instance;
};
} // namespace Inkscape
-#endif // INKSCAPE_PREFERENCES_H
+#endif // INKSCAPE_PREFSTORE_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nil
- fill-column:99
+ fill-column:75
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp
index 7a950c3c3c60a54bff5dfbe76e1aa95301c5281e..004626ac68b5c0b2028b2e3aad0383b610c6bc1f 100644 (file)
--- a/src/prefs-utils.cpp
+++ b/src/prefs-utils.cpp
# include "config.h"
#endif
+#include "prefs-utils.h"
#include "inkscape.h"
#include "xml/repr.h"
-/**
-\brief Checks if the path exists in the preference file
-*/
-bool pref_path_exists(gchar const *path){
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- return (repr != NULL);
-}
-
-/**
-\brief returns the number of sub-prefs
-*/
-unsigned int pref_path_number_of_children(gchar const *path){
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- Inkscape::XML::Node *child_repr = sp_repr_children(repr);
- int nb_child = 0;
- while (child_repr) {
- nb_child ++;
- child_repr = sp_repr_next(child_repr);
- }
- return nb_child;
-}
-
-/**
-\brief creates a new preference and returns its key on success.
-*/
-gchar * create_pref(gchar const *father_path, gchar const *child){
- Inkscape::XML::Node *father = inkscape_get_repr(INKSCAPE, father_path);
- if (! father ) return NULL;
- Inkscape::XML::Node *repr = father->document()->createElement("group");
- repr->setAttribute("id", child, false);
- father->appendChild(repr);
- return g_strdup_printf("%s.%s", father_path,child);
-}
-
-/**
-\brief gets the nth children of a pref, starting from one (first child <=> n=1). returns NULL if out of bounds or father does not exist. Please free all that stuff after use.
-*/
-gchar *get_pref_nth_child(gchar const *father_path, unsigned int n){
- if (n <= 0) return NULL;
- Inkscape::XML::Node *father = inkscape_get_repr(INKSCAPE, father_path);
- if (! father ) return NULL;
- Inkscape::XML::Node *child_repr = sp_repr_children(father);
- unsigned int index = 0;
- while (child_repr && (++index < n)) {
- child_repr = sp_repr_next(child_repr);
- }
- if (child_repr) return g_strdup_printf("%s.%s",father_path,child_repr->attribute("id"));
- return NULL;
-}
-
-void
-prefs_set_int_attribute(gchar const *path, gchar const *attr, long long int value)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- sp_repr_set_int(repr, attr, value);
- }
-}
-
-long long int
-prefs_get_int_attribute(gchar const *path, gchar const *attr, long long int def)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- return sp_repr_get_int_attribute(repr, attr, def);
- } else {
- return def;
- }
-}
-
-/**
-\brief Retrieves an int attribute guarding against screwed-up data; if the value is beyond limits, default is returned
-*/
-long long int
-prefs_get_int_attribute_limited(gchar const *path, gchar const *attr, long long int def, long long int min, long long int max)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- long long int const v = sp_repr_get_int_attribute(repr, attr, def);
- if (v >= min && v <= max) {
- return v;
- } else {
- return def;
- }
- } else {
- return def;
- }
-}
-
-void
-prefs_set_double_attribute(gchar const *path, gchar const *attr, double value)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- sp_repr_set_svg_double(repr, attr, value);
- }
-}
-
-double
-prefs_get_double_attribute(gchar const *path, gchar const *attr, double def)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- return sp_repr_get_double_attribute(repr, attr, def);
- } else {
- return def;
- }
-}
-
-/**
-\brief Retrieves an int attribute guarding against screwed-up data; if the value is beyond limits, default is returned
-*/
-double
-prefs_get_double_attribute_limited(gchar const *path, gchar const *attr, double def, double min, double max)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- double const v = sp_repr_get_double_attribute(repr, attr, def);
- if (v >= min && v <= max) {
- return v;
- } else {
- return def;
- }
- } else {
- return def;
- }
-}
-
-gchar const *
-prefs_get_string_attribute(gchar const *path, gchar const *attr)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- return repr->attribute(attr);
- }
- return NULL;
-}
-
-void
-prefs_set_string_attribute(gchar const *path, gchar const *attr, gchar const *value)
-{
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, path);
- if (repr) {
- repr->setAttribute(attr, value);
- }
-}
void
prefs_set_recent_file(gchar const *uri, gchar const *name)
diff --git a/src/prefs-utils.h b/src/prefs-utils.h
index 328fb53cc3003c81ae9cac59390dca702ddc2e7d..60eb694b5018764a1bcd339e26b2962074a14fbc 100644 (file)
--- a/src/prefs-utils.h
+++ b/src/prefs-utils.h
#include <glib/gtypes.h>
#include <glib/gslist.h>
+#include "preferences.h"
-bool pref_path_exists(gchar const *path);
-unsigned int pref_path_number_of_children(gchar const *path);
-gchar * create_pref(gchar const *father_path, gchar const *child);
-gchar * get_pref_nth_child(gchar const *father_path, unsigned int n);
+inline bool pref_path_exists(gchar const *path){
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->exists(path);
+}
-void prefs_set_int_attribute(gchar const *path, gchar const *attr, long long int value);
-long long int prefs_get_int_attribute(gchar const *path, gchar const *attr, long long int def);
-long long int prefs_get_int_attribute_limited(gchar const *path, gchar const *attr, long long int def, long long int min, long long int max);
+inline unsigned pref_path_number_of_children(gchar const *path){
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->childCount(path);
+}
-void prefs_set_double_attribute(gchar const *path, gchar const *attr, double value);
-double prefs_get_double_attribute(gchar const *path, gchar const *attr, double def);
-double prefs_get_double_attribute_limited(gchar const *path, gchar const *attr, double def, double min, double max);
+inline void
+prefs_set_int_attribute(gchar const *path, gchar const *attr, long long int value)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ ps->setInt(path, attr, value);
+}
-gchar const *prefs_get_string_attribute(gchar const *path, gchar const *attr);
-void prefs_set_string_attribute(gchar const *path, gchar const *attr, gchar const *value);
+inline int
+prefs_get_int_attribute(gchar const *path, gchar const *attr, long long int def)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->getInt(path, attr, def);
+}
+inline int
+prefs_get_int_attribute_limited(gchar const *path, gchar const *attr, long long int def, long long int min, long long int max)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->getIntLimited(path, attr, def, min, max);
+}
+
+inline void
+prefs_set_double_attribute(gchar const *path, gchar const *attr, double value)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ ps->setDouble(path, attr, value);
+}
+
+inline double
+prefs_get_double_attribute(gchar const *path, gchar const *attr, double def)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->getDouble(path, attr, def);
+}
+
+inline double
+prefs_get_double_attribute_limited(gchar const *path, gchar const *attr, double def, double min, double max)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ return ps->getDoubleLimited(path, attr, def, min, max);
+}
+
+inline void
+prefs_set_string_attribute(gchar const *path, gchar const *attr, gchar const *value)
+{
+ Inkscape::Preferences *ps = Inkscape::Preferences::get();
+ ps->setString(path, attr, value);
+}
+
+/// @todo Reimplement using Gtk::RecentManager
void prefs_set_recent_file(const gchar * uri, const gchar * name);
const gchar ** prefs_get_recent_files(void);
index 3e0da0571e92f24f9edb3d97058a8da659906d1c..3bc9d6623740edb22c9d2aad4948a2eb3b73f104 100644 (file)
#include "sp-pattern.h"
#include "sp-radial-gradient-fns.h"
#include "sp-namedview.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-offset.h"
#include "sp-clippath.h"
#include "sp-mask.h"
std::vector<const gchar *> old_ids;
std::vector<const gchar *> new_ids;
- bool relink_clones = prefs_get_int_attribute ("options.relinkclonesonduplicate", "value", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool relink_clones = prefs->getBool("options.relinkclonesonduplicate", "value");
while (reprs) {
Inkscape::XML::Node *old_repr = (Inkscape::XML::Node *) reprs->data;
@@ -369,10 +370,11 @@ void sp_edit_select_all_full (SPDesktop *dt, bool force_all_layers, bool invert)
Inkscape::Selection *selection = sp_desktop_selection(dt);
g_return_if_fail(SP_IS_GROUP(dt->currentLayer()));
-
- PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs_get_int_attribute ("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
- bool onlyvisible = prefs_get_int_attribute ("options.kbselection", "onlyvisible", 1);
- bool onlysensitive = prefs_get_int_attribute ("options.kbselection", "onlysensitive", 1);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
+ bool onlyvisible = prefs->getBool("options.kbselection", "onlyvisible", true);
+ bool onlysensitive = prefs->getBool("options.kbselection", "onlysensitive", true);
GSList *items = NULL;
@@ -1183,7 +1185,8 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const
}
// "clones are unmoved when original is moved" preference
- int compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
bool prefs_unmoved = (compensation == SP_CLONE_COMPENSATION_UNMOVED);
bool prefs_parallel = (compensation == SP_CLONE_COMPENSATION_PARALLEL);
g_return_if_fail(desktop != NULL);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs_get_int_attribute ("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
- bool onlyvisible = prefs_get_int_attribute ("options.kbselection", "onlyvisible", 1);
- bool onlysensitive = prefs_get_int_attribute ("options.kbselection", "onlysensitive", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs->getInt("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
+ bool onlyvisible = prefs->getBool("options.kbselection", "onlyvisible", true);
+ bool onlysensitive = prefs->getBool("options.kbselection", "onlysensitive", true);
SPObject *root;
if (PREFS_SELECTION_ALL != inlayer) {
g_return_if_fail(desktop != NULL);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs_get_int_attribute ("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
- bool onlyvisible = prefs_get_int_attribute ("options.kbselection", "onlyvisible", 1);
- bool onlysensitive = prefs_get_int_attribute ("options.kbselection", "onlysensitive", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
+ bool onlyvisible = prefs->getBool("options.kbselection", "onlyvisible", true);
+ bool onlysensitive = prefs->getBool("options.kbselection", "onlysensitive", true);
SPObject *root;
if (PREFS_SELECTION_ALL != inlayer) {
Inkscape::NodePath::Path *np = shape_editor->get_nodepath();
if (np) {
// take colors from prefs (same as used in outline mode)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
np->helperpath_rgba = clip ?
- prefs_get_int_attribute("options.wireframecolors", "clips", 0x00ff00ff) :
- prefs_get_int_attribute("options.wireframecolors", "masks", 0x0000ffff);
+ prefs->getInt("options.wireframecolors", "clips", 0x00ff00ff) :
+ prefs->getInt("options.wireframecolors", "masks", 0x0000ffff);
np->helperpath_width = 1.0;
sp_nodepath_show_helperpath(np, true);
}
}
if (original) {
-
- bool highlight = prefs_get_int_attribute ("options.highlightoriginal", "value", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool highlight = prefs->getBool("options.highlightoriginal", "value");
if (highlight) {
boost::optional<NR::Rect> a = item->getBounds(sp_item_i2d_affine(item));
boost::optional<NR::Rect> b = original->getBounds(sp_item_i2d_affine(original));
// Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals
// without disturbing clones.
// See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int saved_compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *mark_id = generate_marker(repr_copies, bounds, doc,
( NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r->min()[NR::X],
(void)mark_id;
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("options.clonecompensation", "value", saved_compensation);
g_slist_free (items);
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
return;
}
-
- bool deleteitem = (prefs_get_int_attribute("tools", "cvg_keep_objects", 0) == 0);
- bool wholegroups = (prefs_get_int_attribute("tools", "cvg_convert_whole_groups", 0) != 0);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool deleteitem = !prefs->getBool("tools", "cvg_keep_objects", 0);
+ bool wholegroups = prefs->getBool("tools", "cvg_convert_whole_groups", 0);
for (GSList const *i = items; i != NULL; i = i->next) {
sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups);
// Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals
// without disturbing clones.
// See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int saved_compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *pat_id = pattern_tile(repr_copies, bounds, doc,
( NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r->min()[NR::X],
parent_transform * move);
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("options.clonecompensation", "value", saved_compensation);
if (apply) {
Inkscape::XML::Node *rect = xml_doc->createElement("svg:rect");
Inkscape::XML::Node *parent = SP_OBJECT_REPR(parent_object);
// Calculate resolution
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double res;
- int const prefs_res = prefs_get_int_attribute ("options.createbitmap", "resolution", 0);
- int const prefs_min = prefs_get_int_attribute ("options.createbitmap", "minsize", 0);
+ int const prefs_res = prefs->getInt("options.createbitmap", "resolution", 0);
+ int const prefs_min = prefs->getInt("options.createbitmap", "minsize", 0);
if (0 < prefs_res) {
// If it's given explicitly in prefs, take it
res = prefs_res;
// Find out if we have to run an external filter
gchar const *run = NULL;
- gchar const *filter = prefs_get_string_attribute ("options.createbitmap", "filter");
- if (filter) {
+ Glib::ustring filter = prefs->getString("options.createbitmap", "filter");
+ if (!filter.empty()) {
// filter command is given;
// see if we have a parameter to pass to it
- gchar const *param1 = prefs_get_string_attribute ("options.createbitmap", "filter_param1");
- if (param1) {
- if (param1[strlen(param1) - 1] == '%') {
+ Glib::ustring param1 = prefs->getString("options.createbitmap", "filter_param1");
+ if (!param1.empty()) {
+ if (param1[param1.length() - 1] == '%') {
// if the param string ends with %, interpret it as a percentage of the image's max dimension
gchar p1[256];
- g_ascii_dtostr (p1, 256, ceil (g_ascii_strtod (param1, NULL) * MAX(width, height) / 100));
+ g_ascii_dtostr (p1, 256, ceil (g_ascii_strtod (param1.data(), NULL) * MAX(width, height) / 100));
// the first param is always the image filename, the second is param1
- run = g_strdup_printf ("%s \"%s\" %s", filter, filepath, p1);
+ run = g_strdup_printf ("%s \"%s\" %s", filter.data(), filepath, p1);
} else {
// otherwise pass the param1 unchanged
- run = g_strdup_printf ("%s \"%s\" %s", filter, filepath, param1);
+ run = g_strdup_printf ("%s \"%s\" %s", filter.data(), filepath, param1.data());
}
} else {
// run without extra parameter
- run = g_strdup_printf ("%s \"%s\"", filter, filepath);
+ run = g_strdup_printf ("%s \"%s\"", filter.data(), filepath);
}
}
@@ -2681,8 +2691,9 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la
GSList *mask_items = NULL;
GSList *apply_to_items = NULL;
GSList *items_to_delete = NULL;
- bool topmost = prefs_get_int_attribute ("options.maskobject", "topmost", 1);
- bool remove_original = prefs_get_int_attribute ("options.maskobject", "remove", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool topmost = prefs->getBool("options.maskobject", "topmost", true);
+ bool remove_original = prefs->getBool("options.maskobject", "remove", true);
if (apply_to_layer) {
// all selected items are used for mask, which is applied to a layer
return;
}
- bool remove_original = prefs_get_int_attribute ("options.maskobject", "remove", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool remove_original = prefs->getBool("options.maskobject", "remove", true);
sp_document_ensure_up_to_date(doc);
gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 889e8b8ffc5d23885feaefbc7730f8305f32e508..a9833e05385941e143be6ac05f771f1b4cad1a2a 100644 (file)
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
#include "document.h"
#include "sp-ellipse.h"
-#include "prefs-utils.h"
+#include "preferences.h"
/* Common parent class */
ge->cy.computed = y;
ge->rx.computed = rx;
ge->ry.computed = ry;
- if (prefs_get_double_attribute("tools.shapes.arc", "start", 0.0) != 0)
- ge->start = prefs_get_double_attribute("tools.shapes.arc", "start", 0.0);
- if (prefs_get_double_attribute("tools.shapes.arc", "end", 0.0) != 0)
- ge->end = prefs_get_double_attribute("tools.shapes.arc", "end", 0.0);
- if (!prefs_get_string_attribute("tools.shapes.arc", "open"))
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getDouble("tools.shapes.arc", "start", 0.0) != 0)
+ ge->start = prefs->getDouble("tools.shapes.arc", "start", 0.0);
+ if (prefs->getDouble("tools.shapes.arc", "end", 0.0) != 0)
+ ge->end = prefs->getDouble("tools.shapes.arc", "end", 0.0);
+ if (!prefs->getBool("tools.shapes.arc", "open"))
ge->closed = 1;
else
ge->closed = 0;
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index cad6fa011bbef90d1d7695bc2da187166c95ddf2..7bdb55d007c62bb88b543d1565f810227c38c4ea 100644 (file)
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
#include "svg/svg.h" // for sp_svg_transform_write, used in _copySelection
#include "svg/css-ostringstream.h" // used in _parseColor
#include "file.h" // for file_import, used in _pasteImage
-#include "prefs-utils.h" // for prefs_get_string_attribute, used in _pasteImage
+#include "preferences.h" // for used in _pasteImage
#include "text-context.h"
#include "text-editing.h"
#include "tools-switch.h"
Glib::ustring target = _getBestTarget();
- // Special cases of clipboard content handling go here 00ff00
+ // Special cases of clipboard content handling go here
// Note that target priority is determined in _getBestTarget.
// TODO: Handle x-special/gnome-copied-files and text/uri-list to support pasting files
// in 1 second.
time_t rawtime;
char image_filename[128];
- gchar const *save_folder;
time(&rawtime);
strftime(image_filename, 128, "inkscape_pasted_image_%Y%m%d_%H%M%S.png", localtime( &rawtime ));
- save_folder = (gchar const *) prefs_get_string_attribute("dialogs.save_as", "path");
+ /// @todo Check whether the encoding is correct here
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ std::string save_folder = Glib::filename_from_utf8(prefs->getString("dialogs.save_as", "path"));
- gchar *image_path = g_build_filename(save_folder, image_filename, NULL);
+ gchar *image_path = g_build_filename(save_folder.data(), image_filename, NULL);
img->save(image_path, "png");
file_import(doc, image_path, NULL);
g_free(image_path);
index e2ce5a2e1b1779eadc9bd9917e183fb215234e7a..51b4b3f43c1b321fa2564c5acf5c7a3e7fd4ca95 100644 (file)
--- a/src/ui/context-menu.cpp
+++ b/src/ui/context-menu.cpp
#include "desktop.h"
#include "document.h"
#include "message-stack.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "ui/dialog/dialog-manager.h"
static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu);
}
static gchar* getImageEditorName() {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gchar* value = 0;
- gchar const *choices = prefs_get_string_attribute("options.bitmapeditor", "choices");
- if ( choices && choices[0] ) {
- gchar** splits = g_strsplit(choices, ",", 0);
+ Glib::ustring choices = prefs->getString("options.bitmapeditor", "choices");
+ if (!choices.empty()) {
+ gchar** splits = g_strsplit(choices.data(), ",", 0);
gint numIems = g_strv_length(splits);
- int setting = prefs_get_int_attribute_limited("options.bitmapeditor", "value", 0, 0, numIems);
+ int setting = prefs->getIntLimited("options.bitmapeditor", "value", 0, 0, numIems);
value = g_strdup(splits[setting]);
g_strfreev(splits);
index d26e05f0795b00f1938c467250fc8bc84b9072b2..a92087668916e16ff5bbb5c942cae455d7b4594e 100644 (file)
#include "extension-editor.h"
#include "verbs.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "interface.h"
#include "extension/extension.h"
vbox_page->pack_start(*notebook, true, true, 0);
Inkscape::Extension::db.foreach(dbfunc, this);
-
- gchar const * defaultext = prefs_get_string_attribute("dialogs.extensioneditor", "selected-extension");
- if (defaultext == NULL) defaultext = "org.inkscape.input.svg";
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring defaultext = prefs->getString("dialogs.extensioneditor", "selected-extension");
+ if (defaultext.empty()) defaultext = "org.inkscape.input.svg";
this->setExtension(defaultext);
show_all_children();
Glib::ustring name = row[_page_list_columns._col_name];
/* Set the selection in the preferences */
- prefs_set_string_attribute("dialogs.extensioneditor", "selected-extension", id.c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("dialogs.extensioneditor", "selected-extension", id);
/* Adjust the dialog's title */
gchar title[500];
index d577a6cc427b787a64b8d24b114adf255f99f6d9..6571f4e978d9674428700df9e613dbcd9ad983be 100644 (file)
#include "filter-enums.h"
#include "inkscape.h"
#include "path-prefix.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "selection.h"
#include "sp-feblend.h"
#include "sp-fecolormatrix.h"
void select_file(){
//# Get the current directory for finding files
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring open_path;
- char *attr = (char *)prefs_get_string_attribute("dialogs.open", "path");
- if (attr)
+ Glib::ustring attr = prefs->getString("dialogs.open", "path");
+ if (!attr.empty())
open_path = attr;
//# Test if the open_path directory exists
open_path = fileName;
open_path.append(G_DIR_SEPARATOR_S);
- prefs_set_string_attribute("dialogs.open", "path", open_path.c_str());
+ prefs->setString("dialogs.open", "path", open_path);
_entry.set_text(fileName);
}
void FilterEffectsDialog::update_primitive_infobox()
{
- if (prefs_get_int_attribute ("options.showfiltersinfobox", "value", 1)){
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("options.showfiltersinfobox", "value", true)){
_infobox_icon.show();
_infobox_desc.show();
} else {
for(unsigned int i=0; i<vect1.size(); i++) vect1[i]->hide_all();
_empty_settings.show();
- if (prefs_get_int_attribute ("options.showfiltersinfobox", "value", 1)){
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("options.showfiltersinfobox", "value", true)){
_infobox_icon.show();
_infobox_desc.show();
} else {
index dcfc4e575bfd006ccf9bfbe49878104f44ed973e..2eec6347890d31b6a42927cfce777422e2f1b25b 100644 (file)
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/alignment.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "inkscape-preferences.h"
#include "verbs.h"
#include "selcue.h"
_("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false);
}
-void InkscapePreferences::AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value)
+void InkscapePreferences::AddSelcueCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value)
{
PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
cb->init ( _("Show selection cue"), prefs_path, "selcue", def_value);
p.add_line( false, "", *cb, "", _("Whether selected objects display a selection cue (the same as in selector)"));
}
-void InkscapePreferences::AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value)
+void InkscapePreferences::AddGradientCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value)
{
PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
cb->init ( _("Enable gradient editing"), prefs_path, "gradientdrag", def_value);
p.add_line( false, "", *cb, "", _("Whether selected objects display gradient editing controls"));
}
-void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value) {
+void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value) {
PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
cb->init ( _("Conversion to guides uses edges instead of bounding box"), prefs_path, "convertguides", def_value);
p.add_line( false, "", *cb, "", _("Converting an object to guides places these along the object's true edges (imitating the object's shape), not along the bounding box."));
}
-void InkscapePreferences::AddDotSizeSpinbutton(DialogPage& p, const std::string& prefs_path, double def_value)
+void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring const &prefs_path, double def_value)
{
PrefSpinButton* sb = Gtk::manage( new PrefSpinButton);
sb->init ( prefs_path, "dot-size", 0.0, 1000.0, 0.1, 10.0, def_value, false, false);
}
}
-void InkscapePreferences::AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path, const gchar* banner)
+void InkscapePreferences::AddNewObjectsStyle(DialogPage &p, Glib::ustring const &prefs_path, const gchar *banner)
{
if (banner)
p.add_group_header(banner);
#if ENABLE_LCMS
static void profileComboChanged( Gtk::ComboBoxText* combo )
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int rowNum = combo->get_active_row_number();
if ( rowNum < 1 ) {
- prefs_set_string_attribute( "options.displayprofile", "uri", "" );
+ prefs->setString("options.displayprofile", "uri", "");
} else {
Glib::ustring active = combo->get_active_text();
Glib::ustring path = get_path_for_profile(active);
if ( !path.empty() ) {
- prefs_set_string_attribute( "options.displayprofile", "uri", path.c_str() );
+ prefs->setString("options.displayprofile", "uri", path);
}
}
}
static void proofComboChanged( Gtk::ComboBoxText* combo )
{
Glib::ustring active = combo->get_active_text();
-
Glib::ustring path = get_path_for_profile(active);
+
if ( !path.empty() ) {
- prefs_set_string_attribute( "options.softproof", "uri", path.c_str() );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("options.softproof", "uri", path);
}
}
gchar* tmp = g_strdup_printf("#%02x%02x%02x", (r >> 8), (g >> 8), (b >> 8) );
- prefs_set_string_attribute( "options.softproof", "gamutcolor", tmp );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("options.softproof", "gamutcolor", tmp);
g_free(tmp);
}
#endif // ENABLE_LCMS
void InkscapePreferences::initPageCMS()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int const numIntents = 4;
/* TRANSLATORS: see http://www.newsandtech.com/issues/2004/03-04/pt/03-04_rendering.htm */
Glib::ustring intentLabels[numIntents] = {_("Perceptual"), _("Relative Colorimetric"), _("Saturation"), _("Absolute Colorimetric")};
_page_cms.add_line( false, "", _cms_gamutwarn, "",
_("Highlights colors that are out of gamut for the target device."), false);
- gchar const* colorStr = prefs_get_string_attribute("options.softproof", "gamutcolor");
- Gdk::Color tmpColor( (colorStr && colorStr[0]) ? colorStr : "#00ff00");
+ Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor");
+ Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr);
_cms_gamutcolor.set_color( tmpColor );
_page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "",
_("Selects the color used for out of gamut warning."), false);
#if ENABLE_LCMS
{
std::vector<Glib::ustring> names = ::Inkscape::colorprofile_get_display_names();
- Glib::ustring current = prefs_get_string_attribute( "options.displayprofile", "uri" );
+ Glib::ustring current = prefs->getString( "options.displayprofile", "uri" );
gint index = 0;
_cms_display_profile.append_text(_("<none>"));
}
names = ::Inkscape::colorprofile_get_softproof_names();
- const gchar * tmp = prefs_get_string_attribute( "options.softproof", "uri" );
- current = tmp ? tmp : "";
+ current = prefs->getString("options.softproof", "uri");
index = 0;
for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) {
_cms_proof_profile.append_text( *it );
_misc_bitmap_autoreload.init(_("Automatically reload bitmaps"), "options.bitmapautoreload", "value", true);
_page_bitmaps.add_line( false, "", _misc_bitmap_autoreload, "",
_("Automatically reload linked images when file is changed on disk"));
- gchar const *choices = prefs_get_string_attribute("options.bitmapeditor", "choices");
- if ( choices && choices[0] ) {
- gchar** splits = g_strsplit(choices, ",", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring choices = prefs->getString("options.bitmapeditor", "choices");
+ if (!choices.empty()) {
+ gchar** splits = g_strsplit(choices.data(), ",", 0);
gint numIems = g_strv_length(splits);
Glib::ustring labels[numIems];
@@ -1093,7 +1097,8 @@ bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter)
bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter)
{
Gtk::TreeModel::Row row = *iter;
- int desired_page = prefs_get_int_attribute("dialogs.preferences", "page", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int desired_page = prefs->getInt("dialogs.preferences", "page", 0);
if (desired_page == row[_page_list_columns._col_id])
{
if (desired_page >= PREFS_PAGE_TOOLS && desired_page <= PREFS_PAGE_TOOLS_DROPPER)
_page_frame.remove();
Gtk::TreeModel::Row row = *iter;
_current_page = row[_page_list_columns._col_page];
- prefs_set_int_attribute("dialogs.preferences", "page", row[_page_list_columns._col_id]);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("dialogs.preferences", "page", row[_page_list_columns._col_id]);
_page_title.set_markup("<span size='large'><b>" + row[_page_list_columns._col_name] + "</b></span>");
_page_frame.add(*_current_page);
_current_page->show();
index a6fc96a3fb3123650c629868f69f19271ad12152..30dd2bdaab96307275451249b22192eb46f94fd2 100644 (file)
bool SetMaxDialogSize(const Gtk::TreeModel::iterator& iter);
bool PresentPage(const Gtk::TreeModel::iterator& iter);
- static void AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value);
- static void AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value);
- static void AddConvertGuidesCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value);
- static void AddDotSizeSpinbutton(DialogPage& p, const std::string& prefs_path, double def_value);
- static void AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path, const gchar* banner = NULL);
+ static void AddSelcueCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
+ static void AddGradientCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
+ static void AddConvertGuidesCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
+ static void AddDotSizeSpinbutton(DialogPage& p, Glib::ustring const &prefs_path, double def_value);
+ static void AddNewObjectsStyle(DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL);
void on_pagelist_selection_changed();
void initPageMouse();
index 729d09511c064357bb40ca01394c53e871f55fb1..de22c16d66e15b24ab9b74d380e9a298a5b62bf4 100644 (file)
#include "gc-core.h"
#include <dialogs/dialog-events.h>
#include "io/sys.h"
+#include "preferences.h"
namespace Inkscape
{
//get file url
fileUrl = get_text(posArray[0], 1); //http url
+ //Inkscape::Preferences *prefs = Inkscape::Preferences::get();
//Glib::ustring fileUrl = "dav://"; //dav url
- //fileUrl.append(prefs_get_string_attribute("options.ocalurl", "str"));
+ //fileUrl.append(prefs->getString("options.ocalurl", "str"));
//fileUrl.append("/dav.php/");
//fileUrl.append(get_text(posArray[0], 3)); //author dir
//fileUrl.append("/");
notFoundLabel->hide();
descriptionLabel->set_text("");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring searchTag = searchTagEntry->get_text();
// create the ocal uri to get rss feed
Glib::ustring uri = "http://";
- uri.append(prefs_get_string_attribute("options.ocalurl", "str"));
+ uri.append(prefs->getString("options.ocalurl", "str"));
uri.append("/media/feed/rss/");
uri.append(searchTag);
if (!Glib::get_charset()) //If we are not utf8
index ae291c03d74aa09e9a17662a4448e42c2899285c..f91d4a607094d63725bb005c814285d9c8f23e0d 100644 (file)
#include "inkscape.h"
#include "desktop.h"
#include "message-stack.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "jabber_whiteboard/session-manager.h"
this->_labels[2].set_mnemonic_widget(this->_password);
this->_labels[3].set_mnemonic_widget(this->_port);
- this->_server.set_text(prefs_get_string_attribute("whiteboard.server", "name"));
- this->_port.set_text(prefs_get_string_attribute("whiteboard.server", "port"));
- this->_username.set_text(prefs_get_string_attribute("whiteboard.server", "username"));
- this->_usessl.set_active((prefs_get_int_attribute("whiteboard.server", "ssl", 0) == 1) ? true : false);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ this->_server.set_text(prefs->getString("whiteboard.server", "name"));
+ /// @todo Convert port to an integer preference?
+ this->_port.set_text(prefs->getString("whiteboard.server", "port"));
+ this->_username.set_text(prefs->getString("whiteboard.server", "username"));
+ this->_usessl.set_active(prefs->getBool("whiteboard.server", "ssl", false);
this->_layout.attach(this->_labels[0], 0, 1, 0, 1);
this->_layout.attach(this->_labels[1], 0, 1, 1, 2);
void
WhiteboardConnectDialogImpl::_respCallback(int resp)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (resp == GTK_RESPONSE_OK)
{
Glib::ustring server, port, username, password;
this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
// Save preferences
- prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str());
+ prefs->setString(this->_prefs_path, "server", this->_server.get_text());
break;
default:
break;
this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
// Save preferences
- prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str());
+ prefs->setString(this->_prefs_path, "server", this->_server.get_text());
break;
default:
break;
}
}
-}
+} // namespace Dialog
-}
+} // namespace UI
-}
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/ui/dialog/whiteboard-sharewithchat.cpp b/src/ui/dialog/whiteboard-sharewithchat.cpp
index b2b913de06e3981bc0dff34a23c6c032597e8130..4e9ea7abfcdbd1b37a738754892ad732afdddc4f 100644 (file)
/**
- * Whiteboard share with chatroom dialog
+ * @file
+ * @brief Whiteboard share with chatroom dialog
*
* Authors:
* David Yip <yipdw@rose-hulman.edu>
#include "inkscape.h"
#include "desktop.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "jabber_whiteboard/typedefs.h"
#include "jabber_whiteboard/session-manager.h"
#include "util/ucompose.hpp"
namespace Inkscape {
-
namespace UI {
-
namespace Dialog {
WhiteboardShareWithChatroomDialog*
void
WhiteboardShareWithChatroomDialogImpl::setSessionManager()
{
- this->_desktop = this->getDesktop();
+ this->_desktop = this->getDesktop();
this->_sm = this->_desktop->whiteboard_session_manager();
}
this->_labels[2].set_mnemonic_widget(this->_roompass);
this->_labels[3].set_mnemonic_widget(this->_handle);
-
- this->_roomname.set_text(prefs_get_string_attribute("whiteboard.room", "name"));
- this->_confserver.set_text(prefs_get_string_attribute("whiteboard.room", "server"));
- this->_handle.set_text(prefs_get_string_attribute("whiteboard.server", "username"));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ this->_roomname.set_text(prefs->getString("whiteboard.room", "name"));
+ this->_confserver.set_text(prefs->getString("whiteboard.room", "server"));
+ this->_handle.set_text(prefs->getString("whiteboard.server", "username"));
// Pack table
this->_layout.attach(this->_labels[0], 0, 1, 0, 1);
}
}
-}
-
-}
-
-}
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
index a46bf39bf5f43ec1acc74624c5c6a2d940a96a3b..b11ca2e93e41d49192bded2c20d6cf16bd079b95 100644 (file)
#include <gtkmm/alignment.h>
#include <gtkmm/box.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "ui/widget/preferences-widget.h"
#include "verbs.h"
#include "selcue.h"
this->set_row_spacings(6);
}
-void DialogPage::add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand_widget)
+void DialogPage::add_line(bool indent, Glib::ustring const &label, Gtk::Widget &widget, Glib::ustring const &suffix, const Glib::ustring &tip, bool expand_widget)
{
int start_col;
int row = this->property_n_rows();
}
}
-void DialogPage::set_tip(Gtk::Widget& widget, const Glib::ustring& tip)
+void DialogPage::set_tip(Gtk::Widget& widget, Glib::ustring const &tip)
{
_tooltips.set_tip (widget, tip);
}
-void PrefCheckButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
- bool default_value)
+void PrefCheckButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
+ Glib::ustring const &attr, bool default_value)
{
_prefs_path = prefs_path;
_attr = attr;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->set_label(label);
- this->set_active( prefs_get_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int)default_value) );
+ this->set_active( prefs->getBool(_prefs_path, _attr, default_value) );
}
void PrefCheckButton::on_toggled()
{
if (this->is_visible()) //only take action if the user toggled it
{
- prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int) this->get_active());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(_prefs_path, _attr, this->get_active());
}
}
-void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
- const std::string& string_value, bool default_value, PrefRadioButton* group_member)
+void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
+ Glib::ustring const &attr, Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member)
{
- (void)default_value;
- _value_type = VAL_STRING;
_prefs_path = prefs_path;
_attr = attr;
+ _value_type = VAL_STRING;
_string_value = string_value;
+ (void)default_value;
this->set_label(label);
if (group_member)
{
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
- const gchar* val = prefs_get_string_attribute( _prefs_path.c_str(), _attr.c_str() );
- if ( val )
- this->set_active( std::string( val ) == _string_value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring val = prefs->getString(_prefs_path, _attr);
+ if ( !val.empty() )
+ this->set_active(val == _string_value);
else
this->set_active( false );
}
-void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
- int int_value, bool default_value, PrefRadioButton* group_member)
+void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
+ Glib::ustring const &attr, int int_value, bool default_value, PrefRadioButton* group_member)
{
- _value_type = VAL_INT;
_prefs_path = prefs_path;
_attr = attr;
+ _value_type = VAL_INT;
_int_value = int_value;
this->set_label(label);
if (group_member)
@@ -178,25 +181,28 @@ void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (default_value)
- this->set_active( prefs_get_int_attribute( _prefs_path.c_str(), _attr.c_str(), int_value ) == _int_value);
+ this->set_active( prefs->getInt(_prefs_path, _attr, int_value) == _int_value );
else
- this->set_active( prefs_get_int_attribute( _prefs_path.c_str(), _attr.c_str(), int_value + 1 )== _int_value);
+ this->set_active( prefs->getInt(_prefs_path, _attr, int_value + 1) == _int_value );
}
void PrefRadioButton::on_toggled()
{
this->changed_signal.emit(this->get_active());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
if (this->is_visible() && this->get_active() ) //only take action if toggled by user (to active)
{
if ( _value_type == VAL_STRING )
- prefs_set_string_attribute ( _prefs_path.c_str(), _attr.c_str(), _string_value.c_str());
+ prefs->setString(_prefs_path, _attr, _string_value);
else if ( _value_type == VAL_INT )
- prefs_set_int_attribute ( _prefs_path.c_str(), _attr.c_str(), _int_value);
+ prefs->setInt(_prefs_path, _attr, _int_value);
}
}
-void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr,
+void PrefSpinButton::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
double lower, double upper, double step_increment, double page_increment,
double default_value, bool is_int, bool is_percent)
{
@@ -204,15 +210,17 @@ void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr
_attr = attr;
_is_int = is_int;
_is_percent = is_percent;
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double value;
- if (is_int)
- if (is_percent)
- value = 100 * prefs_get_double_attribute_limited (prefs_path.c_str(), attr.c_str(), default_value, lower/100.0, upper/100.0);
- else
- value = (double) prefs_get_int_attribute_limited (prefs_path.c_str(), attr.c_str(), (int) default_value, (int) lower, (int) upper);
- else
- value = prefs_get_double_attribute_limited (prefs_path.c_str(), attr.c_str(), default_value, lower, upper);
+ if (is_int) {
+ if (is_percent) {
+ value = 100 * prefs->getDoubleLimited(prefs_path, attr, default_value, lower/100.0, upper/100.0);
+ } else {
+ value = (double) prefs->getIntLimited(prefs_path, attr, (int) default_value, (int) lower, (int) upper);
+ }
+ } else {
+ value = prefs->getDoubleLimited(prefs_path, attr, default_value, lower, upper);
+ }
this->set_range (lower, upper);
this->set_increments (step_increment, page_increment);
@@ -230,15 +238,18 @@ void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr
void PrefSpinButton::on_value_changed()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (this->is_visible()) //only take action if user changed value
{
- if (_is_int)
- if (_is_percent)
- prefs_set_double_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_value()/100.0);
- else
- prefs_set_int_attribute(_prefs_path.c_str(), _attr.c_str(), (int) this->get_value());
- else
- prefs_set_double_attribute (_prefs_path.c_str(), _attr.c_str(), this->get_value());
+ if (_is_int) {
+ if (_is_percent) {
+ prefs->setDouble(_prefs_path, _attr, this->get_value()/100.0);
+ } else {
+ prefs->setInt(_prefs_path, _attr, (int) this->get_value());
+ }
+ } else {
+ prefs->setDouble(_prefs_path, _attr, this->get_value());
+ }
}
}
*/
void
ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval) {
- const double zoomcorr = prefs_get_double_attribute("options.zoomcorrection", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ const double zoomcorr = prefs->getDouble("options.zoomcorrection", "value", 1.0);
double mark = 0;
int i = 0;
while (mark <= _drawing_width) {
cr->move_to (0, _height);
cr->line_to (_drawing_width, _height);
- const char *abbr = prefs_get_string_attribute("options.zoomcorrection", "unit");
- if (!strcmp(abbr, "cm")) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring abbr = prefs->getString("options.zoomcorrection", "unit");
+ if (abbr == "cm") {
draw_marks(cr, 0.1, 10);
- } else if (!strcmp(abbr, "ft")) {
+ } else if (abbr == "ft") {
draw_marks(cr, 1/12.0, 12);
- } else if (!strcmp(abbr, "in")) {
+ } else if (abbr == "in") {
draw_marks(cr, 0.25, 4);
- } else if (!strcmp(abbr, "m")) {
+ } else if (abbr == "m") {
draw_marks(cr, 1/10.0, 10);
- } else if (!strcmp(abbr, "mm")) {
+ } else if (abbr == "mm") {
draw_marks(cr, 10, 10);
- } else if (!strcmp(abbr, "pc")) {
+ } else if (abbr == "pc") {
draw_marks(cr, 1, 10);
- } else if (!strcmp(abbr, "pt")) {
+ } else if (abbr == "pt") {
draw_marks(cr, 10, 10);
- } else if (!strcmp(abbr, "px")) {
+ } else if (abbr == "px") {
draw_marks(cr, 10, 10);
} else {
draw_marks(cr, 1, 1);
if (this->is_visible() || freeze) //only take action if user changed value
{
freeze = true;
- prefs_set_double_attribute ("options.zoomcorrection", "value", _slider.get_value() / 100.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("options.zoomcorrection", "value", _slider.get_value() / 100.0);
_sb.set_value(_slider.get_value());
_ruler.redraw();
freeze = false;
if (this->is_visible() || freeze) //only take action if user changed value
{
freeze = true;
- prefs_set_double_attribute ("options.zoomcorrection", "value", _sb.get_value() / 100.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("options.zoomcorrection", "value", _sb.get_value() / 100.0);
_slider.set_value(_sb.get_value());
_ruler.redraw();
freeze = false;
// it needs to be reset later so we don't perform the change in this case
return;
}
- prefs_set_string_attribute ("options.zoomcorrection", "unit", _unit.getUnitAbbr().c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("options.zoomcorrection", "unit", _unit.getUnitAbbr());
double conv = _unit.getConversion(_unit.getUnitAbbr(), "px");
_ruler.set_unit_conversion(conv);
if (_ruler.is_visible()) {
ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, double upper,
double step_increment, double page_increment, double default_value)
{
- double value = prefs_get_double_attribute_limited ("options.zoomcorrection", "value", default_value, lower, upper) * 100.0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double value = prefs->getDoubleLimited("options.zoomcorrection", "value", default_value, lower, upper) * 100.0;
freeze = false;
@@ -432,7 +449,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
_unit.set_data("sensitive", GINT_TO_POINTER(0));
_unit.setUnitType(UNIT_TYPE_LINEAR);
_unit.set_data("sensitive", GINT_TO_POINTER(1));
- _unit.setUnit(prefs_get_string_attribute ("options.zoomcorrection", "unit"));
+ _unit.setUnit(prefs->getString("options.zoomcorrection", "unit"));
Gtk::Table *table = Gtk::manage(new Gtk::Table());
Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
@@ -448,13 +465,14 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
-void PrefCombo::init(const std::string& prefs_path, const std::string& attr,
+void PrefCombo::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
Glib::ustring labels[], int values[], int num_items, int default_value)
{
_prefs_path = prefs_path;
_attr = attr;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int row = 0;
- int value = prefs_get_int_attribute (_prefs_path.c_str(), _attr.c_str(), default_value);
+ int value = prefs->getInt(_prefs_path, _attr, default_value);
for (int i = 0 ; i < num_items; ++i)
{
{
if (this->is_visible()) //only take action if user changed value
{
- prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), _values[this->get_active_row_number()]);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path, _attr, _values[this->get_active_row_number()]);
}
}
-void PrefEntryButtonHBox::init(const std::string& prefs_path, const std::string& attr,
- bool visibility, gchar* default_string)
+void PrefEntryButtonHBox::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ bool visibility, Glib::ustring const &default_string)
{
_prefs_path = prefs_path;
_attr = attr;
_default_string = default_string;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
relatedEntry = new Gtk::Entry();
relatedButton = new Gtk::Button(_("Reset"));
relatedEntry->set_invisible_char('*');
relatedEntry->set_visibility(visibility);
- relatedEntry->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str()));
+ relatedEntry->set_text(prefs->getString(_prefs_path, _attr));
this->pack_start(*relatedEntry);
this->pack_start(*relatedButton);
relatedButton->signal_clicked().connect(
{
if (this->is_visible()) //only take action if user changed value
{
- prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(),
- relatedEntry->get_text().c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path, _attr, relatedEntry->get_text());
}
}
{
if (this->is_visible()) //only take action if user changed value
{
- prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(),
- _default_string);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path, _attr, _default_string);
relatedEntry->set_text(_default_string);
}
}
-void PrefFileButton::init(const std::string& prefs_path, const std::string& attr)
+void PrefFileButton::init(Glib::ustring const &prefs_path, Glib::ustring const &attr)
{
_prefs_path = prefs_path;
_attr = attr;
- select_filename(Glib::filename_from_utf8(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str())));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ select_filename(Glib::filename_from_utf8(prefs->getString(_prefs_path, _attr)));
signal_selection_changed().connect(sigc::mem_fun(*this, &PrefFileButton::onFileChanged));
}
void PrefFileButton::onFileChanged()
{
- prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), Glib::filename_to_utf8(get_filename()).c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path, _attr, Glib::filename_to_utf8(get_filename()));
}
-void PrefEntry::init(const std::string& prefs_path, const std::string& attr,
+void PrefEntry::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
bool visibility)
{
_prefs_path = prefs_path;
_attr = attr;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->set_invisible_char('*');
this->set_visibility(visibility);
- this->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str()));
+ this->set_text(prefs->getString(_prefs_path, _attr));
}
void PrefEntry::on_changed()
{
if (this->is_visible()) //only take action if user changed value
{
- prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_text().c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path, _attr, this->get_text());
}
}
-void PrefColorPicker::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+void PrefColorPicker::init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
guint32 default_rgba)
{
_prefs_path = prefs_path;
_attr = attr;
_title = label;
- this->setRgba32( prefs_get_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int)default_rgba) );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ this->setRgba32( prefs->getInt(_prefs_path, _attr, (int)default_rgba) );
}
void PrefColorPicker::on_changed (guint32 rgba)
{
if (this->is_visible()) //only take action if the user toggled it
{
- prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int) rgba);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path, _attr, (int) rgba);
}
}
-void PrefUnit::init(const std::string& prefs_path, const std::string& attr)
+void PrefUnit::init(Glib::ustring const &prefs_path, Glib::ustring const &attr)
{
_prefs_path = prefs_path;
_attr = attr;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
setUnitType(UNIT_TYPE_LINEAR);
- gchar const * prefval = prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str());
- setUnit(prefval);
+ setUnit(prefs->getString(_prefs_path, _attr));
}
void PrefUnit::on_changed()
{
if (this->is_visible()) //only take action if user changed value
{
- prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), getUnitAbbr().c_str());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(_prefs_path, _attr, getUnitAbbr());
}
}
index 9f10f8ca864ac6394ced8fde2a7065574262a091..da07db5d9aded3f72e81dc11240e5f8e6394bb85 100644 (file)
class PrefCheckButton : public Gtk::CheckButton
{
public:
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ void init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
bool default_value);
protected:
- std::string _prefs_path;
- std::string _attr;
- bool _int_value;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
void on_toggled();
};
class PrefRadioButton : public Gtk::RadioButton
{
public:
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ void init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
int int_value, bool default_value, PrefRadioButton* group_member);
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
- const std::string& string_value, bool default_value, PrefRadioButton* group_member);
+ void init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member);
sigc::signal<void, bool> changed_signal;
protected:
- std::string _prefs_path;
- std::string _attr;
- std::string _string_value;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
+ Glib::ustring _string_value;
int _value_type;
enum
{
class PrefSpinButton : public Gtk::SpinButton
{
public:
- void init(const std::string& prefs_path, const std::string& attr,
+ void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
double lower, double upper, double step_increment, double page_increment,
double default_value, bool is_int, bool is_percent);
protected:
- std::string _prefs_path;
- std::string _attr;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
bool _is_int;
bool _is_percent;
void on_value_changed();
class PrefCombo : public Gtk::ComboBoxText
{
public:
- void init(const std::string& prefs_path, const std::string& attr,
+ void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
Glib::ustring labels[], int values[], int num_items, int default_value);
protected:
- std::string _prefs_path;
- std::string _attr;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
std::vector<int> _values;
void on_changed();
};
class PrefEntry : public Gtk::Entry
{
public:
- void init(const std::string& prefs_path, const std::string& attr,
+ void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
bool mask);
protected:
- std::string _prefs_path;
- std::string _attr;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
void on_changed();
};
class PrefEntryButtonHBox : public Gtk::HBox
{
public:
- void init(const std::string& prefs_path, const std::string& attr,
- bool mask, gchar* default_string);
+ void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ bool mask, Glib::ustring const &default_string);
protected:
- std::string _prefs_path;
- std::string _attr;
- gchar* _default_string;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
+ Glib::ustring _default_string;
Gtk::Button *relatedButton;
Gtk::Entry *relatedEntry;
void onRelatedEntryChangedCallback();
class PrefFileButton : public Gtk::FileChooserButton
{
public:
- void init(const std::string& prefs_path, const std::string& attr);
+ void init(Glib::ustring const &prefs_path, Glib::ustring const &attr);
protected:
- std::string _prefs_path;
- std::string _attr;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
void onFileChanged();
};
PrefColorPicker() : ColorPicker("", "", 0, false) {};
virtual ~PrefColorPicker() {};
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ void init(Glib::ustring const &abel, Glib::ustring const &prefs_path, Glib::ustring const &attr,
guint32 default_rgba);
protected:
- std::string _prefs_path;
- std::string _attr;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
virtual void on_changed (guint32 rgba);
};
class PrefUnit : public UnitMenu
{
public:
- void init(const std::string& prefs_path, const std::string& attr);
+ void init(Glib::ustring const &prefs_path, Glib::ustring const &attr);
protected:
- std::string _prefs_path;
- std::string _attr;
+ Glib::ustring _prefs_path;
+ Glib::ustring _attr;
void on_changed();
};
{
public:
DialogPage();
- void add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand = true);
+ void add_line(bool indent, Glib::ustring const &label, Gtk::Widget& widget, Glib::ustring const &suffix, Glib::ustring const &tip, bool expand = true);
void add_group_header(Glib::ustring name);
- void set_tip(Gtk::Widget& widget, const Glib::ustring& tip);
+ void set_tip(Gtk::Widget &widget, Glib::ustring const &tip);
protected:
Gtk::Tooltips _tooltips;
};
index 4be82339140ad104cb165308dc87aebedd8f9f16..c182fe0174896b38a507ee01ed72f313902a883e 100644 (file)
#include "sp-namedview.h"
#include "interface.h"
#include "toolbox.h"
-#include "prefs-utils.h"
#include "preferences.h"
#include "file.h"
#include "display/canvas-arena.h"
if ( !id ) {
// bad
} else if (strcmp("displayprofile", id) == 0) {
- Glib::ustring current = prefs_get_string_attribute( "options.displayprofile", "uri" );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring current = prefs->getString("options.displayprofile", "uri");
bool enabled = current.length() > 0;
for ( std::list<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it ) {
GtkWidget *hbox;
GtkWidget *eventbox;
GtkStyle *style;
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
new (&dtw->modified_connection) sigc::connection();
widget = GTK_WIDGET (dtw);
dtw->window = 0;
-
dtw->desktop = NULL;
-
dtw->_interaction_disabled_counter = 0;
-
dtw->tt = gtk_tooltips_new ();
/* Main table */
"sticky_zoom",
_("Zoom drawing if window size changes"),
dtw->tt);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs_get_int_attribute ("options.stickyzoom", "value", 0));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("options.stickyzoom", "value"));
gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0);
dtw->vadj = (GtkAdjustment *) gtk_adjustment_new (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
dtw->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (dtw->vadj));
dtw->tt );
#if ENABLE_LCMS
{
- Glib::ustring current = prefs_get_string_attribute( "options.displayprofile", "uri" );
+ Glib::ustring current = prefs->getString("options.displayprofile", "uri");
bool enabled = current.length() > 0;
cms_adjust_set_sensitive( dtw, enabled );
if ( enabled ) {
- long long int active = prefs_get_int_attribute_limited( "options.displayprofile", "enable", 0, 0, 1 );
+ bool active = prefs->getBool("options.displayprofile", "enable");
if ( active ) {
sp_button_toggle_set_down( SP_BUTTON(dtw->cms_adjust), TRUE );
}
#endif // ENABLE_LCMS
gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0);
{
- Inkscape::XML::Node* prefs = Inkscape::Preferences::get();
- if ( prefs ) {
- if (!watcher) {
- watcher = new PrefWatcher();
- prefs->addSubtreeObserver( *watcher );
- }
- watcher->add(dtw);
- } else {
- g_warning("NULL preferences instance encountered");
+ Inkscape::Preferences* prefs = Inkscape::Preferences::get();
+ if (!watcher) {
+ watcher = new PrefWatcher();
+ prefs->addPrefsObserver( watcher );
}
+ watcher->add(dtw);
}
/* Canvas */
dtw->canvas = SP_CANVAS (sp_canvas_new_aa ());
#if ENABLE_LCMS
- dtw->canvas->enable_cms_display_adj = prefs_get_int_attribute_limited( "options.displayprofile", "enable", 0, 0, 1 ) != 0;
+ dtw->canvas->enable_cms_display_adj = prefs->getBool("options.displayprofile", "enable");
#endif // ENABLE_LCMS
GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dtw->canvas), GTK_CAN_FOCUS);
style = gtk_style_copy (GTK_WIDGET (dtw->canvas)->style);
style->bg[GTK_STATE_NORMAL] = style->white;
gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style);
- if ( prefs_get_int_attribute ("options.useextinput", "value", 1) )
+ if ( prefs->getBool("options.useextinput", "value", true) )
gtk_widget_set_extension_events(GTK_WIDGET (dtw->canvas) , GDK_EXTENSION_EVENTS_ALL); //set extension events for tablets, unless disabled in preferences
g_signal_connect (G_OBJECT (dtw->canvas), "event", G_CALLBACK (sp_desktop_widget_event), dtw);
gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0);
/* Dock */
bool create_dock =
- prefs_get_int_attribute_limited ("options.dialogtype", "value", Inkscape::UI::Dialog::FLOATING, 0, 1) ==
+ prefs->getIntLimited("options.dialogtype", "value", Inkscape::UI::Dialog::FLOATING, 0, 1) ==
Inkscape::UI::Dialog::DOCK;
if (create_dock) {
if ( down != dtw->canvas->enable_cms_display_adj ) {
dtw->canvas->enable_cms_display_adj = down;
dtw->requestCanvasUpdate();
- prefs_set_int_attribute( "options.displayprofile", "enable", down ? 1 : 0 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("options.displayprofile", "enable", down);
}
#endif // ENABLE_LCMS
}
* But we save the info here regardless of the setting.
*/
{
- gint full = desktop->is_fullscreen() ? 1 : 0;
- gint maxed = desktop->is_maximized() ? 1 : 0;
- prefs_set_int_attribute("desktop.geometry", "fullscreen", full);
- prefs_set_int_attribute("desktop.geometry", "maximized", maxed);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool maxed = desktop->is_maximized();
+ bool full = desktop->is_fullscreen();
+ prefs->setBool("desktop.geometry", "fullscreen", full);
+ prefs->setBool("desktop.geometry", "maximized", maxed);
gint w, h, x, y;
desktop->getWindowGeometry(x, y, w, h);
// Don't save geom for maximized windows. It
// just tells you the current maximized size, which is not
// as useful as whatever value it had previously.
if (!maxed && !full) {
- prefs_set_int_attribute("desktop.geometry", "width", w);
- prefs_set_int_attribute("desktop.geometry", "height", h);
- prefs_set_int_attribute("desktop.geometry", "x", x);
- prefs_set_int_attribute("desktop.geometry", "y", y);
+ prefs->setInt("desktop.geometry", "width", w);
+ prefs->setInt("desktop.geometry", "height", h);
+ prefs->setInt("desktop.geometry", "x", x);
+ prefs->setInt("desktop.geometry", "y", y);
}
}
// a separate non-maximized size.
if (!dtw->desktop->is_iconified() && !dtw->desktop->is_fullscreen())
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint w, h, x, y;
dtw->getWindowGeometry(x, y, w, h);
- prefs_set_int_attribute("desktop.geometry", "width", w);
- prefs_set_int_attribute("desktop.geometry", "height", h);
- prefs_set_int_attribute("desktop.geometry", "x", x);
- prefs_set_int_attribute("desktop.geometry", "y", y);
+ prefs->setInt("desktop.geometry", "width", w);
+ prefs->setInt("desktop.geometry", "height", h);
+ prefs->setInt("desktop.geometry", "x", x);
+ prefs->setInt("desktop.geometry", "y", y);
}
gtk_window_maximize(topw);
}
// a separate non-maximized size.
if (!dtw->desktop->is_iconified() && !dtw->desktop->is_maximized())
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint w, h, x, y;
dtw->getWindowGeometry(x, y, w, h);
- prefs_set_int_attribute("desktop.geometry", "width", w);
- prefs_set_int_attribute("desktop.geometry", "height", h);
- prefs_set_int_attribute("desktop.geometry", "x", x);
- prefs_set_int_attribute("desktop.geometry", "y", y);
+ prefs->setInt("desktop.geometry", "width", w);
+ prefs->setInt("desktop.geometry", "height", h);
+ prefs->setInt("desktop.geometry", "x", x);
+ prefs->setInt("desktop.geometry", "y", y);
}
gtk_window_fullscreen(topw);
// widget layout is triggered by the resulting window_state_event
sp_desktop_widget_layout (SPDesktopWidget *dtw)
{
bool fullscreen = dtw->desktop->is_fullscreen();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.menu" : "window.menu", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.menu" : "window.menu" ), "state", true)) {
gtk_widget_hide_all (dtw->menubar);
} else {
gtk_widget_show_all (dtw->menubar);
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.commands" : "window.commands", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.commands" : "window.commands" ), "state", true)) {
gtk_widget_hide_all (dtw->commands_toolbox);
} else {
gtk_widget_show_all (dtw->commands_toolbox);
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.toppanel" : "window.toppanel", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.toppanel" : "window.toppanel" ), "state", true)) {
gtk_widget_hide_all (dtw->aux_toolbox);
} else {
// we cannot just show_all because that will show all tools' panels;
show_aux_toolbox (dtw->aux_toolbox);
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.toolbox" : "window.toolbox", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.toolbox" : "window.toolbox" ), "state", true)) {
gtk_widget_hide_all (dtw->tool_toolbox);
} else {
gtk_widget_show_all (dtw->tool_toolbox);
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.statusbar" : "window.statusbar", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.statusbar" : "window.statusbar" ), "state", true)) {
gtk_widget_hide_all (dtw->statusbar);
} else {
gtk_widget_show_all (dtw->statusbar);
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.panels" : "window.panels", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.panels" : "window.panels" ), "state", true)) {
gtk_widget_hide_all( dtw->panels );
} else {
gtk_widget_show_all( dtw->panels );
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.scrollbars" : "window.scrollbars", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.scrollbars" : "window.scrollbars" ), "state", true)) {
gtk_widget_hide_all (dtw->hscrollbar);
gtk_widget_hide_all (dtw->vscrollbar_box);
gtk_widget_hide_all( dtw->cms_adjust );
gtk_widget_show_all( dtw->cms_adjust );
}
- if (prefs_get_int_attribute (fullscreen ? "fullscreen.rulers" : "window.rulers", "state", 1) == 0) {
+ if (!prefs->getBool(( fullscreen ? "fullscreen.rulers" : "window.rulers" ), "state", true)) {
gtk_widget_hide_all (dtw->hruler);
gtk_widget_hide_all (dtw->vruler);
} else {
@@ -1439,8 +1439,8 @@ sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWid
/* we make the desktop window with focus active, signal is connected in interface.c */
bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
{
-
- if (prefs_get_int_attribute_limited("options.bitmapautoreload", "value", 1, 0, 1)) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("options.bitmapautoreload", "value", true)) {
GSList const *imageList = sp_document_get_resource_list(desktop->doc(), "image");
for (GSList const *p = imageList; p; p = p->next) {
SPImage* image = SP_IMAGE(p->data);
void
sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (GTK_WIDGET_VISIBLE (dtw->hruler)) {
gtk_widget_hide_all (dtw->hruler);
gtk_widget_hide_all (dtw->vruler);
- prefs_set_int_attribute (dtw->desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", 0);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", false);
} else {
gtk_widget_show_all (dtw->hruler);
gtk_widget_show_all (dtw->vruler);
- prefs_set_int_attribute (dtw->desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", 1);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", true);
}
}
void
sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (GTK_WIDGET_VISIBLE (dtw->hscrollbar)) {
gtk_widget_hide_all (dtw->hscrollbar);
gtk_widget_hide_all (dtw->vscrollbar_box);
gtk_widget_hide_all( dtw->cms_adjust );
- prefs_set_int_attribute (dtw->desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", 0);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", false);
} else {
gtk_widget_show_all (dtw->hscrollbar);
gtk_widget_show_all (dtw->vscrollbar_box);
gtk_widget_show_all( dtw->cms_adjust );
- prefs_set_int_attribute (dtw->desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", 1);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", true);
}
}
void
sp_spw_toggle_menubar (SPDesktopWidget *dtw, bool is_fullscreen)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (GTK_WIDGET_VISIBLE (dtw->menubar)) {
gtk_widget_hide_all (dtw->menubar);
- prefs_set_int_attribute (is_fullscreen ? "fullscreen.menu" : "window.menu", "state", 0);
+ prefs->setBool(is_fullscreen ? "fullscreen.menu" : "window.menu", "state", false);
} else {
gtk_widget_show_all (dtw->menubar);
- prefs_set_int_attribute (is_fullscreen ? "fullscreen.menu" : "window.menu", "state", 1);
+ prefs->setBool(is_fullscreen ? "fullscreen.menu" : "window.menu", "state", true);
}
}
*/
index fc3a9e66fbf421a4b2f42a201192b71bc13017c4..929af817a0a7c1b274b1975a10892e4cb8d8ba1e 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "ui/widget/style-swatch.h"
-#include "prefs-utils.h"
#include "verbs.h"
#include "sp-namedview.h"
#include "desktop.h"
#include "../libnrtype/font-lister.h"
#include "../libnrtype/font-instance.h"
#include "../connection-pool.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "../inkscape-stock.h"
#include "icon.h"
#include "graphlayout/graphlayout.h"
Inkscape::ICON_SIZE_SMALL_TOOLBAR,
Inkscape::ICON_SIZE_MENU
};
- int index = prefs_get_int_attribute_limited( path, attr, base, 0, G_N_ELEMENTS(sizeChoices) );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int index = prefs->getIntLimited( path, attr, base, 0, G_N_ELEMENTS(sizeChoices) );
return sizeChoices[index];
}
void (*callback)(GtkAdjustment *, GObject *),
gdouble climb = 0.1, guint digits = 3, double factor = 1.0 )
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs_get_double_attribute(path, data, def) * factor,
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs->getDouble(path, data, def) * factor,
lower, upper, step, page, page ) );
if (us) {
sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(us), adj );
}
static void toggle_show_handles (GtkToggleAction *act, gpointer /*data*/) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.nodes", "show_handles", show ? 1 : 0);
+ prefs->setBool("tools.nodes", "show_handles", show);
ShapeEditor *shape_editor = get_current_shape_editor();
if (shape_editor) shape_editor->show_handles(show);
}
static void toggle_show_helperpath (GtkToggleAction *act, gpointer /*data*/) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.nodes", "show_helperpath", show ? 1 : 0);
+ prefs->setBool("tools.nodes", "show_helperpath", show);
ShapeEditor *shape_editor = get_current_shape_editor();
if (shape_editor) shape_editor->show_helperpath(show);
}
sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name)
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.nodes", value_name, sp_units_get_pixels(adj->value, *unit));
+ prefs->setDouble("tools.nodes", value_name, sp_units_get_pixels(adj->value, *unit));
}
// quit if run by the attr_changed listener
@@ -1249,6 +1253,7 @@ sp_node_toolbox_sel_modified (Inkscape::Selection *selection, guint /*flags*/, G
static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
g_object_set_data( holder, "tracker", tracker );
@@ -1377,7 +1382,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_handles), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.nodes", "show_handles", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.nodes", "show_handles", true) );
}
{
@@ -1388,7 +1393,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_helperpath), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.nodes", "show_helperpath", 0 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.nodes", "show_helperpath", false) );
}
{
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
GtkUIManager* mgr = gtk_ui_manager_new();
GError* errVal = 0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/ToolToolbar" );
- if ( prefs_get_int_attribute_limited( "toolbox", "icononly", 1, 0, 1 ) ) {
+ if ( prefs->getIntLimited("toolbox", "icononly", 1, 0, 1) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
Inkscape::IconSize toolboxSize = prefToSize("toolbox.tools", "small");
@@ -1646,6 +1652,7 @@ update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget
static void
setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkSizeGroup* grouper = gtk_size_group_new( GTK_SIZE_GROUP_BOTH );
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
GtkUIManager* mgr = gtk_ui_manager_new();
tmp = 0;
Inkscape::IconSize toolboxSize = prefToSize("toolbox", "small");
- if ( prefs_get_int_attribute_limited( "toolbox", "icononly", 1, 0, 1 ) ) {
+ /// @todo convert to getBool
+ if ( prefs->getIntLimited( "toolbox", "icononly", 1, 0, 1 ) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
" </toolbar>"
"</ui>";
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkUIManager* mgr = gtk_ui_manager_new();
GError* errVal = 0;
gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/CommandsToolbar" );
- if ( prefs_get_int_attribute_limited( "toolbox", "icononly", 1, 0, 1 ) ) {
+ if ( prefs->getBool("toolbox", "icononly", true) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
@@ -1861,7 +1869,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
// do not remember prefs if this call is initiated by an undo change, because undoing object
// creation sets bogus values to its attributes before it is deleted
- prefs_set_int_attribute("tools.shapes.star", "magnitude", (gint)adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("tools.shapes.star", "magnitude", (gint)adj->value);
}
// quit if run by the attr_changed listener
@@ -1898,7 +1907,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.shapes.star", "proportion", adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.shapes.star", "proportion", adj->value);
}
// quit if run by the attr_changed listener
@@ -1941,8 +1951,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
bool flat = ege_select_one_action_get_active( act ) == 0;
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_string_attribute( "tools.shapes.star", "isflatsided",
- flat ? "true" : "false" );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool( "tools.shapes.star", "isflatsided", flat);
}
// quit if run by the attr_changed listener
@@ -1984,7 +1994,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.shapes.star", "rounded", (gdouble) adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.shapes.star", "rounded", (gdouble) adj->value);
}
// quit if run by the attr_changed listener
@@ -2018,7 +2029,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.shapes.star", "randomized", (gdouble) adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.shapes.star", "randomized", (gdouble) adj->value);
}
// quit if run by the attr_changed listener
@@ -2064,8 +2076,8 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n
GtkAdjustment *adj = 0;
- gchar const *flatsidedstr = prefs_get_string_attribute( "tools.shapes.star", "isflatsided" );
- bool isFlatSided = flatsidedstr ? (strcmp(flatsidedstr, "false") != 0) : true;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool isFlatSided = prefs->getBool("tools.shapes.star", "isflatsided", true);
if (!strcmp(name, "inkscape:randomized")) {
adj = GTK_ADJUSTMENT( gtk_object_get_data(GTK_OBJECT(tbl), "randomized") );
@@ -2222,8 +2234,8 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
EgeAdjustmentAction* eact = 0;
- gchar const *flatsidedstr = prefs_get_string_attribute( "tools.shapes.star", "isflatsided" );
- bool isFlatSided = flatsidedstr ? (strcmp(flatsidedstr, "false") != 0) : true;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool isFlatSided = prefs->getBool("tools.shapes.star", "isflatsided", true);
/* Flatsided checkbox */
{
@@ -2379,7 +2391,8 @@ sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
SPUnit const *unit = tracker->getActiveUnit();
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.shapes.rect", value_name, sp_units_get_pixels(adj->value, *unit));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.shapes.rect", value_name, sp_units_get_pixels(adj->value, *unit));
}
// quit if run by the attr_changed listener
}
inkscape_active_document()->current_persp3d = persp3d_get_from_repr(persp_repr);
- prefs_set_string_attribute("tools.shapes.3dbox", "persp", persp_repr->attribute("id"));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("tools.shapes.3dbox", "persp", persp_repr->attribute("id"));
box3d_resync_toolbar(persp_repr, tbl);
}
@@ -2914,6 +2928,7 @@ static void box3d_vp_z_state_changed( GtkToggleAction *act, GtkAction *box3d_ang
static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
EgeAdjustmentAction* eact = 0;
SPDocument *document = sp_desktop_document (desktop);
Persp3D *persp = document->current_persp3d;
@@ -2958,8 +2973,8 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_x_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_x_state_changed), box3d_angle_x );
- gtk_action_set_sensitive( GTK_ACTION(box3d_angle_x), !prefs_get_int_attribute( "tools.shapes.3dbox", "vp_x_state", 1 ) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.shapes.3dbox", "vp_x_state", 1 ) );
+ gtk_action_set_sensitive( GTK_ACTION(box3d_angle_x), !prefs->getBool("tools.shapes.3dbox", "vp_x_state", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.shapes.3dbox", "vp_x_state", true) );
}
/* Angle Y */
@@ -2997,8 +3012,8 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_y_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_y_state_changed), box3d_angle_y );
- gtk_action_set_sensitive( GTK_ACTION(box3d_angle_y), !prefs_get_int_attribute( "tools.shapes.3dbox", "vp_y_state", 1 ) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.shapes.3dbox", "vp_y_state", 1 ) );
+ gtk_action_set_sensitive( GTK_ACTION(box3d_angle_y), !prefs->getBool("tools.shapes.3dbox", "vp_y_state", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.shapes.3dbox", "vp_y_state", true) );
}
/* Angle Z */
@@ -3036,8 +3051,8 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_z_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_z_state_changed), box3d_angle_z );
- gtk_action_set_sensitive( GTK_ACTION(box3d_angle_z), !prefs_get_int_attribute( "tools.shapes.3dbox", "vp_z_state", 1 ) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.shapes.3dbox", "vp_z_state", 1 ) );
+ gtk_action_set_sensitive( GTK_ACTION(box3d_angle_z), !prefs->getBool("tools.shapes.3dbox", "vp_z_state", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.shapes.3dbox", "vp_z_state", true) );
}
sigc::connection *connection = new sigc::connection(
@@ -3057,7 +3072,8 @@ sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_nam
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.shapes.spiral", value_name, adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.shapes.spiral", value_name, adj->value);
}
// quit if run by the attr_changed listener
{
gint mode = ege_select_one_action_get_active(act);
- prefs_set_int_attribute(freehand_tool_name(tbl), "freehand-mode", mode);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(freehand_tool_name(tbl), "freehand-mode", mode);
SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop");
@@ -3321,7 +3338,8 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
{
/* Freehand mode toggle buttons */
{
- guint freehandMode = prefs_get_int_attribute(tool_is_pencil ? "tools.freehand.pencil" : "tools.freehand.pen", "freehand-mode", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint freehandMode = prefs->getInt(( tool_is_pencil ? "tools.freehand.pencil" : "tools.freehand.pen" ), "freehand-mode", 0);
Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
{
@@ -3379,7 +3397,8 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge) {
gint shape = ege_select_one_action_get_active( act );
- prefs_set_int_attribute(freehand_tool_name(dataKludge), "shape", shape);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(freehand_tool_name(dataKludge), "shape", shape);
}
/**
freehand_add_advanced_shape_options(GtkActionGroup* mainActions, GObject* holder, bool tool_is_pencil) {
/*advanced shape options */
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
GList* items = 0;
@@ -3419,7 +3439,7 @@ freehand_add_advanced_shape_options(GtkActionGroup* mainActions, GObject* holder
_("Shape:"), ("Shape"), NULL, GTK_TREE_MODEL(model));
g_object_set( act1, "short_label", _("Shape:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
- ege_select_one_action_set_active( act1, prefs_get_int_attribute(tool_is_pencil ? "tools.freehand.pencil" : "tools.freehand.pen", "shape", 0) );
+ ege_select_one_action_set_active( act1, prefs->getInt(( tool_is_pencil ? "tools.freehand.pencil" : "tools.freehand.pen" ), "shape", 0) );
g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(freehand_change_shape), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act1) );
g_object_set_data( holder, "shape_action", act1 );
return;
}
// in turn, prevent listener from responding
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- prefs_set_double_attribute("tools.freehand.pencil",
- "tolerance", adj->value);
+ prefs->setDouble("tools.freehand.pencil", "tolerance", adj->value);
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
GtkAdjustment * adj = (GtkAdjustment*)g_object_get_data(tbl,
"tolerance");
-
- double v = prefs_get_double_attribute("tools.freehand.pencil",
- "tolerance", adj->value);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double v = prefs->getDouble("tools.freehand.pencil", "tolerance", adj->value);
gtk_adjustment_set_value(adj, v);
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -3559,23 +3579,27 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
static void sp_tweak_width_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
- prefs_set_double_attribute( "tools.tweak", "width", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.tweak", "width", adj->value * 0.01 );
}
static void sp_tweak_force_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
- prefs_set_double_attribute( "tools.tweak", "force", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.tweak", "force", adj->value * 0.01 );
}
static void sp_tweak_pressure_state_changed( GtkToggleAction *act, gpointer /*data*/ )
{
- prefs_set_int_attribute( "tools.tweak", "usepressure", gtk_toggle_action_get_active( act ) ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.tweak", "usepressure", gtk_toggle_action_get_active(act));
}
static void sp_tweak_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
int mode = ege_select_one_action_get_active( act );
- prefs_set_int_attribute("tools.tweak", "mode", mode);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("tools.tweak", "mode", mode);
GtkAction *doh = GTK_ACTION(g_object_get_data( tbl, "tweak_doh"));
GtkAction *dos = GTK_ACTION(g_object_get_data( tbl, "tweak_dos"));
static void sp_tweak_fidelity_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
- prefs_set_double_attribute( "tools.tweak", "fidelity", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.tweak", "fidelity", adj->value * 0.01 );
}
static void tweak_toggle_doh (GtkToggleAction *act, gpointer /*data*/) {
- bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.tweak", "doh", show ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.tweak", "doh", gtk_toggle_action_get_active(act));
}
static void tweak_toggle_dos (GtkToggleAction *act, gpointer /*data*/) {
- bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.tweak", "dos", show ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.tweak", "dos", gtk_toggle_action_get_active(act));
}
static void tweak_toggle_dol (GtkToggleAction *act, gpointer /*data*/) {
- bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.tweak", "dol", show ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.tweak", "dol", gtk_toggle_action_get_active(act));
}
static void tweak_toggle_doo (GtkToggleAction *act, gpointer /*data*/) {
- bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.tweak", "doo", show ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.tweak", "doo", gtk_toggle_action_get_active(act));
}
static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
/* Width */
@@ -3732,14 +3758,14 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
ege_select_one_action_set_icon_size( act, secondarySize );
ege_select_one_action_set_tooltip_column( act, 1 );
- gint mode = prefs_get_int_attribute("tools.tweak", "mode", 0);
+ gint mode = prefs->getInt("tools.tweak", "mode", 0);
ege_select_one_action_set_active( act, mode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_tweak_mode_changed), holder );
g_object_set_data( G_OBJECT(holder), "tweak_tool_mode", act);
}
- guint mode = prefs_get_int_attribute("tools.tweak", "mode", 0);
+ guint mode = prefs->getInt("tools.tweak", "mode", 0);
{
EgeOutputAction* act = ege_output_action_new( "TweakChannelsLabel", _("Channels:"), "", 0 );
@@ -3760,7 +3786,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("H"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doh), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.tweak", "doh", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "doh", 1 ) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_doh", act);
@@ -3775,7 +3801,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("S"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dos), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.tweak", "dos", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "dos", 1 ) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_dos", act );
@@ -3790,7 +3816,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("L"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dol), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.tweak", "dol", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "dol", 1 ) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_dol", act );
@@ -3805,7 +3831,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("O"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doo), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.tweak", "doo", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "doo", 1 ) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_doo", act );
@@ -3839,7 +3865,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_tweak_pressure_state_changed), NULL);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.tweak", "usepressure", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.tweak", "usepressure", true) );
}
}
@@ -3850,6 +3876,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
//########################
static void update_presets_list (GObject *tbl)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (g_object_get_data(tbl, "presets_blocked"))
return;
return;
}
- int total_prefs = pref_path_number_of_children("tools.calligraphic.preset");
+ int total_prefs = prefs->childCount("tools.calligraphic.preset");
- for (int i = 1; i <= total_prefs; i++) {
- gchar *preset_path = get_pref_nth_child("tools.calligraphic.preset", i);
- Inkscape::XML::Node *preset_repr = inkscape_get_repr(INKSCAPE, preset_path);
+ for (int i = 0; i < total_prefs; ++i) {
+ Glib::ustring preset_path = prefs->getNthChild("tools.calligraphic.preset", i);
+ /// @todo Remove the use of _getNode()
+ Inkscape::XML::Node *preset_repr = prefs->_getNode(preset_path);
bool match = true;
void *widget = g_object_get_data(tbl, attr_name);
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
- double v = prefs_get_double_attribute(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
+ double v = prefs->getDouble(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
//std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n";
if (fabs(gtk_adjustment_get_value(adj) - v) > 1e-6) {
break;
}
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
- int v = prefs_get_int_attribute(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
+ bool v = prefs->getBool(preset_path, attr_name);
GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
//std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n";
- if (gtk_toggle_action_get_active(toggle) != v) {
+ if ( static_cast<bool>(gtk_toggle_action_get_active(toggle)) != v ) {
match = false;
break;
}
static void sp_ddc_mass_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "mass", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "mass", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_wiggle_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "wiggle", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "wiggle", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_angle_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "angle", adj->value );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "angle", adj->value );
update_presets_list(tbl);
}
static void sp_ddc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "width", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "width", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_velthin_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute("tools.calligraphic", "thinning", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.calligraphic", "thinning", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_flatness_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "flatness", adj->value * 0.01);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "flatness", adj->value * 0.01);
update_presets_list(tbl);
}
static void sp_ddc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "tremor", adj->value * 0.01 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "tremor", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_cap_rounding_value_changed( GtkAdjustment *adj, GObject* tbl )
{
- prefs_set_double_attribute( "tools.calligraphic", "cap_rounding", adj->value );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "tools.calligraphic", "cap_rounding", adj->value );
update_presets_list(tbl);
}
static void sp_ddc_pressure_state_changed( GtkToggleAction *act, GObject* tbl )
{
- prefs_set_int_attribute( "tools.calligraphic", "usepressure", gtk_toggle_action_get_active( act ) ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.calligraphic", "usepressure", gtk_toggle_action_get_active( act ));
update_presets_list(tbl);
}
static void sp_ddc_trace_background_changed( GtkToggleAction *act, GObject* tbl )
{
- prefs_set_int_attribute( "tools.calligraphic", "tracebackground", gtk_toggle_action_get_active( act ) ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.calligraphic", "tracebackground", gtk_toggle_action_get_active( act ));
update_presets_list(tbl);
}
static void sp_ddc_tilt_state_changed( GtkToggleAction *act, GObject* tbl )
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkAction * calligraphy_angle = static_cast<GtkAction *> (g_object_get_data(tbl,"angle_action"));
- prefs_set_int_attribute( "tools.calligraphic", "usetilt", gtk_toggle_action_get_active( act ) ? 1 : 0 );
+ prefs->setBool("tools.calligraphic", "usetilt", gtk_toggle_action_get_active( act ));
update_presets_list(tbl);
if (calligraphy_angle )
gtk_action_set_sensitive( calligraphy_angle, !gtk_toggle_action_get_active( act ) );
gtk_list_store_set( model, &iter, 0, _("No preset"), 1, 0, -1 );
}
- //TODO: switch back to prefs API
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, "tools.calligraphic.preset" );
- Inkscape::XML::Node *child_repr = sp_repr_children(repr);
+ /// @todo Use public Preferences API instead of node manipulation
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Inkscape::XML::Node *repr = prefs->_getNode("tools.calligraphic.preset", true);
+ Inkscape::XML::Node *child_repr = repr->firstChild();
int ii=1;
while (child_repr) {
GtkTreeIter iter;
char *preset_name = (char *) child_repr->attribute("name");
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, preset_name, 1, ++ii, -1 );
- child_repr = sp_repr_next(child_repr);
+ gtk_list_store_set( model, &iter, 0, preset_name, 1, ii++, -1 );
+ child_repr = child_repr->next();
}
{
static void sp_dcc_save_profile (GtkWidget */*widget*/, GObject *tbl)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop" );
if (! desktop) return;
}
Glib::ustring profile_name = Inkscape::UI::Dialogs::CalligraphicProfileDialog::getProfileName();
- if (!profile_name.c_str() || *profile_name.c_str() == 0) {
+ if (profile_name.empty()) {
// empty name entered
update_presets_list (tbl);
return;
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE));
int new_index = -1;
- gchar *pref_path = NULL;
- int total_prefs = pref_path_number_of_children("tools.calligraphic.preset");
+ Glib::ustring pref_path;
+ int total_prefs = prefs->childCount("tools.calligraphic.preset");
- for (int i = 1; i <= total_prefs; i++) {
- gchar *path = get_pref_nth_child("tools.calligraphic.preset", i);
- const gchar *name = prefs_get_string_attribute(path, "name");
- if (name && !strcmp(name, profile_name.c_str())) {
+ for (int i = 0; i < total_prefs; ++i) {
+ Glib::ustring path = prefs->getNthChild("tools.calligraphic.preset", i);
+ Glib::ustring name = prefs->getString(path, "name");
+ if (!name.empty() && ( profile_name == name )) {
// we already have preset with this name, replace its values
new_index = i;
- pref_path = g_strdup(path);
+ pref_path = path;
break;
}
}
if (new_index == -1) {
// no preset with this name, create
+ /// @todo This is wrong, the name should be encoded in the key
+ /// to allow deletion of presets
new_index = total_prefs + 1;
- gchar *profile_id = g_strdup_printf("dcc%d", new_index);
- pref_path = create_pref("tools.calligraphic.preset", profile_id);
+ gchar *profile_id = g_strdup_printf(".dcc%d", new_index);
+ pref_path = Glib::ustring("tools.calligraphic.preset") + profile_id;
g_free(profile_id);
}
if (GTK_IS_ADJUSTMENT(widget)) {
GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
double v = gtk_adjustment_get_value(adj);
- prefs_set_double_attribute(pref_path, widget_name, v);
+ prefs->setDouble(pref_path, widget_name, v);
//std::cout << "wrote adj " << widget_name << ": " << v << "\n";
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
- int v = gtk_toggle_action_get_active(toggle);
- prefs_set_int_attribute(pref_path, widget_name, v);
+ bool v = gtk_toggle_action_get_active(toggle);
+ prefs->setBool(pref_path, widget_name, v);
//std::cout << "wrote tog " << widget_name << ": " << v << "\n";
} else {
g_warning("Unknown widget type for preset: %s\n", widget_name);
g_warning("Bad key when writing preset: %s\n", widget_name);
}
}
- prefs_set_string_attribute(pref_path, "name", profile_name.c_str());
+ prefs->setString(pref_path, "name", profile_name);
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
-
sp_dcc_build_presets_list (tbl);
-
- g_free(pref_path);
}
static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
gint preset_index = ege_select_one_action_get_active( act );
gint save_presets_index = GPOINTER_TO_INT(g_object_get_data(tbl, "save_presets_index"));
if (g_object_get_data(tbl, "presets_blocked"))
return;
- gchar *const preset_path = get_pref_nth_child("tools.calligraphic.preset", preset_index);
+ // preset_index is one-based so we subtract 1
+ Glib::ustring preset_path = prefs->getNthChild("tools.calligraphic.preset", preset_index - 1);
- if (preset_path) {
+ if (!preset_path.empty()) {
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it
- Inkscape::XML::Node *preset_repr = inkscape_get_repr(INKSCAPE, preset_path);
+ /// @todo Remove the use of _getNode() in this fragment, modify
+ /// the public interface of Preferences if necessary
+ Inkscape::XML::Node *preset_repr = prefs->_getNode(preset_path);
+ // Shouldn't this be std::map?
for ( Inkscape::Util::List<Inkscape::XML::AttributeRecord const> iter = preset_repr->attributeList();
iter;
++iter ) {
void *widget = g_object_get_data(tbl, attr_name);
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
- double v = prefs_get_double_attribute(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
+ double v = prefs->getDouble(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
gtk_adjustment_set_value(adj, v);
//std::cout << "set adj " << attr_name << " to " << v << "\n";
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
- int v = prefs_get_int_attribute(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
+ int v = prefs->getInt(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
gtk_toggle_action_set_active(toggle, v);
//std::cout << "set toggle " << attr_name << " to " << v << "\n";
g_warning("Bad key found in a preset record: %s\n", attr_name);
}
}
- g_free(preset_path);
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
}
static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
g_object_set_data(holder, "presets_blocked", GINT_TO_POINTER(TRUE));
@@ -4315,7 +4361,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_trace_background_changed), holder);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.calligraphic", "tracebackground", 0 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.calligraphic", "tracebackground", false) );
g_object_set_data( holder, "tracebackground", act );
}
@@ -4328,7 +4374,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_pressure_state_changed), holder);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.calligraphic", "usepressure", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.calligraphic", "usepressure", true) );
g_object_set_data( holder, "usepressure", act );
}
@@ -4341,8 +4387,8 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_tilt_state_changed), holder );
- gtk_action_set_sensitive( GTK_ACTION(calligraphy_angle), !prefs_get_int_attribute( "tools.calligraphic", "usetilt", 1 ) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.calligraphic", "usetilt", 1 ) );
+ gtk_action_set_sensitive( GTK_ACTION(calligraphy_angle), !prefs->getBool("tools.calligraphic", "usetilt", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.calligraphic", "usetilt", true) );
g_object_set_data( holder, "usetilt", act );
}
@@ -4390,7 +4436,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_double_attribute("tools.shapes.arc", value_name, (adj->value * M_PI)/ 180);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.shapes.arc", value_name, (adj->value * M_PI)/ 180);
}
// quit if run by the attr_changed listener
@@ -4458,11 +4505,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- if ( ege_select_one_action_get_active( act ) != 0 ) {
- prefs_set_string_attribute("tools.shapes.arc", "open", "true");
- } else {
- prefs_set_string_attribute("tools.shapes.arc", "open", NULL);
- }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.shapes.arc", "open", ege_select_one_action_get_active(act) != 0);
}
// quit if run by the attr_changed listener
@@ -4613,6 +4657,8 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb
static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
EgeAdjustmentAction* eact = 0;
Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
@@ -4680,8 +4726,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
ege_select_one_action_set_icon_size( act, secondarySize );
ege_select_one_action_set_tooltip_column( act, 1 );
- gchar const *openstr = prefs_get_string_attribute("tools.shapes.arc", "open");
- bool isClosed = (!openstr || (openstr && !strcmp(openstr, "false")));
+ bool isClosed = !prefs->getBool("tools.shapes.arc", "open", false);
ege_select_one_action_set_active( act, isClosed ? 0 : 1 );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_arctb_open_state_changed), holder );
}
@@ -4725,7 +4770,8 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
//########################
static void toggle_dropper_pick_alpha( GtkToggleAction* act, gpointer tbl ) {
- prefs_set_int_attribute( "tools.dropper", "pick", gtk_toggle_action_get_active( act ) );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt( "tools.dropper", "pick", gtk_toggle_action_get_active( act ) );
GtkAction* set_action = GTK_ACTION( g_object_get_data(G_OBJECT(tbl), "set_action") );
if ( set_action ) {
if ( gtk_toggle_action_get_active( act ) ) {
}
static void toggle_dropper_set_alpha( GtkToggleAction* act, gpointer tbl ) {
- prefs_set_int_attribute( "tools.dropper", "setalpha", gtk_toggle_action_get_active( act ) ? 1 : 0 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt( "tools.dropper", "setalpha", gtk_toggle_action_get_active( act ) ? 1 : 0 );
spinbutton_defocus(GTK_OBJECT(tbl));
}
*/
static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* mainActions, GObject* holder)
{
- gint pickAlpha = prefs_get_int_attribute( "tools.dropper", "pick", 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint pickAlpha = prefs->getInt( "tools.dropper", "pick", 1 );
{
EgeOutputAction* act = ege_output_action_new( "DropperOpacityAction", _("Opacity:"), "", 0 );
@@ -4783,7 +4831,7 @@ static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* main
g_object_set( act, "short_label", _("Assign"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "set_action", act );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.dropper", "setalpha", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.dropper", "setalpha", 1 ) );
// make sure it's disabled if we're not picking alpha
gtk_action_set_sensitive( GTK_ACTION(act), pickAlpha );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_dropper_set_alpha), holder );
}
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_int_attribute( "tools.lpetool", "mode", mode );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt( "tools.lpetool", "mode", mode );
}
g_object_set_data(tbl, "freeze", GINT_TO_POINTER(FALSE));
static void
lpetool_toggle_show_bbox (GtkToggleAction *act, gpointer data) {
SPDesktop *desktop = static_cast<SPDesktop *>(data);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.lpetool", "show_bbox", show ? 1 : 0);
+ prefs->setInt("tools.lpetool", "show_bbox", show ? 1 : 0);
if (tools_isactive(desktop, TOOLS_LPETOOL)) {
SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
GtkAction *unitact = static_cast<GtkAction*>(g_object_get_data(tbl, "lpetool_units_action"));
SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
if (tools_isactive(desktop, TOOLS_LPETOOL)) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute ("tools.lpetool", "show_measuring_info", show ? 1 : 0);
+ prefs->setInt("tools.lpetool", "show_measuring_info", show ? 1 : 0);
lpetool_show_measuring_info(lc, show);
gtk_action_set_sensitive(GTK_ACTION(unitact), show);
}
static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl) {
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
SPUnit const *unit = tracker->getActiveUnit();
- prefs_set_int_attribute("tools.lpetool", "unitid", unit->unit_id);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("tools.lpetool", "unitid", unit->unit_id);
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (SP_IS_LPETOOL_CONTEXT(desktop->event_context)) {
B *= desktop->doc2dt();
// TODO: should we provide a way to store points in prefs?
- prefs_set_double_attribute ("tools.lpetool", "bbox_upperleftx", A[Geom::X]);
- prefs_set_double_attribute ("tools.lpetool", "bbox_upperlefty", A[Geom::Y]);
- prefs_set_double_attribute ("tools.lpetool", "bbox_lowerrightx", B[Geom::X]);
- prefs_set_double_attribute ("tools.lpetool", "bbox_lowerrighty", B[Geom::Y]);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.lpetool", "bbox_upperleftx", A[Geom::X]);
+ prefs->setDouble("tools.lpetool", "bbox_upperlefty", A[Geom::Y]);
+ prefs->setDouble("tools.lpetool", "bbox_lowerrightx", B[Geom::X]);
+ prefs->setDouble("tools.lpetool", "bbox_lowerrighty", B[Geom::Y]);
lpetool_context_reset_limiting_bbox(SP_LPETOOL_CONTEXT(desktop->event_context));
}
@@ -5012,7 +5065,9 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
tracker->setActiveUnit(sp_desktop_namedview(desktop)->doc_units);
g_object_set_data(holder, "tracker", tracker);
SPUnit const *unit = tracker->getActiveUnit();
- prefs_set_int_attribute("tools.lpetool", "unitid", unit->unit_id);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("tools.lpetool", "unitid", unit->unit_id);
/** Automatically create a list of LPEs that get added to the toolbar **/
{
@@ -5050,7 +5105,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
ege_select_one_action_set_icon_column( act, 2 );
ege_select_one_action_set_tooltip_column( act, 1 );
- gint lpeToolMode = prefs_get_int_attribute("tools.lpetool", "mode", 0);
+ gint lpeToolMode = prefs->getInt("tools.lpetool", "mode", 0);
ege_select_one_action_set_active( act, lpeToolMode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_lpetool_mode_changed), holder );
}
@@ -5064,7 +5119,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_bbox), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.lpetool", "show_bbox", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.lpetool", "show_bbox", 1 ) );
}
/* Set limiting bounding box to bbox of current selection */
@@ -5105,7 +5160,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_measuring_info), holder );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.lpetool", "show_measuring_info", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.lpetool", "show_measuring_info", 1 ) );
}
// add the units menu
@@ -5114,7 +5169,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
gtk_action_group_add_action( mainActions, act );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), (GObject*)holder );
g_object_set_data(holder, "lpetool_units_action", act);
- gtk_action_set_sensitive(act, prefs_get_int_attribute ("tools.lpetool", "show_measuring_info", 1));
+ gtk_action_set_sensitive(act, prefs->getInt("tools.lpetool", "show_measuring_info", 1));
}
/* Open LPE dialog (to adapt parameters numerically) */
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
gint eraserMode = (ege_select_one_action_get_active( act ) != 0) ? 1 : 0;
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_int_attribute( "tools.eraser", "mode", eraserMode );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt( "tools.eraser", "mode", eraserMode );
}
// only take action if run by the attr_changed listener
@@ -5216,7 +5272,9 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
ege_select_one_action_set_icon_column( act, 2 );
ege_select_one_action_set_tooltip_column( act, 1 );
- gint eraserMode = (prefs_get_int_attribute("tools.eraser", "mode", 0) != 0) ? 1 : 0;
+ /// @todo Convert to boolean?
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint eraserMode = (prefs->getInt("tools.eraser", "mode", 0) != 0) ? 1 : 0;
ege_select_one_action_set_active( act, eraserMode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder );
}
static void sp_connector_graph_layout(void)
{
if (!SP_ACTIVE_DESKTOP) return;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// hack for clones, see comment in align-and-distribute.cpp
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ int saved_compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList());
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("options.clonecompensation", "value", saved_compensation);
sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
}
static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GtkObject */*tbl*/ )
{
- if ( gtk_toggle_action_get_active( act ) ) {
- prefs_set_string_attribute("tools.connector", "directedlayout",
- "true");
- } else {
- prefs_set_string_attribute("tools.connector", "directedlayout",
- "false");
- }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.connector", "directedlayout",
+ gtk_toggle_action_get_active( act ));
}
static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GtkObject */*tbl*/ )
{
- if ( gtk_toggle_action_get_active( act ) ) {
- prefs_set_string_attribute("tools.connector", "avoidoverlaplayout",
- "true");
- } else {
- prefs_set_string_attribute("tools.connector", "avoidoverlaplayout",
- "false");
- }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("tools.connector", "avoidoverlaplayout",
+ gtk_toggle_action_get_active( act ));
}
static void connector_length_changed(GtkAdjustment *adj, GObject* tbl)
{
- prefs_set_double_attribute("tools.connector", "length", adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("tools.connector", "length", adj->value);
spinbutton_defocus(GTK_OBJECT(tbl));
}
static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder )
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
{
@@ -6474,9 +6527,8 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- gchar const* tbuttonstate = prefs_get_string_attribute( "tools.connector", "directedlayout" );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act),
- (tbuttonstate && !strcmp(tbuttonstate, "true")) ? TRUE:FALSE );
+ bool tbuttonstate = prefs->getBool("tools.connector", "directedlayout");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_directed_graph_layout_toggled), holder );
}
@@ -6490,9 +6542,8 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- gchar const* tbuttonstate = prefs_get_string_attribute( "tools.connector", "avoidoverlaplayout" );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act),
- (tbuttonstate && !strcmp(tbuttonstate, "true")) ? TRUE:FALSE );
+ bool tbuttonstate = prefs->getBool("tools.connector", "avoidoverlaplayout");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), (tbuttonstate ? TRUE : FALSE ));
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_nooverlaps_graph_layout_toggled), holder );
}
@@ -6525,22 +6576,24 @@ static void paintbucket_channels_changed(EgeSelectOneAction* act, GObject* /*tbl
static void paintbucket_threshold_changed(GtkAdjustment *adj, GObject */*tbl*/)
{
- prefs_set_int_attribute("tools.paintbucket", "threshold", (gint)adj->value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("tools.paintbucket", "threshold", (gint)adj->value);
}
static void paintbucket_autogap_changed(EgeSelectOneAction* act, GObject */*tbl*/)
{
- prefs_set_int_attribute("tools.paintbucket", "autogap", ege_select_one_action_get_active( act ));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("tools.paintbucket", "autogap", ege_select_one_action_get_active( act ));
}
static void paintbucket_offset_changed(GtkAdjustment *adj, GObject *tbl)
{
UnitTracker* tracker = static_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs_set_double_attribute("tools.paintbucket", "offset", (gdouble)sp_units_get_pixels(adj->value, *unit));
-
- prefs_set_string_attribute("tools.paintbucket", "offsetunits", sp_unit_get_abbreviation(unit));
+ prefs->setDouble("tools.paintbucket", "offset", (gdouble)sp_units_get_pixels(adj->value, *unit));
+ prefs->setString("tools.paintbucket", "offsetunits", sp_unit_get_abbreviation(unit));
}
static void paintbucket_defaults (GtkWidget *, GObject *tbl)
static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
@@ -6589,7 +6643,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeSelectOneAction* act1 = ege_select_one_action_new( "ChannelsAction", _("Fill by"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act1, "short_label", _("Fill by:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
- ege_select_one_action_set_active( act1, prefs_get_int_attribute("tools.paintbucket", "channels", 0) );
+ ege_select_one_action_set_active( act1, prefs->getInt("tools.paintbucket", "channels", 0) );
g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(paintbucket_channels_changed), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act1) );
g_object_set_data( holder, "channels_action", act1 );
@@ -6612,9 +6666,9 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
// Create the units menu.
UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- const gchar *stored_unit = prefs_get_string_attribute("tools.paintbucket", "offsetunits");
- if (stored_unit)
- tracker->setActiveUnit(sp_unit_get_by_abbreviation(stored_unit));
+ Glib::ustring stored_unit = prefs->getString("tools.paintbucket", "offsetunits");
+ if (!stored_unit.empty())
+ tracker->setActiveUnit(sp_unit_get_by_abbreviation(stored_unit.data()));
g_object_set_data( holder, "tracker", tracker );
{
GtkAction* act = tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") );
@@ -6654,7 +6708,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeSelectOneAction* act2 = ege_select_one_action_new( "AutoGapAction", _("Close gaps"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act2, "short_label", _("Close gaps:"), NULL );
ege_select_one_action_set_appearance( act2, "compact" );
- ege_select_one_action_set_active( act2, prefs_get_int_attribute("tools.paintbucket", "autogap", 0) );
+ ege_select_one_action_set_active( act2, prefs->getInt("tools.paintbucket", "autogap", 0) );
g_signal_connect( G_OBJECT(act2), "changed", G_CALLBACK(paintbucket_autogap_changed), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act2) );
g_object_set_data( holder, "autogap_action", act2 );