Commits

Vladimir Kolev committed 7e3c584

Option to check for updates for gSharkDown was added
Fixed pep8 to gsharkdown.py

Comments (0)

Files changed (3)

-0.2.7-1
+0.2.9

data/about_dialog.ui

     <property name="icon">gsharkdown_64.png</property>
     <property name="type_hint">dialog</property>
     <property name="program_name">gSharkDown</property>
-    <property name="version">0.2.7-1</property>
+    <property name="version">0.2.9</property>
     <property name="copyright" translatable="yes">(c) Vladimir Kolev 2011</property>
     <property name="comments" translatable="yes">Gnome-toolkit based desktop application for downloading music files from Grooveshark.com</property>
     <property name="website">https://bitbucket.org/vkolev/gsharkdown</property>
                 self.playitems.append(pickle.load(file))
             except:
                 eoferror = False
-        
+
         for i in range(0, len(self.playitems)):
             self.playlist.append([
                 self.playitems[i]['SongName'],
                 self.playitems[i]['SongID']
                 ])
 
-
     def window_close(self, widget, data=None):
         """
         How to act on closing the window
     def check_for_update(self, widget, data=None):
         local = open('%s/VERSION' % BASEPATH, 'r')
         localversion = local.read().replace("\n", "")
-        print localversion
+        checkurl = 'http://bitbucket.org/vkolev/gsharkdown/raw/tip/VERSION'
+        remote = urllib2.urlopen(checkurl)
+        remoteversion = remote.read().replace("\n", "")
+        if remoteversion > localversion:
+            upddiag = gtk.MessageDialog(None,
+                                       gtk.DIALOG_DESTROY_WITH_PARENT,
+                                       gtk.MESSAGE_INFO)
+            upddiag.set_title("New update")
+            othertext = "To update to the latest version click on the button "
+            othertext += "'Update'\nand download it. After that you can "
+            othertext += "remove the old one and install the new gSharkDown"
+            markup = "<b>New version <i>%s</i> is available</b>"
+            upddiag.set_markup(markup % remoteversion)
+            upddiag.format_secondary_text(othertext)
+            upddiag.add_buttons(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL,
+                                gtk.STOCK_EXECUTE, gtk.RESPONSE_OK)
+            if upddiag.run() == gtk.RESPONSE_OK:
+                downurl = "http://bitbucket.org/vkolev/gsharkdown/downloads"
+                webbrowser.open(downurl)
+            upddiag.destroy()
 
     def icon_clicked(self, widget, data=None):
         """
         self.playitems = []
         self.playing = None
 
-
     def toggle_repeat(self, widget, data=None):
         """
         Toggles the configuration option for looping trough the
             self.playing = len(self.playitems) - 2
         self.play_next(self.ff_button)
 
-
     def play_next(self, widget, data=None):
         """
         Plays the next item from the playlist
 
             if index < 0:
                 if int(CONFIG['repeat_playlist']) == 1:
-                    self.playing = len(self.playitems) - 1 
+                    self.playing = len(self.playitems) - 1
                     self.player.set_state(gst.STATE_NULL)
                     song = self.playitems[len(self.playitems) - 1]
                     self.set_songinfos(song)
         """
         Opens the flattr page for gSharkDown
         """
-        webbrowser.open("http://flattr.com/thing/275401/gSharkDown")        
+        webbrowser.open("http://flattr.com/thing/275401/gSharkDown")
 
     def edit_preferences(self, widget, data=None):
         """
         self.prefs = builder.get_object('window1')
         self.dest = builder.get_object('entry1')
         if CONFIG['down_path'] == "":
-            self.dest.set_text(os.environ.get('HOME')+"/Music")
+            self.dest.set_text(os.environ.get('HOME') + "/Music")
         else:
             self.dest.set_text(CONFIG['down_path'])
         self.notify = builder.get_object("checkbutton1")
             CONFIG['show_stat_icon'] = 1
         else:
             CONFIG['show_stat_icon'] = 0
-        
+
         if self.bubble.get_active():
             CONFIG['show_notification'] = 1
         else:
             if widget.get_text() in CONFIG['completition'].split("|"):
                 pass
             else:
-                CONFIG['completition'] = CONFIG['completition'] + widget.get_text() + "|"
+                compl = CONFIG['completition'] + widget.get_text() + "|"
+                CONFIG['completition'] = compl
                 CONFIG.write()
             search_thread = t_search(self, widget.get_text(), "Songs")
             search_thread.run()