Skip to content

Commit 8e7d92c

Browse files
qarkaicaclark
authored andcommitted
Merge log_window_init() into log_window_create()
Also use GdkRectangle as log_window_create() parameter.
1 parent 55f06e0 commit 8e7d92c

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

src/logwindow.cc

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void filter_entry_icon_cb(GtkEntry *entry, GtkEntryIconPosition, GdkEvent
327327
}
328328
#endif
329329

330-
static LogWindow *log_window_create(LayoutWindow *lw)
330+
static LogWindow *log_window_create(GdkRectangle log_window)
331331
{
332332
LogWindow *logwin;
333333
GtkWidget *text;
@@ -343,8 +343,8 @@ static LogWindow *log_window_create(LayoutWindow *lw)
343343
gq_gtk_container_add(window, win_vbox);
344344
gtk_widget_show(win_vbox);
345345

346-
gq_gtk_window_resize(GTK_WINDOW(window), lw->options.log_window.width, lw->options.log_window.height);
347-
gq_gtk_window_move(GTK_WINDOW(window), lw->options.log_window.x, lw->options.log_window.y);
346+
gq_gtk_window_resize(GTK_WINDOW(window), log_window.width, log_window.height);
347+
gq_gtk_window_move(GTK_WINDOW(window), log_window.x, log_window.y);
348348

349349
g_signal_connect(G_OBJECT(window), "delete_event",
350350
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
@@ -455,35 +455,23 @@ static LogWindow *log_window_create(LayoutWindow *lw)
455455
g_signal_connect(logwin->regexp_box, "icon-press", G_CALLBACK(filter_entry_icon_cb), nullptr);
456456
#endif
457457

458+
constexpr const gchar *tags[] = { "black", "blue", "orange", "red" };
459+
for (int i = 0; i < LOG_COUNT; ++i)
460+
{
461+
g_autofree gchar *tag_name = g_strdup_printf("%s_foreground", tags[i]);
462+
463+
logwin->color_tags[i] = gtk_text_buffer_create_tag(buffer, tag_name,
464+
"foreground", tags[i],
465+
"family", "MonoSpace",
466+
NULL);
467+
}
468+
458469
logwin->window = window;
459470
logwin->text = text;
460471
logwin->lines = 1;
461-
lw->log_window = logwin->window;
462472
return logwin;
463473
}
464474

465-
static void log_window_init(LogWindow *logwin)
466-
{
467-
GtkTextBuffer *buffer;
468-
469-
g_assert(logwin != nullptr);
470-
471-
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
472-
473-
logwin->color_tags[LOG_NORMAL] = gtk_text_buffer_create_tag (buffer,
474-
"black_foreground", "foreground", "black",
475-
"family", "MonoSpace", NULL);
476-
logwin->color_tags[LOG_MSG] = gtk_text_buffer_create_tag (buffer,
477-
"blue_foreground", "foreground", "blue",
478-
"family", "MonoSpace", NULL);
479-
logwin->color_tags[LOG_WARN] = gtk_text_buffer_create_tag (buffer,
480-
"orange_foreground", "foreground", "orange",
481-
"family", "MonoSpace", NULL);
482-
logwin->color_tags[LOG_ERROR] = gtk_text_buffer_create_tag (buffer,
483-
"red_foreground", "foreground", "red",
484-
"family", "MonoSpace", NULL);
485-
}
486-
487475
static void log_window_show(LogWindow *logwin)
488476
{
489477
GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
@@ -511,11 +499,9 @@ void log_window_new(LayoutWindow *lw)
511499
{
512500
if (logwindow == nullptr)
513501
{
514-
LogWindow *logwin;
502+
logwindow = log_window_create(lw->options.log_window);
515503

516-
logwin = log_window_create(lw);
517-
log_window_init(logwin);
518-
logwindow = logwin;
504+
lw->log_window = logwindow->window;
519505
}
520506

521507
log_window_show(logwindow);

0 commit comments

Comments
 (0)