/* Generated by GOB (v2.0.20)   (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 20

#define selfp (self->_priv)

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

#include "gmpc-mpddata-model-sort.h"

#include "gmpc-mpddata-model-sort-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 */
/* self casting macros */
#define SELF(x) GMPC_MPDDATA_MODEL_SORT(x)
#define SELF_CONST(x) GMPC_MPDDATA_MODEL_SORT_CONST(x)
#define IS_SELF(x) GMPC_IS_MPDDATA_MODEL_SORT(x)
#define TYPE_SELF GMPC_TYPE_MPDDATA_MODEL_SORT
#define SELF_CLASS(x) GMPC_MPDDATA_MODEL_SORT_CLASS(x)

#define SELF_GET_CLASS(x) GMPC_MPDDATA_MODEL_SORT_GET_CLASS(x)

/* self typedefs */
typedef GmpcMpdDataModelSort Self;
typedef GmpcMpdDataModelSortClass 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);
static void gmpc_mpddata_model_sort_init (GmpcMpdDataModelSort * o) G_GNUC_UNUSED;
static void gmpc_mpddata_model_sort_class_init (GmpcMpdDataModelSortClass * c) G_GNUC_UNUSED;
#line 49 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean gmpc_mpddata_model_sort_row_draggable (GtkTreeDragSource * drag_source, GtkTreePath * path) G_GNUC_UNUSED;
#line 45 "gmpc-mpddata-model-sort.c"
#line 60 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean gmpc_mpddata_model_sort_drag_data_get (GtkTreeDragSource * drag_source, GtkTreePath * path, GtkSelectionData * selection_data) G_GNUC_UNUSED;
#line 48 "gmpc-mpddata-model-sort.c"
#line 66 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean gmpc_mpddata_model_sort_drag_data_delete (GtkTreeDragSource * drag_source, GtkTreePath * path) G_GNUC_UNUSED;
#line 51 "gmpc-mpddata-model-sort.c"
#line 73 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean gmpc_mpddata_model_sort_drag_data_received (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data) G_GNUC_UNUSED;
#line 54 "gmpc-mpddata-model-sort.c"
#line 109 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean gmpc_mpddata_model_sort_row_drop_possible (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data) G_GNUC_UNUSED;
#line 57 "gmpc-mpddata-model-sort.c"

enum {
	PROP_0,
	PROP_PLAYLIST
};

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

/* Short form macros */
#define self_get_playlist gmpc_mpddata_model_sort_get_playlist
#define self_set_playlist gmpc_mpddata_model_sort_set_playlist
#define self_row_draggable gmpc_mpddata_model_sort_row_draggable
#define self_drag_data_get gmpc_mpddata_model_sort_drag_data_get
#define self_drag_data_delete gmpc_mpddata_model_sort_drag_data_delete
#define self_drag_data_received gmpc_mpddata_model_sort_drag_data_received
#define self_row_drop_possible gmpc_mpddata_model_sort_row_drop_possible
#define self_new gmpc_mpddata_model_sort_new


static void
___Gtk_Tree_Drag_Dest_init (GtkTreeDragDestIface *iface)
{
#line 73 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	iface->drag_data_received = self_drag_data_received;
#line 109 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	iface->row_drop_possible = self_row_drop_possible;
#line 85 "gmpc-mpddata-model-sort.c"
}


static void
___Gtk_Tree_Drag_Source_init (GtkTreeDragSourceIface *iface)
{
#line 49 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	iface->row_draggable = self_row_draggable;
#line 60 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	iface->drag_data_get = self_drag_data_get;
#line 66 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	iface->drag_data_delete = self_drag_data_delete;
#line 98 "gmpc-mpddata-model-sort.c"
}

GType
gmpc_mpddata_model_sort_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (GmpcMpdDataModelSortClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gmpc_mpddata_model_sort_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (GmpcMpdDataModelSort),
			0 /* n_preallocs */,
			(GInstanceInitFunc) gmpc_mpddata_model_sort_init,
			NULL
		};

		static const GInterfaceInfo Gtk_Tree_Drag_Dest_info = {
			(GInterfaceInitFunc) ___Gtk_Tree_Drag_Dest_init,
			NULL,
			NULL
		};

		static const GInterfaceInfo Gtk_Tree_Drag_Source_info = {
			(GInterfaceInitFunc) ___Gtk_Tree_Drag_Source_init,
			NULL,
			NULL
		};

		type = g_type_register_static (GMPC_TYPE_MPDDATA_MODEL, "GmpcMpdDataModelSort", &info, (GTypeFlags)0);
		g_type_add_interface_static (type,
			GTK_TYPE_TREE_DRAG_DEST,
			&Gtk_Tree_Drag_Dest_info);
		g_type_add_interface_static (type,
			GTK_TYPE_TREE_DRAG_SOURCE,
			&Gtk_Tree_Drag_Source_info);
	}

	return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::finalize"
	GmpcMpdDataModelSort *self G_GNUC_UNUSED = GMPC_MPDDATA_MODEL_SORT (obj_self);
#line 38 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	if(self->playlist) { g_free ((gpointer) self->playlist); self->playlist = NULL; }
#line 169 "gmpc-mpddata-model-sort.c"
	if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
}
#undef __GOB_FUNCTION__

