/* 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-playlist.h"

#include "gmpc-mpddata-model-playlist-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 22 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"

#include "gmpc-mpddata-model.h" 

#include "gmpc-extras.h" 

#line 32 "gmpc-mpddata-model-playlist.c"

#line 30 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"

#define BLOCK_SIZE 200
#define LOG_DOMAIN "MpdData.Model.Playlist"

#line 39 "gmpc-mpddata-model-playlist.c"
/* self casting macros */
#define SELF(x) GMPC_MPDDATA_MODEL_PLAYLIST(x)
#define SELF_CONST(x) GMPC_MPDDATA_MODEL_PLAYLIST_CONST(x)
#define IS_SELF(x) GMPC_IS_MPDDATA_MODEL_PLAYLIST(x)
#define TYPE_SELF GMPC_TYPE_MPDDATA_MODEL_PLAYLIST
#define SELF_CLASS(x) GMPC_MPDDATA_MODEL_PLAYLIST_CLASS(x)

#define SELF_GET_CLASS(x) GMPC_MPDDATA_MODEL_PLAYLIST_GET_CLASS(x)

/* self typedefs */
typedef GmpcMpdDataModelPlaylist Self;
typedef GmpcMpdDataModelPlaylistClass SelfClass;

/* here are local prototypes */
static void gmpc_mpddata_model_playlist_init (GmpcMpdDataModelPlaylist * o) G_GNUC_UNUSED;
static void gmpc_mpddata_model_playlist_class_init (GmpcMpdDataModelPlaylistClass * c) G_GNUC_UNUSED;
#line 56 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static gboolean gmpc_mpddata_model_playlist_update_callback (GmpcMpdDataModelPlaylist * self) G_GNUC_UNUSED;
#line 58 "gmpc-mpddata-model-playlist.c"
#line 99 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void ___2_gmpc_mpddata_model_playlist_dispose (GObject * obj) G_GNUC_UNUSED;
#line 61 "gmpc-mpddata-model-playlist.c"
#line 105 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void ___3_gmpc_mpddata_model_playlist_finalize (GObject * obj) G_GNUC_UNUSED;
#line 64 "gmpc-mpddata-model-playlist.c"
#line 142 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void gmpc_mpddata_model_playlist_status_changed (GmpcMpdDataModelPlaylist * self, MpdObj * mi, ChangedStatusType what, GmpcConnection * conn) G_GNUC_UNUSED;
#line 67 "gmpc-mpddata-model-playlist.c"
#line 333 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void gmpc_mpddata_model_playlist_connection_changed (GmpcMpdDataModelPlaylist * self, MpdObj * mi, int connect, GmpcConnection * conn) G_GNUC_UNUSED;
#line 70 "gmpc-mpddata-model-playlist.c"
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void gmpc_mpddata_model_playlist_get_value (GtkTreeModel * model, GtkTreeIter * iter, gint column, GValue * value) G_GNUC_UNUSED;
#line 73 "gmpc-mpddata-model-playlist.c"
#line 441 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static gboolean gmpc_mpddata_model_playlist_row_drop_possible (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data) G_GNUC_UNUSED;
#line 76 "gmpc-mpddata-model-playlist.c"
#line 449 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static gboolean gmpc_mpddata_model_playlist_drag_data_received (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data) G_GNUC_UNUSED;
#line 79 "gmpc-mpddata-model-playlist.c"

/*
 * Signal connection wrapper macro shortcuts
 */
#define self_connect__current_song_changed(object,func,data)	gmpc_mpddata_model_playlist_connect__current_song_changed((object),(func),(data))
#define self_connect_after__current_song_changed(object,func,data)	gmpc_mpddata_model_playlist_connect_after__current_song_changed((object),(func),(data))
#define self_connect_data__current_song_changed(object,func,data,destroy_data,flags)	gmpc_mpddata_model_playlist_connect_data__current_song_changed((object),(func),(data),(destroy_data),(flags))
#define self_connect__total_playtime_changed(object,func,data)	gmpc_mpddata_model_playlist_connect__total_playtime_changed((object),(func),(data))
#define self_connect_after__total_playtime_changed(object,func,data)	gmpc_mpddata_model_playlist_connect_after__total_playtime_changed((object),(func),(data))
#define self_connect_data__total_playtime_changed(object,func,data,destroy_data,flags)	gmpc_mpddata_model_playlist_connect_data__total_playtime_changed((object),(func),(data),(destroy_data),(flags))

