Fw: Custom widget with GladeXML
- From: Jaap Karssenberg <j g karssenberg student utwente nl>
- To: "gtk-perl-list gnome org" <gtk-perl-list gnome org>
- Subject: Fw: Custom widget with GladeXML
- Date: Wed, 1 Oct 2003 16:22:08 +0200
Didn't see CC header so forwarding it.
Begin forwarded message:
On Wed, 01 Oct 2003 10:11:30 -0400 (EDT) Chas Owens wrote:
:
: Unfortunatly the custom widget building code looks broken[1]. I am
: working on it now. When it is finished you will use it like this:
:
: use Gtk2;
: use Gtk2::GladeXML;
:
: Gtk2->init;
:
: Gtk2::GladeXML->set_custom_handler(\&custom_handler);
:
: my $glade = Gtk2::GladeXML->new('file.galde');
:
: Gtk2->main;
:
: sub custom_handler {
: my $glade = shift; #the current gladexml object
: my $func_name = shift; #the name of the widget creation
: function my $name = shift; #the name of the widget
: my $str1 = shift; #the args
: my $str2 = shift;
: my $int1 = shift;
: my $int2 = shift;
:
: #you can either build everything here and return a widget or
: #you can farm the work out like this:
: return eval "$func_name(\$glade,\$name,\$str1,\$str2,\$int1,
: \$int2)";
: }
:
: sub create_some_widget {
: my $glade = shift; #the current gladexml object
: my $name = shift; #the name of the widget
: my $str1 = shift; #the args
: my $str2 = shift;
: my $int1 = shift;
: my $int2 = shift;
:
: #create some widget
: }
:
:
: 1. It appears as if the POPs in glade_custom_widget is getting the
: Gtk2::GladeXML object instead of return from the sub. Muppet or Ross,
: can you help shed any light on this. I hacked on it all night (I had
: to teach myself about Perl stack handling) and still can't see what is
: wrong. The code is roughly the same as what Gtk-Perl did and it
: (Gtk::GladeXML) worked. Here is some psuedocode of what I think
: should occur:
:
: user calls Gtk2::GladeXML->set_custom_handler(\&func);
:
: the bindings stick @_ into a static AV so that the next function can
: find it and registers a C function glade_custom_widget with the real
: glade_set_custom_handler.
:
: The user calls Gtk2::GladeXML->new() with a glade file that has custom
: widgets in it.
:
: libglade calls the registered C function (glade_custom_widget)
:
: The C function glade_custom_widget calls the perl function named in
: the first element of the static AV saved earlier with the arguments
: passed to it followed by the rest of the static AV. It then returns
: the return of the perl sub (it should be a Gtk2::Widget).
:
: Everything is fine up to that last bit. I get the warning:
:
: invalid cast from 'GladeXML' to 'GtkObject'
:
: So it sounds to me like a stack pointer mismanagement issue, but I
: can't find anything that looks out of place.
:
--
) ( Jaap Karssenberg || Pardus [Larus]
: : http://pardus-larus.student.utwente.nl/~pardus
) \ / (
",.*'*.," Proud owner of "Perl6 Essentials" 1st edition :)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]