- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: GtkImageView
- Date: Mon, 17 Dec 2007 20:24:44 +0100
On Mon, 2007-12-17 at 14:11 +0100, Jeffrey Ratcliffe wrote:
Unfortunately, there's no automatic way to convert raw structs to Perl
land. In this case, I think the best option would be to represent
GdkPixbufDrawOpts as a hash reference with keys zoom, zoom_rect, etc.
For an example of this kind of thing, take a look at the way
GtkStockItem is handled in Gtk2/xs/GtkStock.xs.
Ah. Thanks! Might I suggest that this and the GdkEvent issue be added
Sounds like a good idea. Can you take a stab at it? The formulations
might make more sense to newcomers if they're written by someone who
just recently learned about them.
Once you have the converter newSVGdkPixbufDrawOpts, you can take this
one step further by installing a custom typemap for GdkPixbufDrawOpts:
"GdkPixbufDrawOpts * T_GPERL_GENERIC_WRAPPER" in a typemap file
installed via ExtUtils::Depends->add_typemaps in Makefile.PL -- like
OK. Almost working. As my Perl is much better than my C these days, I
just can't find the correct syntax:
IImageTool.xs: In function `newSVDrawSettings':
IImageTool.xs:33: error: cannot convert to a pointer type
IImageTool.xs: In function `SvDrawSettings':
IImageTool.xs:62: error: incompatible types in assignment
where the relevant lines are:
hv_store (hv, "zoom_rect", 9, newSVGdkRectangle (settings->zoom_rect), 0);
if (svp) settings->zoom_rect = SvGdkRectangle (*svp);
You're trying to use a GdkRectangle where a GdkRectangle* is wanted. I
think this should work:
hv_store (hv, "zoom_rect", 9, newSVGdkRectangle (&(settings->zoom_rect)), 0);
if (svp) settings->zoom_rect = *(SvGdkRectangle (*svp));
If the settings struct passed into newSVDrawSettings might be free'd
while the corresponding hash reference still lives, you might have to
use newSVGdkRectangle_copy instead.
By the way, why 'DrawSettings' instead of 'GdkPixbufDrawOpts'?
] [Thread Prev