10

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).

Abhranil Das
  • 5,702
  • 6
  • 35
  • 42
Serafina Brocious
  • 30,433
  • 12
  • 89
  • 114
  • `notebook` tag removed as part of the [2012 cleanup](http://meta.stackexchange.com/questions/128315/the-great-stack-overflow-tag-question-cleanup-of-2012). – Abhranil Das Apr 29 '12 at 19:41

1 Answers1

4

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
  • 1,340
  • 13
  • 31
  • Ah hah! I knew it had to be something along those lines. Thank you very, very much. – Serafina Brocious Jul 07 '10 at 09:21
  • @theGtknerd Oh boy... I don't even know which machine that was, or even in which country. A lot has changed in the 9 years that passed since I posted this answer. It does sound like I did it more by drag and drop and less by actual code. I wonder if I could recreate the code without having even the foggiest memory of it. – Radu C May 30 '19 at 09:50
  • I got it in the meantime and posted [here](https://stackoverflow.com/questions/56377755/). – theGtknerd May 30 '19 at 11:50