Pull the search UI construction code out into a distinct function.
[geeqie.git] / src / history_list.c
index b764053..505c499 100644 (file)
@@ -1,13 +1,21 @@
 /*
- * Geeqie
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Authors: John Ellis, Vladimir Nadvornik, Laurent Monin
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include "main.h"
@@ -62,7 +70,7 @@ static gchar *quoted_from_text(const gchar *text)
        return NULL;
 }
 
-gint history_list_load(const gchar *path)
+gboolean history_list_load(const gchar *path)
 {
        FILE *f;
        gchar *key = NULL;
@@ -117,11 +125,12 @@ gint history_list_load(const gchar *path)
        return TRUE;
 }
 
-gint history_list_save(const gchar *path)
+gboolean history_list_save(const gchar *path)
 {
        SecureSaveInfo *ssi;
        GList *list;
        gchar *pathl;
+       gint list_count;
 
        pathl = path_from_utf8(path);
        ssi = secure_open(pathl);
@@ -149,10 +158,15 @@ gint history_list_save(const gchar *path)
                 * so that when reading they are added correctly
                 */
                work = g_list_last(hd->list);
+               list_count = g_list_position(hd->list, g_list_last(hd->list)) + 1;
                while (work && secsave_errno == SS_ERR_NONE)
                        {
-                       secure_fprintf(ssi, "\"%s\"\n", (gchar *)work->data);
+                       if (!(strcmp(hd->key, "path_list") == 0 && list_count > options->open_recent_list_maxsize))
+                               {
+                               secure_fprintf(ssi, "\"%s\"\n", (gchar *)work->data);
+                               }
                        work = work->prev;
+                       list_count--;
                        }
                secure_fputc(ssi, '\n');
                }
@@ -349,3 +363,4 @@ GList *history_list_get_by_key(const gchar *key)
 
        return hd->list;
 }
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */