/* 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-folder-tree-server.h"

#include "mn-evolution-folder-tree-server-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 24 "src/mn-evolution-folder-tree-server.gob"

#include <dbus/dbus.h>
#include <mail/mail-component.h>
#include <mail/em-folder-tree.h>
#include "mn-evolution-plugin.h"
#include "mn-evolution.h"

#include "mn-evolution-folder-tree-server-dbus.h"

#line 36 "mn-evolution-folder-tree-server.c"
/* self casting macros */
#define SELF(x) MN_EVOLUTION_FOLDER_TREE_SERVER(x)
#define SELF_CONST(x) MN_EVOLUTION_FOLDER_TREE_SERVER_CONST(x)
#define IS_SELF(x) MN_IS_EVOLUTION_FOLDER_TREE_SERVER(x)
#define TYPE_SELF MN_TYPE_EVOLUTION_FOLDER_TREE_SERVER
#define SELF_CLASS(x) MN_EVOLUTION_FOLDER_TREE_SERVER_CLASS(x)

#define SELF_GET_CLASS(x) MN_EVOLUTION_FOLDER_TREE_SERVER_GET_CLASS(x)

/* self typedefs */
typedef MNEvolutionFolderTreeServer Self;
typedef MNEvolutionFolderTreeServerClass SelfClass;

/* here are local prototypes */
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
#line 0 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_init (MNEvolutionFolderTreeServer * o);
#line 55 "mn-evolution-folder-tree-server.c"
#line 49 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_folder_selected (MNEvolutionFolderTreeServer * self, const char * uri);
#line 58 "mn-evolution-folder-tree-server.c"
#line 52 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_folder_activated (MNEvolutionFolderTreeServer * self);
#line 61 "mn-evolution-folder-tree-server.c"
#line 55 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_class_init (MNEvolutionFolderTreeServerClass * class);
#line 64 "mn-evolution-folder-tree-server.c"
#line 60 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_constructor (MNEvolutionFolderTreeServer * self);
#line 67 "mn-evolution-folder-tree-server.c"
#line 79 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_finalize (MNEvolutionFolderTreeServer * self);
#line 70 "mn-evolution-folder-tree-server.c"
#line 84 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_plug_destroy_h (GtkObject * object, gpointer user_data);
#line 73 "mn-evolution-folder-tree-server.c"
#line 104 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_selected_h (EMFolderTree * tree, const char * full_name, const char * uri, guint32 flags, gpointer user_data);
#line 76 "mn-evolution-folder-tree-server.c"
#line 115 "src/mn-evolution-folder-tree-server.gob"
static void mn_evolution_folder_tree_server_activated_h (EMFolderTree * tree, const char * full_name, const char * uri, gpointer user_data);
#line 79 "mn-evolution-folder-tree-server.c"

/*
 * Signal connection wrapper macro shortcuts
 */
#define self_connect__folder_selected(object,func,data)	mn_evolution_folder_tree_server_connect__folder_selected((object),(func),(data))
#define self_connect_after__folder_selected(object,func,data)	mn_evolution_folder_tree_server_connect_after__folder_selected((object),(func),(data))
#define self_connect_data__folder_selected(object,func,data,destroy_data,flags)	mn_evolution_folder_tree_server_connect_data__folder_selected((object),(func),(data),(destroy_data),(flags))
#define self_connect__folder_activated(object,func,data)	mn_evolution_folder_tree_server_connect__folder_activated((object),(func),(data))
#define self_connect_after__folder_activated(object,func,data)	mn_evolution_folder_tree_server_connect_after__folder_activated((object),(func),(data))
#define self_connect_data__folder_activated(object,func,data,destroy_data,flags)	mn_evolution_folder_tree_server_connect_data__folder_activated((object),(func),(data),(destroy_data),(flags))

typedef void  (*___Sig1) (MNEvolutionFolderTreeServer *, gchar *, gpointer);

static void
___marshal_Sig1 (GClosure *closure,
	GValue *return_value G_GNUC_UNUSED,
	guint n_param_values,
	const GValue *param_values,
	gpointer invocation_hint G_GNUC_UNUSED,
	gpointer marshal_data)
{
	register ___Sig1 callback;
	register GCClosure *cc = (GCClosure*) closure;
	register gpointer data1, data2;

	g_return_if_fail (n_param_values == 2);

	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = g_value_peek_pointer (param_values + 0);
	} else {
		data1 = g_value_peek_pointer (param_values + 0);
		data2 = closure->data;
	}

	callback = (___Sig1) (marshal_data != NULL ? marshal_data : cc->callback);

	callback ((MNEvolutionFolderTreeServer *)data1,
		(gchar *) g_value_get_string (param_values + 1),
		data2);
}


