Forum: Ruby-Gnome 2 You can drag and drop tabs in Gtk::Notebooks after all!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0158871402c1ecfa57952e8a379cfd10?d=identicon&s=25 Daniel Lucraft (lucraft)
on 2007-07-07 18:09
(Received via mailing list)
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), 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

But don't seem to be where they should be here:
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 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/
This topic is locked and can not be replied to.