summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-07-02 23:26:45 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-07-02 23:26:45 +0000
commitea0c96b081cb912ca08e1a4cdd9d9066a12ea9f8 (patch)
treeb13d684d902aa1824da5083caec7a8cca6202bd7 /src
parentUse Unicode character for ... (diff)
downloadinkscape-ea0c96b081cb912ca08e1a4cdd9d9066a12ea9f8.tar.gz
inkscape-ea0c96b081cb912ca08e1a4cdd9d9066a12ea9f8.zip
patch for bug 1515934
(bzr r1347)
Diffstat (limited to 'src')
-rw-r--r--src/prefs-utils.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp
index 54c83c1e9..a0851a354 100644
--- a/src/prefs-utils.cpp
+++ b/src/prefs-utils.cpp
@@ -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 = sp_repr_new("document");
+ child->setAttribute("uri", uri);
+ recent->addChild(child, NULL);
+ }
+ child->setAttribute("name", name);
}
- child->setAttribute("name", name);
}
}
}