/* 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-evolution-mailbox-properties.h"

#include "mn-evolution-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 28 "src/mn-evolution-mailbox-properties.gob"

#include <glib/gi18n.h>
#include "mn-evolution-mailbox.h"
#include "mn-stock.h"
#include "mn-mailbox-properties-private.h"
#include "mn-shell.h"
#include "mn-evolution-client-dbus.h"
#include "mn-util.h"
#include "mn-evolution-folder-tree-client.h"

#line 37 "mn-evolution-mailbox-properties.c"
/* self casting macros */
#define SELF(x) MN_EVOLUTION_MAILBOX_PROPERTIES(x)
#define SELF_CONST(x) MN_EVOLUTION_MAILBOX_PROPERTIES_CONST(x)
#define IS_SELF(x) MN_IS_EVOLUTION_MAILBOX_PROPERTIES(x)
#define TYPE_SELF MN_TYPE_EVOLUTION_MAILBOX_PROPERTIES
#define SELF_CLASS(x) MN_EVOLUTION_MAILBOX_PROPERTIES_CLASS(x)

#define SELF_GET_CLASS(x) MN_EVOLUTION_MAILBOX_PROPERTIES_GET_CLASS(x)

/* self typedefs */
typedef MNEvolutionMailboxProperties Self;
typedef MNEvolutionMailboxPropertiesClass SelfClass;

/* here are local prototypes */
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
#line 55 "src/mn-evolution-mailbox-properties.gob"
static void mn_evolution_mailbox_properties_class_init (MNEvolutionMailboxPropertiesClass * class);
#line 55 "mn-evolution-mailbox-properties.c"
#line 65 "src/mn-evolution-mailbox-properties.gob"
static void mn_evolution_mailbox_properties_init (MNEvolutionMailboxProperties * self);
#line 58 "mn-evolution-mailbox-properties.c"
#line 84 "src/mn-evolution-mailbox-properties.gob"
static void mn_evolution_mailbox_properties_notify_selected_uri_h (GObject * object, GParamSpec * pspec, gpointer user_data);
#line 61 "mn-evolution-mailbox-properties.c"
#line 102 "src/mn-evolution-mailbox-properties.gob"
static void mn_evolution_mailbox_properties_folder_activated_h (MNEvolutionFolderTreeClient * client, gpointer user_data);
#line 64 "mn-evolution-mailbox-properties.c"
#line 110 "src/mn-evolution-mailbox-properties.gob"
static void ___5_mn_evolution_mailbox_properties_set_mailbox (MNMailboxProperties * properties, MNMailbox * mailbox);
#line 67 "mn-evolution-mailbox-properties.c"
#line 122 "src/mn-evolution-mailbox-properties.gob"
static MNMailbox * ___6_mn_evolution_mailbox_properties_get_mailbox (MNMailboxProperties * properties);
#line 70 "mn-evolution-mailbox-properties.c"

enum {
	PROP_0,
	PROP_COMPLETE,
	PROP_DEFAULT_NAME
};

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

/* Short form macros */
#define self_notify_selected_uri_h mn_evolution_mailbox_properties_notify_selected_uri_h
#define self_folder_activated_h mn_evolution_mailbox_properties_folder_activated_h
GType
mn_evolution_mailbox_properties_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (MNEvolutionMailboxPropertiesClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mn_evolution_mailbox_properties_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (MNEvolutionMailboxProperties),
			0 /* n_preallocs */,
			(GInstanceInitFunc) mn_evolution_mailbox_properties_init,
			NULL
		};

		type = g_type_register_static (MN_TYPE_MAILBOX_PROPERTIES, "MNEvolutionMailboxProperties", &info, (GTypeFlags)0);
	}

	return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "MN:Evolution:Mailbox:Properties::finalize"
	MNEvolutionMailboxProperties *self G_GNUC_UNUSED = MN_EVOLUTION_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);
#line 43 "src/mn-evolution-mailbox-properties.gob"
	if(self->_priv->name) { g_free ((gpointer) self->_priv->name); self->_priv->name = NULL; }
#line 137 "mn-evolution-mailbox-properties.c"
}
#undef __GOB_FUNCTION__

