tags:

views:

188

answers:

1

I'm using a Notebook widget to pull off a tabbed file view, and I've added code to allow detaching pages from an existing Notebook, which spawns a new window with a separate Notebook, containing just that page. However, I'd like the ability to move pages between multiple Notebooks as well.

The Notebook.WindowCreationHook delegate gives me the Notebook the page comes from, the page widget, and the x and y coordinates it's dropped at, but I don't know how I can tell what Notebook it's being dropped onto, if any. Is there a built-in mechanism for this reattachment, or do I have to go by the coordinates? If I have to use the coordinates, what's the best way to take them and get back a Notebook widget? I can store a list of the Notebooks I have floating around, if need be, but even then the code to figure out which one is which will be a bit tough (taking z-order and all that fun stuff into account).

+2  A: 

I decided to go on my own advice (which you voted to -1, and I deleted since it doesn't really answer the question), so here I am risking my reputation again. With code:

http://uplink.kicks-ass.net/~radu/GTK_Sharp_Notebook/

At the above address you'll find two archives of the same thing (since I don't know which one you'll prefer). In the archives there's code I wrote today, and which does this:

The main window contains a Notebook with three tabs, each tab having a random UI element (a button, a calendar, and a checkbox). You can drag the tabs outside of the main window. When you drop them outside of the main window, a new window is created, itself containing a notebook. The tab you just dropped will appear in the new window. You got so far yourself.

Now, if you drag another tab from the main window to the new window, the tab is added to the notebook of the new window rather than create a new window.

Also, if you drag all the tabs away from the new window, back to the main window, the new window is destroyed (after the last tab has been dragged away).

Key to this thing? GroupId = 0 for all the notebooks. They handle the drags and drops themselves.

If you want to hide the tabs in the new windows (before you reattach them), you'd probably want to look into docking widgets rather than notebooks.

Note: I used MonoDevelop under Linux to make the linked application.

Radu C
Ah hah! I knew it had to be something along those lines. Thank you very, very much.
Cody Brocious