[Rhythmbox-devel] Python SIGSEGV


I've been trying to develop a simple plugin for Rhythmbox. I tested it
with Python console and it worked good though the code is as hideous a
hack as it could possibly be. However after wrapping it up as a fully
fashioned Python Plugin it not only stopped working but also started
segfaulting RB itself!

I have posted a bug[1] at the bugzilla (marking it critical, because
breaking a player from a plugin subsystem I consider a critical bug) but
there was absolutely no response for it, so I repost it here.

I attach the code in hope that somebody could tell me either how to do
it correctly or what to fix in RB in order for it to start working.

Prior to segfaulting RB spawns lots of GObject errors too, which are
attached to the bugreport.

Piotr Gaczkowski

[1] http://bugzilla.gnome.org/show_bug.cgi?id=469524
import rhythmdb, rb
import gtk
import random

ui_str = """
  <menubar name="MenuBar">
	<menu name="ControlMenu" action="Control">
	  <menuitem name="RandomArtist" action="RandomArtist"/>
	  <menuitem name="RandomAlbum" action="RandomAlbum"/>

class Randomizer(rb.Plugin):

	def __init__(self):

	def activate(self, shell):
		self.shell = shell
		self.artist_action = gtk.Action ('RandomArtist', _('Random Artist'), _(''), None)
		self.activate_id = self.artist_action.connect ('activate', self.random_artist, shell)
		self.album_action = gtk.Action ('RandomAlbum', _('Random Album'), _(''), None)
		self.activate_id = self.album_action.connect ('activate', self.random_album, shell)
		self.action_group = gtk.ActionGroup ('RandomizerPluginActions')
		self.action_group.add_action_with_accel (self.artist_action,

		self.action_group.add_action_with_accel (self.album_action,
		uim = shell.get_ui_manager ()
		uim.insert_action_group (self.action_group, 0)
		self.ui_id = uim.add_ui_from_string (ui_str)
		uim.ensure_update ()
		self.db = self.shell.props.db
		self.source = self.shell.props.library_source
		self.artists = list()
		self.albums = list()

	def deactivate(self, shell):
		del self.shell
		del self.db
		del self.source
		del self.artists
		del self.albums

	def random_artist(self, action, shell):
		print "Enter random_artist"
		for row in self.source.props.query_model:
			entry = row[0]
			self.artists.append(self.db.entry_get(entry, rhythmdb.PROP_ARTIST))

		random_artist = random.choice(self.artists)
		print random_artist

		for view in self.source.get_property_views():
			if view.props.prop == rhythmdb.PROP_ARTIST:
				print view
				print view.props.title
				print view.props.prop
				print view.set_selection
				print "And now set_selection()"

	def random_album(self, action, shell):
		for row in self.source.props.query_model:
			entry = row[0]
			self.albums.append(self.db.entry_get(entry, rhythmdb.PROP_ALBUM))

		random_album = random.choice(self.albums)

		for view in self.source.get_property_views():
			if view.props.prop == rhythmdb.PROP_ALBUM:
[RB Plugin]
Name=Music randomizer
Description=This plugin randomizes artists or albums
Authors=Piotr Gaczkowski <doomhammerng gmail com>
Copyright=Copyright © 2007 Piotr Gaczkowski

Attachment: signature.asc
Description: To jest =?UTF-8?Q?cz=C4=99=C5=9B=C4=87?= listu podpisana cyfrowo

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