From 27e94a1fb74828d4289110ad8b66e8b3eb8bc55e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 7 May 2011 22:02:25 -0700 Subject: [PATCH] gui: Label message output items in the output viewer treeview. Until now, messages (such as errors and warnings) simply had blank lines in the output viewer summary treeview. This made for funny gaps and a generally puzzling appearance. This fixes the problem. --- src/libpspp/message.c | 31 +++++++++++++++--------------- src/libpspp/message.h | 2 ++ src/ui/gui/psppire-output-window.c | 8 ++++++++ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 80475b3545..4d95ba43ac 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -76,6 +76,21 @@ msg_set_handler (void (*handler) (const struct msg *, void *aux), void *aux) /* Working with messages. */ +const char * +msg_severity_to_string (enum msg_severity severity) +{ + switch (severity) + { + case MSG_S_ERROR: + return _("error"); + case MSG_S_WARNING: + return _("warning"); + case MSG_S_NOTE: + default: + return _("note"); + } +} + /* Duplicate a message */ struct msg * msg_dup (const struct msg *m) @@ -106,7 +121,6 @@ msg_destroy (struct msg *m) char * msg_to_string (const struct msg *m, const char *command_name) { - const char *label; struct string s; ds_init_empty (&s); @@ -166,20 +180,7 @@ msg_to_string (const struct msg *m, const char *command_name) ds_put_cstr (&s, ": "); } - switch (m->severity) - { - case MSG_S_ERROR: - label = _("error"); - break; - case MSG_S_WARNING: - label = _("warning"); - break; - case MSG_S_NOTE: - default: - label = _("note"); - break; - } - ds_put_format (&s, "%s: ", label); + ds_put_format (&s, "%s: ", msg_severity_to_string (m->severity)); if (m->category == MSG_C_SYNTAX && command_name != NULL) ds_put_format (&s, "%s: ", command_name); diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 8ed2844133..3856ee5b81 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -39,6 +39,8 @@ enum msg_severity MSG_N_SEVERITIES }; +const char *msg_severity_to_string (enum msg_severity); + /* Combination of a category and a severity for convenience. */ enum msg_class { diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index b6abd05083..cf65a2f9e6 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -29,6 +29,7 @@ #include "output/cairo.h" #include "output/chart-item.h" #include "output/driver-provider.h" +#include "output/message-item.h" #include "output/output-item.h" #include "output/tab.h" #include "output/table-item.h" @@ -305,6 +306,13 @@ psppire_output_submit (struct output_driver *this, ds_clear (&title); if (is_text_item (item)) ds_put_cstr (&title, text_item_get_text (to_text_item (item))); + else if (is_message_item (item)) + { + const struct message_item *msg_item = to_message_item (item); + const struct msg *msg = message_item_get_msg (msg_item); + ds_put_format (&title, "%s: %s", _("Message"), + msg_severity_to_string (msg->severity)); + } else if (is_table_item (item)) { const char *caption = table_item_get_caption (to_table_item (item)); -- 2.30.2