/*
 * Mail Notification
 * Copyright (C) 2003-2008 Jean-Yves Lefort <jylefort@brutele.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

%headertop{
#include "mn-message-view.h"
%}

%{
#include <glib/gi18n.h>
#include "mn-message-view-private.h"
#include "mn-message.h"
#include "mn-util.h"
#include "mn-text-table.h"
%}

class MN:Standard:Message:View from MN:Message:View
{
  override (MN:Message:View) void
    append_message (MNMessageView *view, MNMessage *message, time_t now)
  {
    Self *self = SELF(view);

    self_append_row(self, _("Mailbox:"), message->mailbox->runtime_name);
    self_append_row(self, _("From:"), message->from);
    self_append_row(self, _("Subject:"), message->subject);

    if (message->sent_time > 0)
      {
	self_append_header(self, _("Sent:"));
	mn_message_view_append_past_time_cell(MN_MESSAGE_VIEW(self), message->sent_time, now);
	mn_text_table_line_break(MN_TEXT_TABLE(self));
      }
  }

  override (MN:Message:View) void
    append_message_separator (MNMessageView *view)
  {
    mn_text_table_append_blank_cell(MN_TEXT_TABLE(view), 0, 12);
    mn_text_table_line_break(MN_TEXT_TABLE(view));
  }

  private void
    append_row (self,
		const char *name (check null),
		const char *value (check null))
  {
    self_append_header(self, name);
    mn_text_table_append_text_cell(MN_TEXT_TABLE(self), value);
    mn_text_table_line_break(MN_TEXT_TABLE(self));
  }

  private void
    append_header (self, const char *name (check null))
  {
    char *markup;

    markup = g_markup_printf_escaped("<span weight=\"bold\">%s</span>", name);
    mn_text_table_append_text_cell_from_markup(MN_TEXT_TABLE(self), markup);
    g_free(markup);
  }

  public GtkWidget *
    new (void)
  {
    return GTK_WIDGET(GET_NEW);
  }
}
