Commits

Rhys !  committed 89a4db2

edit callback uses attribute instead of widget text

  • Participants
  • Parent commits f560078

Comments (0)

Files changed (1)

     Make sure prep_buttons is called.
     '''
 
+    def __init__(self):
+        self.has_lyrics = False
+
     def __got_lyrics(self, lyrics):
         if lyrics:
             self.edit.props.label = '_Edit'
             self.edit.props.sensitive = True
             self.buffer.props.text = lyrics
+            self.has_lyrics = True
         elif self.c_song.artist and self.c_song.title:
             self.edit.props.label = '_Add'
             self.edit.props.sensitive = True
             self.buffer.props.text = 'Lyrics not found.'
+            self.has_lyrics = False
         else:
             self.edit.props.label = '_Edit'
             self.edit.props.sensitive = False
             self.buffer.props.text = 'Could not determine artist and title.'
+            self.has_lyrics = False
 
     def get_lyrics(self, force_refresh=False):
         self.edit.props.sensitive = False
 
     def edit_callback(self, widget):
         u = urllib.quote
-        if widget.props.label == '_Edit':
-            webbrowser.open_new('http://www.lyrcl.org/edit/%s:%s' % (u(self.c_song.artist), u(self.c_song.title)))
-        elif widget.props.label == '_Add':
-            webbrowser.open_new('http://www.lyrcl.org/add?artist=%s&song=%s' % (u(self.c_song.artist), u(self.c_song.title)))
+        if self.has_lyrics:
+            webbrowser.open_new('http://www.lyrcl.org/edit/%s:%s' % (
+                u(self.c_song.artist), u(self.c_song.title)))
         else:
-            print 'Edit button has unexpected text. THIS SHOULD NOT HAPPEN.'
+            webbrowser.open_new('http://www.lyrcl.org/add?artist=%s&song=%s' % (
+                u(self.c_song.artist), u(self.c_song.title)))
 
     def create_lyrics_view(self):
         tview = gtk.TextView()
 
 class LyricPane(LyricsShowyThing):
     def __init__(self, db, song_info):
+        super(self.__class__, self).__init__()
         self.song_info_property = song_info.get_property
         self.c_song = CurrentSong(db)