enum {
	FOLDER_SELECTED_SIGNAL,
	FOLDER_ACTIVATED_SIGNAL,
	LAST_SIGNAL
};

enum {
	PROP_0,
	PROP_ID,
	PROP_URI
};

static guint object_signals[LAST_SIGNAL] = {0};

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

/* Short form macros */
#define self_folder_selected mn_evolution_folder_tree_server_folder_selected
#define self_folder_activated mn_evolution_folder_tree_server_folder_activated
#define self_plug_destroy_h mn_evolution_folder_tree_server_plug_destroy_h
#define self_selected_h mn_evolution_folder_tree_server_selected_h
#define self_activated_h mn_evolution_folder_tree_server_activated_h
#define self_new mn_evolution_folder_tree_server_new
GType
mn_evolution_folder_tree_server_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (MNEvolutionFolderTreeServerClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mn_evolution_folder_tree_server_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (MNEvolutionFolderTreeServer),
			0 /* n_preallocs */,
			(GInstanceInitFunc) mn_evolution_folder_tree_server_init,
			NULL
		};

		type = g_type_register_static (G_TYPE_OBJECT, "MNEvolutionFolderTreeServer", &info, (GTypeFlags)0);
	}

	return type;
}

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

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


static GObject *
___constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
{
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::constructor"
	GObject *obj_self;
	MNEvolutionFolderTreeServer *self;
	obj_self = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_properties);
	self = MN_EVOLUTION_FOLDER_TREE_SERVER (obj_self);
#line 60 "src/mn-evolution-folder-tree-server.gob"
	mn_evolution_folder_tree_server_constructor (self);
#line 200 "mn-evolution-folder-tree-server.c"
	return obj_self;
}
#undef __GOB_FUNCTION__


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::finalize"
	MNEvolutionFolderTreeServer *self G_GNUC_UNUSED = MN_EVOLUTION_FOLDER_TREE_SERVER (obj_self);
	gpointer priv G_GNUC_UNUSED = self->_priv;
#line 79 "src/mn-evolution-folder-tree-server.gob"
	mn_evolution_folder_tree_server_finalize (self);
#line 214 "mn-evolution-folder-tree-server.c"
	if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
}
#undef __GOB_FUNCTION__

