~roignac/+junk/rhythmbox-vkontakte

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# - encoding: utf8 - 
#
# Copyright © 2010 Alexey Grunichev
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import rb, rhythmdb
import gobject, gtk
from VkontakteSource import VkontakteSource

popup_ui = """
<ui>
	<popup name="VkontakteSourceViewPopup">
		<menuitem name="AddToQueueLibraryPopup" action="AddToQueue"/>
	</popup>
</ui>
"""

class VkontaktePlugin(rb.Plugin):
		
	def activate(self, shell):
		entry_type = shell.props.db.entry_register_type("VkontakteEntryType")
		source_group = rb.rb_source_group_get_by_name("library")
		self.source = gobject.new(VkontakteSource, name=_("Vkontakte"), shell=shell, plugin=self, entry_type=entry_type, source_group=source_group)
		# Set the source's icon
		width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
		icon = gtk.gdk.pixbuf_new_from_file_at_size(self.find_file("icon.ico"), width, height)
		self.source.props.icon = icon
		
		shell.append_source(self.source, None)
		shell.register_entry_type_for_source(self.source, entry_type)
		
		ui = shell.get_ui_manager()
		self.uid = ui.add_ui_from_string(popup_ui)
		ui.ensure_update()

	def deactivate(self, shell):
		self.source.delete_thyself()
		del self.source