After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 412210 - RhythmDB's metadata gathering isn't usable from python
RhythmDB's metadata gathering isn't usable from python
Status: RESOLVED FIXED
Product: rhythmbox
Classification: Other
Component: general
HEAD
Other Linux
: Normal normal
: ---
Assigned To: RhythmBox Maintainers
RhythmBox Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-02-26 12:12 UTC by James "Doc" Livingston
Modified: 2007-02-27 10:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (17.08 KB, patch)
2007-02-26 12:16 UTC, James "Doc" Livingston
none Details | Review
move along, nothing to see here (25.89 KB, patch)
2007-02-26 20:54 UTC, James "Doc" Livingston
committed Details | Review
test case in the art display plugin (1.33 KB, patch)
2007-02-27 00:33 UTC, Claudio Saavedra
none Details | Review

Description James "Doc" Livingston 2007-02-26 12:12:41 UTC
Python can't connect to the metadata gathering signal of RhythmDB, because it uses a hash table parameter in the callback, and they don't carry enough information to use from Python (types etc).
Comment 1 James "Doc" Livingston 2007-02-26 12:16:45 UTC
Created attachment 83384 [details] [review]
patch

This patch adds a String-GValue map class, which is implemented using a GHashTable, and bound to Python. The use of GHashTable in the signal is replaces with the new class, and it can be seen to work with the following fragment, runnable from the python console:

shell.props.db.connect('entry-extra-metadata-gather', lambda db, e, m: m.set('xxx', 'yyy'))
map = shell.props.db.entry_gather_metadata(shell.props.shell_player.get_playing_entry())
map.size()
map.get('xxx')



I've also changed rb_value_free() to use gslices instead of malloc/free, and  changed the metadata-dbus code accordingly.
Comment 2 Jonathan Matthew 2007-02-26 13:04:10 UTC
The new files are missing from the patch, but what I can see of it looks good.
It'd be nice if we could make the string-gvalue map look like a python dict, but maybe that's more trouble than it's worth.
Comment 3 James "Doc" Livingston 2007-02-26 20:54:46 UTC
Created attachment 83422 [details] [review]
move along, nothing to see here

New files added to patch, while no-one was watching.
Comment 4 Jonathan Matthew 2007-02-26 22:21:00 UTC
Looks sensible enough, and it seems to work.
Comment 5 Claudio Saavedra 2007-02-27 00:33:04 UTC
Created attachment 83435 [details] [review]
test case in the art display plugin

As a test case I hacked the art display plugin. It seems to work perfectly, as I can retrieve the metadata from the map in the python console, but on each call to the attached callback there's a warning in the console:

Traceback (most recent call last):
  • File "/opt/gnome-2.18/lib/rhythmbox/plugins/artdisplay/__init__.py", line 351 in cover_art_uri_gather
    metadata.set('coverArt-uri', self.art_widget.current_uri)
TypeError: can't map metadata to GType system

Can't say what's wrong, though, and it may be just me.
Comment 6 Claudio Saavedra 2007-02-27 00:56:39 UTC
Nevermind, I forgot to check if current_uri is not null. Your patch works pretty well!
Comment 7 James "Doc" Livingston 2007-02-27 07:42:09 UTC
In particular, the TypeError occurs because we don't know what to map None to. There are three possible types it could be G_TYPE_POINTER, G_TYPE_BOXED and G_TYPE_OBJECT.

I've committed the patch to trunk, with a small change that makes it use a more meaningful error message when you try to store None.



I'm leaving the bug open, because I want to allow you to do "metadata['cover-art-uri'] = foo" as well.
Comment 8 James "Doc" Livingston 2007-02-27 09:58:46 UTC
RBStringValueMap now supports Python's map protocol, so indexing like that works :)
Comment 9 Alex Lancaster 2007-02-27 10:19:16 UTC
Last commit (r4868) breaks build:

 gcc -DHAVE_CONFIG_H -I. -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/bindings/python -I../.. -I/home/alex/src/remote-cvs/gnome.org/rhythmbox -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/lib -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/metadata -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/player -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/rhythmdb -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/widgets -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/sources -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/iradio -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/podcast -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/plugins -I/home/alex/src/remote-cvs/gnome.org/rhythmbox/shell -DORBIT2=1 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libgnomeui-2.0 -I/usr/include/libgnome-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/libbonoboui-2.0 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/gnome-vfs-2.0/include -I/usr/include/gnome-keyring-1 -I/usr/include/orbit-2.0 -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/libxml2 -I/usr/include/libglade-2.0 -I/usr/include/gnome-vfs-module-2.0 -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -Wcomment -Wformat -Wnonnull -Wimplicit-int -Wimplicit -Wmain -Wmissing-braces -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused-function -Wunused-label -Wunused-value -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align -Wall -Werror -std=gnu89 -I/usr/include/pygtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/python2.4 -Wno-error -g -O2 -MT rb_la-rhythmdb.lo -MD -MP -MF .deps/rb_la-rhythmdb.Tpo -c rhythmdb.c  -fPIC -DPIC -o .libs/rb_la-rhythmdb.o
rhythmdb.override: In function '_wrap_rhythmdb_entry_type__get_can_sync_metadata':
rhythmdb.override:479: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override:480: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override:483: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override:484: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override: In function '_wrap_rhythmdb_entry_type__set_can_sync_metadata':
rhythmdb.override:515: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override:519: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override: In function '_wrap_rhythmdb_entry_get':
rhythmdb.override:110: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override: In function '_wrap_rhythmdb_entry_set':
rhythmdb.override:145: warning: dereferencing type-punned pointer will break strict-aliasing rules
rhythmdb.override: At top level:
rhythmdb.override:734: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_wrap_rb_string_value_map_mp_length'
rhythmdb.override:798: error: '_wrap_rb_string_value_map_mp_length' undeclared here (not in a function)
make[4]: *** [rb_la-rhythmdb.lo] Error 1
Comment 10 Alex Lancaster 2007-02-27 10:36:25 UTC
Fixed again in SVN.