From 84313cdc37b7ad5f13fa0c39fcdf54a19212501b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 12 Sep 2012 14:20:12 +0200 Subject: [itip-formatter] Do not include empty values in a printout --- modules/itip-formatter/itip-view.c | 60 ++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'modules/itip-formatter/itip-view.c') diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c index 07c01b2c97..7e91f3444d 100644 --- a/modules/itip-formatter/itip-view.c +++ b/modules/itip-formatter/itip-view.c @@ -871,18 +871,30 @@ append_text_table_row (GString *buffer, g_string_append_printf ( buffer, "%s%s\n", - id, (value && *value) ? "" : "hidden=\"\"", label, value); + id, (value && *value) ? "" : "hidden=\"\"", label, value ? value : ""); } else { g_string_append_printf ( buffer, - "\n", - id); + "%s\n", + id, g_strcmp0 (id, TABLE_ROW_SUMMARY) == 0 ? "" : " hidden=\"\"", value ? value : ""); } } +static void +append_text_table_row_nonempty (GString *buffer, + const gchar *id, + const gchar *label, + const gchar *value) +{ + if (!value || !*value) + return; + + append_text_table_row (buffer, id, label, value); +} + static void append_info_item_row (ItipView *view, const gchar *table_id, @@ -1547,13 +1559,15 @@ itip_view_write_for_printing (ItipView *view, "
\n"); /* The first section listing the sender */ - /* FIXME What to do if the send and organizer do not match */ - g_string_append_printf ( - buffer, - "
%s
\n", - view->priv->sender ? view->priv->sender : ""); + if (view->priv->sender && *view->priv->sender) { + /* FIXME What to do if the send and organizer do not match */ + g_string_append_printf ( + buffer, + "
%s
\n", + view->priv->sender); - g_string_append (buffer, "
\n"); + g_string_append (buffer, "
\n"); + } /* Elementary event information */ g_string_append ( @@ -1561,35 +1575,37 @@ itip_view_write_for_printing (ItipView *view, "\n"); - append_text_table_row ( + append_text_table_row_nonempty ( buffer, TABLE_ROW_SUMMARY, NULL, view->priv->summary); - append_text_table_row ( + append_text_table_row_nonempty ( buffer, TABLE_ROW_LOCATION, _("Location:"), view->priv->location); - append_text_table_row ( + append_text_table_row_nonempty ( buffer, TABLE_ROW_START_DATE, view->priv->start_header, view->priv->start_label); - append_text_table_row ( + append_text_table_row_nonempty ( buffer, TABLE_ROW_END_DATE, view->priv->end_header, view->priv->end_label); - append_text_table_row ( + append_text_table_row_nonempty ( buffer, TABLE_ROW_STATUS, _("Status:"), view->priv->status); - append_text_table_row ( + append_text_table_row_nonempty ( buffer, TABLE_ROW_COMMENT, _("Comment:"), view->priv->comment); - g_string_append (buffer, "
\n"); + g_string_append (buffer, "
\n"); /* Description */ - g_string_append_printf ( - buffer, - "
%s
\n", - view->priv->description ? "" : "hidden=\"\"", view->priv->description); + if (view->priv->description && *view->priv->description) { + g_string_append_printf ( + buffer, + "
%s
\n", + view->priv->description ? "" : "hidden=\"\"", view->priv->description); - g_string_append (buffer, "
"); + g_string_append (buffer, ""); + } } void -- cgit