Changeset - e4aafd2242aa
[Not reviewed]
default
0 1 0
Drew Perttula - 10 years ago 2015-06-14 15:44:03
drewp@bigasterisk.com
CC try to debug why it jumps to random songs sometimes.
Ignore-this: 6fe1bf762a0c34ca07e6966546d986e6
1 file changed with 18 insertions and 6 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -74,13 +74,13 @@ class Main(object):
 
        graph.addHandler(updateTitle)
 

	
 
        songChoice = Observable(None) # to be connected with the session song
 

	
 
        self.registerGraphToSongChoice(wtree, session, graph, songChoice)
 
        self.registerSongChoiceToGraph(session, graph, songChoice)
 
        self.current_player_song = self.registerCurrentPlayerSongToUi(wtree, graph, songChoice)
 
        self.registerCurrentPlayerSongToUi(wtree, graph, songChoice)
 

	
 
        ec = EditChoice(graph, songChoice, label="Editing song:")
 
        wtree.get_object("currentSongEditChoice").add(ec)
 
        ec.show()
 
        
 
        wtree.get_object("subterms").connect("add", self.onSubtermChildAdded)
 
@@ -100,20 +100,33 @@ class Main(object):
 
            if not wtree.get_object("followPlayerSongChoice").get_active():
 
                songChoice(current)
 
                dispatcher.send("song_has_changed")
 
        graph.addHandler(setSong)
 

	
 
    def registerSongChoiceToGraph(self, session, graph, songChoice):
 
        def songToGraph(newSong):
 
        self.muteSongChoiceUntil = 0
 
        def songChoiceToGraph(newSong):
 
            if newSong is Local:
 
                raise NotImplementedError('what do i patch')
 
            log.debug('songToGraph is going to set to %r', newSong)
 
            log.debug('songChoiceToGraph is going to set to %r', newSong)
 
            import traceback; traceback.print_stack()
 

	
 
            # I get bogus newSong values in here sometimes. This
 
            # workaround may not even be helping.
 
            now = time.time()
 
            if now < self.muteSongChoiceUntil:
 
                log.debug('muted')
 
                return
 
            self.muteSongChoiceUntil = now + 1
 
            
 
            graph.patchObject(context=session, subject=session,
 
                              predicate=L9['currentSong'], newObject=newSong)
 
        songChoice.subscribe(songToGraph)
 
            
 
            
 
            
 
        songChoice.subscribe(songChoiceToGraph)
 

	
 
    def registerCurrentPlayerSongToUi(self, wtree, graph, songChoice):
 
        """current_player_song 'song' param -> playerSong ui
 
        and
 
        current_player_song 'song' param -> songChoice, if you're in autofollow
 
        """
 
@@ -124,19 +137,18 @@ class Main(object):
 
                log.debug("update playerSong to %s", ps.get_uri())
 
                def setLabel():
 
                    ps.set_label(graph.label(song))
 
                graph.addHandler(setLabel)
 
                ps.set_uri(song)
 
            if song != songChoice():
 
                log.debug('song %s != songChoice %s', song, songChoice())
 
                if wtree.get_object("followPlayerSongChoice").get_active():
 
                    log.debug('followPlayerSongChoice is on')
 
                    songChoice(song)
 
                
 
        dispatcher.connect(current_player_song, "current_player_song")
 
        return current_player_song
 
        self.current_player_song = current_player_song
 
        
 
    def setupNewSubZone(self):
 
        self.wtree.get_object("newSubZone").drag_dest_set(
 
            flags=Gtk.DestDefaults.ALL,
 
            targets=[Gtk.TargetEntry('text/uri-list', 0, 0)],
 
            actions=Gdk.DragAction.COPY)
0 comments (0 inline, 0 general)