dynamic gtk menus
As described in the previous post,
pcb-rnd will feature dynamic menus. I first implemented this in the
gtk hid.
It turned out gtk was way too OOP for my taste1. It took about 6
hours total, to implement and debug the feature. (As a comparison, it
took about 90 minutes to make the research related to
the resource structs in PCB and implement the HID modifications for
the new hid command). The trickiest part was
to figure the need of calling a show() on the menubar after adding
the new items.
When I didn't have that, only plain action menu/submenus showed up
(in already existing menu/ widgets), but
new (main) menus and menu/submenu/submenus didn't. After many hours of gdb
sessions I finally made sure (by printing all the widgets to stderr
recursively) that:
- I am really adding the new widgets...
- ... under the right parent
- ... with the right properties
Then I also printed allocated dimensions and coordinates - but the values
were misleading. Finally I figured there was different flags like realization
and visibility, so printed them too. This revealed that all my new menus were
there in an invisible state.
Footnotes
1: not because of the show() call, but because of the way objects
are stored in memory: too many generic pointers casted forth and back, makes it
really hard to print all properties of a menu item (including its label)
with gdb.