typedef void  (*___Sig1) (GmpcMpdDataModelPlaylist *, gpointer , gpointer , 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 == 3);

	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 ((GmpcMpdDataModelPlaylist *)data1,
		(gpointer ) g_value_get_pointer (param_values + 1),
		(gpointer ) g_value_get_pointer (param_values + 2),
		data2);
}


typedef void  (*___Sig2) (GmpcMpdDataModelPlaylist *, glong , glong , gpointer);

static void
___marshal_Sig2 (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 ___Sig2 callback;
	register GCClosure *cc = (GCClosure*) closure;
	register gpointer data1, data2;

	g_return_if_fail (n_param_values == 3);

	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 = (___Sig2) (marshal_data != NULL ? marshal_data : cc->callback);

	callback ((GmpcMpdDataModelPlaylist *)data1,
		(glong ) g_value_get_long (param_values + 1),
		(glong ) g_value_get_long (param_values + 2),
		data2);
}


enum {
	CURRENT_SONG_CHANGED_SIGNAL,
	TOTAL_PLAYTIME_CHANGED_SIGNAL,
	LAST_SIGNAL
};

static guint object_signals[LAST_SIGNAL] = {0};

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

/* Short form macros */
#define self_update_callback gmpc_mpddata_model_playlist_update_callback
#define self_new gmpc_mpddata_model_playlist_new
#define self_status_changed gmpc_mpddata_model_playlist_status_changed
#define self_current_song_changed gmpc_mpddata_model_playlist_current_song_changed
#define self_total_playtime_changed gmpc_mpddata_model_playlist_total_playtime_changed
#define self_connection_changed gmpc_mpddata_model_playlist_connection_changed
#define self_is_current_song gmpc_mpddata_model_playlist_is_current_song
#define self_get_value gmpc_mpddata_model_playlist_get_value
#define self_row_drop_possible gmpc_mpddata_model_playlist_row_drop_possible
#define self_drag_data_received gmpc_mpddata_model_playlist_drag_data_received
#define self_trigger_total_playtime_signal gmpc_mpddata_model_playlist_trigger_total_playtime_signal
#define self_get_total_playtime gmpc_mpddata_model_playlist_get_total_playtime


static void
___Gtk_Tree_Drag_Dest_init (GtkTreeDragDestIface *iface)
{
#line 441 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	iface->row_drop_possible = self_row_drop_possible;
#line 449 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	iface->drag_data_received = self_drag_data_received;
#line 190 "gmpc-mpddata-model-playlist.c"
}


static void
___Gtk_Tree_Model_init (GtkTreeModelIface *iface)
{
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	iface->get_value = self_get_value;
#line 199 "gmpc-mpddata-model-playlist.c"
}

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

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (GmpcMpdDataModelPlaylistClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gmpc_mpddata_model_playlist_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (GmpcMpdDataModelPlaylist),
			0 /* n_preallocs */,
			(GInstanceInitFunc) gmpc_mpddata_model_playlist_init,
			NULL
		};

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

		static const GInterfaceInfo Gtk_Tree_Model_info = {
			(GInterfaceInitFunc) ___Gtk_Tree_Model_init,
			NULL,
			NULL
		};

		type = g_type_register_static (GMPC_TYPE_MPDDATA_MODEL, "GmpcMpdDataModelPlaylist", &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_MODEL,
			&Gtk_Tree_Model_info);
	}

	return type;
}

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

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


static void
___dispose (GObject *obj_self)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::dispose"
#line 99 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	___2_gmpc_mpddata_model_playlist_dispose(obj_self);
#line 269 "gmpc-mpddata-model-playlist.c"
}
#undef __GOB_FUNCTION__


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::finalize"
	GmpcMpdDataModelPlaylist *self G_GNUC_UNUSED = GMPC_MPDDATA_MODEL_PLAYLIST (obj_self);
	gpointer priv G_GNUC_UNUSED = self->_priv;
