Use statically-allocated thread private data
[projects/chimara/chimara.git] / libchimara / garglk.c
index 78bdfd5015033dce59d2ebd8edf14a1f7fe00597..27ddd07e2b459b8b39cdb53caaf9d97791a8283a 100644 (file)
@@ -8,7 +8,7 @@
 #include "style.h"
 #include "garglk.h"
 
-extern GPrivate *glk_data_key;
+extern GPrivate glk_data_key;
 
 /**
  * garglk_fileref_get_name:
@@ -40,7 +40,7 @@ garglk_fileref_get_name(frefid_t fref)
 void 
 garglk_set_program_name(const char *name)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        glk_data->program_name = g_strdup(name);
        g_object_notify(G_OBJECT(glk_data->self), "program-name");
 }
@@ -64,7 +64,7 @@ garglk_set_program_name(const char *name)
 void 
 garglk_set_program_info(const char *info)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        glk_data->program_info = g_strdup(info);
        g_object_notify(G_OBJECT(glk_data->self), "program-info");
 }
@@ -83,46 +83,25 @@ garglk_set_program_info(const char *info)
 void 
 garglk_set_story_name(const char *name)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        glk_data->story_name = g_strdup(name);
        g_object_notify(G_OBJECT(glk_data->self), "story-name");
 }
 
 /**
- * garglk_set_line_terminators:
- * @win: A window.
- * @keycodes: An array of <code>keycode_</code> constants.
- * @numkeycodes: The length of @keycodes.
+ * garglk_set_story_title:
+ * @title: Title bar text for the currently running story.
  *
- * Amends the current line input request of @win to include terminating key
- * codes. Any of the specified key codes will terminate the line input request 
- * (without printing a newline). 
- *
- * Usually, in the event structure returned from a line input request, @val2 is
- * zero, but if garglk_set_line_terminators() has been called during that input
- * request, @val2 will be filled in with the key code that terminated the input
- * request.
- *
- * This function only applies to one input request; any subsequent line input
- * requests on that window are treated normally.
- *
- * If @numkeycodes is zero, then any previous call to 
- * garglk_set_line_terminators() is cancelled and the input request is treated
- * normally.
+ * This function is a hint to the library to put @title in the title bar of the
+ * window that the Glk program is running in. It overrides
+ * garglk_set_program_name() and garglk_set_story_name(), if they were displayed
+ * in the title bar, although they may still be displayed somewhere else.
  *
  * <warning><para>This function is not currently implemented.</para></warning>
  */
-void 
-garglk_set_line_terminators(winid_t win, const glui32 *keycodes, glui32 numkeycodes)
+void
+garglk_set_story_title(const char *title)
 {
-       VALID_WINDOW(win, return);
-       g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
-       
-       if(win->input_request_type != INPUT_REQUEST_LINE && win->input_request_type != INPUT_REQUEST_LINE_UNICODE) {
-               ILLEGAL(_("Tried to set the line terminators on a window without a line input request."));
-               return;
-       }
-
        WARNING(_("Not implemented"));
 }
 
@@ -139,7 +118,7 @@ garglk_set_line_terminators(winid_t win, const glui32 *keycodes, glui32 numkeyco
 void 
 garglk_unput_string(char *str)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        g_return_if_fail(glk_data->current_stream != NULL);
 
        WARNING(_("Not implemented"));
@@ -156,7 +135,7 @@ garglk_unput_string(char *str)
 void 
 garglk_unput_string_uni(glui32 *str)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        g_return_if_fail(glk_data->current_stream != NULL);
        
        WARNING(_("Not implemented"));
@@ -314,7 +293,7 @@ garglk_set_zcolors_stream(strid_t str, glui32 fg, glui32 bg)
 void 
 garglk_set_zcolors(glui32 fg, glui32 bg)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        g_return_if_fail(glk_data->current_stream != NULL);
 
        garglk_set_zcolors_stream(glk_data->current_stream, fg, bg);
@@ -410,7 +389,7 @@ garglk_set_reversevideo_stream(strid_t str, glui32 reverse)
 void 
 garglk_set_reversevideo(glui32 reverse)
 {
-       ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+       ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
        g_return_if_fail(glk_data->current_stream != NULL);
        g_return_if_fail(glk_data->current_stream->window != NULL);