[GTK3] Clear sidebar in async input requests

This commit is contained in:
Maximilian Mader 2020-01-31 01:53:02 +01:00
parent 66e2e75102
commit f1122f3c2d
Signed by: Max
GPG Key ID: F71D56A3151C4FB3

View File

@ -59,8 +59,8 @@ static gchar *vram_viewer_active_tab = "";
static gboolean vram_viewer_is_cgb = false; static gboolean vram_viewer_is_cgb = false;
static uint8_t vram_viewer_palette_data[16][0x40]; static uint8_t vram_viewer_palette_data[16][0x40];
static bool running = false; static volatile bool running = false;
static bool stopping = false; static volatile bool stopping = false;
#define tileset_buffer_length 256 * 192 * 4 #define tileset_buffer_length 256 * 192 * 4
static uint32_t tileset_buffer[tileset_buffer_length] = {0}; static uint32_t tileset_buffer[tileset_buffer_length] = {0};
@ -420,7 +420,16 @@ static char *sync_console_input(GB_gameboy_t *gb) {
return input; return input;
} }
static void clear_sidebar() {
GtkTextView *sidebar_output = builder_get(GTK_TEXT_VIEW, "console_sidebar_output");
GtkTextBuffer *sidebar_output_text_buf = gtk_text_view_get_buffer(sidebar_output);
gtk_text_buffer_set_text(sidebar_output_text_buf, "", -1);
}
static char *async_console_input(GB_gameboy_t *gb) { static char *async_console_input(GB_gameboy_t *gb) {
// TODO: This is rather ugly
g_idle_add((GSourceFunc) clear_sidebar, NULL);
if (debugger_input_queue->len == 0) return NULL; if (debugger_input_queue->len == 0) return NULL;
g_mutex_lock(&debugger_input_mutex); g_mutex_lock(&debugger_input_mutex);
@ -515,9 +524,7 @@ static void append_pending_output(void) {
g_rec_mutex_lock(&console_output_lock); g_rec_mutex_lock(&console_output_lock);
if (should_clear_sidebar) { if (should_clear_sidebar) {
GtkTextView *sidebar_output = builder_get(GTK_TEXT_VIEW, "console_sidebar_output"); clear_sidebar();
GtkTextBuffer *sidebar_output_text_buf = gtk_text_view_get_buffer(sidebar_output);
gtk_text_buffer_set_text(sidebar_output_text_buf, "", -1);
should_clear_sidebar = FALSE; should_clear_sidebar = FALSE;
} }