From 12a4fe18405a9132efc3ef19570bf0c59dd6b427 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sun, 18 Jun 2017 11:03:09 +0100 Subject: [PATCH] Eliminate FIXME: Log window line limit Set log window line limit in Preferences/Behavior --- doc/docbook/GuideOptionsBehavior.xml | 8 ++++++++ src/logwindow.c | 7 +++---- src/options.c | 2 ++ src/options.h | 2 ++ src/preferences.c | 3 +++ src/rcfile.c | 4 ++++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/docbook/GuideOptionsBehavior.xml b/doc/docbook/GuideOptionsBehavior.xml index f81c2d22..ec414d9f 100644 --- a/doc/docbook/GuideOptionsBehavior.xml +++ b/doc/docbook/GuideOptionsBehavior.xml @@ -196,6 +196,14 @@ Displayed when compiled with the option --enable-debug-log. This defines the verbosity of debug info sent to console and log window (0 disables the debug output). + + + Log Window max. lines + + + The maximum number of data lines to be displayed. The window will show the most recent data. + + diff --git a/src/logwindow.c b/src/logwindow.c index e70e9e48..8a678d91 100644 --- a/src/logwindow.c +++ b/src/logwindow.c @@ -220,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) @@ -233,7 +232,7 @@ 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; @@ -248,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); } diff --git a/src/options.c b/src/options.c index 9a1ff342..817969df 100644 --- a/src/options.c +++ b/src/options.c @@ -170,6 +170,8 @@ ConfOptions *init_options(ConfOptions *options) options->stereo.fixed_x2 = 0; options->stereo.fixed_y2 = 1125; + options->log_window_lines = 1000; + return options; } diff --git a/src/options.h b/src/options.h index 11acdcbb..a45c0593 100644 --- a/src/options.h +++ b/src/options.h @@ -54,6 +54,8 @@ struct _ConfOptions gboolean use_saved_window_positions_for_new_windows; gboolean tools_restore_state; + guint log_window_lines; + /* info sidebar component heights */ struct { gint height; diff --git a/src/preferences.c b/src/preferences.c index aebc7689..1e7ad4c0 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -2196,6 +2196,9 @@ static void config_tab_behavior(GtkWidget *notebook) pref_spin_new_int(group, _("Debug level:"), NULL, DEBUG_LEVEL_MIN, DEBUG_LEVEL_MAX, 1, get_debug_level(), &debug_c); + + pref_spin_new_int(group, _("Log Window max. lines:"), NULL, + 1, 99999, 1, options->log_window_lines, &options->log_window_lines); #endif } diff --git a/src/rcfile.c b/src/rcfile.c index ec853789..81178587 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -335,6 +335,8 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_BOOL(*options, use_saved_window_positions_for_new_windows); WRITE_NL(); WRITE_BOOL(*options, tools_restore_state); + WRITE_NL(); WRITE_UINT(*options, log_window_lines); + /* File operations Options */ WRITE_NL(); WRITE_BOOL(*options, file_ops.enable_in_place_rename); WRITE_NL(); WRITE_BOOL(*options, file_ops.confirm_delete); @@ -629,6 +631,8 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_BOOL(*options, use_saved_window_positions_for_new_windows)) continue; if (READ_BOOL(*options, tools_restore_state)) continue; + if (READ_UINT(*options, log_window_lines)) continue; + /* Properties dialog options */ if (READ_CHAR(*options, properties.tabs_order)) continue; -- 2.20.1