Commits

Damián Nohales  committed 1a14613

Change the download popup menu depending on download state

  • Participants
  • Parent commits b1cfd0c

Comments (0)

Files changed (1)

File lib/SharkDown.py

         """
         if event.button == 3:
             path = treeview.get_path_at_pos(int(event.x), int(event.y))
-            selection = treeview.get_selection()
-            rows = selection.get_selected_rows()
-            try:
-                if path[0] not in rows[1]:
-                    # Unselect if the user click the right button outside 
-                    # the selected items - empty field.
-                    selection.unselect_all()
-                    selection.select_path(path[0])
-            except TypeError:
-                pass
-
-            # still not sure about this. The point is that there are many rows selected
-            # when you click the right mouse button, but then on_cancel_download still 
-            # has no idea what is selected.
-            if selection.count_selected_rows() > 1:
-                self.downmenu.popup(None, None, None, event.button, event.time)
-            else:
+            
+            if path != None:
+                selection = treeview.get_selection()
+                rows = selection.get_selected_rows()
+                selection.unselect_all()
+                selection.select_path(path[0])
+                
+                song = self.downloads.get_song(path[0])
+                if song.get_state() == Song.STATE_PAUSED:
+                    self.downmenu.get_children()[0].hide()
+                    self.downmenu.get_children()[1].show()
+                else:
+                    self.downmenu.get_children()[1].hide()
+                    self.downmenu.get_children()[0].show()
+                    
                 self.downmenu.popup(None, None, None, event.button, event.time)
 
     def on_cancel_all_downloads(self, widget, data = None):