Commits

Vladimir Kolev committed 95f62cc

Fixining icon loading and list clear

Comments (0)

Files changed (1)

 locale.bindtextdomain(APP, DIR)
 gettext.bindtextdomain(APP, DIR)
 gettext.textdomain(APP)
-gettext.install(APP, localedir=DIR, unicode=True)
+gettext.install(APP, localedir = DIR, unicode = True)
 
 LAST_KEY = "51fd71dc8939360b25a1029e556258a4"
 LAST_SECRET = "cf35dd38f998ca4d3af4adbe59ae23f7"
             raise KeyError()
     except KeyError:
         CONFIG['show_notification'] = 0
-        
+
     try:
         test = CONFIG['quit_without_confirmation']
     except KeyError:
         CONFIG['quit_without_confirmation'] = 1
-        
+
     try:
         test = CONFIG['startup_update_check']
     except KeyError:
     scrobbled = 0
     # Download dictionary in form Filename : Thread
     downqueue = {}
-    
+
     last_iter = None
 
     def __init__(self):
         completition.set_minimum_key_length(1)
         completition.set_text_column(0)
         self.entry.set_completion(completition)
-        
+
         # Results List definition
         # Model: Title, Artist, Album, SongID, Song Array
         self.result = gtk.ListStore(str, str, str, str, object)
         self.sw2.add(self.play_view)
         #self._create_play_columns()
         #self.selector = self.play_view.get_selection()
-        
+
         # Download list definition
         # Model: File Name, SongID, Progress, Size, Thread Object
         self.downloads = gtk.ListStore(str, str, int, str, object)
         self.downloads_expander = builder.get_object('expander_download')
         self.update_downloads_count()
         self.downmenu = builder.get_object('downloadmenu')
-        
+
         self.staticon = lib.guihelpers.GsharkIndicator(self)
 
         if os.path.exists("%s/.gsharkdown/playlist.pkl" % os.environ.get("HOME")):
 
         if int(CONFIG['show_notification']) == 1 and HAVE_NOTIFY:
             pynotify.init("gSharkDown")
-            
+
         # Set default directory if is empty
         if CONFIG['down_path'] == "":
             CONFIG['down_path'] = os.path.join(glib.get_user_special_dir(glib.USER_DIRECTORY_MUSIC), "Grooveshark")
-        
+
         # Scrobbling initialisation
         self.lastfm = ""
         if int(CONFIG['scrobbling']) == 1 and HAVE_PYLAST:
-            self.lastfm = pylast.LastFMNetwork(api_key=LAST_KEY,
-                                          api_secret=LAST_SECRET,
-                                          username=CONFIG['lastuser'],
-                                          password_hash=CONFIG['lastpass'])
+            self.lastfm = pylast.LastFMNetwork(api_key = LAST_KEY,
+                                          api_secret = LAST_SECRET,
+                                          username = CONFIG['lastuser'],
+                                          password_hash = CONFIG['lastpass'])
 
         builder.connect_signals(self)
         self.tlisten = KeyListenerThread(self)
             if CONFIG['startup_update_check'] == 1:
                 self.check_for_update(None)
         self.window.show_all()
-    
+
     def get_playing_iter(self):
         iter = self.playlist.get_iter_first()
         while iter != None:
             if self.playlist[iter][5] > 400:
                 return iter
             iter = self.playlist.iter_next(iter)
-            
+
         return None
-    
+
     def get_iter_last(self, model):
         """
         Get the last iter from a model
         """
         rows = model.iter_n_children(None);
-        return model.get_iter([rows-1]);
-    
+        return model.get_iter([rows - 1]);
+
     def result_song(self, index):
         return self.result[index][4]
-    
+
     def playlist_song(self, index):
         return self.playlist[index][4]
 
-    def show_prefs_menu(self, button, data=None):
+    def show_prefs_menu(self, button, data = None):
         self.prefsmenu.popup(None, None, None, 0, 0)
-    
+
     def add_song_to_playlist(self, song):
