# Making a treeview reorderable AND drag/drop sensitive

**URL:** <https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500>\
**Category:** Ruby-Gnome 2\
**Created:** [March 21, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500 "2010-03-21T18:22:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@marcop](https://www.ruby-forum.com/u/marcop)\
**Post date:** [March 21, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500/1 "2010-03-21T18:22:00Z")

</div>

Hi,

does anyone knows if it is possible to make a gtk treeview drag/drop  
sensitive (from the same app and/or from another app) and making it  
reorderable?  
It looks like it’s mutually exclusive: connecting the treeview to the  
drag\_data\_received invalidates the reorderable property and setting  
reorderable to true after making the signal\_connect on  
drag\_data\_receveived disables it.

Any idea or link or something else?

Thanks.

---

<div class="post-metadata">

**Author:** ![marcop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@marcop](https://www.ruby-forum.com/u/marcop)\
**Post date:** [March 21, 2010, 8:09pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500/2 "2010-03-21T20:09:25Z")

</div>

It has been a while since I have messed with Ruby/Gnome2, but looking at  
the  
information available in the documentation, you should receive  
Gdk::EventDND  
for motions, EG when a drag and drop is occurring, you should receive  
motion  
events under the Gdk::EventDND. If you setup a DND on your root window,  
you  
can temporarily set your TreeView to have the drag\_data\_received, and  
once  
the operation is complete for the drag and drop, you can have it reset  
the  
reorderable property on the TreeView.

That would be the only way I could think of how to do it. But as I  
said,  
it’s been a while since I messed with Ruby/Gnome2.

hth,

Mario

On Sun, Mar 21, 2010 at 1:22 PM, Marc Madmac \<

---

<div class="post-metadata">

**Author:** ![marcop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@marcop](https://www.ruby-forum.com/u/marcop)\
**Post date:** [March 21, 2010, 9:37pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500/3 "2010-03-21T21:37:14Z")

</div>

Thanks for your advise, i will give it a try!

Marc

---

<div class="post-metadata">

**Author:** ![marcop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@marcop](https://www.ruby-forum.com/u/marcop)\
**Post date:** [March 23, 2010, 8:04pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500/4 "2010-03-23T20:04:44Z")

</div>

Yes!!! I finally made it work! To do it, i made the parent window (a  
scrolledwindow in my case) dnd sensitive and it receives the drop  
notification and there’s no need to mess with the treeview itself.

Easy but hard to find!

Thanks a lot, Mario.

Marc

---

<div class="post-metadata">

**Author:** ![marcop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@marcop](https://www.ruby-forum.com/u/marcop)\
**Post date:** [March 23, 2010, 11:10pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500/5 "2010-03-23T23:10:50Z")

</div>

It works but there’s one drawback: the tree view doesn’t scroll when  
there are more entries that can fit in the view. It’s somewhat logical  
since it’s the scroll window itself that is notified and not the tree  
view.

It doesn’t matter in my use case but I guess it may be a cause of  
concern in other cases.

I’ll try to work around this problem when I have time to do it.

Thanks again.

Marc

---

<div class="post-metadata">

**Author:** ![marcop](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@marcop](https://www.ruby-forum.com/u/marcop)\
**Post date:** [March 23, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/making-a-treeview-reorderable-and-drag-drop-sensitive/185500/6 "2010-03-23T22:51:00Z")

</div>

Not a problem Marc,

I didn’t think about the ScrolledWindow setup myself. Well, at least  
you  
found the way.

On Tue, Mar 23, 2010 at 3:04 PM, Marc Madmac \<
