3 /* Global tree of all windows */
4 static GNode *root_window = NULL;
8 * @split: The window to split to create the new window. Must be 0 if there
10 * @method: Position of the new window and method of size computation. One of
11 * #winmethod_Above, #winmethod_Below, #winmethod_Left, or #winmethod_Right
12 * OR'ed with #winmethod_Fixed or #winmethod_Proportional. If @wintype is
13 * #wintype_Blank, then #winmethod_Fixed is not allowed.
14 * @size: Size of the new window, in percentage points if @method is
15 * #winmethod_Proportional, otherwise in characters if @wintype is
16 * #wintype_TextBuffer or #wintype_TextGrid, or pixels if @wintype is
18 * @wintype: Type of the new window. One of #wintype_Blank, #wintype_TextGrid,
19 * #wintype_TextBuffer, or #wintype_Graphics.
20 * @rock: The new window's rock value.
22 * If there are no windows, create a new root window. @split must be 0, and
23 * @method and @size are ignored. Otherwise, split window @split into two, with
24 * position, size, and type specified by @method, @size, and @wintype. See the
25 * Glk documentation for the window placement algorithm.
27 * Returns: the new window.
30 glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype,
33 extern GtkBuilder *builder;
37 g_warning("glk_window_open: splitting of windows not implemented");
41 if(root_window != NULL)
43 g_warning("glk_window_open: there is already a window");
46 /* We only create one window and don't support any more than that */
47 winid_t new_window = g_new0(struct glk_window_struct, 1);
48 root_window = g_node_new(new_window);
50 new_window->rock = rock;
51 new_window->window_type = wintype;
53 GtkBox *vbox = GTK_BOX( gtk_builder_get_object(builder, "vbox") );
56 error_dialog(NULL, NULL, "Could not find vbox");
62 case wintype_TextBuffer:
64 /* We need to put these declarations inside their own scope */
65 GtkWidget *scroll_window = gtk_scrolled_window_new(NULL, NULL);
66 GtkWidget *window = gtk_text_view_new();
67 gtk_container_add( GTK_CONTAINER(scroll_window), window );
68 gtk_box_pack_end(vbox, scroll_window, TRUE, TRUE, 0);
69 gtk_widget_show_all(scroll_window);
71 new_window->widget = window;
72 new_window->window_stream = window_stream_new(new_window);
73 new_window->echo_stream = NULL;
74 new_window->input_request_type = INPUT_REQUEST_NONE;
75 new_window->line_input_buffer = NULL;
76 new_window->line_input_buffer_unicode = NULL;
80 g_warning("glk_window_open: unsupported window type");
85 new_window->window_node = root_window;
94 * Sets the current stream to @win's window stream.
97 glk_set_window(winid_t win)
99 glk_stream_set_current( glk_window_get_stream(win) );
103 * glk_window_get_stream:
106 * Gets the stream associated with @win.
108 * Returns: The window stream.
110 strid_t glk_window_get_stream(winid_t win)
112 return win->window_stream;