rhythmbox r6178 - in trunk: . bindings/python widgets
- From: jmatthew svn gnome org
- To: svn-commits-list gnome org
- Subject: rhythmbox r6178 - in trunk: . bindings/python widgets
- Date: Fri, 6 Mar 2009 09:13:46 +0000 (UTC)
Author: jmatthew
Date: Fri Mar 6 09:13:46 2009
New Revision: 6178
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6178&view=rev
Log:
2009-03-06 Jonathan Matthew <jonathan d14n org>
patch by: Tim Retout <tim retout co uk>, Mike Gratton <mike vee net>
* bindings/python/override_common.c:
(_rhythmdb_query_model_sort_data_free),
(_rhythmdb_query_model_sort_func):
* bindings/python/override_common.h:
* bindings/python/rb.defs:
* bindings/python/rb.override:
* bindings/python/rhythmdb.override:
* widgets/rb-entry-view.c: (rb_entry_view_resort_model):
Add bindings for the methods used to add custom columns to entry
views. Fixes #432318.
Modified:
trunk/ChangeLog
trunk/bindings/python/override_common.c
trunk/bindings/python/override_common.h
trunk/bindings/python/rb.defs
trunk/bindings/python/rb.override
trunk/bindings/python/rhythmdb.override
trunk/widgets/rb-entry-view.c
Modified: trunk/bindings/python/override_common.c
==============================================================================
--- trunk/bindings/python/override_common.c (original)
+++ trunk/bindings/python/override_common.c Fri Mar 6 09:13:46 2009
@@ -263,3 +263,53 @@
return array;
}
+/* query model sorting stuff */
+void
+_rhythmdb_query_model_sort_data_free (PyRhythmDBQueryModelSortData *data)
+{
+ PyGILState_STATE __py_state;
+ __py_state = pyg_gil_state_ensure();
+
+ Py_DECREF (data->func);
+ Py_DECREF (data->data);
+ g_free (data);
+
+ pyg_gil_state_release(__py_state);
+}
+
+int
+_rhythmdb_query_model_sort_func (RhythmDBEntry *a, RhythmDBEntry *b, PyRhythmDBQueryModelSortData *data)
+{
+ PyObject *args;
+ PyObject *py_result;
+ PyObject *py_a, *py_b;
+ int result;
+ PyGILState_STATE __py_state;
+
+ __py_state = pyg_gil_state_ensure();
+
+ py_a = pyg_boxed_new (RHYTHMDB_TYPE_ENTRY, a, FALSE, FALSE);
+ py_b = pyg_boxed_new (RHYTHMDB_TYPE_ENTRY, b, FALSE, FALSE);
+ if (data->data)
+ args = Py_BuildValue ("(OOO)", py_a, py_b, data->data);
+ else
+ args = Py_BuildValue ("(OO)", py_a, py_b);
+
+ Py_DECREF (py_a);
+ Py_DECREF (py_b);
+
+ py_result = PyEval_CallObject (data->func, args);
+ Py_DECREF (args);
+
+ if (!py_result) {
+ PyErr_Print();
+ return NULL;
+ }
+ result = PyInt_AsLong (py_result);
+
+ Py_DECREF (py_result);
+ pyg_gil_state_release(__py_state);
+
+ return result;
+}
+/* end query model sorting stuff */
Modified: trunk/bindings/python/override_common.h
==============================================================================
--- trunk/bindings/python/override_common.h (original)
+++ trunk/bindings/python/override_common.h Fri Mar 6 09:13:46 2009
@@ -34,6 +34,8 @@
#ifndef __OVERRIDE_COMMON_H
#define __OVERRIDE_COMMON_H
+#include "rhythmdb.h"
+
PyObject * _helper_wrap_gobject_glist (const GList *list); /* references objects */
PyObject * _helper_wrap_string_glist (const GList *list); /* duplicated strings */
PyObject * _helper_wrap_pointer_glist (const GList *list,
@@ -53,5 +55,19 @@
GType type);
GList * _helper_unwrap_gobject_pylist (PyObject *py_list); /* does not reference objects */
GPtrArray* _helper_unwrap_boxed_gptrarray (PyObject *list, GType type); /* does not copy boxed */
+
+/* query model sorting stuff */
+typedef struct {
+ PyObject *func;
+ PyObject *data;
+} PyRhythmDBQueryModelSortData;
+
+void _rhythmdb_query_model_sort_data_free (PyRhythmDBQueryModelSortData *data);
+
+int _rhythmdb_query_model_sort_func (RhythmDBEntry *a,
+ RhythmDBEntry *b,
+ PyRhythmDBQueryModelSortData *data);
+/* end query model sorting stuff */
+
#endif /* __OVERRIDE_COMMON_H */
Modified: trunk/bindings/python/rb.defs
==============================================================================
--- trunk/bindings/python/rb.defs (original)
+++ trunk/bindings/python/rb.defs Fri Mar 6 09:13:46 2009
@@ -1373,8 +1373,24 @@
'("GtkTreeViewColumn*" "column")
'("const-char*" "title")
'("const-char*" "key")
- '("GCompareDataFunc" "sort_func")
- '("RhythmDBPropType" "sort_propid")
+ '("GCompareDataFunc" "sort_func" (optional))
+ '("gpointer" "data" (optional))
+ '("GDestroyNotify" "data_destroy" (optional))
+ )
+)
+
+(define-method insert_column_custom
+ (of-object "RBEntryView")
+ (c-name "rb_entry_view_insert_column_custom")
+ (return-type "none")
+ (parameters
+ '("GtkTreeViewColumn*" "column")
+ '("const-char*" "title")
+ '("const-char*" "key")
+ '("GCompareDataFunc" "sort_func" (optional))
+ '("gpointer" "data" (optional))
+ '("GDestroyNotify" "data_destroy" (optional))
+ '("gint" "position")
)
)
Modified: trunk/bindings/python/rb.override
==============================================================================
--- trunk/bindings/python/rb.override (original)
+++ trunk/bindings/python/rb.override Fri Mar 6 09:13:46 2009
@@ -83,6 +83,100 @@
*_get_type
*_quark
%%
+override rb_entry_view_append_column_custom kwargs
+static PyObject *
+_wrap_rb_entry_view_append_column_custom(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "column", "title", "key", "sort_func", "sort_data", NULL };
+ PyGObject *pycolumn = NULL;
+ PyObject *pyfunc = NULL;
+ PyObject *pyarg = NULL;
+ char *title, *key;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "Ozz|OO:RBEntryView.append_column_custom",
+ kwlist, &pycolumn, &title, &key, &pyfunc, &pyarg))
+ return NULL;
+
+ if (pyfunc != Py_None && pyfunc != NULL) {
+ PyRhythmDBQueryModelSortData *data;
+
+ if (!PyCallable_Check(pyfunc)) {
+ PyErr_SetString(PyExc_TypeError,
+ "sort_func must be a callable object");
+ return NULL;
+ }
+ data = g_new0(PyRhythmDBQueryModelSortData, 1);
+ data->func = pyfunc;
+ data->data = pyarg;
+ Py_INCREF(data->func);
+ Py_XINCREF(data->data);
+
+ rb_entry_view_append_column_custom(RB_ENTRY_VIEW(self->obj),
+ GTK_TREE_VIEW_COLUMN(pycolumn->obj),
+ title, key,
+ (GCompareDataFunc) _rhythmdb_query_model_sort_func,
+ data,
+ (GDestroyNotify) _rhythmdb_query_model_sort_data_free);
+ } else {
+ rb_entry_view_append_column_custom(RB_ENTRY_VIEW(self->obj),
+ GTK_TREE_VIEW_COLUMN(pycolumn->obj),
+ title, key, NULL, NULL, NULL);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override rb_entry_view_insert_column_custom kwargs
+static PyObject *
+_wrap_rb_entry_view_insert_column_custom(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "column", "title", "key", "position", "sort_func", "sort_data", NULL };
+ PyGObject *pycolumn;
+ PyObject *pyfunc = NULL;
+ PyObject *pyarg = NULL;
+ char *title, *key;
+ int position;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "Ozzi|OO:RBEntryView.insert_column_custom",
+ kwlist, &pycolumn, &title, &key, &position, &pyfunc, &pyarg))
+ return NULL;
+
+ if (pyfunc != Py_None && pyfunc != NULL) {
+ PyRhythmDBQueryModelSortData *data;
+ if (!PyCallable_Check(pyfunc)) {
+ PyErr_SetString(PyExc_TypeError,
+ "sort_func must be a callable object");
+ return NULL;
+ }
+ data = g_new0(PyRhythmDBQueryModelSortData, 1);
+ data->func = pyfunc;
+ data->data = pyarg;
+ Py_INCREF(data->func);
+ Py_XINCREF(data->data);
+
+ rb_entry_view_insert_column_custom(RB_ENTRY_VIEW(self->obj),
+ GTK_TREE_VIEW_COLUMN(pycolumn->obj),
+ title, key,
+ (GCompareDataFunc) _rhythmdb_query_model_sort_func,
+ data, (GDestroyNotify) _rhythmdb_query_model_sort_data_free,
+ position);
+ } else {
+ rb_entry_view_insert_column_custom(RB_ENTRY_VIEW(self->obj),
+ GTK_TREE_VIEW_COLUMN(pycolumn->obj),
+ title, key,
+ NULL, NULL, NULL,
+ position);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
override rb_entry_view_get_selected_entries noargs
static PyObject *
_wrap_rb_entry_view_get_selected_entries(PyGObject *self)
Modified: trunk/bindings/python/rhythmdb.override
==============================================================================
--- trunk/bindings/python/rhythmdb.override (original)
+++ trunk/bindings/python/rhythmdb.override Fri Mar 6 09:13:46 2009
@@ -49,57 +49,6 @@
Py_XDECREF (o);
}
-
-/* query model sorting stuff */
-typedef struct {
- PyObject *func;
- PyObject *data;
-} PyRhythmDBQueryModelSortData;
-
-static void
-_rhythmdb_query_model_sort_data_free (PyRhythmDBQueryModelSortData *data)
-{
- PyGILState_STATE __py_state;
- __py_state = pyg_gil_state_ensure();
-
- Py_DECREF (data->func);
- Py_DECREF (data->data);
- g_free (data);
-
- pyg_gil_state_release(__py_state);
-}
-
-static int
-_rhythmdb_query_model_sort_func (RhythmDBEntry *a, RhythmDBEntry *b, PyRhythmDBQueryModelSortData *data)
-{
- PyObject *args;
- PyObject *py_result;
- PyObject *py_a, *py_b;
- int result;
- PyGILState_STATE __py_state;
-
- __py_state = pyg_gil_state_ensure();
-
- py_a = pyg_boxed_new (RHYTHMDB_TYPE_ENTRY, a, FALSE, FALSE);
- py_b = pyg_boxed_new (RHYTHMDB_TYPE_ENTRY, b, FALSE, FALSE);
- if (data->data)
- args = Py_BuildValue ("(OOO)", py_a, py_b, data->data);
- else
- args = Py_BuildValue ("(OO)", py_a, py_b);
-
- py_result = PyEval_CallObject (data->func, args);
- result = PyInt_AsLong (py_result);
-
- Py_DECREF (py_a);
- Py_DECREF (py_b);
- Py_DECREF (args);
- Py_DECREF (py_result);
- pyg_gil_state_release(__py_state);
-
- return result;
-}
-/* end query model sorting stuff */
-
typedef struct {
PyObject *func;
PyObject *data;
Modified: trunk/widgets/rb-entry-view.c
==============================================================================
--- trunk/widgets/rb-entry-view.c (original)
+++ trunk/widgets/rb-entry-view.c Fri Mar 6 09:13:46 2009
@@ -2545,7 +2545,7 @@
rhythmdb_query_model_set_sort_order (view->priv->model,
sort_data->func,
sort_data->data,
- sort_data->data_destroy,
+ NULL,
(view->priv->sorting_order == GTK_SORT_DESCENDING));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]