/* Generated by GOB (v2.0.15)   (do not edit directly) */

/* End world hunger, donate to the World Food Programme, http://www.wfp.org */

#define GOB_VERSION_MAJOR 2
#define GOB_VERSION_MINOR 0
#define GOB_VERSION_PATCHLEVEL 15

#define selfp (self->_priv)

#include <string.h> /* memset() */

#include "mn-webmail-mailbox-properties.h"

#include "mn-webmail-mailbox-properties-private.h"

#ifdef G_LIKELY
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
#else /* ! G_LIKELY */
#define ___GOB_LIKELY(expr) (expr)
#define ___GOB_UNLIKELY(expr) (expr)
#endif /* G_LIKELY */

#line 25 "src/mn-webmail-mailbox-properties.gob"

#include <glib/gi18n.h>
#include "mn-webmail-mailbox.h"
#include "mn-mailbox-properties-private.h"
#include "mn-authenticated-mailbox-properties-private.h"
#include "mn-util.h"

#line 34 "mn-webmail-mailbox-properties.c"
/* self casting macros */
#define SELF(x) MN_WEBMAIL_MAILBOX_PROPERTIES(x)
#define SELF_CONST(x) MN_WEBMAIL_MAILBOX_PROPERTIES_CONST(x)
#define IS_SELF(x) MN_IS_WEBMAIL_MAILBOX_PROPERTIES(x)
#define TYPE_SELF MN_TYPE_WEBMAIL_MAILBOX_PROPERTIES
#define SELF_CLASS(x) MN_WEBMAIL_MAILBOX_PROPERTIES_CLASS(x)

#define SELF_GET_CLASS(x) MN_WEBMAIL_MAILBOX_PROPERTIES_GET_CLASS(x)

/* self typedefs */
typedef MNWebmailMailboxProperties Self;
typedef MNWebmailMailboxPropertiesClass SelfClass;

/* here are local prototypes */
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
#line 0 "src/mn-webmail-mailbox-properties.gob"
static void mn_webmail_mailbox_properties_class_init (MNWebmailMailboxPropertiesClass * c);
#line 52 "mn-webmail-mailbox-properties.c"
#line 81 "src/mn-webmail-mailbox-properties.gob"
static void mn_webmail_mailbox_properties_init (MNWebmailMailboxProperties * self);
#line 55 "mn-webmail-mailbox-properties.c"
#line 131 "src/mn-webmail-mailbox-properties.gob"
static void mn_webmail_mailbox_properties_radio_toggled_h (GtkToggleButton * togglebutton, gpointer user_data);
#line 58 "mn-webmail-mailbox-properties.c"
#line 142 "src/mn-webmail-mailbox-properties.gob"
static void ___3_mn_webmail_mailbox_properties_set_mailbox (MNMailboxProperties * properties, MNMailbox * mailbox);
#line 61 "mn-webmail-mailbox-properties.c"
#line 159 "src/mn-webmail-mailbox-properties.gob"
static MNMailbox * ___4_mn_webmail_mailbox_properties_get_mailbox (MNMailboxProperties * properties);
#line 64 "mn-webmail-mailbox-properties.c"

enum {
	PROP_0,
	PROP_COMPLETE,
	PROP_DEFAULT_NAME
};

/* pointer to the class of our parent */
static MNAuthenticatedMailboxPropertiesClass *parent_class = NULL;

/* Short form macros */
#define self_radio_toggled_h mn_webmail_mailbox_properties_radio_toggled_h
GType
mn_webmail_mailbox_properties_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (MNWebmailMailboxPropertiesClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mn_webmail_mailbox_properties_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (MNWebmailMailboxProperties),
			0 /* n_preallocs */,
			(GInstanceInitFunc) mn_webmail_mailbox_properties_init,
			NULL
		};

		type = g_type_register_static (MN_TYPE_AUTHENTICATED_MAILBOX_PROPERTIES, "MNWebmailMailboxProperties", &info, (GTypeFlags)G_TYPE_FLAG_ABSTRACT);
	}

	return type;
}

/* a macro for creating a new object of our type */
#define GET_NEW ((MNWebmailMailboxProperties *)g_object_new(mn_webmail_mailbox_properties_get_type(), NULL))

/* a function for creating a new object of our type */
#include <stdarg.h>
static MNWebmailMailboxProperties * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
static MNWebmailMailboxProperties *
GET_NEW_VARG (const char *first, ...)
{
	MNWebmailMailboxProperties *ret;
	va_list ap;
	va_start (ap, first);
	ret = (MNWebmailMailboxProperties *)g_object_new_valist (mn_webmail_mailbox_properties_get_type (), first, ap);
	va_end (ap);
	return ret;
}


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::finalize"
	MNWebmailMailboxProperties *self G_GNUC_UNUSED = MN_WEBMAIL_MAILBOX_PROPERTIES (obj_self);
	gpointer priv G_GNUC_UNUSED = self->_priv;
	if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
}
#undef __GOB_FUNCTION__