#line 55 "src/mn-evolution-mailbox-properties.gob"
static void 
mn_evolution_mailbox_properties_class_init (MNEvolutionMailboxPropertiesClass * class G_GNUC_UNUSED)
{
#line 145 "mn-evolution-mailbox-properties.c"
#define __GOB_FUNCTION__ "MN:Evolution:Mailbox:Properties::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) class;
	MNMailboxPropertiesClass *mn_mailbox_properties_class = (MNMailboxPropertiesClass *)class;

	g_type_class_add_private(class,sizeof(MNEvolutionMailboxPropertiesPrivate));

	parent_class = g_type_class_ref (MN_TYPE_MAILBOX_PROPERTIES);

#line 110 "src/mn-evolution-mailbox-properties.gob"
	mn_mailbox_properties_class->set_mailbox = ___5_mn_evolution_mailbox_properties_set_mailbox;
#line 122 "src/mn-evolution-mailbox-properties.gob"
	mn_mailbox_properties_class->get_mailbox = ___6_mn_evolution_mailbox_properties_get_mailbox;
#line 158 "mn-evolution-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");
    }
 {
#line 56 "src/mn-evolution-mailbox-properties.gob"

    MNMailboxPropertiesClass *p_class = MN_MAILBOX_PROPERTIES_CLASS(class);

    p_class->type = "evolution";
    p_class->stock_id = MN_STOCK_EVOLUTION_MAILBOX;
    p_class->combo_label = "Evolution";
    p_class->enable_check_delay = FALSE;
  
#line 179 "mn-evolution-mailbox-properties.c"
 }
}
#undef __GOB_FUNCTION__
#line 65 "src/mn-evolution-mailbox-properties.gob"
static void 
mn_evolution_mailbox_properties_init (MNEvolutionMailboxProperties * self G_GNUC_UNUSED)
{
#line 187 "mn-evolution-mailbox-properties.c"
#define __GOB_FUNCTION__ "MN:Evolution:Mailbox:Properties::init"
	self->_priv = G_TYPE_INSTANCE_GET_PRIVATE(self,MN_TYPE_EVOLUTION_MAILBOX_PROPERTIES,MNEvolutionMailboxPropertiesPrivate);
 {
#line 66 "src/mn-evolution-mailbox-properties.gob"

    MNMailboxProperties *properties = MN_MAILBOX_PROPERTIES(self);
    GtkWidget *vbox;

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

    selfp->tree = mn_evolution_folder_tree_client_new();
    gtk_box_pack_start(GTK_BOX(vbox), selfp->tree, TRUE, TRUE, 0);
    gtk_widget_show(selfp->tree);

    g_object_connect(selfp->tree,
		     "swapped-signal::notify::connected", mn_mailbox_properties_notify_complete, self,
		     "signal::notify::selected-uri", self_notify_selected_uri_h, self,
		     "signal::folder-activated", self_folder_activated_h, self,
		     NULL);
  
#line 209 "mn-evolution-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:Evolution:Mailbox:Properties::get_property"
{
	MNEvolutionMailboxProperties *self G_GNUC_UNUSED;

	self = MN_EVOLUTION_MAILBOX_PROPERTIES (object);

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

      MNEvolutionFolderTreeClient *tree = MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree);
      g_value_set_boolean(VAL, mn_evolution_folder_tree_client_get_connected(tree) && tree->selected_uri != NULL);
    
#line 233 "mn-evolution-mailbox-properties.c"
		}
		break;
	case PROP_DEFAULT_NAME:
		{
#line 53 "src/mn-evolution-mailbox-properties.gob"
 g_value_set_string(VAL, selfp->name); 
#line 240 "mn-evolution-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 84 "src/mn-evolution-mailbox-properties.gob"
static void 
mn_evolution_mailbox_properties_notify_selected_uri_h (GObject * object, GParamSpec * pspec, gpointer user_data)
{
#line 261 "mn-evolution-mailbox-properties.c"
#define __GOB_FUNCTION__ "MN:Evolution:Mailbox:Properties::notify_selected_uri_h"
{
#line 86 "src/mn-evolution-mailbox-properties.gob"
	
    Self *self = user_data;
    MNEvolutionClient *client;
    char *name = NULL;

    client = mn_evolution_client_get();
    if (client->proxy)
      org_gnome_MailNotification_Evolution_get_folder_name(client->proxy, MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree)->selected_uri, &name, NULL);

    g_free(selfp->name);
    selfp->name = name;

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

#line 102 "src/mn-evolution-mailbox-properties.gob"
static void 
mn_evolution_mailbox_properties_folder_activated_h (MNEvolutionFolderTreeClient * client, gpointer user_data)
{
#line 287 "mn-evolution-mailbox-properties.c"
#define __GOB_FUNCTION__ "MN:Evolution:Mailbox:Properties::folder_activated_h"
{
#line 104 "src/mn-evolution-mailbox-properties.gob"
	
    Self *self = user_data;

    gtk_window_activate_default(GTK_WINDOW(MN_MAILBOX_PROPERTIES(self)->dialog));
  }}
#line 296 "mn-evolution-mailbox-properties.c"
#undef __GOB_FUNCTION__

#line 110 "src/mn-evolution-mailbox-properties.gob"
static void 
___5_mn_evolution_mailbox_properties_set_mailbox (MNMailboxProperties * properties G_GNUC_UNUSED, MNMailbox * mailbox)
#line 302 "mn-evolution-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:Evolution:Mailbox:Properties::set_mailbox"
{
#line 112 "src/mn-evolution-mailbox-properties.gob"
	
    Self *self = SELF(properties);
    MNEvolutionMailbox *evolution_mailbox = MN_EVOLUTION_MAILBOX(mailbox);

    mn_evolution_folder_tree_client_set_selected_uri(MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree), evolution_mailbox->uri);

    g_free(selfp->name);
    selfp->name = g_strdup(evolution_mailbox->folder_name);
  }}
#line 319 "mn-evolution-mailbox-properties.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 122 "src/mn-evolution-mailbox-properties.gob"
static MNMailbox * 
___6_mn_evolution_mailbox_properties_get_mailbox (MNMailboxProperties * properties G_GNUC_UNUSED)
#line 326 "mn-evolution-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:Evolution:Mailbox:Properties::get_mailbox"
{
#line 124 "src/mn-evolution-mailbox-properties.gob"
	
    Self *self = SELF(properties);
    MNMailbox *mailbox;

    mailbox = PARENT_HANDLER(properties);

    g_object_set(mailbox,
		 MN_EVOLUTION_MAILBOX_PROP_URI(MN_EVOLUTION_FOLDER_TREE_CLIENT(selfp->tree)->selected_uri),
		 MN_EVOLUTION_MAILBOX_PROP_FOLDER_NAME(selfp->name),
		 NULL);

    return mailbox;
  }}
#line 348 "mn-evolution-mailbox-properties.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER
