def init(self):
        self.__activated = False
        self.__shell = self.props.shell
        self.__db = self.__shell.props.db
        self.__player = self.__shell.props.shell_player
        self.__plugin = self.props.plugin
        self.__entry_type = self.props.entry_type

        self.gconf = GConf.Client.get_default()
        self.vbox_main = None
        
        self.create_window()
        self.create_popups()
        
        # Pandora
        self.pandora = make_pandora()
        self.worker = GObjectWorker()
        
        self.stations_model = StationsModel(self.__db, self.__entry_type)
        self.songs_model = SongsModel(self.__db, self.__entry_type)
        self.songs_list.set_model(self.songs_model)
        self.props.query_model = self.songs_model # Enables skipping
        
        self.current_station = None
        self.current_song = None
        self.connected = False
        self.request_outstanding = False
        
        self.songs_action = SongsAction(self)
        self.stations_action = StationsAction(self, self.__plugin)
        
        self.notification_icon = NotificationIcon(self.__plugin, self.songs_action)
        self.refresh_notification_icon()
        
        self.connect_all()

        self.retrying = False
        self.waiting_for_playlist = False
class PandoraSource(RB.StreamingSource):
#    __gproperties__ = {
#            'plugin': (rb.Plugin,
#            'plugin',
#            'plugin',
#            gobject.PARAM_WRITABLE | gobject.PARAM_CONSTRUCT_ONLY)
#    }
      
    def __init__(self):
        RB.StreamingSource.__init__(self,name="PandoraPlugin")
        
    def init(self):
        self.__activated = False
        self.__shell = self.props.shell
        self.__db = self.__shell.props.db
        self.__player = self.__shell.props.shell_player
        self.__plugin = self.props.plugin
        self.__entry_type = self.props.entry_type

        self.gconf = GConf.Client.get_default()
        self.vbox_main = None
        
        self.create_window()
        self.create_popups()
        
        # Pandora
        self.pandora = make_pandora()
        self.worker = GObjectWorker()
        
        self.stations_model = StationsModel(self.__db, self.__entry_type)
        self.songs_model = SongsModel(self.__db, self.__entry_type)
        self.songs_list.set_model(self.songs_model)
        self.props.query_model = self.songs_model # Enables skipping
        
        self.current_station = None
        self.current_song = None
        self.connected = False
        self.request_outstanding = False
        
        self.songs_action = SongsAction(self)
        self.stations_action = StationsAction(self, self.__plugin)
        
        self.notification_icon = NotificationIcon(self.__plugin, self.songs_action)
        self.refresh_notification_icon()
        
        self.connect_all()

        self.retrying = False
        self.waiting_for_playlist = False

    def refresh_notification_icon(self, icon_enabled = None):
        if icon_enabled:
            enabled = icon_enabled
        else:
            enabled = self.gconf.get_bool(GCONF_KEYS['icon'])

        if enabled and self.__player.get_playing_source() == self:
            self.notification_icon.show()
        else:
            self.notification_icon.hide()
            
    def do_selected(self):
        print "do_selected"

    def do_get_status(self, *args):
        """Return the current status of the Pandora source.
        
        Called by Rhythmbox to figure out what to show on the statusbar.
        
        Args:
            args: Unknown
        
        Returns:
            A tuple of:
                the text status to display
                the status to display on the progress bar
                the progress value, if the progress value is less than zero, the progress bar will pulse.
        """
        progress_text = None
        progress = 1
        text = ""

        if self.connected:
            self.error_area.hide()
            num_stations = self.stations_model.get_num_entries()
            if num_stations > 1:
                text =  str(num_stations) + " stations"
            else:
                text =  str(num_stations) + " station"
        else:
            text = "Not connected to Pandora"

        # Display Current Station Info
        if self.__player.get_playing() and self.__player.get_playing_source() == self:
            station_name = self.current_station.name
            text = "Playing " + station_name + ", " + text 
        if self.request_outstanding:
            progress_text = self.request_description
            progress = -1
        return (text, progress_text, progress)

    def do_impl_get_entry_view(self):
        print "do_impl_get_entry_view"
        return self.songs_list

    def do_impl_can_pause(self):
        """Indicate that pausing of source entries is available.
        
        Called by Rhythmbox to determine whether playback of entries from the source can be paused.
        
        Returns:
            True to indicate the pausing is supported.
        """
        return True

    def do_impl_handle_eos(self):
        """Handle End Of Stream event by going to the next song.
        
        Called by Rhythmbox to handle EOS events when playing entries from this source.
        
        Returns:
            The source EOF type indicating to skip to the next song.
        """
        return RB.SourceEOFType(3) # next

    def do_impl_try_playlist(self):
        """Don't try to parse playback URIs in this source as playlists.
        
        Called by Rhythmbox to determine if URIs should be parsed as playlists rather than just played.
        
        Returns:
            False to disable playlist parsing.
        """
        return False

    def do_songs_show_popup(self, view, over_entry):
        if over_entry:
            selected = view.get_selected_entries()
            if len(selected) == 1:
                self.show_single_popup("/PandoraSongViewPopup")

    def do_stations_show_popup(self, view, over_entry):
        if over_entry:
            selected = view.get_selected_entries()
            if len(selected) == 1:
                self.show_single_popup("/PandoraStationViewPopup")
        else:
            self.show_single_popup("/PandoraSourceMainPopup")

    def show_single_popup(self, popup):
        popup = self.__player.props.ui_manager.get_widget(popup)
        popup.popup(None, None, None, None, 3, Gtk.get_current_event_time())

    def playing_source_changed(self, source):
        print "Playing source changed"
        if not self.notification_icon:
            return
        if self != source:
            self.notification_icon.hide()
        else:
            self.notification_icon.show()

    def playing_entry_changed(self, entry):
        print "Playing Entry changed"
        if not self.__db or not entry:
            return
        if entry.get_entry_type() != self.__entry_type:
            return
        self.get_metadata(entry)

        url = entry.get_playback_uri()
        
        self.current_song = self.songs_model.get_song(url)
        if self.songs_model.is_last_entry(entry):
            self.get_playlist()

    def create_window(self):
        if self.vbox_main:
            self.remove(self.vbox_main)
            self.vbox_main.hide_all()
            self.vbox_main = None

        self.stations_list = widgets.StationEntryView(self.__db, self.__player)
        self.songs_list = widgets.SongEntryView(self.__db, self.__player, self.__plugin)
        
        self.vbox_main = Gtk.VBox(False, 5)

        paned = Gtk.VPaned()
        frame1 = Gtk.Frame()
        frame1.set_shadow_type(Gtk.ShadowType.OUT)
        frame1.add(self.stations_list)
        paned.pack1(frame1, True, False)
        frame2 = Gtk.Frame()
        frame2.set_shadow_type(Gtk.ShadowType.OUT)
        frame2.add(self.songs_list)
        paned.pack2(frame2, True, False)
        self.vbox_main.pack_start(paned, True, True, 0)
 
        self.error_area = widgets.ErrorView(self.__plugin, self.do_impl_activate)
        error_frame = self.error_area.get_error_frame()
        self.vbox_main.pack_end(error_frame, False, False, 0)
 
        self.vbox_main.show_all()
        self.error_area.hide()
        self.add(self.vbox_main)


    def connect_all(self):
        self.stations_list.connect('show_popup', self.do_stations_show_popup)
        self.songs_list.connect('show_popup', self.do_songs_show_popup)
        self.songs_action.connect()
        self.stations_action.connect()


    def create_popups(self):
        self.action_group = Gtk.ActionGroup('PandoraPluginActions')
        action = Gtk.Action('SongInfo', _('Song Info...'), _('View song information in browser'), 'gtk-info')
        self.action_group.add_action(action)
        action = Gtk.Action('LoveSong', _('Love Song'), _('I love this song'), 'gtk-about')
        self.action_group.add_action(action)
        action = Gtk.Action('BanSong', _('Ban Song'), _("I don't like this song"), 'gtk-cancel')
        self.action_group.add_action(action)
        action = Gtk.Action('TiredSong', _('Tired of this song'), _("I'm tired of this song"), 'gtk-jump-to')
        self.action_group.add_action(action)
        action = Gtk.Action('Bookmark', _('Bookmark'), _('Bookmark...'), 'gtk-add')
        self.action_group.add_action(action)
        action = Gtk.Action('BookmarkSong', _('Song'), _("Bookmark this song"), None)
        self.action_group.add_action(action)
        action = Gtk.Action('BookmarkArtist', _('Artist'), _("Bookmark this artist"), None)
        self.action_group.add_action(action)

        action = Gtk.Action('AddStation', _('Create a New Station'), _('Create a new Pandora station'), 'gtk-add')
        self.action_group.add_action(action)

        action = Gtk.Action('StationInfo', _('Station Info...'), _('View station information in browser'), 'gtk-info')
        self.action_group.add_action(action)
        action = Gtk.Action('DeleteStation', _('Delete this Station'), _('Delete this Pandora Station'), 'gtk-remove')
        self.action_group.add_action(action)

        manager = self.__player.props.ui_manager
        manager.insert_action_group(self.action_group, 0)
        popup_file = rb.find_plugin_file(self.__plugin, "pandora/pandora-ui.xml")
        self.ui_id = manager.add_ui_from_file(popup_file)
        manager.ensure_update()

     # rhyhtmbox api break up (0.13.2 - 0.13.3)   
    def do_selected(self):
        print "Activating source."
        if not self.__activated:
            try:
                self.username, self.password = self.get_pandora_account_info()
            except AccountNotSetException, (instance):
                # Ask user to configure account
                self.error_area.show(instance.parameter)
                # Retry after the user has put in account information.
                return
            
            self.pandora_connect()
            
            self.__activated = True