gtk_container_new_child (was Re: Wrapping Box Container)



Hi,

On Mon, Aug 30, 2010 at 9:51 PM, Havoc Pennington <hp pobox com> wrote:
> With my proposed padding cleanup though that issue goes away:
>
> child = g_object_new(TYPE_MYCHILD, "padding", 5, "h-align",
> GTK_ALIGN_FILL_HORIZONTAL, NULL);
> insert_child(layout, child, 2, GTK_WRAP_BOX_PACK_Y_EXPAND);
>

Really great would be:

gtk_container_add_with_properties(layout, child,
                                                  "position", 2,
                                                  "y-expand", TRUE,
                                                  "padding", 5,
                                                  "h-align",
GTK_ALIGN_FILL_HORIZONTAL,
                                                  NULL);

which would work if we made gtk_container_set() and friends fall back
to props on the child if not finding a child prop on the container.
Kind of magic, but also really handy and results in very readable
code.

The patch is kind of a pain because gtkcontainer.c relies on weird
gobject internals (seriously, #include <gobject/gobjectnotifyqueue.c>
?) and stealing part of g_object_set() with public GObject API
basically isn't possible. However, either a bit of a hack in here or a
quick API addition to libgobject would make this a simple feature to
accomplish.

EVEN MORE AWESOME would be:

child = gtk_container_new_child(layout, MY_TYPE_WHATEVER,
                                                  "position", 2,
                                                  "y-expand", TRUE,
                                                  "padding", 5,
                                                  "h-align",
GTK_ALIGN_FILL_HORIZONTAL,
                                                  NULL);

sweet! even construct-only properties could be set here.

Havoc


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