source: gutenbach-rhythmbox-plugin/__init__.py @ 7e6a613

debianmacno-cupsweb
Last change on this file since 7e6a613 was 7e6a613, checked in by Jessica B. Hamrick <jhamrick@…>, 14 years ago

Initial commit.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import rb
2import gtk
3import urlparse
4import urllib
5import subprocess
6
7menu_ui = """
8<ui> 
9  <popup name="BrowserSourceViewPopup">
10    <menuitem name="Pikamp3" action="SendToPikamp3"/>
11  </popup>
12</ui>
13"""
14class Pikamp3Plugin(rb.Plugin):
15    def __init__(self):
16        rb.Plugin.__init__(self)
17
18    def activate(self, shell):
19        self.shell = shell
20        # Create action for sending a track to pikamp3
21        action = gtk.Action('SendToPikamp3', _('Send to pikamp3'),
22                _("Queue selected tracks to the pikamp3 server."),
23                "")
24        action.connect('activate', self.pikamp3_action, shell)
25        action_group = gtk.ActionGroup('Pikamp3ActionGroup')
26        action_group.add_action(action)
27        manager = shell.get_ui_manager()
28        manager.insert_action_group(action_group)
29        manager.add_ui_from_string(menu_ui)
30
31    def deactivate(self, shell):
32        del self.shell
33
34    def pikamp3_action(self, action, shell):
35        source = shell.get_property("selected-source")
36        for entry in source.get_entry_view().get_selected_entries():
37            uri = entry.get_playback_uri()
38            p = urlparse.urlparse(urllib.unquote(uri))
39            if p.scheme == "file":
40                path = p.path
41                command = 'lpr -P pikamp3@lbsg.mit.edu "%s"' % path
42                print command
43                subprocess.Popen(command, shell=True)
44
45
46
Note: See TracBrowser for help on using the repository browser.