Hi,
I am having a strange problem in Gtk. I used Glade to build my gui.
In my main gui window, I have a combo box (call it ComboBoxMain) of 10 elements. In my gui's main menu bar, I have an option called X. When X is selected, I show a dialog window which has a combo box (call it ComboBoxDialog) in it and a table. The ComboBoxDialog has the same 10 elements as the ComboBoxMain. The dialog's table displays certain data based on the selection in ComboBoxDialog. The entry box in ComboBoxDialog has a changed signal callback associated with it - call it on_ComboBoxDialog_changed.
When the X menu option is selected, the following is done:
sub on_X_clicked {
my ($class, $data, $object, $instance, $event) = @_;
my $me = __PACKAGE__."->on_X_clicked";
# Get ref to hash of all widgets on our form
my $mainForm = $__PACKAGE__::all_forms->{$instance};
my $dialogForm = $__PACKAGE__::all_forms->{'routeControlDialog-1'};
print "I just called on_X_clicked \n";
#populate the dropdown with all the data and default to the data already selected in the mainWindow
my $Selection = $mainForm->{'comboLHEntry'}->get_text();
$dialogForm->{'physRouteEntry'}->set_text( $Selection );
$dialogForm->{"routeControlDialog"}->show_all();
} # End of sub on_X_clicked
My changed signal callback is:
sub on_ComboBoxDialog_changed {
my ($class, $data, $object, $instance, $event) = @_;
my $me = __PACKAGE__."-> on_ComboBoxDialog_changed";
# Get ref to hash of all widgets on our form
my $dialogForm = $__PACKAGE__::all_forms->{'routeControlDialog-1'};
my $Selection = $dialogForm->{'physRouteEntry'}->get_text(); # this is the data in the Dialog's combo box
print "physRouteEntry combo box has a change: $Selection \n";
} # End of on_ComboBoxDialog_changed
So I would expect that every time menu option X is selected, $dialogForm->{'physRouteEntry'}->set_text( $Selection ) would set off the signal on_ComboBoxDialog_changed to get executed once. Hence I should only see one print statement executed from on_ComboBoxDialog_changed. Actually, it gets executed twice every time. I tried stepping through with the perl debugger and I get the signal executed twice when a set_text is done.
Any ideas on what am I doing wrong? Is there something besides set_text I can use here accomplish the same task but only execute the callback once?
Thanks,
Tommy