[Gtk-sharp-list] Buttons from Gtk.Stock and reparenting

Mike Kestner mkestner@speakeasy.net
Mon, 03 Nov 2003 23:23:41 -0600


On Mon, 2003-11-03 at 07:07, Leo Spalteholz wrote:

> Now this works (as in it displays the stock button content) but then 
> immediately crashes as soon as the interface displays.

Probably needs some ref magic on the Reparent method.  Please file a bug
for this and attach your sample proggie.

> Is there something fundementally wrong with my NewFromStock method or is 
> that not the problem?   Any help is greatly appreciated.. This has been 
> driving me right up the wall all day.  :(

The real problem as I see it is that public Button (string) should be
calling gtk_button_new_from_stock, since that falls back to
new_with_mnemonic if the string isn't a stock id.  If the preferred ctor
were set properly, you could just chain up to the string ctor and forget
about this reparenting hack.

Anyone up for some metadata hacking?  

If not, please file a bug for that and I'll get to it as soon as
possible. If you need a workaround in the meantime, you could always
just PInvoke gtk_button_new_from_stock directly in your ctor and assign
the returned handle to Raw. Take a look at the NewFromStock method in
the generated source for the specifics.

-- 
Mike Kestner <mkestner@speakeasy.net>