From: Ben Pfaff Date: Sun, 8 May 2011 05:02:25 +0000 (-0700) Subject: gui: Label message output items in the output viewer treeview. X-Git-Tag: v0.7.9~310 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e94a1fb74828d4289110ad8b66e8b3eb8bc55e;p=pspp-builds.git 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. --- diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 80475b35..4d95ba43 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 8ed28441..3856ee5b 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 b6abd050..cf65a2f9 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));