Re: [gtk-list] glade_perl and on_new_file1_activate



odemah@linuxfr.org wrote:
> 
> Hi all,
> i am back after a long break
> Currently, I use Glade (0.5.5) and Perl-Glade 0.48.
> 
> I make an application which open a Window (made with gnome widget)
> and i want to open a dialogbox (which i already build)
> when i click on "File/New".
> So i went to the "properties" and found the "on_new_file1_activate"
> but now i don't know where (in handler? in Object? in Data?)
> i say to glade to open my dialogbox and how.
Hi Olivier,

There is no need to do anything in Glade, just specify the handler on the
'Signals' page as you have already done. 

Then you edit the signal handler that Glade-Perl generated for you.

Older versions of Glade-Perl (<= 0.47) used to overwrite the Project.pm
file at every run but since you are using Glade-Perl-0.48 you can safely 
edit the src/Project.pm file and the changes will be preserved - only the
UI construction code is regenerated to src/ProjectUI.pm

If you are regenerating an old project you may already have an incomplete
copy of src/Project.pm that will not be overwritten. The skeleton signal
handlers are also saved in file src/ProjectSIGS.pm and you can cut and
paste them into any existing src/Project.pm file or, probably simpler, just
delete the src/Project.pm file and let Glade-Perl recreate it.

Right - editing src/Project.pm I use something like the following - make
sure that it is in the right class (same name as the Glade Window name).

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

  my $fs = fileselection1->new;
  $fs->TOPLEVEL->set_title("We are in ".__PACKAGE__);
  $fs->TOPLEVEL->show;

} # End of sub on_new_file1_activate

Then in the fileselection1 class:

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

  $form->{'fileselection1'}->hide;

} # End of sub on_ok_button1_clicked

Or whatever you want the UI to do.

HTH, Dermot




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