Re: Reshowing Icons in a Grid



On Fri, Mar 14, 2014 at 4:53 PM, Marshall Lake <mlake mlake net> wrote:

I have 10 different icons stored in 10 files.  I want to display these 10
icons in different locations in a gtk_grid_new().

It works fine once.

If I gtk_widget_destroy(grid), create a new grid, and try to display these
10 icons a second time (some in different grid locations and some not) I get

gtk_grid_attach: assertion `gtk_widget_get_parent (child) == NULL' failed

and several

gtk_grid_attach: assertion `GTK_IS_WIDGET (child)' failed

However, if I re-load the icons from their files after
gtk_widget_destroy(grid) it works fine the second time.

Most widgets are "floating" on creation. Then when you add them to a
container they get sinked. When you destroy the grid, it unrefs all
its children before it is destroyed. If that is the only reference
your icons, they are destroyed as well.

You can g_object_sink_ref(your_icon) after you create them the first
time, then you should be able to add them to new containers after they
are destroyed.


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