#line 105 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	___3_gmpc_mpddata_model_playlist_finalize(obj_self);
#line 282 "gmpc-mpddata-model-playlist.c"
}
#undef __GOB_FUNCTION__

static void 
gmpc_mpddata_model_playlist_init (GmpcMpdDataModelPlaylist * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::init"
	o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,GMPC_TYPE_MPDDATA_MODEL_PLAYLIST,GmpcMpdDataModelPlaylistPrivate);
#line 44 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->conn = NULL;
#line 293 "gmpc-mpddata-model-playlist.c"
#line 44 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->status_changed = 0;
#line 296 "gmpc-mpddata-model-playlist.c"
#line 44 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->connection_changed = 0;
#line 299 "gmpc-mpddata-model-playlist.c"
#line 48 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->playlist_id = 0;
#line 302 "gmpc-mpddata-model-playlist.c"
#line 49 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->total_time = 0;
#line 305 "gmpc-mpddata-model-playlist.c"
#line 50 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->loaded_songs = 0;
#line 308 "gmpc-mpddata-model-playlist.c"
#line 50 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->old_highlight = -1;
#line 311 "gmpc-mpddata-model-playlist.c"
#line 53 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->update_timeout = 0;
#line 314 "gmpc-mpddata-model-playlist.c"
#line 54 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	o->_priv->last_pos = 0;
#line 317 "gmpc-mpddata-model-playlist.c"
}
#undef __GOB_FUNCTION__
static void 
gmpc_mpddata_model_playlist_class_init (GmpcMpdDataModelPlaylistClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;

	g_type_class_add_private(c,sizeof(GmpcMpdDataModelPlaylistPrivate));

	parent_class = g_type_class_ref (GMPC_TYPE_MPDDATA_MODEL);

	object_signals[CURRENT_SONG_CHANGED_SIGNAL] =
		g_signal_new ("current_song_changed",
			G_TYPE_FROM_CLASS (g_object_class),
			(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
			G_STRUCT_OFFSET (GmpcMpdDataModelPlaylistClass, current_song_changed),
			NULL, NULL,
			___marshal_Sig1,
			G_TYPE_NONE, 2,
			G_TYPE_POINTER,
			G_TYPE_POINTER);
	if ___GOB_UNLIKELY(sizeof(GtkTreePath * ) != sizeof(gpointer ) || sizeof(GtkTreeIter * ) != sizeof(gpointer ) || parent_class == NULL /* avoid warning */) {
		g_error("/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob line 320: Type mismatch of \"current_song_changed\" signal signature");
	}
	object_signals[TOTAL_PLAYTIME_CHANGED_SIGNAL] =
		g_signal_new ("total_playtime_changed",
			G_TYPE_FROM_CLASS (g_object_class),
			(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
			G_STRUCT_OFFSET (GmpcMpdDataModelPlaylistClass, total_playtime_changed),
			NULL, NULL,
			___marshal_Sig2,
			G_TYPE_NONE, 2,
			G_TYPE_LONG,
			G_TYPE_LONG);
	if ___GOB_UNLIKELY(sizeof(unsigned long ) != sizeof(glong ) || sizeof(unsigned long ) != sizeof(glong ) || parent_class == NULL /* avoid warning */) {
		g_error("/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob line 327: Type mismatch of \"total_playtime_changed\" signal signature");
	}

#line 99 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_object_class->dispose = ___dispose;
#line 105 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_object_class->finalize = ___finalize;
#line 361 "gmpc-mpddata-model-playlist.c"
	c->current_song_changed = NULL;
	c->total_playtime_changed = NULL;
}
#undef __GOB_FUNCTION__



#line 56 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static gboolean 
gmpc_mpddata_model_playlist_update_callback (GmpcMpdDataModelPlaylist * self)
{
#line 373 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::update_callback"
#line 56 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 56 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self), (gboolean )0);
#line 379 "gmpc-mpddata-model-playlist.c"
{
#line 57 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
			static const unsigned int step_size = 100;
			unsigned int num_rows =  GMPC_MPDDATA_MODEL(self)->num_rows;
			if(self->_priv->loaded_songs <num_rows)
			{
				unsigned int i = 0;
				MpdData *data =  GMPC_MPDDATA_MODEL(self)->_priv->data;
				data = mpd_data_get_first(data);
				if(!data) return TRUE;
				for(i=0; i < (self->_priv->last_pos);i++)
				{
					data = (MpdData *)mpd_data_get_next_real(data,FALSE);
				}


				for(i=0;i< step_size && data;i++)
				{
					if(data->song == NULL)
					{ 
						data->song = mpd_playlist_get_song_from_pos(self->_priv->mi,i+self->_priv->last_pos);
						if(data->song)
						{
							self->_priv->loaded_songs++;
							if(data->song->time>0)
							{
								self->_priv->total_time += data->song->time;
								self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);
							}
						}

					}
					data = mpd_data_get_next_real(data, FALSE);
				}
				self->_priv->last_pos += step_size;
			}
			else 
			{
				self->_priv->last_pos = 0;
			} 
			return TRUE;
		}}
#line 423 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 99 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void 
___2_gmpc_mpddata_model_playlist_dispose (GObject * obj G_GNUC_UNUSED)
#line 429 "gmpc-mpddata-model-playlist.c"
#define PARENT_HANDLER(___obj) \
	{ if(G_OBJECT_CLASS(parent_class)->dispose) \
		(* G_OBJECT_CLASS(parent_class)->dispose)(___obj); }
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::dispose"
{
#line 102 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
            gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(obj), NULL);
        }}
#line 440 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 105 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void 
___3_gmpc_mpddata_model_playlist_finalize (GObject * obj G_GNUC_UNUSED)
#line 447 "gmpc-mpddata-model-playlist.c"
#define PARENT_HANDLER(___obj) \
	{ if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(___obj); }
{
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::finalize"
{
#line 108 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
            Self *self = GMPC_MPDDATA_MODEL_PLAYLIST(obj); 
            if(self->_priv->status_changed > 0)
            {
                g_signal_handler_disconnect(G_OBJECT(gmpcconn),self->_priv->status_changed);
                self->_priv->status_changed = 0;
            }
            if(self->_priv->connection_changed > 0)
            {
                g_signal_handler_disconnect(G_OBJECT(gmpcconn),self->_priv->connection_changed);
                self->_priv->connection_changed = 0;
            }
            if(self->_priv->update_timeout > 0)
            {
                g_source_remove(self->_priv->update_timeout);
                self->_priv->update_timeout  = 0;
            }
            PARENT_HANDLER(obj);
        }}
#line 474 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 127 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
GmpcMpdDataModelPlaylist * 
gmpc_mpddata_model_playlist_new (GmpcConnection * conn, MpdObj * mi)
{
#line 482 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::new"
#line 127 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (!(conn) || GMPC_IS_CONNECTION (conn), (GmpcMpdDataModelPlaylist * )0);
#line 127 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (conn != NULL, (GmpcMpdDataModelPlaylist * )0);
#line 127 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (mi != NULL, (GmpcMpdDataModelPlaylist * )0);
#line 490 "gmpc-mpddata-model-playlist.c"
{
#line 129 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
            Self *self = GET_NEW;
            self->_priv->conn = conn;
            self->_priv->status_changed = g_signal_connect_swapped(G_OBJECT(conn), "status_changed", G_CALLBACK(self_status_changed), self);
            self->_priv->connection_changed = g_signal_connect_swapped(G_OBJECT(conn), "connection_changed", G_CALLBACK(self_connection_changed), self);
            self->_priv->mi = mi;
						
						if(cfg_get_single_value_as_int_with_default(config, "playlist", "background-loading", FALSE))
						{
							self->_priv->update_timeout  = g_timeout_add_seconds(1, (GSourceFunc)(self_update_callback), self);
						}
							return self;
        }}
#line 506 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 142 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void 
gmpc_mpddata_model_playlist_status_changed (GmpcMpdDataModelPlaylist * self, MpdObj * mi, ChangedStatusType what, GmpcConnection * conn)
{
#line 513 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::status_changed"
#line 142 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (self != NULL);
#line 142 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self));
#line 142 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (!(conn) || GMPC_IS_CONNECTION (conn));
#line 521 "gmpc-mpddata-model-playlist.c"
{
#line 145 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
        if(what&MPD_CST_PLAYLIST)
        {
            MpdData *data  = NULL;
            int new_length = mpd_playlist_get_playlist_length(mi);
           
            int old_length = GMPC_MPDDATA_MODEL(self)->num_rows; 
            /* if it was empty just add everything */
            if(new_length == 0)
            {
                self->_priv->loaded_songs=0;
                self->_priv->total_time =0;
                self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);

                
                gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(self), NULL);


            }
            else if(old_length == 0)
            {
                int  i;
                for(i = new_length; i > 0; i--)
                {
                    data= mpd_new_data_struct_append(data);
                    data->type = MPD_DATA_TYPE_SONG;
                    data->song = NULL;
                }
                gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(self), mpd_data_get_first(data));
            }
            else
            {
                data = mpd_playlist_get_changes_posid(mi, self->_priv->playlist_id);
                /* if the new length is shorter then the old, remove rows at the end */
                if(new_length < old_length)
                {
                    int i;
                    MpdData_real *odata = (MpdData_real *)mpd_data_get_first(GMPC_MPDDATA_MODEL(self)->_priv->data);
                    while(odata->next)odata = odata->next;
                    /* data should be last */

                    for(i=old_length-1;i>=new_length;i--)
                    {
                        GtkTreePath *path = gtk_tree_path_new(); 
                        gtk_tree_path_append_index(path, i);
                        gtk_tree_model_row_deleted(GTK_TREE_MODEL(self), path);
                        gtk_tree_path_free(path);

                        if(odata->song)
                        {
                            self->_priv->loaded_songs--;
                            if(odata->song->time > 0)
                            {
                                self->_priv->total_time -= odata->song->time;
                                self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);
                            }
                        }

                        odata = (MpdData_real *)mpd_data_delete_item((MpdData *)odata);
                       GMPC_MPDDATA_MODEL(self)->num_rows--;
                    }
                }
                /* if it's longer, append rows */
                else if ( new_length > old_length)
                {
                    int i;
                    MpdData_real *odata = (MpdData_real *)mpd_data_get_first(GMPC_MPDDATA_MODEL(self)->_priv->data);
                    /* get the last element */
                    while(odata->next) odata = odata->next;
                    for(i=old_length; i< new_length;i++)
                    {
                       GtkTreePath *path = gtk_tree_path_new(); 
                       GtkTreeIter iter;
                       /* Append node */
                       odata = (MpdData_real *)mpd_new_data_struct_append((MpdData *)odata);
                       odata->type = MPD_DATA_TYPE_SONG;
                       odata->song = NULL;
                        /* Create iter */
                       iter.stamp = GMPC_MPDDATA_MODEL(self)->_priv->stamp;
                       iter.user_data = NULL; 
                       iter.user_data2 =  GINT_TO_POINTER(GMPC_MPDDATA_MODEL(self)->num_rows);
                       /* show the path */
                       gtk_tree_path_append_index(path, i);
                        /* insert it */
                       gtk_tree_model_row_inserted(GTK_TREE_MODEL(self), path, &iter);
                       gtk_tree_path_free(path);
                       GMPC_MPDDATA_MODEL(self)->num_rows++;

                    }
                }
                /* Now mark the changed rows */
                if(data)
                {
                    int i=0;
                    MpdData_real *list_iter =(MpdData_real *) mpd_data_get_first(GMPC_MPDDATA_MODEL(self)->_priv->data);
                    MpdData_real *data_iter =(MpdData_real *) mpd_data_get_first(data);
                    while(data_iter && list_iter)
                    {
                        GtkTreeIter iter;
                        GtkTreePath *path = gtk_tree_path_new(); 
                       /* get the right entry */
                        for(;list_iter != NULL && i!= data_iter->song->pos;i++)
                            list_iter = list_iter->next;

                        if(list_iter)
                        {
                            if(list_iter->song)
                            {
                                self->_priv->loaded_songs--;
                                if(list_iter->song->time > 0)
                                {
                                    self->_priv->total_time -= list_iter->song->time;
                                    self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);
                                }
                            }

                            if(list_iter->song)
                                mpd_freeSong(list_iter->song);
                            list_iter->song = NULL;

                            iter.stamp = GMPC_MPDDATA_MODEL(self)->_priv->stamp;
                            iter.user_data = NULL; 
                            iter.user_data2 =  GINT_TO_POINTER(i);
                            gtk_tree_path_append_index(path, i);
                            gtk_tree_model_row_changed(GTK_TREE_MODEL(self), path, &iter);


                        }
                        gtk_tree_path_free(path);
                        data_iter = data_iter->next;
                    }
                    mpd_data_free(data);
                }
            }
            if(GMPC_MPDDATA_MODEL(self)->num_rows != new_length)
            {
                g_log(LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Playlist out of sync: %i-%i \n",GMPC_MPDDATA_MODEL(self)->num_rows,new_length);
            }
            self->_priv->playlist_id = mpd_playlist_get_playlist_id(mi);
        }
        if(what&(MPD_CST_SONGID|MPD_CST_SONGPOS|MPD_CST_STATE))
        {
            GtkTreeIter iter;
            GtkTreePath *path = NULL;
            int i = mpd_player_get_current_song_pos(self->_priv->mi);
            if(self->_priv->old_highlight >= 0)
            {
                /* get the right entry */
                path = gtk_tree_path_new(); 
                iter.stamp = GMPC_MPDDATA_MODEL(self)->_priv->stamp;
                iter.user_data = NULL; 
                iter.user_data2 =  GINT_TO_POINTER(self->_priv->old_highlight);
                gtk_tree_path_append_index(path, self->_priv->old_highlight);
                gtk_tree_model_row_changed(GTK_TREE_MODEL(self), path, &iter);
                gtk_tree_path_free(path);
                self->_priv->old_highlight = -1;
            }
            if(i >= 0)
            {
                /* Needs to be set before updating */
                self->_priv->old_highlight = i;
                /* get the right entry */
                path = gtk_tree_path_new(); 
                iter.stamp = GMPC_MPDDATA_MODEL(self)->_priv->stamp;
                iter.user_data = NULL; 
                iter.user_data2 =  GINT_TO_POINTER(i);
                gtk_tree_path_append_index(path, i);
                gtk_tree_model_row_changed(GTK_TREE_MODEL(self), path, &iter);
                self_current_song_changed(self, path, &iter);
                gtk_tree_path_free(path);
            }
        }

    }}
#line 698 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 320 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
void 
gmpc_mpddata_model_playlist_current_song_changed (GmpcMpdDataModelPlaylist * self, GtkTreePath * path, GtkTreeIter * iter)
{
#line 705 "gmpc-mpddata-model-playlist.c"
	GValue ___param_values[3];
	GValue ___return_val;

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

#line 320 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (self != NULL);
#line 320 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self));
#line 716 "gmpc-mpddata-model-playlist.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_POINTER);
	g_value_set_pointer (&___param_values[1], (gpointer ) path);

	___param_values[2].g_type = 0;
	g_value_init (&___param_values[2], G_TYPE_POINTER);
	g_value_set_pointer (&___param_values[2], (gpointer ) iter);

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

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

#line 327 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
void 
gmpc_mpddata_model_playlist_total_playtime_changed (GmpcMpdDataModelPlaylist * self, unsigned long loaded_songs, unsigned long total_playtime)
{
#line 744 "gmpc-mpddata-model-playlist.c"
	GValue ___param_values[3];
	GValue ___return_val;

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

#line 327 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (self != NULL);
#line 327 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self));
#line 755 "gmpc-mpddata-model-playlist.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_LONG);
	g_value_set_long (&___param_values[1], (glong ) loaded_songs);

	___param_values[2].g_type = 0;
	g_value_init (&___param_values[2], G_TYPE_LONG);
	g_value_set_long (&___param_values[2], (glong ) total_playtime);

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

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

#line 333 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void 
gmpc_mpddata_model_playlist_connection_changed (GmpcMpdDataModelPlaylist * self, MpdObj * mi, int connect, GmpcConnection * conn)
{
#line 783 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::connection_changed"
#line 333 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (self != NULL);
#line 333 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self));
#line 333 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (!(conn) || GMPC_IS_CONNECTION (conn));
#line 791 "gmpc-mpddata-model-playlist.c"
{
#line 336 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
        if(connect == 0)
        {
            gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(self), NULL);
            self->_priv->playlist_id = 0;
            self->_priv->loaded_songs = 0;
            self->_priv->total_time = 0;
            self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);
        }
    }}
#line 804 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 347 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
gboolean 
gmpc_mpddata_model_playlist_is_current_song (GtkTreeModel * model, GtkTreeIter * iter)
{
#line 811 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::is_current_song"
#line 347 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (model != NULL, (gboolean )0);
#line 347 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (GTK_IS_TREE_MODEL (model), (gboolean )0);
#line 347 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_val_if_fail (iter != NULL, (gboolean )0);
#line 819 "gmpc-mpddata-model-playlist.c"
{
#line 350 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
        Self *self = GMPC_MPDDATA_MODEL_PLAYLIST(model);
        int n = GPOINTER_TO_INT(iter->user_data2);
        if(n == self->_priv->old_highlight)
            return TRUE;
        return FALSE;
    }}
#line 829 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static void 
gmpc_mpddata_model_playlist_get_value (GtkTreeModel * model, GtkTreeIter * iter, gint column, GValue * value)
{
#line 836 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::get_value"
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (model != NULL);
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GTK_IS_TREE_MODEL (model));
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (iter != NULL);
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (column >= 0);
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (column < MPDDATA_MODEL_N_COLUMNS);
#line 365 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (value != NULL);
#line 850 "gmpc-mpddata-model-playlist.c"
{
#line 367 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
        Self *self = GMPC_MPDDATA_MODEL_PLAYLIST(model);
        MpdData_real *data = iter->user_data;	
        int n = GPOINTER_TO_INT(iter->user_data2);
        if(data == NULL) {
            g_warning("data == NULL :: %i:: %i:: %i :: %i",n, GMPC_MPDDATA_MODEL(self)->num_rows,
            GMPC_MPDDATA_MODEL(self)->_priv->stamp,
            iter->stamp

            );

            g_value_init(value, GMPC_MPDDATA_MODEL(self)->types[column]);
            return;
        }
        if(data->song == NULL)
        {
            int rs = n - n%BLOCK_SIZE;
            int end = ((rs+(BLOCK_SIZE-1)) >= GMPC_MPDDATA_MODEL(self)->num_rows)? GMPC_MPDDATA_MODEL(self)->num_rows-1:rs+(BLOCK_SIZE-1);

            MpdData_real *edit =(MpdData_real *) data;
            MpdData_real *miter,*data2 = (MpdData_real *)mpd_playlist_get_song_from_pos_range(self->_priv->mi,rs, end); 

            /* rewind to start block */
            while(n>rs){ edit = edit->prev; rs++;}

            data2 =(MpdData_real *) mpd_data_get_first((MpdData *)data2);
            miter =data2;
            while(data2){
                if(edit->song == NULL)
                {
                    edit->song = data2->song;
                    data2->song = NULL;
                    self->_priv->loaded_songs++;
                    if(edit->song->time>0)
                    {
                        self->_priv->total_time += edit->song->time;
                    }
                }
                edit = edit->next;
                data2  = data2->next;
            }
            mpd_data_free((MpdData *)miter);

            self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);
        }
        /**
         * If the fetch failed, return an empty value, otherwise we will get crashes
         */
        if(data->song == NULL)
        {
            g_value_init(value, GMPC_MPDDATA_MODEL(self)->types[column]);
            g_log(LOG_DOMAIN, G_LOG_LEVEL_WARNING,"failed to get song entry\n");
            return;
        }
        if(column == MPDDATA_MODEL_COL_ICON_ID)
        {
            if(n == mpd_player_get_current_song_pos(self->_priv->mi))
            {
                g_value_init(value, GMPC_MPDDATA_MODEL(self)->types[column]);
                g_value_set_string(value, "gtk-media-play-ltr");
                return;
            }

        }
        /**
         * Call the parent function again
         */
        if(n < GMPC_MPDDATA_MODEL(self)->num_rows)
            gmpc_mpddata_model_get_value(model, iter, column, value);
    }}
