Re: Setting a RadioItem created with ItemFactory
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-perl-list gnome org
- Subject: Re: Setting a RadioItem created with ItemFactory
- Date: Thu, 04 Jan 2007 13:50:16 +0000
On Thu, 2007-01-04 at 14:10 +0100, Jeffrey Ratcliffe wrote:
I have a group of RadioItems created with ItemFactory:
you should not use that: switching to Gtk2::UIManager usually solves
most issues, and UIManager is at least actively maintained - while
ItemFactory is deprecated.
{ path => '/_Frontend'),
item_type => '<Branch>' },
{ path => '/_Frontend/scan_image',
item_type => '<RadioItem>',
callback => \&change_frontend,
callback_action => 1 },
{ path => '/_Frontend/scan_adf',
item_type => '/Frontend/scanimage',
callback => \&change_frontend,
callback_action => 2 },
The callbacks work fine, but how can I set one of the items to be active?
get the MenuItem widget from the ItemFactory using its path and then set
it to be active:
$factory->get_item('/Frontend/scan_image')->set_active(TRUE);
Using Gtk2::UIManager would make this a bit simpler: just set the value
of the active RadioAction when adding the actions to the ActionGroup:
use constant {
SCAN_IMAGE => 0,
SCAN_ADF => 1,
};
my @radio_actions = (
[ 'ScanImage', undef, 'Scan Image', undef, undef, SCAN_IMAGE, ],
[ 'ScanAdf', undef, 'Scan Adf', undef, undef, SCAN_ADF, ],
)
my $radio_actions_ref = \ radio_actions;
my $on_change_ref = \&on_change;
# set the the action wit value 'SCAN_ADF' as the default
$action_group->add_radio_actions($radio_actions_ref, SCAN_ADF, $on_change_ref);
ciao,
Emmanuele.
--
Emmanuele Bassi, E: ebassi gmail com
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]