# Snapping a widget to another widget

**URL:** <https://www.ruby-forum.com/t/snapping-a-widget-to-another-widget/91634>\
**Category:** Ruby-Gnome 2\
**Created:** [April 11, 2007, 12:10am UTC](https://www.ruby-forum.com/t/snapping-a-widget-to-another-widget/91634 "2007-04-11T00:10:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 11, 2007, 12:10am UTC](https://www.ruby-forum.com/t/snapping-a-widget-to-another-widget/91634/1 "2007-04-11T00:10:27Z")

</div>

Hi  
In winamp, but also in beep-media-player, you can drag a little  
widget like the playlist, and attached it to another widget like  
the equalizer. I think this functionanility rocks.

Is this somehow possible in ruby-gtk?

Else I’d really have to dig into the C code of beep-media-player  
to find out how they do it, then try to wrap something around  
it… but my C is really bad 🙂

=  
Search for products and services at:

> **[mail.com Search](https://search.mail.com/web)**
>
> mail.com Search – quick, clear, accurate

–  
Powered by Outblaze

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys-and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 11, 2007, 9:42am UTC](https://www.ruby-forum.com/t/snapping-a-widget-to-another-widget/91634/2 "2007-04-11T09:42:08Z")

</div>

Roebe XXX wrote:

> Hi  
> In winamp, but also in beep-media-player, you can drag a little  
> widget like the playlist, and attached it to another widget like  
> the equalizer. I think this functionanility rocks.
> 
> Is this somehow possible in ruby-gtk?

I don’t know winamp, but I assume you want some way of customizing the  
UI at run-time by dragging widgets around.

As a starting point take a look at Gtk::HandleBox. With it you can  
detach a widget from its original location and it will appear in a  
frame which sort of floats above the original app. You can then  
reattach it. I believe you are forced to reattach it back to  
its original location, so this isn’t exactly what you want.

If this is not enough, it shouldn’t be too hard to code your own  
solution, with a bit of drag and drop (see Gtk::Drag) and reparenting  
of the dragged widget.

Martin.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys-and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
