X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=inline;f=src%2Fprefs-utils.cpp;h=14a37ee4b90d2d7d4f6a6a2983a1f478401ae7c3;hb=b03899b976eaea0d850429cae78aca08f64245c6;hp=54c83c1e9580805d1c37ab2d0f20d9bea031273f;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp index 54c83c1e9..14a37ee4b 100644 --- a/src/prefs-utils.cpp +++ b/src/prefs-utils.cpp @@ -19,7 +19,7 @@ void -prefs_set_int_attribute(gchar const *path, gchar const *attr, gint value) +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) { @@ -27,8 +27,8 @@ prefs_set_int_attribute(gchar const *path, gchar const *attr, gint value) } } -gint -prefs_get_int_attribute(gchar const *path, gchar const *attr, gint def) +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) { @@ -41,12 +41,12 @@ prefs_get_int_attribute(gchar const *path, gchar const *attr, gint def) /** \brief Retrieves an int attribute guarding against screwed-up data; if the value is beyond limits, default is returned */ -gint -prefs_get_int_attribute_limited(gchar const *path, gchar const *attr, gint def, gint min, gint max) +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) { - gint const v = sp_repr_get_int_attribute(repr, attr, def); + long long int const v = sp_repr_get_int_attribute(repr, attr, def); if (v >= min && v <= max) { return v; } else { @@ -123,26 +123,32 @@ prefs_set_recent_file(gchar const *uri, gchar const *name) if (uri != NULL) { Inkscape::XML::Node *recent = inkscape_get_repr(INKSCAPE, "documents.recent"); if (recent) { - Inkscape::XML::Node *child = sp_repr_lookup_child(recent, "uri", uri); - if (child) { - recent->changeOrder(child, NULL); - } else { - if (recent->childCount() >= max_documents) { - child = recent->firstChild(); - // count to the last - for (unsigned i = 0; i + 2 < max_documents; ++i) { - child = child->next(); - } - // remove all after the last - while (child->next()) { - sp_repr_unparent(child->next()); - } + // remove excess recent files + if (recent->childCount() >= max_documents) { + Inkscape::XML::Node *child = recent->firstChild(); + // count to the last + for (unsigned i = 0; child && i + 1 < max_documents; ++i) { + child = child->next(); } - child = sp_repr_new("document"); - child->setAttribute("uri", uri); - recent->addChild(child, NULL); + // remove all after the last + while (child) { + Inkscape::XML::Node *next = child->next(); + sp_repr_unparent(child); + child = next; + } + } + + if (max_documents > 0) { + Inkscape::XML::Node *child = sp_repr_lookup_child(recent, "uri", uri); + if (child) { + recent->changeOrder(child, NULL); + } else { + child = recent->document()->createElement("document"); + child->setAttribute("uri", uri); + recent->addChild(child, NULL); + } + child->setAttribute("name", name); } - child->setAttribute("name", name); } } }