Re: Wrapping Box Container



it'd be great to avoid the GtkBox stuff I was whining about in the
padding thread, e.g.

void                  egg_wrap_box_insert_child           (EggWrapBox
         *layout,
							   GtkWidget            *widget,
							   gint                  index,
							   guint                 xpad,
							   guint                 ypad,
							   gboolean              xexpand,
							   gboolean              yexpand,
							   gboolean              xfill,
							   gboolean              yfill);

when you type this in it reads:

  insert_child(layout, child, 2, 5, 5, FALSE, TRUE, TRUE, FALSE)

which is completely unreadable without going back and forth to the
docs... worse, no compiler error if you mix any of these up. Bools and
ints are really only OK as args if the function name makes clear what
they are, imo. Otherwise, go enum or struct...

if not doing the nice padding cleanup, I would consider:

  insert_child(layout, child, 2, 5, 5, GTK_WRAP_BOX_PACK_Y_EXPAND |
GTK_WRAP_BOX_PACK_X_FILL)

I'd be tempted to name it insert_child_with_padding honestly so it'd
be clear what those numbers were when reading.

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

i.e. dump padding and fill/alignment out of the wrap box code entirely. Woohoo!

One other trivial thing I noticed:

void                  egg_wrap_box_set_natural_length     (EggWrapBox
         *layout,
							   guint                 length);

I think "guint" here is just misleading; it's not like you can use
UINT_MAX, GTK uses signed int for most layout internally to avoid
screwy bugs caused by subtraction ending up < 0.
Also public API like set_size_request and GtkSizeRequest iface is all
signed int.

Havoc


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