rhythmbox r5750 - in trunk: . bindings/python



Author: jmatthew
Date: Sun Jun 15 10:11:30 2008
New Revision: 5750
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5750&view=rev

Log:
2008-06-15  Jonathan Matthew  <jonathan d14n org>

	patch by: John Millikin  <jmillikin gmail com>

	* bindings/python/rhythmdb.override:
	Improve bindings for keyword methods: don't require a refstring for
	the keyword to already exist when adding one, and add an override for
	entry_keywords_get().  From #324540.


Modified:
   trunk/ChangeLog
   trunk/bindings/python/rhythmdb.override

Modified: trunk/bindings/python/rhythmdb.override
==============================================================================
--- trunk/bindings/python/rhythmdb.override	(original)
+++ trunk/bindings/python/rhythmdb.override	Sun Jun 15 10:11:30 2008
@@ -362,12 +362,51 @@
 	}
 }
 %%
+override rhythmdb_entry_keywords_get kwargs
+static PyObject *
+_wrap_rhythmdb_entry_keywords_get (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+	static char *kwlist[] = { "entry", NULL };
+	PyObject *py_entry = NULL, *retval;
+	RhythmDBEntry *entry;
+	GList *keywords, *keyword;
+
+	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:RhythmDB.entry_keywords_get", kwlist, &py_entry))
+		return NULL;
+	if (pyg_boxed_check(py_entry, RHYTHMDB_TYPE_ENTRY)) {
+		entry = pyg_boxed_get(py_entry, RhythmDBEntry);
+	} else {
+		char *s = g_strdup_printf ("entry should be a RhythmDBEntry, is a %s", g_type_name (pyg_type_from_object (py_entry)));
+		PyErr_SetString(PyExc_TypeError, s);
+		g_free (s);
+		return NULL;
+	}
+
+	keywords = rhythmdb_entry_keywords_get (RHYTHMDB (self->obj), entry);
+	keyword = keywords;
+	retval = PyList_New (0);
+	while (keyword)
+	{
+		PyObject *pystring;
+		RBRefString *refstring;
+		
+		refstring = keyword->data;
+		pystring = PyString_FromString (rb_refstring_get (refstring));
+		rb_refstring_unref (refstring);
+		PyList_Append (retval, pystring);
+		Py_DECREF (pystring);
+		keyword = keyword->next;
+	}
+	g_list_free (keywords);
+	return retval;
+}
+%%
 override rhythmdb_entry_keyword_add kwargs
 static PyObject *
 _wrap_rhythmdb_entry_keyword_add (PyGObject *self, PyObject *args, PyObject *kwargs)
 {
 	static char *kwlist[] = { "entry", "keyword", NULL };
-	PyObject *py_entry = NULL;
+	PyObject *py_entry = NULL, *retval;
 	const char *string = NULL;
 	RhythmDBEntry *entry;
 	RBRefString *refstring;
@@ -388,9 +427,11 @@
 		return NULL;
 	}
 
-	refstring = rb_refstring_find (string);
+	refstring = rb_refstring_new (string);
 	if (refstring != NULL) {
-		return py_return_boolean (rhythmdb_entry_keyword_add (RHYTHMDB (self->obj), entry, refstring));
+		retval = py_return_boolean (rhythmdb_entry_keyword_add (RHYTHMDB (self->obj), entry, refstring));
+		rb_refstring_unref (refstring);
+		return retval;
 	} else {
 		Py_RETURN_FALSE;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]