X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fwindow.c;h=b3995f09189b8234982a3df80977ef9114f487b8;hb=583f9aec7dff8c4d5456f053ef53279cc2261574;hp=53f264dc91200ebdfcce700dfdc7db822d2d3b2b;hpb=d0d1517f5447d0bd95c6b9769a92054f4c7fcaae;p=rodin%2Fchimara.git
diff --git a/libchimara/window.c b/libchimara/window.c
index 53f264d..b3995f0 100644
--- a/libchimara/window.c
+++ b/libchimara/window.c
@@ -35,7 +35,7 @@ window_new_common(glui32 rock)
}
static void
-window_close_common(winid_t win)
+window_close_common(winid_t win, gboolean destroy_node)
{
ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
@@ -45,7 +45,8 @@ window_close_common(winid_t win)
win->disprock.ptr = NULL;
}
- g_node_destroy(win->window_node);
+ if(destroy_node)
+ g_node_destroy(win->window_node);
win->magic = MAGIC_FREE;
g_free(win);
}
@@ -458,6 +459,7 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
case wintype_TextGrid:
{
GtkWidget *textview = gtk_text_view_new();
+ GtkTextBuffer *textbuffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(textview) );
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(textview), GTK_WRAP_NONE );
gtk_text_view_set_editable( GTK_TEXT_VIEW(textview), FALSE );
@@ -479,6 +481,9 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
/* Connect signal handlers */
win->keypress_handler = g_signal_connect( G_OBJECT(textview), "key-press-event", G_CALLBACK(on_window_key_press_event), win );
g_signal_handler_block( G_OBJECT(textview), win->keypress_handler );
+
+ /* Create the styles available to the window stream */
+ style_init_textgrid(textbuffer);
}
break;
@@ -522,7 +527,7 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
(for line input) */
gtk_text_buffer_create_tag(textbuffer, "uneditable", "editable", FALSE, "editable-set", TRUE, NULL);
- /* Create the default styles available to the window stream */
+ /* Create the styles available to the window stream */
style_init_textbuffer(textbuffer);
/* Mark the position where the user will input text */
@@ -656,7 +661,7 @@ free_winids_below(winid_t win)
free_winids_below(win->window_node->children->data);
free_winids_below(win->window_node->children->next->data);
}
- window_close_common(win);
+ window_close_common(win, FALSE);
}
/**
@@ -770,14 +775,14 @@ glk_window_close(winid_t win, stream_result_t *result)
g_node_append(new_parent_node, sibling_node);
}
- window_close_common( (winid_t) pair_node->data );
+ window_close_common( (winid_t) pair_node->data, TRUE);
}
else /* it was the root window */
{
glk_data->root_window = NULL;
}
- window_close_common(win);
+ window_close_common(win, FALSE);
/* Schedule a redraw */
g_mutex_lock(glk_data->arrange_lock);
@@ -895,17 +900,26 @@ glk_window_clear(winid_t win)
/**
* glk_set_window:
- * @win: A window.
+ * @win: A window, or %NULL.
*
* Sets the current stream to @win's window stream. It is exactly equivalent to
* |[ #glk_stream_set_current(#glk_window_get_stream(@win)) ]|
* See Streams.
+ *
+ * Chimara
+ *
+ * Although this is not mentioned in the specification, @win may also be
+ * %NULL, in which case the current stream is also set to %NULL.
+ *
*/
void
glk_set_window(winid_t win)
{
- VALID_WINDOW(win, return);
- glk_stream_set_current( glk_window_get_stream(win) );
+ VALID_WINDOW_OR_NULL(win, return);
+ if(win)
+ glk_stream_set_current( glk_window_get_stream(win) );
+ else
+ glk_stream_set_current(NULL);
}
/**