X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fopenbox;a=blobdiff_plain;f=openbox%2Fdebug.c;h=ad083b1712088d9c5a9c10fc430edc9808301ee6;hp=6b92c9ec9dd74f4aec81978282d3ef4e987cb142;hb=HEAD;hpb=d78ae0546dae17eda6084a1bd33e63637ba802e5 diff --git a/openbox/debug.c b/openbox/debug.c index 6b92c9ec..ad083b17 100644 --- a/openbox/debug.c +++ b/openbox/debug.c @@ -38,6 +38,8 @@ static guint rr_handler_id = 0; static guint obt_handler_id = 0; static guint ob_handler_id = 0; static guint ob_handler_prompt_id = 0; +static GList *prompt_queue = NULL; +static gboolean allow_prompts = TRUE; static void log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data); @@ -102,11 +104,11 @@ void ob_debug_enable(ObDebugType type, gboolean enable) static inline void log_print(FILE *out, const gchar* log_domain, const gchar *level, const gchar *message) { - fprintf(out, log_domain); + fprintf(out, "%s", log_domain); fprintf(out, "-"); - fprintf(out, level); + fprintf(out, "%s", level); fprintf(out, ": "); - fprintf(out, message); + fprintf(out, "%s", message); fprintf(out, "\n"); fflush(out); } @@ -134,8 +136,10 @@ static void log_handler(const gchar *log_domain, GLogLevelFlags log_level, static void prompt_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer data) { - if (ob_state() == OB_STATE_RUNNING) - prompt_show_message(message, _("Openbox"), _("Close")); + if (ob_state() == OB_STATE_RUNNING && allow_prompts) + prompt_queue = g_list_prepend(prompt_queue, g_strdup(message)); + else + log_handler(log_domain, log_level, message, data); } static inline void log_argv(ObDebugType type, @@ -161,7 +165,7 @@ static inline void log_argv(ObDebugType type, g_free(a); } - g_debug(message); + g_debug("%s", message); g_free(message); } @@ -182,3 +186,16 @@ void ob_debug_type(ObDebugType type, const gchar *a, ...) log_argv(type, a, vl); va_end(vl); } + +void ob_debug_show_prompts(void) +{ + if (prompt_queue) { + allow_prompts = FALSE; /* avoid recursive prompts */ + while (prompt_queue) { + prompt_show_message(prompt_queue->data, "Openbox", _("Close")); + g_free(prompt_queue->data); + prompt_queue = g_list_delete_link(prompt_queue, prompt_queue); + } + allow_prompts = TRUE; + } +}