Passing a GType to a native function from Perl
- From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- To: "gtk-perl-list gnome org List" <gtk-perl-list gnome org>
- Subject: Passing a GType to a native function from Perl
- Date: Mon, 14 Nov 2011 09:23:19 +0100
Hi,
Libsoup has functions that expect a GType as their argument [1].
Here's the prototype of one of them:
void soup_session_remove_feature_by_type (SoupSession *session, GType
feature_type);
WebKit registers some "features" that I would like to remove from a
Perl script. I couldn't find a direct way to pass a GType or to
retrieve one from Perl without using XS. Is that possible?
For now I added the following XS code to HTTP::Soup:
void
soup_session_remove_feature_by_type (SoupSession *session, const char *name)
PREINIT:
GType type;
CODE:
type = gperl_type_from_package(name);
if (type) {
soup_session_remove_feature_by_type(session, type);
}
Which allows me to do:
my $session = Gtk3::WebKit->get_default_session();
$session->remove_feature_by_type('Gtk3::WebKit::SoupAuthDialog');
# Provide my own login/password
$session->signal_connect('authenticate' => sub {
my ($session, $message, $auth) = @_;
$auth->authenticate($login, $password);
});
Is there a better way to achieve this?
[1] http://developer.gnome.org/libsoup/stable/SoupSession.html
--
Emmanuel Rodriguez
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]