problem with accessing a widget from outside of signal handler subs



Hi, maybe this question is too simple for you, but i can't find it out.

I use the actual glade-perl 0.60 with glade 0.6.4 and gtk-perl 0.7008. 
I generated with help of glade-perl a set of perl files. I have a tree
widget which I want to access from project.pm 

The definition of the tree is in projectUI.pm , I successfully modified
the tree in signal subs in project.pm. 

My problem is: I have created a package "tree" with a sub create_root( )
, which I want to run at beginning (of program execution) Where do I
have to call tree:create_root(), so that it is called at beginning?

Another Problem is, I can't get reference to the tree!

I have snipped out the code to show you my problem.

------------------------------------------------------------------------
----------------------------------------------------------
#=======================================================================
=======
#=== Below is the package "tree" , which includes tree modifying subs 
#=======================================================================
=======
package tree;

sub create_root {
    my $form = ???????????????                  <--
    my $tree = ???????????????
    my $leaf = new_with_label Gtk::TreeItem( "Network Client" );
    $form->{'datatree'}->append( $leaf );
    $leaf->show();
    my $subtree = new Gtk::Tree();
    $leaf->set_subtree( $subtree );
    $leaf->expand;
}

#=======================================================================
=======
#=== Below are the signal handlers for 'main' class 
#=======================================================================
=======
package main;
sub gtk_main_quit {
    my ($class, $data, $object, $instance, $event) = @_;
    my $me = __PACKAGE__."->gtk_main_quit";
    # Get ref to hash of all widgets on our form
    my $form = $__PACKAGE__::all_forms->{$instance};

    # REPLACE the line below with the actions to be taken when
__PACKAGE__."->gtk_main_quit." is called
    #__PACKAGE__->show_skeleton_message($me, \ _, __PACKAGE__,
"$Glade::PerlRun::pixmaps_directory/Logo.xpm");
    #Gtk->exit( 0 );
    Gtk->main_quit;
} # End of sub gtk_main_quit

sub on_Start_clicked {
    my ($class, $data, $object, $instance, $event) = @_;
    my $me = __PACKAGE__."->on_Start_clicked";
    # Get ref to hash of all widgets on our form
    my $form = $__PACKAGE__::all_forms->{$instance};

    # REPLACE the line below with the actions to be taken when
__PACKAGE__."->on_Start_clicked." is called
    #__PACKAGE__->show_skeleton_message($me, \ _, __PACKAGE__,
"$Glade::PerlRun::pixmaps_directory/Logo.xpm");

    tree::create_root();

} # End of sub on_Start_clicked
------------------------------------------------------------------------
----------------------------------------------------------


in sub tree:create_root(), how can I access the 'datatree' if I don't
have know what $form is. Because all is declared as strict (my declared)
I don't have access to $form or $window.

I have temporarily "solved" the problem with delivering $form to the
sub. But this only works from locations where $form is valid. (in signal
handlers)


Please help me with this problem.
Sebastian







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