static void 
mn_evolution_folder_tree_server_init (MNEvolutionFolderTreeServer * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::init"
	o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,MN_TYPE_EVOLUTION_FOLDER_TREE_SERVER,MNEvolutionFolderTreeServerPrivate);
}
#undef __GOB_FUNCTION__
#line 55 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_class_init (MNEvolutionFolderTreeServerClass * class G_GNUC_UNUSED)
{
#line 231 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) class;

	g_type_class_add_private(class,sizeof(MNEvolutionFolderTreeServerPrivate));

	parent_class = g_type_class_ref (G_TYPE_OBJECT);

	object_signals[FOLDER_SELECTED_SIGNAL] =
		g_signal_new ("folder_selected",
			G_TYPE_FROM_CLASS (g_object_class),
			(GSignalFlags)(G_SIGNAL_RUN_LAST),
			G_STRUCT_OFFSET (MNEvolutionFolderTreeServerClass, folder_selected),
			NULL, NULL,
			___marshal_Sig1,
			G_TYPE_NONE, 1,
			G_TYPE_STRING);
	if ___GOB_UNLIKELY(sizeof(const char * ) != sizeof(gchar *) || parent_class == NULL /* avoid warning */) {
		g_error("src/mn-evolution-folder-tree-server.gob line 49: Type mismatch of \"folder_selected\" signal signature");
	}
	object_signals[FOLDER_ACTIVATED_SIGNAL] =
		g_signal_new ("folder_activated",
			G_TYPE_FROM_CLASS (g_object_class),
			(GSignalFlags)(G_SIGNAL_RUN_LAST),
			G_STRUCT_OFFSET (MNEvolutionFolderTreeServerClass, folder_activated),
			NULL, NULL,
			g_cclosure_marshal_VOID__VOID,
			G_TYPE_NONE, 0);

	class->folder_selected = NULL;
	class->folder_activated = NULL;
	g_object_class->constructor = ___constructor;
	g_object_class->finalize = ___finalize;
	g_object_class->get_property = ___object_get_property;
	g_object_class->set_property = ___object_set_property;
    {
	GParamSpec   *param_spec;

	param_spec = g_param_spec_uint
		("id" /* name */,
		 NULL /* nick */,
		 NULL /* blurb */,
		 0 /* minimum */,
		 G_MAXUINT /* maximum */,
		 0 /* default_value */,
		 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (g_object_class,
		PROP_ID,
		param_spec);
	param_spec = g_param_spec_string
		("uri" /* name */,
		 NULL /* nick */,
		 NULL /* blurb */,
		 NULL /* default_value */,
		 (GParamFlags)(G_PARAM_WRITABLE));
	g_object_class_install_property (g_object_class,
		PROP_URI,
		param_spec);
    }
 {
#line 56 "src/mn-evolution-folder-tree-server.gob"

    dbus_g_object_type_install_info(TYPE_SELF, &dbus_glib_mn_evolution_folder_tree_server_object_info);
  
#line 295 "mn-evolution-folder-tree-server.c"
 }
}
#undef __GOB_FUNCTION__

static void
___object_set_property (GObject *object,
	guint property_id,
	const GValue *VAL G_GNUC_UNUSED,
	GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::set_property"
{
	MNEvolutionFolderTreeServer *self G_GNUC_UNUSED;

	self = MN_EVOLUTION_FOLDER_TREE_SERVER (object);

	switch (property_id) {
	case PROP_ID:
		{
#line 38 "src/mn-evolution-folder-tree-server.gob"
self->_priv->id = g_value_get_uint (VAL);
#line 316 "mn-evolution-folder-tree-server.c"
		}
		break;
	case PROP_URI:
		{
#line 45 "src/mn-evolution-folder-tree-server.gob"

      em_folder_tree_set_selected(EM_FOLDER_TREE(selfp->tree), g_value_get_string(VAL), FALSE);
    
#line 325 "mn-evolution-folder-tree-server.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__

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:Folder:Tree:Server::get_property"
{
	MNEvolutionFolderTreeServer *self G_GNUC_UNUSED;

	self = MN_EVOLUTION_FOLDER_TREE_SERVER (object);

	switch (property_id) {
	case PROP_ID:
		{
#line 38 "src/mn-evolution-folder-tree-server.gob"
g_value_set_uint (VAL, self->_priv->id);
#line 356 "mn-evolution-folder-tree-server.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 49 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_folder_selected (MNEvolutionFolderTreeServer * self, const char * uri)
{
#line 376 "mn-evolution-folder-tree-server.c"
	GValue ___param_values[2];
	GValue ___return_val;

memset (&___return_val, 0, sizeof (___return_val));
memset (&___param_values, 0, sizeof (___param_values));

#line 49 "src/mn-evolution-folder-tree-server.gob"
	g_return_if_fail (self != NULL);
#line 49 "src/mn-evolution-folder-tree-server.gob"
	g_return_if_fail (MN_IS_EVOLUTION_FOLDER_TREE_SERVER (self));
#line 387 "mn-evolution-folder-tree-server.c"

	___param_values[0].g_type = 0;
	g_value_init (&___param_values[0], G_TYPE_FROM_INSTANCE (self));
	g_value_set_instance (&___param_values[0], (gpointer) self);

	___param_values[1].g_type = 0;
	g_value_init (&___param_values[1], G_TYPE_STRING);
	g_value_set_static_string (&___param_values[1], (gchar *) uri);

	g_signal_emitv (___param_values,
		object_signals[FOLDER_SELECTED_SIGNAL],
		0 /* detail */,
		&___return_val);

	g_value_unset (&___param_values[0]);
	g_value_unset (&___param_values[1]);
}

#line 52 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_folder_activated (MNEvolutionFolderTreeServer * self)
{
#line 410 "mn-evolution-folder-tree-server.c"
	GValue ___param_values[1];
	GValue ___return_val;

memset (&___return_val, 0, sizeof (___return_val));
memset (&___param_values, 0, sizeof (___param_values));

#line 52 "src/mn-evolution-folder-tree-server.gob"
	g_return_if_fail (self != NULL);
#line 52 "src/mn-evolution-folder-tree-server.gob"
	g_return_if_fail (MN_IS_EVOLUTION_FOLDER_TREE_SERVER (self));
#line 421 "mn-evolution-folder-tree-server.c"

	___param_values[0].g_type = 0;
	g_value_init (&___param_values[0], G_TYPE_FROM_INSTANCE (self));
	g_value_set_instance (&___param_values[0], (gpointer) self);

	g_signal_emitv (___param_values,
		object_signals[FOLDER_ACTIVATED_SIGNAL],
		0 /* detail */,
		&___return_val);

	g_value_unset (&___param_values[0]);
}


#line 60 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_constructor (MNEvolutionFolderTreeServer * self)
{
#line 440 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::constructor"
{
#line 61 "src/mn-evolution-folder-tree-server.gob"
	
    EMFolderTreeModel *model;

    model = mail_component_peek_tree_model(mail_component_peek());
    selfp->tree = em_folder_tree_new_with_model(model);

    selfp->plug = gtk_plug_new((GdkNativeWindow) selfp->id);
    gtk_container_add(GTK_CONTAINER(selfp->plug), selfp->tree);
    gtk_widget_show_all(selfp->plug);

    g_signal_connect(selfp->plug, "destroy", G_CALLBACK(self_plug_destroy_h), self);

    g_object_connect(selfp->tree,
		     "signal::folder-selected", self_selected_h, self,
		     "signal::folder-activated", self_activated_h, self,
		     NULL);
  }}
#line 461 "mn-evolution-folder-tree-server.c"
#undef __GOB_FUNCTION__

#line 79 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_finalize (MNEvolutionFolderTreeServer * self)
{
#line 468 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::finalize"
{
#line 80 "src/mn-evolution-folder-tree-server.gob"
	
    g_signal_handlers_disconnect_by_func(selfp->plug, self_plug_destroy_h, self);
  }}
#line 475 "mn-evolution-folder-tree-server.c"
#undef __GOB_FUNCTION__

#line 84 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_plug_destroy_h (GtkObject * object, gpointer user_data)
{
#line 482 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::plug_destroy_h"
{
#line 86 "src/mn-evolution-folder-tree-server.gob"
	
    Self *self = user_data;
    char *service;
    GError *err = NULL;

    /* the MN side is gone: unregister and unreference the server */

    service = g_strdup_printf(MN_EVOLUTION_FOLDER_TREE_SERVER_SERVICE, selfp->id);
    if (! mn_evolution_plugin_unregister_server(service, &err))
      {
	g_warning("unable to unregister D-Bus service \"%s\": %s", service, err->message);
	g_error_free(err);
      }
    g_free(service);

    g_object_unref(self);
  }}
#line 503 "mn-evolution-folder-tree-server.c"
#undef __GOB_FUNCTION__

#line 104 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_selected_h (EMFolderTree * tree, const char * full_name, const char * uri, guint32 flags, gpointer user_data)
{
#line 510 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::selected_h"
{
#line 110 "src/mn-evolution-folder-tree-server.gob"
	
    Self *self = user_data;
    self_folder_selected(self, uri);
  }}
#line 518 "mn-evolution-folder-tree-server.c"
#undef __GOB_FUNCTION__

#line 115 "src/mn-evolution-folder-tree-server.gob"
static void 
mn_evolution_folder_tree_server_activated_h (EMFolderTree * tree, const char * full_name, const char * uri, gpointer user_data)
{
#line 525 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::activated_h"
{
#line 120 "src/mn-evolution-folder-tree-server.gob"
	
    Self *self = user_data;
    self_folder_activated(self);
  }}
#line 533 "mn-evolution-folder-tree-server.c"
#undef __GOB_FUNCTION__

#line 125 "src/mn-evolution-folder-tree-server.gob"
MNEvolutionFolderTreeServer * 
mn_evolution_folder_tree_server_new (guint32 id)
{
#line 540 "mn-evolution-folder-tree-server.c"
#define __GOB_FUNCTION__ "MN:Evolution:Folder:Tree:Server::new"
{
#line 127 "src/mn-evolution-folder-tree-server.gob"
	
    return GET_NEW_VARG(MN_EVOLUTION_FOLDER_TREE_SERVER_PROP_ID(id), NULL);
  }}
#line 547 "mn-evolution-folder-tree-server.c"
#undef __GOB_FUNCTION__
