Re: Bug in Gtk2::ToggleButton->new_from_stock()

On May 27, 2006, at 3:32 AM, Jörn Reder wrote:

I think I found a bug in Gtk2::ToggleButton. When using new_from_stock()
a Gtk2::Button is returned.

Your call to Gtk2::ToggleButton->new_from_stock() is resolving to Gtk2::Button::new_from_stock(), because ToggleButton isa Button, and there is no gtk_toggle_button_new_from_stock().  lists


Gtk2::ToggleButton::new() is calls gtk_toggle_button_new_with_mnemonic () if it gets an argument, otherwise gtk_toggle_button_new().

So, the solution is to take advantage of Gtk2::Button::set_use_stock (), like this:

#!/usr/bin/perl -w
use strict;
use Glib 'TRUE';
use Gtk2 -init;

my $window = Gtk2::Window->new;
$window->signal_connect (destroy => sub { Gtk2->main_quit });

my $toggle = Gtk2::ToggleButton->new ('gtk-ok');
$toggle->set_use_stock (TRUE);

$window->add ($toggle);

And then mama would throw the live crawdads in the boilin' water. And one day I decided I'd make my own crawdads. So I threw the crawdads in the pot, but without any water. It was just like makin' popcorn.
   -- Ear-bending cellmate, "Raising Arizona"

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