static void 
mn_webmail_mailbox_properties_class_init (MNWebmailMailboxPropertiesClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
	MNMailboxPropertiesClass *mn_mailbox_properties_class = (MNMailboxPropertiesClass *)c;

	g_type_class_add_private(c,sizeof(MNWebmailMailboxPropertiesPrivate));

	parent_class = g_type_class_ref (MN_TYPE_AUTHENTICATED_MAILBOX_PROPERTIES);

#line 142 "src/mn-webmail-mailbox-properties.gob"
	mn_mailbox_properties_class->set_mailbox = ___3_mn_webmail_mailbox_properties_set_mailbox;
#line 159 "src/mn-webmail-mailbox-properties.gob"
	mn_mailbox_properties_class->get_mailbox = ___4_mn_webmail_mailbox_properties_get_mailbox;
#line 146 "mn-webmail-mailbox-properties.c"
	g_object_class->finalize = ___finalize;
	g_object_class->get_property = ___object_get_property;
    {
	g_object_class_override_property (g_object_class,
		PROP_COMPLETE,
		"complete");
	g_object_class_override_property (g_object_class,
		PROP_DEFAULT_NAME,
		"default_name");
    }
}
#undef __GOB_FUNCTION__
#line 81 "src/mn-webmail-mailbox-properties.gob"
static void 
mn_webmail_mailbox_properties_init (MNWebmailMailboxProperties * self G_GNUC_UNUSED)
{
#line 163 "mn-webmail-mailbox-properties.c"
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::init"
	self->_priv = G_TYPE_INSTANCE_GET_PRIVATE(self,MN_TYPE_WEBMAIL_MAILBOX_PROPERTIES,MNWebmailMailboxPropertiesPrivate);
 {
#line 82 "src/mn-webmail-mailbox-properties.gob"

    MNMailboxProperties *properties = MN_MAILBOX_PROPERTIES(self);
    MNAuthenticatedMailboxProperties *auth = MN_AUTHENTICATED_MAILBOX_PROPERTIES(self);
    GtkWidget *folder_vbox;
    GtkWidget *hbox;

    gtk_box_pack_start(GTK_BOX(auth->account_vbox), auth->username_vbox, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(auth->account_vbox), auth->password_vbox, FALSE, FALSE, 0);

    /* translators: header capitalization */
    folder_vbox = mn_mailbox_properties_add_general_section(properties, _("Folder"));

    selfp->inbox_radio = gtk_radio_button_new_with_mnemonic(NULL, _("In_box"));
    gtk_size_group_add_widget(properties->label_size_group, selfp->inbox_radio);

    gtk_box_pack_start(GTK_BOX(folder_vbox), selfp->inbox_radio, FALSE, FALSE, 0);

    selfp->other_radio = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(selfp->inbox_radio), _("_Other:"));
    gtk_size_group_add_widget(properties->label_size_group, selfp->other_radio);

    selfp->folder_entry = gtk_entry_new();
    gtk_widget_set_sensitive(selfp->folder_entry, FALSE);

    hbox = gtk_hbox_new(FALSE, 12);
    gtk_box_pack_start(GTK_BOX(hbox), selfp->other_radio, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), selfp->folder_entry, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(folder_vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show_all(folder_vbox);

    properties->entries = mn_g_slist_append_elements(properties->entries,
						     auth->username_entry,
						     auth->password_entry,
						     selfp->folder_entry,
						     NULL);

    g_signal_connect(selfp->inbox_radio, "toggled", G_CALLBACK(self_radio_toggled_h), self);
    g_signal_connect(selfp->other_radio, "toggled", G_CALLBACK(self_radio_toggled_h), self);

    g_object_connect(auth->username_entry,
		     "swapped-signal::changed", mn_mailbox_properties_notify_complete, self,
		     "swapped-signal::changed", mn_mailbox_properties_notify_default_name, self,
		     NULL);

    g_object_connect(selfp->folder_entry,
		     "swapped-signal::changed", mn_mailbox_properties_notify_complete, self,
		     "swapped-signal::changed", mn_mailbox_properties_notify_default_name, self,
		     NULL);
  
#line 216 "mn-webmail-mailbox-properties.c"
 }
}
#undef __GOB_FUNCTION__