#line 923 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 441 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static gboolean 
gmpc_mpddata_model_playlist_row_drop_possible (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data)
{
#line 930 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::row_drop_possible"
{
#line 445 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
			return TRUE;
		}}
#line 937 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 449 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
static gboolean 
gmpc_mpddata_model_playlist_drag_data_received (GtkTreeDragDest * drag_dest, GtkTreePath * dest, GtkSelectionData * selection_data)
{
#line 944 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::drag_data_received"
{
#line 453 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
           GtkTreePath *path=NULL;
           GtkTreeModel *model=NULL;

           Self *self = NULL;
           gint *ind = NULL, *ind2 = NULL;
           if(dest == NULL || !gtk_tree_get_row_drag_data(selection_data, &model, &path))
           {
               return FALSE;
           }
           if(model != GTK_TREE_MODEL(drag_dest)) {
                GtkTreeIter iter;
                mpd_Song *song = NULL;
               ind = gtk_tree_path_get_indices(dest);
               if(gtk_tree_model_get_iter(model, &iter, path)) 
               {
                   gtk_tree_model_get(model, &iter,MPDDATA_MODEL_COL_MPDSONG, &song, -1);
                   if(song && song->file) {
                       int destp = ind[0];
                       int length = mpd_playlist_get_playlist_length(connection); 
                       mpd_playlist_add(connection,song->file);
                       if(destp >= 0)
                           mpd_playlist_move_pos(connection, length, destp);
                   }
               }
               return FALSE;
           }
           if(GMPC_MPDDATA_MODEL(model)->num_rows < 2)
           {
               gtk_tree_path_free(path);
               return FALSE;
           }
           self =  GMPC_MPDDATA_MODEL_PLAYLIST(model);
           ind = gtk_tree_path_get_indices(dest);
           ind2 = gtk_tree_path_get_indices(path);
           if(ind && ind2)
           {
               int original = ind2[0];
               int destination = ind[0];
     /*		if(destination >0 && ind[1] != '\0') destination--; */
               if(destination > original) destination--;
               mpd_playlist_move_pos(self->_priv->mi,original,destination);
           }
           gtk_tree_path_free(path);
           return TRUE;
       }}
#line 994 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 500 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
void 
gmpc_mpddata_model_playlist_trigger_total_playtime_signal (GmpcMpdDataModelPlaylist * self)
{
#line 1001 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::trigger_total_playtime_signal"
#line 500 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (self != NULL);
#line 500 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self));
#line 1007 "gmpc-mpddata-model-playlist.c"
{
#line 503 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
           self_total_playtime_changed(self, self->_priv->loaded_songs, self->_priv->total_time);
       }}
#line 1013 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__

#line 506 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
void 
gmpc_mpddata_model_playlist_get_total_playtime (GmpcMpdDataModelPlaylist * self, unsigned long * loaded_songs, unsigned long * total_time)
{
#line 1020 "gmpc-mpddata-model-playlist.c"
#define __GOB_FUNCTION__ "Gmpc:MpdData:Model:Playlist::get_total_playtime"
#line 506 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (self != NULL);
#line 506 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	g_return_if_fail (GMPC_IS_MPDDATA_MODEL_PLAYLIST (self));
#line 1026 "gmpc-mpddata-model-playlist.c"
{
#line 509 "/usr/src/extras/gmpc/gmpc-11.8.16-2.x86_64/src/gmpc-11.8.16/src/gmpc-mpddata-model-playlist.gob"
	
            if(loaded_songs)
                (*loaded_songs) = self->_priv->loaded_songs;
            if(total_time)
                (*total_time)= self->_priv->total_time;
       }}
#line 1035 "gmpc-mpddata-model-playlist.c"
#undef __GOB_FUNCTION__
