From bc02fd0eb0d94c078621c59ae23ce8b70da0efd6 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Mon, 11 Sep 2017 18:19:46 +0100 Subject: [PATCH] Optional timer data in log window --- src/debug.c | 11 ++++++++++- src/logwindow.c | 11 +++++++++++ src/options.c | 1 + src/options.h | 1 + src/preferences.c | 3 +++ src/rcfile.c | 2 ++ src/typedefs.h | 1 - 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/debug.c b/src/debug.c index 851bb79c..3f965b4e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -97,7 +97,16 @@ void log_domain_print_debug(const gchar *domain, const gchar *file_name, const g message = g_strdup_vprintf(format, ap); va_end(ap); - location = g_strdup_printf("%s:%s:%d:", file_name, function_name, line_number); + if (options && options->log_window.timer_data) + { + location = g_strdup_printf("%s:%s:%s:%d:", get_exec_time(), file_name, + function_name, line_number); + } + else + { + location = g_strdup_printf("%s:%s:%d:", file_name, function_name, line_number); + } + buf = g_strconcat(location, message, NULL); log_domain_print_message(domain,buf); g_free(location); diff --git a/src/logwindow.c b/src/logwindow.c index 3d21cc10..21b72232 100644 --- a/src/logwindow.c +++ b/src/logwindow.c @@ -44,6 +44,7 @@ struct _LogWindow GtkWidget *bar; GtkWidget *pause; GtkWidget *wrap; + GtkWidget *timer_data; GtkWidget *debug_level; }; @@ -99,6 +100,13 @@ static void log_window_line_wrap_cb(GtkWidget *widget, gpointer data) } } +static void log_window_timer_data_cb(GtkWidget *widget, gpointer data) +{ + LogWindow *logwin = data; + + options->log_window.timer_data = !options->log_window.timer_data; +} + static void log_window_regexp_cb(GtkWidget *text_entry, gpointer data) { gchar *new_regexp; @@ -167,6 +175,9 @@ static LogWindow *log_window_create(LayoutWindow *lw) logwin->wrap = pref_button_new(hbox, NULL, "Line wrap", FALSE, G_CALLBACK(log_window_line_wrap_cb), logwin); + logwin->timer_data = pref_button_new(hbox, NULL, "Timer data", FALSE, + G_CALLBACK(log_window_timer_data_cb), logwin); + pref_label_new(hbox, "Filter regexp"); textbox = gtk_entry_new(); diff --git a/src/options.c b/src/options.c index a79dc28f..a9d6b033 100644 --- a/src/options.c +++ b/src/options.c @@ -173,6 +173,7 @@ ConfOptions *init_options(ConfOptions *options) options->log_window_lines = 1000; options->log_window.line_wrap = TRUE; options->log_window.paused = FALSE; + options->log_window.timer_data = FALSE; return options; } diff --git a/src/options.h b/src/options.h index ac996dda..26bc0038 100644 --- a/src/options.h +++ b/src/options.h @@ -272,6 +272,7 @@ struct _ConfOptions struct { gboolean paused; gboolean line_wrap; + gboolean timer_data; } log_window; }; diff --git a/src/preferences.c b/src/preferences.c index 6c29cdea..e01a61d9 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -2243,6 +2243,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_checkbox_new_int(group, _("Timer data"), + options->log_window.timer_data, &c_options->log_window.timer_data); + 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 9ed1342b..460a46cb 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -336,6 +336,7 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_BOOL(*options, tools_restore_state); WRITE_NL(); WRITE_UINT(*options, log_window_lines); + WRITE_NL(); WRITE_BOOL(*options, log_window.timer_data); /* File operations Options */ WRITE_NL(); WRITE_BOOL(*options, file_ops.enable_in_place_rename); @@ -632,6 +633,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_BOOL(*options, tools_restore_state)) continue; if (READ_INT(*options, log_window_lines)) continue; + if (READ_BOOL(*options, log_window.timer_data)) continue; /* Properties dialog options */ if (READ_CHAR(*options, properties.tabs_order)) continue; diff --git a/src/typedefs.h b/src/typedefs.h index 7f05639e..2aef5582 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -638,7 +638,6 @@ struct _LayoutOptions gint h; gint x; gint y; - gboolean paused; } log_window; gboolean tools_float; -- 2.20.1