Change I/O signals to pass a unique window ID
authorPhilip Chimento <philip.chimento@gmail.com>
Sat, 26 Oct 2013 23:03:36 +0000 (16:03 -0700)
committerPhilip Chimento <philip.chimento@gmail.com>
Sat, 26 Oct 2013 23:03:36 +0000 (16:03 -0700)
Change the 'char-input', 'line-input', and 'text-buffer-output'
signals to pass a unique window ID string as well as the
window rock value. If a client program wants to keep track of
input and output in all windows, then the window rock will
not do by itself - all open windows might have rock 0, for
example. The string ID is guaranteed to be unique for each
window, though its contents are implementation-defined.

libchimara/chimara-glk.c
libchimara/chimara-glk.h
libchimara/chimara-if.c
libchimara/chimara-marshallers.txt
libchimara/input.c
libchimara/strio.c
libchimara/window.c
libchimara/window.h

index 718562218509b149f13656612c4847f96550436d..9d9b4696e6f8dd58a7a3ba46aa9413ba4ee18b86 100644 (file)
@@ -680,46 +680,64 @@ chimara_glk_class_init(ChimaraGlkClass *klass)
                g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
        /**
         * ChimaraGlk::char-input:
                g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
        /**
         * ChimaraGlk::char-input:
-        * @glk: The widget that received the signal
+        * @self: The widget that received the signal
         * @window_rock: The rock value of the window that received character input
         * (see <link linkend="chimara-Rocks">Rocks</link>)
         * @window_rock: The rock value of the window that received character input
         * (see <link linkend="chimara-Rocks">Rocks</link>)
-        * @keysym: The key that was typed, in the form of a key symbol from 
+        * @window_id_string: A string value uniquely identifying the window that
+        * received character input
+        * @keysym: The key that was typed, in the form of a key symbol from
         * <filename class="headerfile">gdk/gdkkeysyms.h</filename>
         * <filename class="headerfile">gdk/gdkkeysyms.h</filename>
-        * 
+        *
         * Emitted when a Glk window receives character input.
         * Emitted when a Glk window receives character input.
+        * The @window_rock can be used to identify the window.
+        * However, rock values in Glk are allowed to be identical for different
+        * windows, so Chimara also provides a string value with which the window
+        * can be uniquely identified.
         */
        chimara_glk_signals[CHAR_INPUT] = g_signal_new("char-input",
                G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, char_input), NULL, NULL,
         */
        chimara_glk_signals[CHAR_INPUT] = g_signal_new("char-input",
                G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, char_input), NULL, NULL,
-               _chimara_marshal_VOID__UINT_UINT,
-               G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+               _chimara_marshal_VOID__UINT_STRING_UINT,
+               G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT);
        /**
         * ChimaraGlk::line-input:
        /**
         * ChimaraGlk::line-input:
-        * @glk: The widget that received the signal
+        * @self: The widget that received the signal
         * @window_rock: The rock value of the window that received line input (see
         * <link linkend="chimara-Rocks">Rocks</link>)
         * @window_rock: The rock value of the window that received line input (see
         * <link linkend="chimara-Rocks">Rocks</link>)
+        * @window_id_string: A string value uniquely identifying the window that
+        * received the input
         * @text: The text that was typed
         * @text: The text that was typed
-        * 
+        *
         * Emitted when a Glk window receives line input.
         * Emitted when a Glk window receives line input.
+        * The @window_rock can be used to identify the window.
+        * However, rock values in Glk are allowed to be identical for different
+        * windows, so Chimara also provides a string value with which the window
+        * can be uniquely identified.
         */
        chimara_glk_signals[LINE_INPUT] = g_signal_new("line-input",
                G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, line_input), NULL, NULL,
         */
        chimara_glk_signals[LINE_INPUT] = g_signal_new("line-input",
                G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, line_input), NULL, NULL,
