Changeset 0159c0a


Ignore:
Timestamp:
Nov 29, 2009, 5:59:45 PM (14 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
master, debian, mac, no-cups, web
Children:
d566e6b
Parents:
7e6a613
git-author:
Jessica B. Hamrick <jhamrick@…> (11/29/09 17:59:45)
git-committer:
Jessica B. Hamrick <jhamrick@…> (11/29/09 17:59:45)
Message:

-Changed the name from pikamp3 to gutenbach.
-Added comments.
-Moved printername and hostname to constructor.
-Created UI XML file for future preferences dialogue.

Location:
gutenbach-rhythmbox-plugin
Files:
2 added
3 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • gutenbach-rhythmbox-plugin/__init__.py

    r7e6a613 r0159c0a  
    55import subprocess
    66
    7 menu_ui = """
     7# UI Change is an extra item added to right-click menu when clicking on tracks
     8popup_ui = """
    89<ui>
    910  <popup name="BrowserSourceViewPopup">
    10     <menuitem name="Pikamp3" action="SendToPikamp3"/>
     11    <menuitem name="Gutenbach" action="SendToGutenbach"/>
    1112  </popup>
    1213</ui>
    1314"""
    14 class Pikamp3Plugin(rb.Plugin):
     15class GutenbachPlugin(rb.Plugin):
    1516    def __init__(self):
    1617        rb.Plugin.__init__(self)
     
    1819    def activate(self, shell):
    1920        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."),
     21        # Create action for sending a track to gutenbach
     22        action = gtk.Action('SendToGutenbach', _('Send to gutenbach'),
     23                _("Queue selected tracks to the gutenbach server."),
    2324                "")
    24         action.connect('activate', self.pikamp3_action, shell)
    25         action_group = gtk.ActionGroup('Pikamp3ActionGroup')
     25        action.connect('activate', self.gutenbach_action, shell)
     26        action_group = gtk.ActionGroup('GutenbachActionGroup')
    2627        action_group.add_action(action)
    2728        manager = shell.get_ui_manager()
    2829        manager.insert_action_group(action_group)
    29         manager.add_ui_from_string(menu_ui)
     30        manager.add_ui_from_string(popup_ui)
     31
     32        # Default configuration options
     33        self.printer = "pikamp3"
     34        self.printer_host = "lbsg.mit.edu"
    3035
    3136    def deactivate(self, shell):
    3237        del self.shell
    3338
    34     def pikamp3_action(self, action, shell):
     39    def gutenbach_action(self, action, shell):
    3540        source = shell.get_property("selected-source")
     41        # For each track currently selected in the song browser
    3642        for entry in source.get_entry_view().get_selected_entries():
     43            # Only play files that are stored on the user's computer
    3744            uri = entry.get_playback_uri()
    3845            p = urlparse.urlparse(urllib.unquote(uri))
    3946            if p.scheme == "file":
    4047                path = p.path
    41                 command = 'lpr -P pikamp3@lbsg.mit.edu "%s"' % path
     48                if self.printer_host:
     49                    printer = '@'.join([self.printer, self.printer_host])
     50                else:
     51                    printer = self.printer
     52                command = 'lpr -P %s "%s"' % (printer, path)
    4253                print command
    4354                subprocess.Popen(command, shell=True)
    4455
    45 
    46 
Note: See TracChangeset for help on using the changeset viewer.