0

I have a Window object which contains only a grid. I want to use Gtk::Builder to get a pointer to the grid, and then use some Gtk::Box's Gtk::Box->pack_end() to add the grid to it many times (with manipulated contents each time).

Though each time that pack_end() is called I get:

gtk_box_pack: assertion 'gtk_widget_get_parent (child) == NULL' failed in my terminal and nothing gets added to the box.

What should I do?

Thanks

* EDIT: Goal: I want entries of a DB table to be put into a fancy widget for each record, though all the records being shown vertically one after the other. I thought I can create the fancy widget as a window in Glade and use Gtk::Builder to get a pointer to it. So in the fancy's Glade file I have a window containing a grid that has my custom appearance. I get the above error when I try to add the pointer to the fancy *grid*, to the visible window's Box. I hope I'm clear.

ergosys
  • 47,835
  • 5
  • 49
  • 70
Haix64
  • 806
  • 1
  • 13
  • 21

1 Answers1

0

Here's the solution to gtk_box_pack: assertion 'gtk_widget_get_parent (child) == NULL' failed:

All that needs to be done at the first place is that you should draw the widgets WITHOUT a window, so when loaded with builder, it won't have a parent and thus the assersion succeeds.

Though here's another point: When I add the first instance of the grid to the Box, the second one results in the same error again. After a couple of trials and errors I realized that in each interation you should use Gtk::Builder::create_from_file() to create a new parent-less instance of the grid to be able to use, and this way it works.

There has to be a great difference in performance, in case number of records is gonna be big, but Gtk::Widget's copy constructor is private and direct copying is not possible, and since it wasn't my main obsession I didn't insist on resolving this "performance" issue.

Haix64
  • 806
  • 1
  • 13
  • 21
  • 4
    In the future, you might try posting some code with your question. I don't understand what your first point is about, but the second would be obvious to many had you shown us what you were doing. – ergosys Aug 13 '12 at 00:45
  • @ergosys Oh I'm sorry, I guess I ought to, though the code was too sparse for me to put together every parent's constructor and so. I understand stackoverflow is about programming, but I'd like to differentiate it from "coding" which is NOT the ONLY thing we do. Thank you. – Haix64 Aug 13 '12 at 06:47