static void 
gmpc_mpddata_model_sort_init (GmpcMpdDataModelSort * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::init"
#line 38 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	o->playlist = NULL;
#line 181 "gmpc-mpddata-model-sort.c"
}
#undef __GOB_FUNCTION__
static void 
gmpc_mpddata_model_sort_class_init (GmpcMpdDataModelSortClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;

	parent_class = g_type_class_ref (GMPC_TYPE_MPDDATA_MODEL);

	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_string
		("playlist" /* name */,
		 "playlist" /* nick */,
		 "The current playlist name" /* blurb */,
		 NULL /* default_value */,
		 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (g_object_class,
		PROP_PLAYLIST,
		param_spec);
    }
}
#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__ "Gmpc:MpdData:Model:Sort::set_property"
{
	GmpcMpdDataModelSort *self G_GNUC_UNUSED;

	self = GMPC_MPDDATA_MODEL_SORT (object);

	switch (property_id) {
	case PROP_PLAYLIST:
		{
#line 40 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
{ char *old = self->playlist; self->playlist = g_value_dup_string (VAL); g_free (old); }
#line 227 "gmpc-mpddata-model-sort.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__ "Gmpc:MpdData:Model:Sort::get_property"
{
	GmpcMpdDataModelSort *self G_GNUC_UNUSED;

	self = GMPC_MPDDATA_MODEL_SORT (object);

	switch (property_id) {
	case PROP_PLAYLIST:
		{
#line 40 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
g_value_set_string (VAL, self->playlist);
#line 258 "gmpc-mpddata-model-sort.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 40 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
gchar * 
gmpc_mpddata_model_sort_get_playlist (GmpcMpdDataModelSort * self)
{
#line 279 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::get_playlist"
{
#line 40 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
		gchar* val; g_object_get (G_OBJECT (self), "playlist", &val, NULL); return val;
}}
#line 285 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 40 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
void 
gmpc_mpddata_model_sort_set_playlist (GmpcMpdDataModelSort * self, gchar * val)
{
#line 292 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::set_playlist"
{
#line 40 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
		g_object_set (G_OBJECT (self), "playlist", val, NULL);
}}
#line 298 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 49 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean 
gmpc_mpddata_model_sort_row_draggable (GtkTreeDragSource * drag_source, GtkTreePath * path)
{
#line 305 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::row_draggable"
{
#line 51 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	
			if(mpd_server_check_version(connection, 0,13,0))
			{
				return TRUE;
			}
			return FALSE;
		}}
#line 316 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 60 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean 
gmpc_mpddata_model_sort_drag_data_get (GtkTreeDragSource * drag_source, GtkTreePath * path, GtkSelectionData * selection_data)
{
#line 323 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::drag_data_get"
{
#line 62 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	
			return FALSE;
		}}
#line 330 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 66 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean 
gmpc_mpddata_model_sort_drag_data_delete (GtkTreeDragSource * drag_source, GtkTreePath * path)
{
#line 337 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::drag_data_delete"
{
#line 68 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	
			return TRUE;
		}}
#line 344 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 73 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean 
gmpc_mpddata_model_sort_drag_data_received (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data)
{
#line 351 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::drag_data_received"
{
#line 77 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	
			GtkTreePath *path=NULL;
			GtkTreeModel *model=NULL;
			gint *ind = NULL, *ind2 = NULL;
            printf("Got drop\n");
			if(dest == NULL || !gtk_tree_get_row_drag_data(selection_data, &model, &path))
			{
				return FALSE;
			}
			if(GMPC_MPDDATA_MODEL(model)->num_rows < 2)
			{
				gtk_tree_path_free(path);
				return FALSE;
			}
			ind = gtk_tree_path_get_indices(dest);
			ind2 = gtk_tree_path_get_indices(path);
			if(ind && ind2 && GMPC_MPDDATA_MODEL_SORT(model)->playlist)
			{
				MpdData *data = NULL;
				int original = ind2[0];
				int destination = ind[0];
				/*		if(destination >0 && ind[1] != '\0') destination--; */
				if(destination > original) destination--;
				mpd_database_playlist_move(connection, GMPC_MPDDATA_MODEL_SORT(model)->playlist,original,destination);
				data = mpd_database_get_playlist_content(connection, GMPC_MPDDATA_MODEL_SORT(model)->playlist); 
				gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(model), data);		
			}
			gtk_tree_path_free(path);
			return TRUE;
		}}
#line 385 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 109 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
static gboolean 
gmpc_mpddata_model_sort_row_drop_possible (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data)
{
#line 392 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::row_drop_possible"
{
#line 113 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	
			return TRUE;
		}}
#line 399 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__

#line 119 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
GmpcMpdDataModelSort * 
gmpc_mpddata_model_sort_new (void)
{
#line 406 "gmpc-mpddata-model-sort.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Sort::new"
{
#line 121 "/usr/src/ports/gmpc/gmpc-11.8.16-3.i686/src/gmpc-11.8.16/src/gmpc-mpddata-model-sort.gob"
	
			return GET_NEW;
		}}
#line 413 "gmpc-mpddata-model-sort.c"
#undef __GOB_FUNCTION__
