[gnome-boxes] collection-view: Implement prelight on mouse hover



commit 2b9d1314c0739a7a2f4737ef058bd7a5b4c0fc7b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Mar 5 15:57:23 2014 +0000

    collection-view: Implement prelight on mouse hover
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710279

 src/collection-view.vala |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 175264c..dbbb620 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -32,6 +32,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
 
     private Gtk.ListStore store;
     private Gtk.TreeModelFilter model_filter;
+    private Gtk.TreeIter? prelight_iter; // Iter of item under the cursor
 
     construct {
         category = new Category (_("New and Recent"), Category.Kind.NEW);
@@ -56,7 +57,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         store.get (iter, ModelColumns.ITEM, out item);
         Machine machine = item as Machine;
         return_if_fail (machine != null);
-        var pixbuf = machine.pixbuf;
+        var pixbuf = (iter == prelight_iter)? machine.orig_pixbuf : machine.pixbuf;
 
         if ("favorite" in machine.config.categories)
             emblem_icons += create_symbolic_emblem ("emblem-favorite");
@@ -278,6 +279,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         selection_mode_request.connect (() => {
             App.app.selection_mode = true;
         });
+        (get_generic_view () as Gtk.IconView).motion_notify_event.connect (on_motion_notify);
         show_all ();
     }
 
@@ -337,4 +339,31 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         });
         machine.set_data<uint> ("activity_timeout", activity_timeout);
     }
+
+    private bool on_motion_notify (Gtk.Widget widget,
+                                   Gdk.Event  event) {
+        var icon_view = widget as Gtk.IconView;
+        var motion = (Gdk.EventMotion) event;
+        int x, y;
+
+        icon_view.convert_widget_to_bin_window_coords ((int) motion.x, (int) motion.y,
+                                                       out x, out y);
+        var path = icon_view.get_path_at_pos (x, y);
+        if (path != null) {
+            Gtk.TreeIter filter_iter;
+
+            model_filter.get_iter (out filter_iter, path);
+            model_filter.convert_iter_to_child_iter (out prelight_iter, filter_iter);
+        } else {
+            prelight_iter = null;
+        }
+
+        store.foreach ((store, path, iter) => {
+            update_screenshot (iter);
+
+            return false;
+        });
+
+        return false;
+    }
 }


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