[gnome-music/wip/gbsneto/flowbox: 13/13] albums: bring back selection mode on right click



commit a32dc0ea1a15fcc7902ce16987772fd53842aed9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 9 14:13:02 2016 -0300

    albums: bring back selection mode on right click
    
    We used to have this for free when using GdMainView but,
    as long as we're not using it anymore, we have to deal with
    it manually.
    
    This patch reimplements the selection mode on Albums view
    with right-click.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760164

 data/AlbumCover.ui |   14 ++++++++++----
 gnomemusic/view.py |   12 ++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/data/AlbumCover.ui b/data/AlbumCover.ui
index 800850d..c954f37 100644
--- a/data/AlbumCover.ui
+++ b/data/AlbumCover.ui
@@ -11,12 +11,18 @@
         <property name="can_focus">False</property>
         <property name="margin_bottom">4</property>
         <child>
-          <object class="GtkImage" id="image">
+          <object class="GtkEventBox" id="events">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="vexpand">True</property>
-            <property name="valign">end</property>
-            <property name="halign">center</property>
+            <child>
+              <object class="GtkImage" id="image">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="vexpand">True</property>
+                <property name="valign">end</property>
+                <property name="halign">center</property>
+              </object>
+            </child>
           </object>
         </child>
         <child type="overlay">
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 70a4a61..78540e1 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -481,12 +481,17 @@ class Albums(ViewContainer):
         child.check = builder.get_object('check')
         child.title = builder.get_object('title')
         child.subtitle = builder.get_object('subtitle')
+        child.events = builder.get_object('events')
         child.media_item = item
 
         child.title.set_label(title)
         child.subtitle.set_label(artist)
         child.image.set_from_pixbuf(self._loadingIcon)
 
+        child.events.connect('button-release-event',
+                             self._on_album_event_triggered,
+                             child)
+
         child.check.connect('notify::active', self._on_child_toggled, child)
 
         child.check.bind_property('visible', self, 'selection_mode',
@@ -500,6 +505,13 @@ class Albums(ViewContainer):
 
         return child
 
+    @log
+    def _on_album_event_triggered(self, evbox, event, child):
+        if event.button is 3:
+            self._on_selection_mode_request()
+            child.check.set_active(not child.check.get_active())
+            child.check.show()
+
     def _on_lookup_ready(self, icon, path, child):
         child.image.set_from_pixbuf(icon)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]