-        song_string = "<span>%s</span>\n<span fgcolor='#777777'>%s</span>" % (self.get_sliced_string(song['SongName'], 25), self.get_sliced_string(song['ArtistName'],20))
+        song_string = "<span>%s</span>\n<span fgcolor='#777777'>%s</span>" % (self.get_sliced_string(song['SongName'], 25), self.get_sliced_string(song['ArtistName'], 20))
         #if len(song_string) > 14:
         #    song_string = song_string[:13] + "..."
-        tooltip = _("<b>Title:</b> {title}\n").format(title=song['SongName'])
-        tooltip += _("<b>Artist:</b> {artist}\n").format(artist=song['ArtistName'])
-        tooltip += _("<b>Album:</b> {album}\n").format(album=song['AlbumName'])
-        tooltip += _("<b>Year:</b> {year}").format(year=song['Year'])
-        
+        tooltip = _("<b>Title:</b> {title}\n").format(title = song['SongName'])
+        tooltip += _("<b>Artist:</b> {artist}\n").format(artist = song['ArtistName'])
+        tooltip += _("<b>Album:</b> {album}\n").format(album = song['AlbumName'])
+        tooltip += _("<b>Year:</b> {year}").format(year = song['Year'])
+
         appended_iter = self.playlist.append([
             song_string,
             self.create_loading_track_icon(),
             song,
             400
         ])
-        
+
         thread = SongCoverThread(self, appended_iter)
         thread.start()
-    
+
     def create_default_track_icon(self):
         default = gtk.gdk.pixbuf_new_from_file("%s/data/sdefault.png" % BASEPATH)
         return self.create_cornered_image(default)
-    
+
     def create_loading_track_icon(self):
         default = gtk.gdk.pixbuf_new_from_file("%s/data/loading.png" % BASEPATH)
         return self.create_cornered_image(default)
-    
+
     def create_cornered_image(self, pixbuf):
         corners = gtk.gdk.pixbuf_new_from_file("%s/data/corners.png" % BASEPATH)
         corners.composite(pixbuf, 0, 0, pixbuf.props.width, pixbuf.props.height,
                           0, 0, 1.0, 1.0, gtk.gdk.INTERP_HYPER, 255)
         return pixbuf
-    
+
+    def recover_icon(self, cover_url):
+        try:
+            url = "http://beta.grooveshark.com/static/amazonart/s%s"
+            response = urllib2.urlopen(url % cover_url)
+            loader = gtk.gdk.PixbufLoader()
+            loader.write(response.read())
+            loader.close()
+            image = loader.get_pixbuf()
+            return image
+        except:
+            image = self.create_default_track_icon()
+            return image
+
     def get_current_cover_url(self, iter):
         song = self.playlist.get_value(self.last_iter, 4)
-        try: 
+        try:
             return song['CoverArtFilename']
         except:
             return "sdefault"
-        
+
 
     def load_saved_playlist(self, path):
         """
         file = open(path, 'rb')
         eoferror = True
         playitems = []
-        
+
         while eoferror:
             try:
                 playitems.append(pickle.load(file))
 
         for i in range(0, len(playitems)):
             self.add_song_to_playlist(playitems[i])
-                
+
     def save_playlist(self, path):
         """
         Saves the playlist from the playlist treeview to 
             error.show_all()
 
 
-    def save_as_playlist(self, widget, data=None):
+    def save_as_playlist(self, widget, data = None):
         """
         Saves the playlist to .pkl file in directory
         choosen from the user
             self.save_playlist(filename)
         savedlg.destroy()
 
-    def open_saved_playlist(self, widget, data=None):
+    def open_saved_playlist(self, widget, data = None):
         """
         Opens a usersaved playlist from .pkl file
         """
             self.play_by_index(0)
         opendlg.destroy()
 
-    def window_close(self, widget, data=None):
+    def window_close(self, widget, data = None):
         """
         Closes the main window
         """
         self.windowstate = 0
         return True
 
-    def check_for_update(self, widget, data=None):
+    def check_for_update(self, widget, data = None):
         """
         Checks if a new version of the application is available
         on the application website. NEVER change the VERSION file
         t = UpdateThread(BASEPATH, markup, nmarkup, othertext)
         t.start()
 
-    def icon_clicked(self, widget, data=None):
+    def icon_clicked(self, widget, data = None):
         """
         Executed on left clicking the statusicon
         """
         for the search results
         """
         rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("Title"), rendererText, text=0)
+        column = gtk.TreeViewColumn(_("Title"), rendererText, text = 0)
         column.set_resizable(True)
         column.set_max_width(300)
         self.result_view.append_column(column)
 
         rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("Artist"), rendererText, text=1)
+        column = gtk.TreeViewColumn(_("Artist"), rendererText, text = 1)
         column.set_resizable(True)
         self.result_view.append_column(column)
 
         rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("Album"), rendererText, text=2)
+        column = gtk.TreeViewColumn(_("Album"), rendererText, text = 2)
         column.set_resizable(True)
         column.set_max_width(150)
         self.result_view.append_column(column)
 
         rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("SongID"), rendererText, text=3)
+        column = gtk.TreeViewColumn(_("SongID"), rendererText, text = 3)
         column.set_resizable(True)
         self.result_view.append_column(column)
-        
+
     def _create_downloads_columns(self):
         """
         Generate the TreeView columns in the main window
         for the download list items
         """
         rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("File name"), rendererText, text=0)
-        column.set_resizable(True)
-        self.downloads_view.append_column(column)
-        
-        rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("SongID"), rendererText, text=1)
-        column.set_resizable(True)
-        self.downloads_view.append_column(column)
-        
-        rendererProgress = gtk.CellRendererProgress()
-        column = gtk.TreeViewColumn(_("Download progress"), rendererProgress, value=2)
-        column.set_resizable(True)
-        self.downloads_view.append_column(column)
-        
-        rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_("Size"), rendererText, text=3)
+        column = gtk.TreeViewColumn(_("File name"), rendererText, text = 0)
         column.set_resizable(True)
         self.downloads_view.append_column(column)
 
-    def quit_app(self, widget, data=None):
+        rendererText = gtk.CellRendererText()
+        column = gtk.TreeViewColumn(_("SongID"), rendererText, text = 1)
+        column.set_resizable(True)
+        self.downloads_view.append_column(column)
+
+        rendererProgress = gtk.CellRendererProgress()
+        column = gtk.TreeViewColumn(_("Download progress"), rendererProgress, value = 2)
+        column.set_resizable(True)
+        self.downloads_view.append_column(column)
+
+        rendererText = gtk.CellRendererText()
+        column = gtk.TreeViewColumn(_("Size"), rendererText, text = 3)
+        column.set_resizable(True)
+        self.downloads_view.append_column(column)
+
+    def quit_app(self, widget, data = None):
         """
         Confirmation dialog when exiting the application
         """
         if CONFIG['quit_without_confirmation'] == '0':
             dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
-                                  type=gtk.MESSAGE_QUESTION,
-                                  buttons=gtk.BUTTONS_YES_NO,
-                                  message_format=_("Are you sure to quit?"))
+                                  type = gtk.MESSAGE_QUESTION,
+                                  buttons = gtk.BUTTONS_YES_NO,
+                                  message_format = _("Are you sure to quit?"))
             dialog.set_title(_("Quit?"))
             response = dialog.run()
             dialog.destroy()
         else:
             response = gtk.RESPONSE_YES
-        
+
         if response == gtk.RESPONSE_YES:
             self.save_playlist("%s/.gsharkdown/playlist.pkl" % os.environ.get("HOME"))
             self.cancel_all_downloads()
             gtk.main_quit()
 
-    def copy_song(self, widget, data=None):
+    def copy_song(self, widget, data = None):
         """
         Copy the selected song name from the results list in the
         GNOME Clipboard
             clipboard.set_text(copystring)
             clipboard.store()
 
-    def add_to_playlist(self, widget, data=None):
+    def add_to_playlist(self, widget, data = None):
         """
         Adds selected item from the results to the playlist
         """
         select = self.result_view.get_selection().get_selected_rows()
         for item in select[1]:
             song = self.result_song(item[0])
-            
+
             self.add_song_to_playlist(song)
 
-    def remove_from_playlist(self, widget, data=None):
+    def remove_from_playlist(self, widget, data = None):
         """
         Removes an item from the playlist and the playitems list
         """
             if next != None:
                 self.play_view.get_selection().select_iter(next)
 
-    def clear_playlist(self, widget, data=None):
+    def clear_playlist(self, widget, data = None):
         """
         Removes all items from the playlist
         """
-        self.stop_play()
+        if self.last_iter != None:
+            self.stop_play()
         self.playlist.clear()
 
-    def toggle_repeat(self, widget, data=None):
+    def toggle_repeat(self, widget, data = None):
         """
         Toggles the configuration option for looping trough the
         playlist
         CONFIG['repeat_playlist'] = int(widget.get_active())
         CONFIG.write()
 
-    def toggle_shuffle(self, widget, data=None):
+    def toggle_shuffle(self, widget, data = None):
         """
         Toggle the configuration option for shuffleing the playlist
         """
         CONFIG['shuffle_playlist'] = int(widget.get_active())
         CONFIG.write()
 
-    def double_click_start(self, widget, path, data=None):
+    def double_click_start(self, widget, path, data = None):
         """
         Starts playling on double click event on the playlist
         treeview.
         self.play_view.unselect_all()
         self.play_by_index(path[0])
 
-    def on_result_row_activated(self, path, column, data=None):
+    def on_result_row_activated(self, path, column, data = None):
         """
         On double click in the search treeview the item is added to 
         the playlist and starts playling.
         song = self.result_song(column[0])
         self.add_song_to_playlist(song)
 
-    def play_next(self, widget, data=None):
+    def play_next(self, widget, data = None):
         """
         Plays the next item from the playlist
         """
         else:
             index = self.playlist.get_path(self.get_playing_iter())[0] + 1
             if int(CONFIG['shuffle_playlist']) == 1:
-                index = random.randint(0, len(self.playlist)-1)
+                index = random.randint(0, len(self.playlist) - 1)
 
             if index >= len(self.playlist):
                 if int(CONFIG['repeat_playlist']) == 1:
             else:
                 self.play_by_index(index)
 
-    def play_previous(self, widget, data=None):
+    def play_previous(self, widget, data = None):
         """
         Plays the previous song from the playlist
         """
         else:
             index = self.playlist.get_path(self.get_playing_iter())[0] - 1
             if int(CONFIG['shuffle_playlist']) == 1:
-                index = random.randint(0, len(self.playlist)-1)
+                index = random.randint(0, len(self.playlist) - 1)
 
             if index < 0:
                 if int(CONFIG['repeat_playlist']) == 1:
             index = 0
 
         if index >= len(self.playlist):
-            index = len(self.playlist)-1
-        
-        iter = self.playlist.get_iter((index, ))
-        
+            index = len(self.playlist) - 1
+
+        iter = self.playlist.get_iter((index,))
+
         if iter != self.get_playing_iter():
             self.scrobbled = 0
             for item in self.playlist:
                        int(CONFIG['repeat_playlist']),
                       self.lastfm)
             t.start()
-            
+
     def stop_play(self):
         """
         Stop current playing
         self.play_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
         self.set_songinfos()
 
-    def on_volume_change(self, widget, data=0.5):
+    def on_volume_change(self, widget, data = 0.5):
         """
         Volume change handler
         """
         self.player.set_property("volume", float(data))
         return True
 
-    def show_info(self, widget, data=None):
+    def show_info(self, widget, data = None):
         """
         Song infromation dialog for first item selected from the search results.
         """
             song = self.result_song(select[1][0])
             dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
                                       0, gtk.BUTTONS_OK,)
-            dialog.set_title(_("Song Information - {songid}").format(songid=song['SongID']))
-            _filename = _("<b>Filename:</b> {artist} - {title}.mp3\n").format(artist=song['ArtistName'],
-                                                       title=song['SongName'])
-            _artist = _("<b>Artist:</b> {artist}\n").format(artist=song['ArtistName'])
-            _title = _("<b>Title:</b> {title}\n").format(title=song['SongName'])
+            dialog.set_title(_("Song Information - {songid}").format(songid = song['SongID']))
+            _filename = _("<b>Filename:</b> {artist} - {title}.mp3\n").format(artist = song['ArtistName'],
+                                                       title = song['SongName'])
+            _artist = _("<b>Artist:</b> {artist}\n").format(artist = song['ArtistName'])
+            _title = _("<b>Title:</b> {title}\n").format(title = song['SongName'])
             _duration = "%.2f" % (float(song['EstimateDuration']) / 60)
-            _duration = _("<b>Duration:</b> {mins}:{secs} min\n").format(mins=_duration.split(".")[0],
-                                                      secs=_duration.split(".")[1])
-            _album = _("<b>Album:</b> {album}\n").format(album=song['AlbumName'])
-            _year = _("<b>Year:</b> {year}\n").format(year=song['Year'])
+            _duration = _("<b>Duration:</b> {mins}:{secs} min\n").format(mins = _duration.split(".")[0],
+                                                      secs = _duration.split(".")[1])
+            _album = _("<b>Album:</b> {album}\n").format(album = song['AlbumName'])
+            _year = _("<b>Year:</b> {year}\n").format(year = song['Year'])
             info = _filename + _artist + _title + _duration + _album + _year
             image = gtk.Image()
             try:
             dialog.run()
             dialog.destroy()
 
-    def get_lyrics(self, widget, data=None):
+    def get_lyrics(self, widget, data = None):
         """
         Tries to retrieve lyrics for selected song from the playlist.
         """
             #lyric = lib.lyrdblib.search(song['ArtistName'],
             #                             song['SongName'])
 
-    def show_about(self, widget, data=None):
+    def show_about(self, widget, data = None):
         """
         About dialog for the application
         """
         about.run()
         about.destroy()
 
-    def flattr_this(self, widget, data=None):
+    def flattr_this(self, widget, data = None):
         """
         Opens the flattr page for gSharkDown
         """
         webbrowser.open("http://flattr.com/thing/275401/gSharkDown")
 
-    def edit_preferences(self, widget, data=None):
+    def edit_preferences(self, widget, data = None):
         """
         Preferences dialog with save and close buttons
         """
         builder.connect_signals(self)
         self.prefs.show_all()
 
-    def on_scrobble_toggle(self, widget, data=None):
+    def on_scrobble_toggle(self, widget, data = None):
         self.lastuser.set_sensitive(widget.get_active())
         self.lastpass.set_sensitive(widget.get_active())
 
-    def save_preferences(self, widget, data=None):
+    def save_preferences(self, widget, data = None):
         """
         Saves the information from the Preferences dialog in the
         configuration file
             CONFIG['show_notification'] = 1
         else:
             CONFIG['show_notification'] = 0
-            
+
         if self.startup_check.get_active():
             CONFIG['startup_update_check'] = 1
         else:
             CONFIG['scrobbling'] = 1
             CONFIG['lastuser'] = self.lastuser.get_text()
             CONFIG['lastpass'] = pylast.md5(self.lastpass.get_text())
-            self.lastfm = pylast.LastFMNetwork(api_key=LAST_KEY,
-                                          api_secret=LAST_SECRET,
-                                          username=CONFIG['lastuser'],
-                                          password_hash=CONFIG['lastpass'])
+            self.lastfm = pylast.LastFMNetwork(api_key = LAST_KEY,
+                                          api_secret = LAST_SECRET,
+                                          username = CONFIG['lastuser'],
+                                          password_hash = CONFIG['lastpass'])
 
         else:
             CONFIG['scrobbling'] = 0
         CONFIG.write()
         self.prefs.destroy()
 
-    def close_preferences(self, widget, data=None):
+    def close_preferences(self, widget, data = None):
         """
         Closes the Preferences dialog discarding any changes
         """
         self.prefs.destroy()
 
-    def search_grooveshark(self, widget, data=None):
+    def search_grooveshark(self, widget, data = None):
         """
         Starts the search thread
         """
             search_thread = SearchThread(self, widget.get_text(), "Songs")
             search_thread.start()
 
-    def play_selected(self, widget, data=None, row=None):
+    def play_selected(self, widget, data = None, row = None):
         """
         Starts the play thread
         """
         else:
             self.stop_play()
 
-    def set_songinfos(self, song=None):
+    def set_songinfos(self, song = None):
         """
         Updates some labels and icons when a song is playing
         """
                 pass
             else:
                 name = self.playlist.get_value(self.last_iter, 1)
-                self.playlist.set(self.last_iter, 1, 
-                                  self.create_track_icon(self.get_current_cover_url(name)))
+                self.playlist.set(self.last_iter, 1,
+                                  self.create_cornered_image(self.recover_icon(
+                                                    self.get_current_cover_url(name))))
             playing = self.get_playing_iter()
             if playing == None:
                 playing = self.playlist.get_iter_first()
             image = gtk.Image()
             image.set_from_stock(gtk.STOCK_MEDIA_STOP, gtk.ICON_SIZE_MENU)
             self.staticon.change_playbutton(image)
-            
+
             image1 = self.playlist.get_value(playing, 1)
             play = gtk.gdk.pixbuf_new_from_file('%s/data/play.png' % BASEPATH)
             play.composite(image1, 0, 0, image1.props.width, image1.props.height,
                               0, 0, 1.0, 1.0, gtk.gdk.INTERP_HYPER, 255)
             self.playlist.set(playing, 1, image1)
-            
+
             self.songinfo.set_markup(
-                _("<b>Playing:</b> {artist} - {title}").format(artist=self.current_song['ArtistName'],
-                                         title=self.current_song['SongName'])
+                _("<b>Playing:</b> {artist} - {title}").format(artist = self.current_song['ArtistName'],
+                                         title = self.current_song['SongName'])
             )
             if int(CONFIG['show_notification']) == 1:
                 n = pynotify.Notification(_("Now playing"),
             self.staticon.change_status_stopped()
             image = gtk.Image()
             name = self.playlist.get_value(self.last_iter, 1)
-            self.playlist.set(self.last_iter, 1, 
-                              self.create_track_icon(self.get_current_cover_url(name)))
+            self.playlist.set(self.last_iter, 1,
+                              self.create_cornered_image(self.recover_icon(
+                                                    self.get_current_cover_url(name))))
             image.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU)
             self.staticon.change_playbutton(image)
             self.songinfo.set_markup("")
-    
+
     def get_overwritten_filename(self, filename):
         """
         Gets the file name depending on whether user want to overwrite the file,
 
             dialog.set_default_response(gtk.RESPONSE_NONE)
             dialog.set_resizable(False)
-            dialog.set_size_request(600,175)
+            dialog.set_size_request(600, 175)
             response = dialog.run()
             dialog.destroy()
         else:
             response = 0
-            
+
         if response == 1:
             i = 1
             newfilename = ""
                 i += 1
                 split = os.path.splitext(filename)
                 newfilename = split[0] + " (%d)" % i + split[1]
-            
+
             return newfilename
         elif response == 0:
             return filename
         else:
             return None
-    
-    def download_selected(self, widget, data=None):
+
+    def download_selected(self, widget, data = None):
         """
         Starts the download thread
         """
             filename = filename.replace('/', '-')
             filename = os.path.join(CONFIG['down_path'], filename)
             filename = self.get_overwritten_filename(filename)
