Damián Nohales avatar Damián Nohales committed 11d338f

Added PlayList scrolling with mouse wheel.

Comments (0)

Files changed (2)

         self.get_view().set_item_width(120);
         self.get_view().set_columns(999)
         
+        self.get_view().add_events(gtk.gdk.SCROLL_MASK)
+        self.get_view().connect("scroll-event", self.on_mouse_wheel_scroll)
+        
+    def on_mouse_wheel_scroll(self, widget, event):
+        # We need to assume that the IconView has a ScrolledWindow as parent 
+        adjustment = self.get_view().get_parent().get_hadjustment()
+        if event.direction == gtk.gdk.SCROLL_UP:
+            newvalue = adjustment.get_value() - adjustment.get_step_increment()
+            if newvalue < 0:
+                newvalue = 0
+        else:
+            newvalue = adjustment.get_value() + adjustment.get_step_increment()
+            if newvalue > adjustment.get_upper() - adjustment.get_page_size():
+                newvalue = adjustment.get_upper() - adjustment.get_page_size()
+        adjustment.set_value(newvalue)
+        
     def get_selected_rows(self):
         return self.get_view().get_selected_items()
     
         self.result.get_view().connect("row-activated", self.on_result_row_activated)
 
         # Play List definition
-        self.sw2 = builder.get_object('scrolledwindow2')
-        self.playlist = PlayList(gtk.IconView())
+        playlist_sw = builder.get_object('scrolledwindow2')
+        playlist_view = gtk.IconView()
+        playlist_sw.add(playlist_view)
+        self.playlist = PlayList(playlist_view)
         self.playlist.get_view().connect('item-activated', self.on_playlist_double_click)
         self.playlist.get_view().show()
-        self.sw2.add(self.playlist.get_view())
 
         # Download list definition
         self.downloads = DownloadList(builder.get_object('list_downloads'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.