Re: [gtkmm] Gtk::Notebook problem



On Sun, 2003-09-07 at 16:32, Daniel Sundberg wrote:

> 
> I think you should create multiple textview that which uses the same textbuffer. As far as I know that is how you are supposed to use the gtk+ *view widgets.
> 
> To to answer your question: you can't add a widget to more than one container.
> 

My problem is that I want to do a text editor that can handle multiple
text buffers. I want to open different text files in separate pages in a
Gtk::Notebook (or for example have an option New File that opens a
Notebook page with a TextView that contains an empty buffer).

I think that it would be a waste of memory to alloc multiple TextView
objects and the associated ScrolledWindows(used to manage the scrollbars
for the textview) when I can manage a std::vector<ustring> containing
the contents of the textbuffers and only load the apropriate content for
the selected page (in the same TextView object)...

>From what I can unstand  my problem is that  the underlying gtk+ widget
GtkScroledWindow* gets attached to the first Page when i call
append_page (having its member 'parent' set to a pointer != NULL). When
I call append_page again the assertion (widget->parent == NULL)
obviously fails...

Isn't there any way I can detach the ScrolledWindow from the NoteBook
Page and then attach it to another one (the one that gets selected or
the one that is gets created from the New File option)?

That's called "reparenting" and it's documented in the GTK+ FAQ
(http://www.gtk.org/faq/#AEN599), but I want to do it in C++ (the gtkmm
way). I don't want to make a mess of my code using gobj(), and then
playing with C functions...




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]