-            
+
             if filename != None:
                 try:
                     tDownload = DownloadThread(self, song, filename)
                     tDownload.start()
                 except:
                     pass
-            
+
     def update_downloads_count(self):
         """
         Update the label wich indicates the downloads count.
                 self.downmenu.popup(None, None, None, event.button, event.time)
             else:
                 self.downmenu.popup(None, None, None, event.button, event.time)
-    
+
     def cancel_download(self, path):
         """
         Cancel a download by a list path
         # TODO: Should improve the busy waiting
         while(thread.is_alive()):
             pass
-    
+
     def cancel_all_downloads(self):
         """
         Cancel all downloads
             iter = self.downloads.iter_next(iter)
             self.cancel_download(path)
 
-    def on_cancel_download(self, menu, data=None):
+    def on_cancel_download(self, menu, data = None):
         """
         Cancel the download. Have to check how to cancel the thread.
         """
         select = self.downloads_view.get_selection().get_selected_rows()
         for path in select[1]:
             self.cancel_download(path)
-            
-    def on_stop_download(self, button, data=None):
+
+    def on_stop_download(self, button, data = None):
         """
         Stop download, in order to be resumed later
         """
         pass
-    
-    def on_resume_download(self, button, data=None):
+
+    def on_resume_download(self, button, data = None):
         """
         Resume stopped download
         """
         with an short url to share with friends.
         """
         pass
-    
+
     def get_sliced_string(self, str, max):
-        sliced = str[0:max-3]
+        sliced = str[0:max - 3]
         if len(sliced) < len(str):
-            return sliced+"..."
+            return sliced + "..."
         else:
             return str
 
     def __init__(self, app):
         self.app = app
         bus_name = dbus.service.BusName('org.gsharkdown.Single',
-                                       bus=dbus.SessionBus())
+                                       bus = dbus.SessionBus())
         dbus.service.Object.__init__(self, bus_name, '/org/gsharkdown/Single')
 
-    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+    @dbus.service.method(dbus_interface = 'org.gsharkdown.Single')
     def get_current(self):
         """
         Method to get the current playing song used in the
             song = song + " - "
             song = song + self.app.current_song['SongName']
             return song
-        
-    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+
+    @dbus.service.method(dbus_interface = 'org.gsharkdown.Single')
     def get_state(self):
         """
         Method to get the player state used in the commandline interface
             return "Stopped"
         else:
             return "Playing"
-        
-    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+
+    @dbus.service.method(dbus_interface = 'org.gsharkdown.Single')
     def get_info(self):
         """
         Method to get information about the current playing song
             info += "Album:" + song['AlbumName'] + "\n"
             info += "Year:" + song['Year'] + "\n"
             return info
-        
-    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+
+    @dbus.service.method(dbus_interface = 'org.gsharkdown.Single')
     def get_version(self):
         """
         Method to return the current version of gSharkDown.
         version = f.read()
         f.close()
         return version
-    
-    @dbus.service.method(dbus_interface='org.gsharkdown.Single')
+
+    @dbus.service.method(dbus_interface = 'org.gsharkdown.Single')
     def get_help(self):
         """
         Method to read the HELP file and display the help message
         when using the commandline interface.
-        """        
+        """
         return open("%s/HELP" % BASEPATH, 'r').read()
 
 if __name__ == "__main__":
             elif sys.argv[1] in ["--info", "-i", "info"]:
                 method = dbus.SessionBus().get_object("org.gsharkdown.Single",
                             "/org/gsharkdown/Single").get_dbus_method("get_info")
-            elif sys.argv[1] in ["--version", "-v","version"]:
+            elif sys.argv[1] in ["--version", "-v", "version"]:
                 method = dbus.SessionBus().get_object("org.gsharkdown.Single",
                             "/org/gsharkdown/Single").get_dbus_method("get_version")
             elif sys.argv[1] in ["--help", "-h", "help"]: