/*
 * 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 <gtk/gtk.h>
#include "mn-mailbox.h"
%}

%{
#include "mn-util.h"
#include "mn-mailbox-properties-dialog.h"
%}

class MN:Mailbox:Properties from G:Object (abstract)
{
  classwide const char *type;
  classwide const char *stock_id;
  classwide const char *combo_label;
  classwide gboolean enable_check_delay = TRUE;

  protected GtkWidget *dialog;
  property POINTER dialog (flags = CONSTRUCT_ONLY, link, type = GtkWidget *);

  protected GtkSizeGroup *label_size_group = {gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL)} unrefwith g_object_unref;

  protected GSList *entries destroywith g_slist_free;

  private GSList *general_sections destroywith mn_g_object_slist_free;

  property BOOLEAN complete
    get { g_value_set_boolean(VAL, TRUE); };

  property STRING default_name
    get { g_value_set_string(VAL, NULL); };

  property INT default_check_delay
    get
    {
      MNMailboxClass *class;

      class = mn_mailbox_get_class_from_name(SELF_GET_CLASS(self)->type);
      g_value_set_int(VAL, class->default_check_delay);
      g_type_class_unref(class);
    };

  virtual public void
    activate (self);

  virtual public void
    deactivate (self);

  virtual public void
    set_mailbox (self, MN:Mailbox *mailbox (check null type));

  virtual public MNMailbox *
    get_mailbox (self)
  {
    return mn_mailbox_new(SELF_GET_CLASS(self)->type, NULL);
  }

  protected GtkWidget *
    add_general_section (self, const char *title (check null))
  {
    GtkWidget *section;
    GtkWidget *vbox;

    section = mn_hig_section_new_with_box(title, NULL, &vbox);
    g_object_ref_sink(section);
    gtk_widget_show(section);

    selfp->general_sections = g_slist_append(selfp->general_sections, section);
    return vbox;
  }

  override (MN:Mailbox:Properties) void
    activate (MNMailboxProperties *properties)
  {
    Self *self = SELF(properties);
    GSList *l;

    MN_LIST_FOREACH(l, selfp->general_sections)
      gtk_box_pack_start(GTK_BOX(MN_MAILBOX_PROPERTIES_DIALOG(properties->dialog)->general_vbox), l->data, TRUE, TRUE, 0);
  }

  override (MN:Mailbox:Properties) void
    deactivate (MNMailboxProperties *properties)
  {
    Self *self = SELF(properties);
    GSList *l;

    MN_LIST_FOREACH(l, selfp->general_sections)
      gtk_container_remove(GTK_CONTAINER(MN_MAILBOX_PROPERTIES_DIALOG(properties->dialog)->general_vbox), l->data);
  }

  protected void
    notify_complete (self)
  {
    g_object_notify(G_OBJECT(self), "complete");
  }

  protected void
    notify_default_name (self)
  {
    g_object_notify(G_OBJECT(self), "default-name");
  }

  protected void
    notify_default_check_delay (self)
  {
    g_object_notify(G_OBJECT(self), "default-check-delay");
  }
}
