From: P. F. Chimento Date: Sun, 21 Nov 2010 01:04:52 +0000 (+0100) Subject: Added API to tell whether forced input is pending X-Git-Tag: v0.9~166 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=b57624149a9c9d937f91f4c7838d9d68f11f7e10;p=projects%2Fchimara%2Fchimara.git Added API to tell whether forced input is pending Added the functions chimara_glk_is_char_input_pending() chimara_glk_is_line_input_pending() --- diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 5cdf63e..eba6a23 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -1362,8 +1362,8 @@ chimara_glk_feed_char_input(ChimaraGlk *glk, guint keyval) * request. @text does not need to end with a newline. You can call this * function even when no window has requested line input, in which case the text * will be saved for the following window that requests line input. This has the - * disadvantage that if more than one window has requested character input, it - * is arbitrary which one gets the text. + * disadvantage that if more than one window has requested line input, it is + * arbitrary which one gets the text. */ void chimara_glk_feed_line_input(ChimaraGlk *glk, const gchar *text) @@ -1375,6 +1375,40 @@ chimara_glk_feed_line_input(ChimaraGlk *glk, const gchar *text) event_throw(glk, evtype_ForcedLineInput, NULL, 0, 0); } +/** + * chimara_glk_is_char_input_pending: + * @glk: a #ChimaraGlk widget + * + * Use this function to tell if character input forced by + * chimara_glk_feed_char_input() has been passed to an input request or not. + * + * Returns: %TRUE if forced character input is pending, %FALSE otherwise. + */ +gboolean +chimara_glk_is_char_input_pending(ChimaraGlk *glk) +{ + g_return_val_if_fail(glk || CHIMARA_IS_GLK(glk), FALSE); + CHIMARA_GLK_USE_PRIVATE(glk, priv); + return g_async_queue_length(priv->char_input_queue) > 0; +} + +/** + * chimara_glk_is_line_input_pending: + * @glk: a #ChimaraGlk widget + * + * Use this function to tell if line input forced by + * chimara_glk_feed_line_input() has been passed to an input request or not. + * + * Returns: %TRUE if forced line input is pending, %FALSE otherwise. + */ +gboolean +chimara_glk_is_line_input_pending(ChimaraGlk *glk) +{ + g_return_val_if_fail(glk || CHIMARA_IS_GLK(glk), FALSE); + CHIMARA_GLK_USE_PRIVATE(glk, priv); + return g_async_queue_length(priv->line_input_queue) > 0; +} + /** * chimara_glk_get_tag: * @glk: a #ChimarGlk widget diff --git a/libchimara/chimara-glk.h b/libchimara/chimara-glk.h index df6aaef..f4d9edd 100644 --- a/libchimara/chimara-glk.h +++ b/libchimara/chimara-glk.h @@ -91,6 +91,8 @@ void chimara_glk_wait(ChimaraGlk *glk); gboolean chimara_glk_get_running(ChimaraGlk *glk); void chimara_glk_feed_char_input(ChimaraGlk *glk, guint32 keyval); void chimara_glk_feed_line_input(ChimaraGlk *glk, const gchar *text); +gboolean chimara_glk_is_char_input_pending(ChimaraGlk *glk); +gboolean chimara_glk_is_line_input_pending(ChimaraGlk *glk); GtkTextTag *chimara_glk_get_tag(ChimaraGlk *glk, ChimaraGlkWindowType window, const gchar *name); const gchar **chimara_glk_get_tag_names(ChimaraGlk *glk); gint chimara_glk_get_num_tag_names(ChimaraGlk *glk);