-               _chimara_marshal_VOID__UINT_STRING,
-               G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+               _chimara_marshal_VOID__UINT_STRING_STRING,
+               G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
        /**
         * ChimaraGlk::text-buffer-output:
        /**
         * ChimaraGlk::text-buffer-output:
-        * @glk: The widget that received the signal
+        * @self: The widget that received the signal
         * @window_rock: The rock value of the window that was printed to (see <link
         * linkend="chimara-Rocks">Rocks</link>)
         * @window_rock: The rock value of the window that was printed to (see <link
         * linkend="chimara-Rocks">Rocks</link>)
-        * 
+        * @window_id_string: A string value uniquely identifying the window that
+        * was printed to
+        *
         * Emitted when text is printed to a text buffer window.
         * Emitted when text is printed to a text buffer window.
+        * The @window_rock can be used to identify the window.
+        * However, rock values in Glk are allowed to be identical for different
+        * windows, so Chimara also provides a string value with which the window
+        * can be uniquely identified.
         */
        chimara_glk_signals[TEXT_BUFFER_OUTPUT] = g_signal_new("text-buffer-output",
                G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, text_buffer_output), NULL, NULL,
         */
        chimara_glk_signals[TEXT_BUFFER_OUTPUT] = g_signal_new("text-buffer-output",
                G_OBJECT_CLASS_TYPE(klass), 0,
                G_STRUCT_OFFSET(ChimaraGlkClass, text_buffer_output), NULL, NULL,
-               _chimara_marshal_VOID__UINT_STRING,
-               G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+               _chimara_marshal_VOID__UINT_STRING_STRING,
+               G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
        /**
         * ChimaraGlk::iliad-screen-update:
         * @self: The widget that received the signal
        /**
         * ChimaraGlk::iliad-screen-update:
         * @self: The widget that received the signal
index 8001adafbfdb3f40ccc0ce4101bb8fc971e8ba12..953f84ee0eddd6f63b2af2fa0e89090708435ba0 100644 (file)
@@ -33,9 +33,9 @@ typedef struct {
        void(* stopped) (ChimaraGlk *self);
        void(* started) (ChimaraGlk *self);
        void(* waiting) (ChimaraGlk *self);
        void(* stopped) (ChimaraGlk *self);
        void(* started) (ChimaraGlk *self);
        void(* waiting) (ChimaraGlk *self);
-       void(* char_input) (ChimaraGlk *self, guint32 window_rock, guint keysym);
-       void(* line_input) (ChimaraGlk *self, guint32 window_rock, gchar *text);
-       void(* text_buffer_output) (ChimaraGlk *self, guint32 window_rock, gchar *text);
+       void(* char_input) (ChimaraGlk *self, guint32 window_rock, char *string_id, unsigned keysym);
+       void(* line_input) (ChimaraGlk *self, guint32 window_rock, char *string_id, char *text);
+       void(* text_buffer_output) (ChimaraGlk *self, guint32 window_rock, char *string_id, char *text);
        void(* iliad_screen_update) (ChimaraGlk *self, gboolean typing);
 } ChimaraGlkClass;
 
        void(* iliad_screen_update) (ChimaraGlk *self, gboolean typing);
 } ChimaraGlkClass;
 
index 0d9979741a819385b2131dc046c971ace2bc2b65..2fb74c85e3477e5f845730abc5985904ec978ba2 100644 (file)
@@ -131,7 +131,7 @@ chimara_if_stopped(ChimaraGlk *glk)
 }
 
 static void
 }
 
 static void
-chimara_if_char_input(ChimaraGlk *glk, guint32 win_rock, guint keysym)
+chimara_if_char_input(ChimaraGlk *glk, guint32 win_rock, char *string_id, unsigned keysym)
 {
        CHIMARA_IF_USE_PRIVATE(glk, priv);
        g_assert(priv->input == NULL);
 {
        CHIMARA_IF_USE_PRIVATE(glk, priv);
        g_assert(priv->input == NULL);
@@ -142,7 +142,7 @@ chimara_if_char_input(ChimaraGlk *glk, guint32 win_rock, guint keysym)
 }
 
 static void
 }
 
 static void
-chimara_if_line_input(ChimaraGlk *glk, guint32 win_rock, gchar *input)
+chimara_if_line_input(ChimaraGlk *glk, guint32 win_rock, char *string_id, char *input)
 {
        CHIMARA_IF_USE_PRIVATE(glk, priv);
        g_assert(priv->input == NULL);
 {
        CHIMARA_IF_USE_PRIVATE(glk, priv);
        g_assert(priv->input == NULL);
@@ -150,7 +150,7 @@ chimara_if_line_input(ChimaraGlk *glk, guint32 win_rock, gchar *input)
 }
 
 static void
 }
 
 static void
-chimara_if_text_buffer_output(ChimaraGlk *glk, guint32 win_rock, gchar *output)
+chimara_if_text_buffer_output(ChimaraGlk *glk, guint32 win_rock, char *string_id, char *output)
 {
        CHIMARA_IF_USE_PRIVATE(glk, priv);
        g_string_append(priv->response, output);
 {
        CHIMARA_IF_USE_PRIVATE(glk, priv);
        g_string_append(priv->response, output);
index 559ccfcf48a2a2af6f2288095e8ea39c99b4f4e8..235640fe12727f2a2fb45ccc8a5ac77d449c5e5f 100644 (file)
@@ -1,6 +1,6 @@
 # Extra callback marshallers for chimara
 # Run this file through glib-genmarshal to create chimara-marshallers.c
 # Extra callback marshallers for chimara
 # Run this file through glib-genmarshal to create chimara-marshallers.c
-VOID:UINT,UINT
-VOID:UINT,STRING
+VOID:UINT,STRING,UINT
+VOID:UINT,STRING,STRING
 VOID:STRING,STRING
 VOID:BOOLEAN
 VOID:STRING,STRING
 VOID:BOOLEAN
index f6b7fb5113f9f2897ec15e2c51e31e843a83f9a9..7a7521455cf172ee5d87f9d4f1663a25e534530e 100644 (file)
@@ -466,7 +466,7 @@ on_char_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win
        ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(widget, CHIMARA_TYPE_GLK));
        g_assert(glk);
        event_throw(glk, evtype_CharInput, win, keycode, 0);
        ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(widget, CHIMARA_TYPE_GLK));
        g_assert(glk);
        event_throw(glk, evtype_CharInput, win, keycode, 0);
-       g_signal_emit_by_name(glk, "char-input", win->rock, event->keyval);
+       g_signal_emit_by_name(glk, "char-input", win->rock, win->librock, event->keyval);
 
        /* Only one keypress will be handled */
        win->input_request_type = INPUT_REQUEST_NONE;
 
        /* Only one keypress will be handled */
        win->input_request_type = INPUT_REQUEST_NONE;
@@ -687,7 +687,7 @@ finish_text_buffer_line_input(winid_t win, gboolean emit_signal)
        {
                ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
                g_assert(glk);
        {
                ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
                g_assert(glk);
-               g_signal_emit_by_name(glk, "line-input", win->rock, inserted_text);
+               g_signal_emit_by_name(glk, "line-input", win->rock, win->librock, inserted_text);
        }
 
        /* Add the text to the window input history */
        }
 
        /* Add the text to the window input history */
@@ -742,7 +742,7 @@ finish_text_grid_line_input(winid_t win, gboolean emit_signal)
     {
                ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
                g_assert(glk);
     {
                ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
                g_assert(glk);
-               g_signal_emit_by_name(glk, "line-input", win->rock, text);
+               g_signal_emit_by_name(glk, "line-input", win->rock, win->librock, text);
     }
 
        /* Add the text to the window input history */
     }
 
        /* Add the text to the window input history */
@@ -924,7 +924,7 @@ force_char_input_from_queue(winid_t win, event_t *event)
        gdk_threads_enter();
        ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
        g_assert(glk);
        gdk_threads_enter();
        ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
        g_assert(glk);
-       g_signal_emit_by_name(glk, "char-input", win->rock, keyval);
+       g_signal_emit_by_name(glk, "char-input", win->rock, win->librock, keyval);
        gdk_threads_leave();
 
        event->type = evtype_CharInput;
        gdk_threads_leave();
 
        event->type = evtype_CharInput;
index b6e8f32403604ccfbdb68a2c964e9a1519f8cbd7..2a2f231d18a6733cf5ae4abdd43bfcb9bf703ccf 100644 (file)
@@ -77,7 +77,7 @@ flush_window_buffer(winid_t win)
 
                ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
                g_assert(glk);
 
                ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK));
                g_assert(glk);
