2 * Copyright (C) 2008 - 2016 The Geeqie Team
4 * Authors: Vladimir Nadvornik, Laurent Monin
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "logwindow.h"
31 GtkWidget *scrolledwin;
33 GtkTextTag *color_tags[LOG_COUNT];
35 GtkWidget *regexp_box;
39 GtkWidget *timer_data;
40 GtkWidget *debug_level;
41 gint debug_value; /**< Not used */
42 GtkWidget *search_entry_box;
43 gboolean highlight_all;
46 enum LogWindowSearchDirection {
47 LOGWINDOW_SEARCH_BACKWARDS,
48 LOGWINDOW_SEARCH_FORWARDS
51 static LogWindow *logwindow = nullptr;
53 static void hide_cb(GtkWidget *, LogWindow *)
57 static gboolean iter_char_search_cb(gunichar ch, gpointer data)
61 if (ch == GPOINTER_TO_UINT(data))
74 * @brief Handle escape and F1 keys
80 * If escape key pressed, hide log window. \n
81 * If no text selected, form a selection bounded by space characters or
82 * start and end of line. \n
83 * If F1 pressed, execute command line program: \n
84 * <options->log_window.action> <selected text>
87 static gboolean key_pressed(GtkWidget *, GdkEventKey *event, LogWindow *logwin)
89 GtkTextBuffer *buffer;
91 GtkTextIter chr_start;
92 GtkTextIter cursor_iter;
94 GtkTextIter line_start;
95 GtkTextMark *cursor_mark;
99 if (event && event->keyval == GDK_KEY_Escape)
100 gtk_widget_hide(logwin->window);
102 if (event && event->keyval == GDK_KEY_F1)
104 if (strlen(options->log_window.action) > 0)
106 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
108 if (!gtk_text_buffer_get_has_selection(buffer))
110 cursor_mark = gtk_text_buffer_get_insert(buffer);
111 gtk_text_buffer_get_iter_at_mark(buffer, &cursor_iter, cursor_mark);
113 line_start = cursor_iter;
114 gtk_text_iter_set_line_offset(&line_start, 0);
115 line_end = cursor_iter;
116 gtk_text_iter_forward_to_line_end(&line_end);
118 chr_start = cursor_iter;
119 gtk_text_iter_backward_find_char(&chr_start, static_cast<GtkTextCharPredicate>(iter_char_search_cb), GUINT_TO_POINTER(' '), &line_start);
121 chr_end = cursor_iter;
122 gtk_text_iter_forward_find_char(&chr_end, static_cast<GtkTextCharPredicate>(iter_char_search_cb), GUINT_TO_POINTER(' '), &line_end);
124 gtk_text_buffer_select_range(buffer, &chr_start, &chr_end);
127 if (gtk_text_buffer_get_selection_bounds(gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)), &chr_start, &chr_end))
129 sel_text = gtk_text_buffer_get_text( gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)), &chr_start, &chr_end, FALSE);
131 cmd_line = g_strconcat(options->log_window.action, " ", sel_text, NULL);
145 static void log_window_pause_cb(GtkWidget *, gpointer)
147 options->log_window.paused = !options->log_window.paused;
150 static void log_window_line_wrap_cb(GtkWidget *, gpointer data)
152 auto logwin = static_cast<LogWindow *>(data);
154 options->log_window.line_wrap = !options->log_window.line_wrap;
156 if (options->log_window.line_wrap)
158 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(logwin->text), GTK_WRAP_WORD);
162 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(logwin->text), GTK_WRAP_NONE);
166 static void log_window_timer_data_cb(GtkWidget *, gpointer)
168 options->log_window.timer_data = !options->log_window.timer_data;
171 static void log_window_regexp_cb(GtkWidget *text_entry, gpointer)
175 new_regexp = g_strdup(gtk_entry_get_text(GTK_ENTRY(text_entry)));
176 set_regexp(new_regexp);
180 static void remove_green_bg(LogWindow *logwin)
182 GtkTextIter start_find;
183 GtkTextIter start_match;
184 GtkTextIter end_match;
185 GtkTextBuffer *buffer;
191 text = gtk_entry_get_text(GTK_ENTRY(logwin->search_entry_box));
192 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
193 gtk_text_buffer_get_start_iter(buffer, &start_find);
195 while (gtk_text_iter_forward_search(&start_find, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
197 list = gtk_text_iter_get_tags(&start_match);
200 g_object_get(list->data, "name", &tag_name, NULL);
201 if (g_strcmp0(tag_name, "green_bg") == 0)
203 gtk_text_buffer_remove_tag_by_name(buffer, "green_bg", &start_match, &end_match);
209 offset = gtk_text_iter_get_offset(&end_match);
210 gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
214 static void search_activate_event(GtkEntry *, LogWindow *logwin)
216 GtkTextIter start_find;
217 GtkTextIter start_match;
218 GtkTextIter end_match;
219 GtkTextBuffer *buffer;
220 GtkTextMark *cursor_mark;
221 GtkTextIter cursor_iter;
225 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
226 text = gtk_entry_get_text(GTK_ENTRY(logwin->search_entry_box));
228 if (logwin->highlight_all)
230 gtk_text_buffer_get_start_iter(buffer, &start_find);
232 while (gtk_text_iter_forward_search(&start_find, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
234 gtk_text_buffer_apply_tag_by_name(buffer, "gray_bg", &start_match, &end_match);
235 offset = gtk_text_iter_get_offset(&end_match);
236 gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
241 cursor_mark = gtk_text_buffer_get_insert(buffer);
242 gtk_text_buffer_get_iter_at_mark(buffer, &cursor_iter, cursor_mark);
244 if (gtk_text_iter_forward_search(&cursor_iter, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
246 gtk_text_buffer_apply_tag_by_name(buffer, "gray_bg", &start_match, &end_match);
251 static gboolean search_keypress_event(GtkWidget *, GdkEventKey *, LogWindow *logwin, LogWindowSearchDirection direction)
253 GtkTextIter start_find;
254 GtkTextIter start_match;
255 GtkTextIter end_match;
256 GtkTextIter start_sel;
259 GtkTextBuffer *buffer;
260 GtkTextMark *cursor_mark;
261 GtkTextIter cursor_iter;
263 gboolean match_found = FALSE;
266 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
267 gtk_text_buffer_get_start_iter(buffer, &start_find);
269 text = gtk_entry_get_text(GTK_ENTRY(logwin->search_entry_box));
270 if (strlen(text) == 0)
272 selected = gtk_text_buffer_get_selection_bounds(buffer, &start_sel, &end_sel);
275 text = gtk_text_buffer_get_text(buffer, &start_sel, &end_sel, FALSE);
276 gtk_entry_set_text(GTK_ENTRY(logwin->search_entry_box), text);
280 if (logwin->highlight_all)
282 while (gtk_text_iter_forward_search(&start_find, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
284 gtk_text_buffer_apply_tag_by_name(buffer, "gray_bg", &start_match, &end_match);
285 offset = gtk_text_iter_get_offset(&end_match);
286 gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
290 cursor_mark = gtk_text_buffer_get_insert(buffer);
291 gtk_text_buffer_get_iter_at_mark(buffer, &cursor_iter, cursor_mark);
293 if (direction == LOGWINDOW_SEARCH_BACKWARDS)
295 match_found = gtk_text_iter_backward_search( &cursor_iter, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr);
299 match_found = gtk_text_iter_forward_search( &cursor_iter, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr);
304 remove_green_bg(logwin);
306 gtk_text_buffer_apply_tag_by_name(buffer, "green_bg", &start_match, &end_match);
308 if (direction == LOGWINDOW_SEARCH_BACKWARDS)
310 gtk_text_buffer_place_cursor(buffer, &start_match);
314 gtk_text_buffer_place_cursor(buffer, &end_match);
317 cursor_mark = gtk_text_buffer_get_insert(buffer);
318 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(logwin->text), cursor_mark, 0.2, FALSE, 0.0, 0.0);
324 static gboolean backwards_keypress_event_cb(GtkWidget *widget, GdkEventKey *event, LogWindow *logwin)
326 search_keypress_event(widget, event, logwin, LOGWINDOW_SEARCH_BACKWARDS);
331 static gboolean forwards_keypress_event_cb(GtkWidget *widget, GdkEventKey *event, LogWindow *logwin)
333 search_keypress_event(widget, event, logwin, LOGWINDOW_SEARCH_FORWARDS);
338 static gboolean all_keypress_event_cb(GtkToggleButton *widget, LogWindow *logwin)
340 logwin->highlight_all = gtk_toggle_button_get_active(widget);
345 static gboolean debug_changed_cb(GtkSpinButton *widget, LogWindow *)
347 set_debug_level((gtk_spin_button_get_value(widget)));
352 static void search_entry_icon_cb(GtkEntry *, GtkEntryIconPosition pos, GdkEvent *, gpointer userdata)
354 auto logwin = static_cast<LogWindow *>(userdata);
355 GtkTextIter start_find;
356 GtkTextIter end_find;
357 GtkTextBuffer *buffer;
359 if (pos == GTK_ENTRY_ICON_SECONDARY)
361 gtk_entry_set_text(GTK_ENTRY(logwin->search_entry_box), "");
363 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
364 gtk_text_buffer_get_start_iter(buffer, &start_find);
365 gtk_text_buffer_get_end_iter(buffer, &end_find);
366 gtk_text_buffer_remove_tag_by_name(buffer, "gray_bg", &start_find, &end_find);
367 gtk_text_buffer_remove_tag_by_name(buffer, "green_bg", &start_find, &end_find);
371 static void filter_entry_icon_cb(GtkEntry *entry, GtkEntryIconPosition, GdkEvent *, gpointer)
373 const gchar *blank = "";
374 gtk_entry_set_text(entry, blank);
378 static LogWindow *log_window_create(LayoutWindow *lw)
382 GtkWidget *scrolledwin;
384 GtkTextBuffer *buffer;
389 GtkWidget *label = nullptr;
390 GtkWidget *search_box;
391 GtkWidget *backwards_button;
392 GtkWidget *forwards_button;
393 GtkWidget *all_button;
396 GtkWidget *image = nullptr;
398 logwin = g_new0(LogWindow, 1);
400 window = window_new(GTK_WINDOW_TOPLEVEL, "log", nullptr, nullptr, _("Log"));
402 win_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
403 gtk_container_add(GTK_CONTAINER(window), win_vbox);
404 gtk_widget_show(win_vbox);
406 gtk_window_resize(GTK_WINDOW(window), lw->options.log_window.w,
407 lw->options.log_window.h);
408 gtk_window_move(GTK_WINDOW(window), lw->options.log_window.x, lw->options.log_window.y);
410 g_signal_connect(G_OBJECT(window), "delete_event",
411 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
412 g_signal_connect(G_OBJECT(window), "key_press_event",
413 G_CALLBACK(key_pressed), logwin);
414 g_signal_connect(G_OBJECT(window), "hide",
415 G_CALLBACK(hide_cb), logwin);
416 gtk_widget_realize(window);
418 scrolledwin = gtk_scrolled_window_new(nullptr, nullptr);
419 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
420 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
421 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
424 gtk_box_pack_start(GTK_BOX(win_vbox), scrolledwin, TRUE, TRUE, 0);
425 gtk_widget_show(scrolledwin);
427 text = gtk_text_view_new();
428 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
429 if (options->log_window.line_wrap)
431 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
435 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_NONE);
437 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
438 gtk_text_buffer_get_start_iter(buffer, &iter);
439 gtk_text_buffer_create_mark(buffer, "end", &iter, FALSE);
440 gtk_container_add(GTK_CONTAINER(scrolledwin), text);
441 gtk_widget_show(text);
444 gtk_text_buffer_create_tag(buffer, "gray_bg", "background", "gray", NULL);
445 gtk_text_buffer_create_tag(buffer, "green_bg", "background", "#00FF00", NULL);
447 hbox = pref_box_new(win_vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
449 gtk_widget_show(hbox);
450 logwin->debug_level = pref_spin_new_int(hbox, _("Debug level:"), nullptr, 0, 4, 1, get_debug_level(), &logwin->debug_value);
451 g_signal_connect(logwin->debug_level, "value-changed", G_CALLBACK(debug_changed_cb), logwin);
453 logwin->pause = gtk_toggle_button_new();
454 label = gtk_label_new("Pause");
455 gtk_widget_set_tooltip_text(GTK_WIDGET(logwin->pause), _("Pause scrolling"));
456 gtk_container_add(GTK_CONTAINER(logwin->pause), label) ;
457 gtk_box_pack_start(GTK_BOX(hbox),logwin->pause, FALSE, FALSE, 0) ;
458 g_signal_connect(logwin->pause, "toggled", G_CALLBACK(log_window_pause_cb), logwin);
459 gtk_widget_show_all(logwin->pause);
461 logwin->wrap = gtk_toggle_button_new();
462 label = gtk_label_new("Wrap");
463 gtk_widget_set_tooltip_text(GTK_WIDGET(logwin->wrap), _("Enable line wrap"));
464 gtk_container_add(GTK_CONTAINER(logwin->wrap), label) ;
465 gtk_box_pack_start(GTK_BOX(hbox),logwin->wrap, FALSE, FALSE, 0) ;
466 g_signal_connect(logwin->wrap, "toggled", G_CALLBACK(log_window_line_wrap_cb), logwin);
467 gtk_widget_show_all(logwin->wrap);
469 logwin->timer_data = gtk_toggle_button_new();
470 label = gtk_label_new("Timer");
471 gtk_widget_set_tooltip_text(GTK_WIDGET(logwin->timer_data), _("Enable timer data"));
472 gtk_container_add(GTK_CONTAINER(logwin->timer_data), label) ;
473 gtk_box_pack_start(GTK_BOX(hbox),logwin->timer_data, FALSE, FALSE, 0) ;
474 if (options->log_window.timer_data)
476 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(logwin->timer_data), TRUE);
478 g_signal_connect(logwin->timer_data, "toggled", G_CALLBACK(log_window_timer_data_cb), logwin);
479 gtk_widget_show_all(logwin->timer_data);
481 search_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
482 gtk_container_add(GTK_CONTAINER(hbox), search_box);
483 gtk_widget_show(search_box);
485 logwin->search_entry_box = gtk_entry_new();
486 gtk_box_pack_start(GTK_BOX(search_box), logwin->search_entry_box, FALSE, FALSE, 0);
487 gtk_widget_show(logwin->search_entry_box);
488 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(logwin->search_entry_box), GTK_ENTRY_ICON_PRIMARY, "edit-find");
489 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(logwin->search_entry_box), GTK_ENTRY_ICON_SECONDARY, "edit-clear");
490 gtk_widget_show(search_box);
491 gtk_widget_set_tooltip_text(logwin->search_entry_box, _("Search for text in log window"));
492 g_signal_connect(logwin->search_entry_box, "icon-press", G_CALLBACK(search_entry_icon_cb), logwin);
493 g_signal_connect(logwin->search_entry_box, "activate", G_CALLBACK(search_activate_event), logwin);
495 theme = gtk_icon_theme_get_default();
496 pixbuf = gtk_icon_theme_load_icon(theme, "pan-up-symbolic", 20, GTK_ICON_LOOKUP_GENERIC_FALLBACK, nullptr);
497 image = gtk_image_new_from_pixbuf(pixbuf);
498 backwards_button = gtk_button_new();
499 gtk_button_set_image(GTK_BUTTON(backwards_button), GTK_WIDGET(image));
500 gtk_widget_set_tooltip_text(backwards_button, _("Search backwards"));
501 gtk_box_pack_start(GTK_BOX(search_box), backwards_button, FALSE, FALSE, 0);
502 gtk_widget_show(backwards_button);
503 g_signal_connect(backwards_button, "button_release_event", G_CALLBACK(backwards_keypress_event_cb), logwin);
504 g_object_unref(pixbuf);
506 pixbuf = gtk_icon_theme_load_icon(theme, "pan-down-symbolic", 20, GTK_ICON_LOOKUP_GENERIC_FALLBACK, nullptr);
507 image = gtk_image_new_from_pixbuf(pixbuf);
508 forwards_button = gtk_button_new();
509 gtk_button_set_image(GTK_BUTTON(forwards_button), GTK_WIDGET(image));
510 gtk_widget_set_tooltip_text(forwards_button, _("Search forwards"));
511 gtk_box_pack_start(GTK_BOX(search_box), forwards_button, FALSE, FALSE, 0);
512 gtk_widget_show(forwards_button);
513 g_signal_connect(forwards_button, "button_release_event", G_CALLBACK(forwards_keypress_event_cb), logwin);
514 g_object_unref(pixbuf);
516 pixbuf = gtk_icon_theme_load_icon(theme, "edit-select-all-symbolic", 20, GTK_ICON_LOOKUP_GENERIC_FALLBACK, nullptr);
517 image = gtk_image_new_from_pixbuf(pixbuf);
518 all_button = gtk_toggle_button_new();
519 gtk_button_set_image(GTK_BUTTON(all_button), GTK_WIDGET(image));
520 gtk_widget_set_tooltip_text(GTK_WIDGET(all_button), _("Highlight all"));
521 gtk_box_pack_start(GTK_BOX(search_box), all_button, FALSE, FALSE, 0) ;
522 g_signal_connect(all_button, "toggled", G_CALLBACK(all_keypress_event_cb), logwin);
523 gtk_widget_show_all(all_button);
524 g_object_unref(pixbuf);
526 pref_label_new(hbox, _("Filter regexp"));
528 textbox = gtk_entry_new();
529 gtk_box_pack_start(GTK_BOX(hbox), textbox, FALSE, FALSE, 0);
530 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(textbox), GTK_ENTRY_ICON_SECONDARY, "edit-clear");
531 gtk_widget_show(textbox);
532 g_signal_connect(G_OBJECT(textbox), "activate",
533 G_CALLBACK(log_window_regexp_cb), logwin);
534 g_signal_connect(textbox, "icon-press", G_CALLBACK(filter_entry_icon_cb), logwin);
537 logwin->window = window;
538 logwin->scrolledwin = scrolledwin;
541 logwin->regexp_box = textbox;
542 lw->log_window = logwin->window;
546 static void log_window_init(LogWindow *logwin)
548 GtkTextBuffer *buffer;
550 g_assert(logwin != nullptr);
552 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
554 logwin->color_tags[LOG_NORMAL] = gtk_text_buffer_create_tag (buffer,
555 "black_foreground", "foreground", "black",
556 "family", "MonoSpace", NULL);
557 logwin->color_tags[LOG_MSG] = gtk_text_buffer_create_tag (buffer,
558 "blue_foreground", "foreground", "blue",
559 "family", "MonoSpace", NULL);
560 logwin->color_tags[LOG_WARN] = gtk_text_buffer_create_tag (buffer,
561 "orange_foreground", "foreground", "orange",
562 "family", "MonoSpace", NULL);
563 logwin->color_tags[LOG_ERROR] = gtk_text_buffer_create_tag (buffer,
564 "red_foreground", "foreground", "red",
565 "family", "MonoSpace", NULL);
568 static void log_window_show(LogWindow *logwin)
570 GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
571 GtkTextBuffer *buffer;
575 buffer = gtk_text_view_get_buffer(text);
576 mark = gtk_text_buffer_get_mark(buffer, "end");
577 gtk_text_view_scroll_mark_onscreen(text, mark);
579 gtk_window_present(GTK_WINDOW(logwin->window));
581 log_window_append("", LOG_NORMAL); // to flush memorized lines
583 regexp = g_strdup(get_regexp());
584 if (regexp != nullptr)
586 gtk_entry_set_text(GTK_ENTRY(logwin->regexp_box), regexp);
591 void log_window_new(LayoutWindow *lw)
593 if (logwindow == nullptr)
597 logwin = log_window_create(lw);
598 log_window_init(logwin);
602 log_window_show(logwindow);
610 static void log_window_insert_text(GtkTextBuffer *buffer, GtkTextIter *iter,
611 const gchar *text, GtkTextTag *tag)
615 if (!text || !*text) return;
617 str_utf8 = utf8_validate_or_convert(text);
618 gtk_text_buffer_insert_with_tags(buffer, iter, str_utf8, -1, tag, NULL);
622 void log_window_append(const gchar *str, LogType type)
625 GtkTextBuffer *buffer;
627 static GList *memory = nullptr;
629 if (logwindow == nullptr)
632 auto msg = g_new(LogMsg, 1);
634 msg->text = g_strdup(str);
637 memory = g_list_prepend(memory, msg);
639 while (g_list_length(memory) >= static_cast<guint>(options->log_window_lines))
641 GList *work = g_list_last(memory);
642 auto oldest_msg = static_cast<LogMsg *>(work->data);
644 g_free(oldest_msg->text);
645 memory = g_list_delete_link(memory, work);
651 text = GTK_TEXT_VIEW(logwindow->text);
652 buffer = gtk_text_view_get_buffer(text);
654 if (options->log_window_lines > 0 && logwindow->lines >= options->log_window_lines)
656 GtkTextIter start, end;
658 gtk_text_buffer_get_start_iter(buffer, &start);
660 gtk_text_iter_forward_lines(&end, logwindow->lines - options->log_window_lines);
661 gtk_text_buffer_delete(buffer, &start, &end);
664 gtk_text_buffer_get_end_iter(buffer, &iter);
667 GList *work = g_list_last(memory);
672 auto oldest_msg = static_cast<LogMsg *>(work->data);
674 log_window_insert_text(buffer, &iter, oldest_msg->text,
675 logwindow->color_tags[oldest_msg->type]);
678 memory = g_list_delete_link(memory, work);
683 log_window_insert_text(buffer, &iter, str, logwindow->color_tags[type]);
685 if (!options->log_window.paused)
687 if (gtk_widget_get_visible(GTK_WIDGET(text)))
691 mark = gtk_text_buffer_get_mark(buffer, "end");
692 gtk_text_view_scroll_mark_onscreen(text, mark);
696 logwindow->lines = gtk_text_buffer_get_line_count(buffer);
698 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */