summaryrefslogtreecommitdiffstats
path: root/src/selection-chemistry.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2008-09-16 17:15:22 +0000
committertweenk <tweenk@users.sourceforge.net>2008-09-16 17:15:22 +0000
commit9d87d30b72145fdee954992a9dc70f8c60174d7d (patch)
tree194a94ece6ed668ad7dc529de2cdd09b7565c6fe /src/selection-chemistry.cpp
parentfix leak of the arena and arenaitem (diff)
downloadinkscape-9d87d30b72145fdee954992a9dc70f8c60174d7d.tar.gz
inkscape-9d87d30b72145fdee954992a9dc70f8c60174d7d.zip
Refactored preferences handling into a new version of
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. (bzr r6823)
Diffstat (limited to 'src/selection-chemistry.cpp')
-rw-r--r--src/selection-chemistry.cpp92
1 files changed, 52 insertions, 40 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 3e0da0571..3bc9d6623 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -64,7 +64,7 @@
#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"
@@ -263,7 +263,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
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);
@@ -1621,9 +1624,10 @@ sp_selection_item_next(SPDesktop *desktop)
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) {
@@ -1650,9 +1654,10 @@ sp_selection_item_prev(SPDesktop *desktop)
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) {
@@ -1718,9 +1723,10 @@ void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip)
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);
}
@@ -2052,8 +2058,8 @@ sp_select_clone_original(SPDesktop *desktop)
}
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));
@@ -2141,8 +2147,9 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
// 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],
@@ -2152,7 +2159,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
(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);
@@ -2189,9 +2196,10 @@ void sp_selection_to_guides(SPDesktop *desktop)
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);
@@ -2262,8 +2270,9 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
// 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],
@@ -2272,7 +2281,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
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");
@@ -2502,9 +2511,10 @@ sp_selection_create_bitmap_copy (SPDesktop *desktop)
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;
@@ -2536,25 +2546,25 @@ sp_selection_create_bitmap_copy (SPDesktop *desktop)
// 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
@@ -2784,7 +2795,8 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
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";