-               g_signal_emit_by_name(glk, "text-buffer-output", win->rock, win->buffer->str);
+               g_signal_emit_by_name(glk, "text-buffer-output", win->rock, win->librock, win->buffer->str);
        }
                break;
 
        }
                break;
 
index a4366b4b8ca4c6f11c15da94c38c504f42b53386..1cd23ef6ec63fa60337d04f260b5fcebc840f44a 100644 (file)
@@ -15,6 +15,7 @@ window_new_common(glui32 rock)
        
        win->magic = MAGIC_WINDOW;
        win->rock = rock;
        
        win->magic = MAGIC_WINDOW;
        win->rock = rock;
+       win->librock = g_strdup_printf("%p", win);
        if(glk_data->register_obj)
                win->disprock = (*glk_data->register_obj)(win, gidisp_Class_Window);
        
        if(glk_data->register_obj)
                win->disprock = (*glk_data->register_obj)(win, gidisp_Class_Window);
        
@@ -64,7 +65,8 @@ window_close_common(winid_t win, gboolean destroy_node)
                g_node_destroy(win->window_node);
        
        win->magic = MAGIC_FREE;
                g_node_destroy(win->window_node);
        
        win->magic = MAGIC_FREE;
-       
+
+       g_free(win->librock);
        g_list_foreach(win->history, (GFunc)g_free, NULL);
        g_list_free(win->history);
        g_slist_free(win->extra_line_terminators);
        g_list_foreach(win->history, (GFunc)g_free, NULL);
        g_list_free(win->history);
        g_slist_free(win->extra_line_terminators);
index aa3250274a5e5e3609e12252457b587f7a61a0cf..1ce7aaa6d3d40a498fd17a3019fbde49a7b00224 100644 (file)
@@ -32,6 +32,7 @@ struct glk_window_struct
 {
        /*< private >*/
        glui32 magic, rock;
 {
        /*< private >*/
        glui32 magic, rock;
+       char *librock; /* "library rock" - unique string identifier */
        gidispatch_rock_t disprock;
        /* Pointer to the node in the global tree that contains this window */
        GNode *window_node;
        gidispatch_rock_t disprock;
        /* Pointer to the node in the global tree that contains this window */
        GNode *window_node;