# You can drag and drop tabs in Gtk::Notebooks after all!

**URL:** <https://www.ruby-forum.com/t/you-can-drag-and-drop-tabs-in-gtk-notebooks-after-all/108825>\
**Category:** Ruby-Gnome 2\
**Created:** [July 7, 2007, 6:09pm UTC](https://www.ruby-forum.com/t/you-can-drag-and-drop-tabs-in-gtk-notebooks-after-all/108825 "2007-07-07T18:09:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [July 7, 2007, 6:09pm UTC](https://www.ruby-forum.com/t/you-can-drag-and-drop-tabs-in-gtk-notebooks-after-all/108825/1 "2007-07-07T18:09:52Z")

</div>

Hi

I’ve just noticed that it is possible to enable drag and drop reordering  
of tabs in a Gtk::Notebook in Ruby-Gnome2. I’m posting this to the list  
because:  
(a) I didn’t know about it until now, I’ve been using the techniques in  
the mdi.rb example on the web site  
([http://ruby-gnome2.sourceforge.jp/hiki.cgi?MDI](http://ruby-gnome2.sourceforge.jp/hiki.cgi?MDI)), which are a lot more  
complicated for sure.  
(b) people have asked about it before  
(c) it’s apparently not documented in the online documentation. Please  
let me know if there’s some reason this is not documented, like  
instability, otherwise I’m going to switch to using it right away.

Apologies if everyone already knew about this except me.

This example has two notebooks with two tabs each. You can reorder tabs  
within the notebooks and drag between them.

* * *

require ‘gtk2’

win = Gtk::Window.new(“Notebook”)  
hbox = Gtk::HBox.new

nb = Gtk::Notebook.new  
nb.append\_page(l1=Gtk::Label.new(“foo”), Gtk::Label.new(“foo”))  
nb.append\_page(l2=Gtk::Label.new(“bar”), Gtk::Label.new(“bar”))  
nb.set\_tab\_reorderable(l1, true)  
nb.set\_tab\_reorderable(l2, true)  
nb.set\_tab\_detachable(l1, true)  
nb.set\_tab\_detachable(l2, true)  
nb.set\_group\_id(0)

nb2 = Gtk::Notebook.new  
nb2.append\_page(l12=Gtk::Label.new(“foo2”), Gtk::Label.new(“foo2”))  
nb2.append\_page(l22=Gtk::Label.new(“bar2”), Gtk::Label.new(“bar2”))  
nb2.set\_tab\_reorderable(l12, true)  
nb2.set\_tab\_reorderable(l22, true)  
nb2.set\_tab\_detachable(l12, true)  
nb2.set\_tab\_detachable(l22, true)  
nb2.set\_group\_id(0)

hbox.pack\_start(nb)  
hbox.pack\_start(nb2)  
win.add(hbox)

win.show\_all  
Gtk.main

* * *

The ‘set\_tab\_reorderable’, ‘set\_tab\_detachable’ and ‘set\_group\_id’  
methods are documented in the Gtk docs here:  
[http://developer.gnome.org/doc/API/2.0/gtk/GtkNotebook.html](http://developer.gnome.org/doc/API/2.0/gtk/GtkNotebook.html)

But don’t seem to be where they should be here:  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ANotebook](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ANotebook)

Anyway, sorry if everyone knows this already! I know I’m very glad to  
have found it.

best,  
Dan

* * *

This [SF.net](http://SF.net) email is sponsored by DB2 Express  
Download DB2 Express C - the FREE version of DB2 express and take  
control of your XML. No limits. Just data. Click to get it now.  
[http://sourceforge.net/powerbar/db2/](http://sourceforge.net/powerbar/db2/)