static void
___object_get_property (GObject *object,
	guint property_id,
	GValue *VAL G_GNUC_UNUSED,
	GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::get_property"
{
	MNWebmailMailboxProperties *self G_GNUC_UNUSED;

	self = MN_WEBMAIL_MAILBOX_PROPERTIES (object);

	switch (property_id) {
	case PROP_COMPLETE:
		{
#line 41 "src/mn-webmail-mailbox-properties.gob"

      gboolean complete;

      complete = mn_authenticated_mailbox_properties_is_complete(MN_AUTHENTICATED_MAILBOX_PROPERTIES(self));
      if (complete)
	{
	  gboolean other_active;
	  const char *folder;

	  other_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->other_radio));
	  folder = gtk_entry_get_text(GTK_ENTRY(selfp->folder_entry));

	  if (other_active && ! *folder)
	    complete = FALSE;
	}

      g_value_set_boolean(VAL, complete);
    
#line 254 "mn-webmail-mailbox-properties.c"
		}
		break;
	case PROP_DEFAULT_NAME:
		{
#line 62 "src/mn-webmail-mailbox-properties.gob"

      const char *username;
      gboolean other_active;
      const char *folder;
      MNMailboxClass *class;

      username = gtk_entry_get_text(GTK_ENTRY(MN_AUTHENTICATED_MAILBOX_PROPERTIES(self)->username_entry));
      g_assert(*username != 0);

      other_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->other_radio));
      folder = gtk_entry_get_text(GTK_ENTRY(selfp->folder_entry));

      class = mn_mailbox_get_class_from_name(MN_MAILBOX_PROPERTIES_CLASS(SELF_GET_CLASS(self))->type);
      g_value_take_string(VAL, mn_webmail_mailbox_build_name(MN_WEBMAIL_MAILBOX_CLASS(class),
							     username,
							     other_active ? folder : NULL));
      g_type_class_unref(class);
    
#line 278 "mn-webmail-mailbox-properties.c"
		}
		break;
	default:
/* Apparently in g++ this is needed, glib is b0rk */
#ifndef __PRETTY_FUNCTION__
#  undef G_STRLOC
#  define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__)
#endif
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
#undef __GOB_FUNCTION__



#line 131 "src/mn-webmail-mailbox-properties.gob"
static void 
mn_webmail_mailbox_properties_radio_toggled_h (GtkToggleButton * togglebutton, gpointer user_data)
{
#line 299 "mn-webmail-mailbox-properties.c"
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::radio_toggled_h"
{
#line 133 "src/mn-webmail-mailbox-properties.gob"
	
    Self *self = user_data;

    gtk_widget_set_sensitive(selfp->folder_entry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->other_radio)));

    g_object_notify(G_OBJECT(self), "complete");
    g_object_notify(G_OBJECT(self), "default-name");
  }}
#line 311 "mn-webmail-mailbox-properties.c"
#undef __GOB_FUNCTION__

#line 142 "src/mn-webmail-mailbox-properties.gob"
static void 
___3_mn_webmail_mailbox_properties_set_mailbox (MNMailboxProperties * properties G_GNUC_UNUSED, MNMailbox * mailbox)
#line 317 "mn-webmail-mailbox-properties.c"
#define PARENT_HANDLER(___properties,___mailbox) \
	{ if(MN_MAILBOX_PROPERTIES_CLASS(parent_class)->set_mailbox) \
		(* MN_MAILBOX_PROPERTIES_CLASS(parent_class)->set_mailbox)(___properties,___mailbox); }
{
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::set_mailbox"
{
#line 144 "src/mn-webmail-mailbox-properties.gob"
	
    Self *self = SELF(properties);
    MNWebmailMailbox *webmail_mailbox = MN_WEBMAIL_MAILBOX(mailbox);

    PARENT_HANDLER(properties, mailbox);

    if (! strcmp(webmail_mailbox->folder, "Inbox"))
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selfp->inbox_radio), TRUE);
    else
      {
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selfp->other_radio), TRUE);
	gtk_entry_set_text(GTK_ENTRY(selfp->folder_entry), webmail_mailbox->folder);
      }
  }}
#line 339 "mn-webmail-mailbox-properties.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 159 "src/mn-webmail-mailbox-properties.gob"
static MNMailbox * 
___4_mn_webmail_mailbox_properties_get_mailbox (MNMailboxProperties * properties G_GNUC_UNUSED)
#line 346 "mn-webmail-mailbox-properties.c"
#define PARENT_HANDLER(___properties) \
	((MN_MAILBOX_PROPERTIES_CLASS(parent_class)->get_mailbox)? \
		(* MN_MAILBOX_PROPERTIES_CLASS(parent_class)->get_mailbox)(___properties): \
		((MNMailbox * )0))
{
#define __GOB_FUNCTION__ "MN:Webmail:Mailbox:Properties::get_mailbox"
{
#line 161 "src/mn-webmail-mailbox-properties.gob"
	
    Self *self = SELF(properties);
    MNMailbox *mailbox;

    mailbox = PARENT_HANDLER(properties);

    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selfp->other_radio)))
      g_object_set(mailbox, MN_WEBMAIL_MAILBOX_PROP_FOLDER((char *) gtk_entry_get_text(GTK_ENTRY(selfp->folder_entry))), NULL);

    return mailbox;
  }}
#line 366 "mn-webmail-mailbox-properties.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER
