* Changing styles no longer affects existing windows
[rodin/chimara.git] / libchimara / window.c
index 53f264dc91200ebdfcce700dfdc7db822d2d3b2b..c835ccb31534e8f4816cca5aa397f2322d70864f 100644 (file)
@@ -458,6 +458,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 +480,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 +526,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 */
@@ -895,17 +899,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 <link linkend="chimara-Streams">Streams</link>.
+ *
+ * <note><title>Chimara</title>
+ * <para>
+ *   Although this is not mentioned in the specification, @win may also be 
+ *   %NULL, in which case the current stream is also set to %NULL.
+ * </para></note>
  */
 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);
 }
 
 /**