[Xfce4-commits] <postler:master> Indicate destination of dragged message with blinking

Christian Dywan noreply at xfce.org
Mon Feb 21 20:04:01 CET 2011


Updating branch refs/heads/master
         to 23f7c3900f59e9a0de4555b58debd46f3024a516 (commit)
       from 3b02fd869191fc4ba50cb7f63e83ee6fc674758b (commit)

commit 23f7c3900f59e9a0de4555b58debd46f3024a516
Author: Sergio Spinatelli <spinatelli.sergio at gmail.com>
Date:   Mon Feb 21 20:01:29 2011 +0100

    Indicate destination of dragged message with blinking

 postler/postler-folders.vala |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index b105546..b959417 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -14,6 +14,8 @@ public class Postler.Folders : Gtk.TreeView {
     AccountInfo local_info;
     Gtk.TreeStore store;
     Gtk.TreeIter? selected_folder = null;
+    Gtk.TreeIter? drop_folder = null;
+    int blink_counter = -1;
 
     public Postler.Messages messages { get; set; }
     public string? selected_location { get; private set; }
@@ -92,6 +94,42 @@ public class Postler.Folders : Gtk.TreeView {
         selected_folder = null;
     }
 
+    bool on_drag_drop (Gdk.DragContext context, int x, int y, uint time_) {
+        if (selected_folder == null) {
+            var model = get_model ();
+            get_selection ().get_selected (out model, out selected_folder);
+        }
+        Gtk.TreePath path;
+        Gtk.TreeViewDropPosition pos;
+        if (get_dest_row_at_pos (x, y, out path, out pos)) {
+            var selection = get_selection ();
+            selection.select_path (path);
+            var model = get_model ();
+            model.get_iter_from_string (out drop_folder, path.to_string ());
+            if (selected_folder != drop_folder)
+                GLib.Timeout.add (350, blink);
+        }
+        return true;
+    }
+
+    bool blink () {
+        blink_counter++;
+        if (blink_counter > 5) {
+            drop_folder = null;
+            blink_counter = -1;
+            get_selection ().select_iter (selected_folder);
+            selected_folder = null;
+            return false;
+        }
+        if ((blink_counter % 2) == 0) {
+            get_selection ().unselect_all ();
+            return true;
+        } else {
+            get_selection ().select_iter (drop_folder);
+            return true;
+        }
+    }
+
     public Folders (Accounts accounts) {
         /* Drag and Drop */
         Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, {}, Gdk.DragAction.MOVE);
@@ -99,6 +137,7 @@ public class Postler.Folders : Gtk.TreeView {
         drag_data_received.connect (on_drag_data_received);
         drag_motion.connect (on_drag_motion);
         drag_leave.connect (on_drag_leave);
+        drag_drop.connect (on_drag_drop);
 
         this.accounts = accounts;
 



More information about the Xfce4-commits mailing list