List Info

Thread: Closing a Glade Window




Closing a Glade Window
user name
2006-10-30 18:55:13
hi Cyril - you should keep gtk-perl-list on the loop;

On Mon, 2006-10-30 at 15:44 +0000, Cyril Cheneson wrote:
> or, if you don't have Gtk2::Widget::hide_on_delete you
can implement it
> > like this:
> >
> >   $window->signal_connect(delete_event =>
sub { $window->hide(); TRUE; });

> my $main = Gtk2::Window->new;
> my $btn = Gtk2::Button->new('Click here');
> $main->add($btn);
> $btn->signal_connect( button_release_event =>
&show_dlg );
> $main->show_all;
> 
> 
> Gtk2->main;
> 
> my $glade;
> sub show_dlg {
>     $glade = Gtk2::GladeXML->new('example.glade');
>     $glade->signal_autoconnect_from_package('main');
>     $glade->signal_connect(delete_event => sub {
$glade->hide; 1} );
> }
> 
> sub on_button1_clicked {
>     print "In on_button1_clickedn";
>     $glade->hide;
> }

Gtk2::GladeXML is not a widget - you can't call Gtk2::Widget
methods
like hide() on it, as the Perl interpreter is trying to tell
you:

> So using Gtk2->main_quit is not what I need.
> Using hide/destroy give me the following errors:
> (this is for hide)
> *** unhandled exception in callback:
> ***   Can't locate auto/Gtk2/GladeXML/hide.al in INC (INC
contains:
> /etc/perl /usr/local/lib/perl/5.8.7
/usr/local/share/perl/5.8.7
> /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8
/usr/share/perl/5.8
> /usr/local/lib/site_perl .) at ./example.pl line 25

you must get the widget from the glade object using its
name, like:

  $window = $glade->get_widget('main-window');

and then connect the signals to the widget.  or you can add
a callback
on the delete-event signal using Glade, like you did for the
clicked
event of the button.

inside that callback you just call the hide_on_delete
method:

  sub on_window_delete_event {
      my $window = shift;

      return $window->hide_on_delete();
  }

ciao,
 Emmanuele.

_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Closing a Glade Window
user name
2006-10-30 19:01:19
On 10/30/06, Emmanuele Bassi <ebassigmail.com> wrote:
> hi Cyril - you should keep gtk-perl-list on the loop;
>

Sorry I didnt notice I just replied to you :P

>
> you must get the widget from the glade object using its
name, like:
>
>   $window = $glade->get_widget('main-window');
>

I m  going to try this first thing in the morning

Thanks a lot for your help

Cyril
_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )