From fa0d4db4f90d50d82ccdd6628eec91476a567a88 Mon Sep 17 00:00:00 2001
From: Gustavo Carneiro <gjc@inescporto.pt>
Date: Thu, 28 Jan 2010 16:10:16 +0000
Subject: Bug 608331 - totem-pl-parser doesn't build with latest totem-pl-parser

---
diff --git a/totem/plparser.defs b/totem/plparser.defs
index 184578e..9f25ff1 100644
--- a/totem/plparser.defs
+++ b/totem/plparser.defs
@@ -1,8 +1,24 @@
 ;; -*- scheme -*-
 ; object definitions ...
+
+(define-object Parser
+  (in-module "totem.plparser")
+  (parent "GObject")
+  (c-name "TotemPlParser")
+  (gtype-id "TOTEM_TYPE_PL_PARSER")
+)
+
+(define-object Playlist
+  (in-module "totem.playlist")
+  (parent "GObject")
+  (c-name "TotemPlPlaylist")
+  (gtype-id "TOTEM_TYPE_PL_PLAYLIST")
+)
+
 ;; Enumerations and flags ...
 
-(define-enum ParserResult
+
+(define-enum PlParserResult
   (in-module "Totem")
   (c-name "TotemPlParserResult")
   (gtype-id "TOTEM_TYPE_PL_PARSER_RESULT")
@@ -10,10 +26,12 @@
     '("unhandled" "TOTEM_PL_PARSER_RESULT_UNHANDLED")
     '("error" "TOTEM_PL_PARSER_RESULT_ERROR")
     '("success" "TOTEM_PL_PARSER_RESULT_SUCCESS")
+    '("ignored" "TOTEM_PL_PARSER_RESULT_IGNORED")
+    '("cancelled" "TOTEM_PL_PARSER_RESULT_CANCELLED")
   )
 )
 
-(define-enum ParserType
+(define-enum PlParserType
   (in-module "Totem")
   (c-name "TotemPlParserType")
   (gtype-id "TOTEM_TYPE_PL_PARSER_TYPE")
@@ -21,47 +39,60 @@
     '("pls" "TOTEM_PL_PARSER_PLS")
     '("m3u" "TOTEM_PL_PARSER_M3U")
     '("m3u-dos" "TOTEM_PL_PARSER_M3U_DOS")
+    '("xspf" "TOTEM_PL_PARSER_XSPF")
+    '("iriver-pla" "TOTEM_PL_PARSER_IRIVER_PLA")
   )
 )
 
-(define-enum ParserError
+(define-enum PlParserError
   (in-module "Totem")
   (c-name "TotemPlParserError")
   (gtype-id "TOTEM_TYPE_PL_PARSER_ERROR")
   (values
-    '("open" "TOTEM_PL_PARSER_ERROR_VFS_OPEN")
-    '("write" "TOTEM_PL_PARSER_ERROR_VFS_WRITE")
+    '("no-disc" "TOTEM_PL_PARSER_ERROR_NO_DISC")
+    '("mount-failed" "TOTEM_PL_PARSER_ERROR_MOUNT_FAILED")
   )
 )
 
 
 ;; From totem-pl-parser.h
 
-(define-object Parser
-  (in-module "PlaylistParser")
-  (parent "GObject")
-  (c-name "TotemPlParser")
-  (gtype-id "TOTEM_TYPE_PL_PARSER")
-)
-
-(define-function totem_pl_parser_error_quark
+(define-function error_quark
   (c-name "totem_pl_parser_error_quark")
   (return-type "GQuark")
 )
 
-(define-function totem_pl_parser_get_type
+(define-function get_type
   (c-name "totem_pl_parser_get_type")
   (return-type "GType")
 )
 
-(define-method write
+(define-function parse_duration
+  (c-name "totem_pl_parser_parse_duration")
+  (return-type "gint64")
+  (parameters
+    '("const-char*" "duration")
+    '("gboolean" "debug")
+  )
+)
+
+(define-function parse_date
+  (c-name "totem_pl_parser_parse_date")
+  (return-type "guint64")
+  (parameters
+    '("const-char*" "date_str")
+    '("gboolean" "debug")
+  )
+)
+
+(define-method save
   (of-object "TotemPlParser")
-  (c-name "totem_pl_parser_write")
+  (c-name "totem_pl_parser_save")
   (return-type "gboolean")
   (parameters
-    '("GtkTreeModel*" "model")
-    '("TotemPlParserIterFunc" "func")
-    '("const-char*" "output")
+    '("TotemPlPlaylist*" "playlist")
+    '("GFile*" "dest")
+    '("const-gchar*" "title")
     '("TotemPlParserType" "type")
     '("GError**" "error")
   )
@@ -76,20 +107,243 @@
   )
 )
 
+(define-method add_ignored_mimetype
+  (of-object "TotemPlParser")
+  (c-name "totem_pl_parser_add_ignored_mimetype")
+  (return-type "none")
+  (parameters
+    '("const-char*" "mimetype")
+  )
+)
+
 (define-method parse
   (of-object "TotemPlParser")
   (c-name "totem_pl_parser_parse")
   (return-type "TotemPlParserResult")
   (parameters
-    '("const-char*" "url")
+    '("const-char*" "uri")
     '("gboolean" "fallback")
   )
 )
 
-(define-function totem_pl_parser_new
+(define-method parse_async
+  (of-object "TotemPlParser")
+  (c-name "totem_pl_parser_parse_async")
+  (return-type "none")
+  (parameters
+    '("const-char*" "uri")
+    '("gboolean" "fallback")
+    '("GCancellable*" "cancellable")
+    '("GAsyncReadyCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method parse_finish
+  (of-object "TotemPlParser")
+  (c-name "totem_pl_parser_parse_finish")
+  (return-type "TotemPlParserResult")
+  (parameters
+    '("GAsyncResult*" "async_result")
+    '("GError**" "error")
+  )
+)
+
+(define-method parse_with_base
+  (of-object "TotemPlParser")
+  (c-name "totem_pl_parser_parse_with_base")
+  (return-type "TotemPlParserResult")
+  (parameters
+    '("const-char*" "uri")
+    '("const-char*" "base")
+    '("gboolean" "fallback")
+  )
+)
+
+(define-method parse_with_base_async
+  (of-object "TotemPlParser")
+  (c-name "totem_pl_parser_parse_with_base_async")
+  (return-type "none")
+  (parameters
+    '("const-char*" "uri")
+    '("const-char*" "base")
+    '("gboolean" "fallback")
+    '("GCancellable*" "cancellable")
+    '("GAsyncReadyCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-function new
   (c-name "totem_pl_parser_new")
   (is-constructor-of "TotemPlParser")
   (return-type "TotemPlParser*")
 )
 
+(define-function metadata_get_type
+  (c-name "totem_pl_parser_metadata_get_type")
+  (return-type "GType")
+)
+
+
+
+;; From totem-pl-parser-mini.h
+
+(define-function can_parse_from_data
+  (c-name "totem_pl_parser_can_parse_from_data")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "data")
+    '("gsize" "len")
+    '("gboolean" "debug")
+  )
+)
+
+(define-function can_parse_from_filename
+  (c-name "totem_pl_parser_can_parse_from_filename")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "filename")
+    '("gboolean" "debug")
+  )
+)
+
+
+
+;; From totem-pl-playlist.h
+
+(define-function totem_pl_playlist_get_type
+  (c-name "totem_pl_playlist_get_type")
+  (return-type "GType")
+)
+
+(define-function totem_pl_playlist_new
+  (c-name "totem_pl_playlist_new")
+  (is-constructor-of "TotemPlPlaylist")
+  (return-type "TotemPlPlaylist*")
+)
+
+(define-method size
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_size")
+  (return-type "guint")
+)
+
+(define-method prepend
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_prepend")
+  (return-type "none")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+)
+
+(define-method append
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_append")
+  (return-type "none")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+)
+
+(define-method insert
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_insert")
+  (return-type "none")
+  (parameters
+    '("gint" "position")
+    '("TotemPlPlaylistIter*" "iter")
+  )
+)
+
+(define-method iter_first
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_iter_first")
+  (return-type "gboolean")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+)
+
+(define-method iter_next
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_iter_next")
+  (return-type "gboolean")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+)
+
+(define-method iter_prev
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_iter_prev")
+  (return-type "gboolean")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+)
+
+(define-method get_value
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_get_value")
+  (return-type "gboolean")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+    '("const-gchar*" "key")
+    '("GValue*" "value")
+  )
+)
+
+(define-method get_valist
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_get_valist")
+  (return-type "none")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+    '("va_list" "args")
+  )
+)
+
+(define-method get
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_get")
+  (return-type "none")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+  (varargs #t)
+)
+
+(define-method set_value
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_set_value")
+  (return-type "gboolean")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+    '("const-gchar*" "key")
+    '("GValue*" "value")
+  )
+)
+
+(define-method set_valist
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_set_valist")
+  (return-type "none")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+    '("va_list" "args")
+  )
+)
+
+(define-method set
+  (of-object "TotemPlPlaylist")
+  (c-name "totem_pl_playlist_set")
+  (return-type "none")
+  (parameters
+    '("TotemPlPlaylistIter*" "iter")
+  )
+  (varargs #t)
+)
+
 
diff --git a/totem/plparser.override b/totem/plparser.override
index 3cbe2fb..48e1853 100644
--- a/totem/plparser.override
+++ b/totem/plparser.override
@@ -5,7 +5,7 @@ headers
 #include "pygobject.h"
 #include "totem-pl-parser.h"
 #include "totem-pl-parser-builtins.h"
-#include <gtk/gtk.h>
+#include "totem-pl-parser-mini.h"
 #include <glib.h>
 
 #include "config.h"
@@ -14,108 +14,8 @@ headers
 modulename totem.plparser
 %%
 import gobject.GObject as PyGObject_Type
-import gtk.TreeModel as PyGtkTreeModel_Type
 %%
 ignore-glob
   *_get_type
   *_error_quark
-%%
-override totem_pl_parser_write kwargs
-
-typedef struct {
-	PyObject *func;
-	PyObject *data;
-	gboolean has_error;
-} PyPlParserIterFuncData;
-
-static void
-_pl_parser_iter_func (GtkTreeModel *model, GtkTreeIter *iter, char **uri, char **title,
-		      gboolean *custom_title, gpointer user_data)
-{
-	PyObject *args = NULL;
-	PyObject *result = NULL;
-	char *tmp_uri = NULL, *tmp_title = NULL;
-	PyPlParserIterFuncData *data = user_data;
-	PyObject *py_custom_title = NULL;
-
-	if (data->has_error)
-		return;
-
-	if (data->data)
-		args = Py_BuildValue ("(NNO)",
-				      pygobject_new((GObject *)model),
-				      pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE),
-				      data->data);
-	else
-		args = Py_BuildValue ("(NN)",
-				      pygobject_new((GObject *)model),
-				      pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE));
-	result = PyEval_CallObject (data->func, args);
-	Py_DECREF (args);
-	
-	if (result == NULL) {
-		data->has_error = TRUE;
-		return;
-	}
-	  /* ?! */
-	/* PyObject_Print (result, stdout, 0); */
-
-	if (PyString_Check (result)) {
-		tmp_uri = PyString_AsString (result);
-		if (tmp_uri == NULL) {
-			PyErr_SetString (PyExc_TypeError,
-					 "Callback function must return one"
-					 " string or a tuple of two strings.");
-			data->has_error = TRUE;
-		}
-	} else if (!PyTuple_Check (result) ||
-		   !PyArg_ParseTuple (result, "ss|O", &tmp_uri, &tmp_title, &py_custom_title))
-	{
-		PyErr_SetString (PyExc_TypeError,
-				 "Callback function must return one "
-				 "string or a tuple of two strings,"
-				 " or two strings and a boolean.");
-		data->has_error = TRUE;
-	}
-	
-	/* g_strdup handles NULL case for us */
-	*uri = g_strdup (tmp_uri);
-	*title = g_strdup (tmp_title);
-	*custom_title = py_custom_title? PyObject_IsTrue(py_custom_title) : FALSE;
-	
-	Py_DECREF (result);
-}
 
-static PyObject *
-_wrap_totem_pl_parser_write (PyGObject *self, PyObject *args, PyObject *kwargs)
-{
-	static char *kwlist[] = {"model", "iter_func", "output", "type", NULL};
-	PyGObject *model;
-	char *output;
-	TotemPlParserType type;
-	GError *error = NULL;
-	PyPlParserIterFuncData data = {0, };
-	
-	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Osi|O:Parser.write",
-					 kwlist, &PyGtkTreeModel_Type, &model,
-					 &data.func, &output, &type, &data.data))
-		return NULL;
-	/* verify arguments' integrity */
-	if (!PyCallable_Check (data.func)) {
-		PyErr_SetString (PyExc_TypeError, "iter_func must be callable");
-		return NULL;
-	}
-	if (!totem_pl_parser_write (TOTEM_PL_PARSER(self->obj),
-	                            GTK_TREE_MODEL(model->obj),
-	                            _pl_parser_iter_func,
-	                            output,type, &data, &error))
-	{
-		/* return an GError */
-		pyg_error_check(&error);
-		return NULL;
-	}
-	if (data.has_error)
-		return NULL;
-	Py_INCREF(Py_None);
-	return Py_None;
-}
--
cgit v0.8.3.1
