Eliminate FIXME: Log window line limit
[geeqie.git] / src / logwindow.c
index cf6230f..8a678d9 100644 (file)
@@ -1,13 +1,21 @@
 /*
- * Geeqie
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
- * Author: Vladimir Nadvornik, Laurent Monin
- * based on logwindow.[ch] from Sylpheed 2.4.7 (C) Hiroyuki Yamamoto
+ * Authors: Vladimir Nadvornik, Laurent Monin
  *
- * 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 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 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"
@@ -26,7 +34,7 @@ struct _LogWindow
        GtkWidget *window;
        GtkWidget *scrolledwin;
        GtkWidget *text;
-       
+
        GdkColor colors[LOG_COUNT];
 
        guint lines;
@@ -160,7 +168,7 @@ static void log_window_show(LogWindow *logwin)
        GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
        GtkTextBuffer *buffer;
        GtkTextMark *mark;
-       
+
        g_assert(logwin != NULL);
 
        buffer = gtk_text_view_get_buffer(text);
@@ -212,7 +220,6 @@ void log_window_append(const gchar *str, LogType type)
        GtkTextView *text;
        GtkTextBuffer *buffer;
        GtkTextIter iter;
-       guint line_limit = 1000; //FIXME: option
        static GList *memory = NULL;
 
        if (logwindow == NULL)
@@ -225,11 +232,11 @@ void log_window_append(const gchar *str, LogType type)
 
                        memory = g_list_prepend(memory, msg);
 
-                       while (g_list_length(memory) >= line_limit)
+                       while (g_list_length(memory) >= options->log_window_lines)
                                {
                                GList *work = g_list_last(memory);
                                LogMsg *oldest_msg = work->data;
-                       
+
                                g_free(oldest_msg->text);
                                memory = g_list_delete_link(memory, work);
                                }
@@ -240,13 +247,13 @@ void log_window_append(const gchar *str, LogType type)
        text = GTK_TEXT_VIEW(logwindow->text);
        buffer = gtk_text_view_get_buffer(text);
 
-       if (line_limit > 0 && logwindow->lines >= line_limit)
+       if (options->log_window_lines > 0 && logwindow->lines >= options->log_window_lines)
                {
                GtkTextIter start, end;
 
                gtk_text_buffer_get_start_iter(buffer, &start);
                end = start;
-               gtk_text_iter_forward_lines(&end, logwindow->lines - line_limit);
+               gtk_text_iter_forward_lines(&end, logwindow->lines - options->log_window_lines);
                gtk_text_buffer_delete(buffer, &start, &end);
                }
 
@@ -259,9 +266,9 @@ void log_window_append(const gchar *str, LogType type)
                {
                GList *prev;
                LogMsg *oldest_msg = work->data;
-               
+
                log_window_insert_text(buffer, &iter, oldest_msg->text, logdefs[oldest_msg->type].tag);
-               
+
                prev = work->prev;
                memory = g_list_delete_link(memory, work);
                work = prev;
@@ -273,7 +280,7 @@ void log_window_append(const gchar *str, LogType type)
        if (gtk_widget_get_visible(GTK_WIDGET(text)))
                {
                GtkTextMark *mark;
-               
+
                mark = gtk_text_buffer_get_mark(buffer, "end");
                gtk_text_view_scroll_mark_onscreen(text, mark);
                }