From: John H. Kelm <johnhkelm@us...> - 2005-07-27 17:49:46
Update of /cvsroot/gaim/web/htdocs/summerofcode/john/posts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19355/posts
--- NEW FILE: 2005-07-27.txt ---
Gtk-Perl and Gaim
After some tinkering I have an interesting announcement. It looks as though gtk-perl will now work with the Gaim Perl plugin--albeit with some cajoling. If I am able to resolve the namespace problems created by loading the plugins with local binding without using a bit of a hack it would be virtually seamless. However, in the meantime a convinient workaround uses an eval statement to encapsulate all of the gtk-perl code in the perl scripts. What this allows for is the creation of a <code>GtkWidget</code> that can then be passed to gaim API calls.
As an example I constructed a way to not only have regular plugin preference pages, but also those that are created with a <code>GtkWidget</code> that is accessed through the plugin info hash from the perl script. The perl loader plugin takes the name of a perl sub routine containing gtk-perl methods that returns a <code>GtkWidget</code> (The example uses a <code>GtkFrame</code> to represent a plugin preferences page). The <code>GaimGtkPluginPrefUiInfo</code> for the script plugin is created and contains a pointer to a C function that runs the perl subroutine using <code>call_pv</code>. The tricky part was figuring out how to take what gtk-perl creates and converting it into a <code>GtkWidget *</code> that could then be inserted into <code>GaimGtkPluginUiInfo</code>. After searching through the gtk-perl code for a while I realized they hide the pointer to the data I wanted in the magic pointer field of the perl variable. By extracting the pointer I could not get a <code>GtkWidget</code>.
The following are screenshots showing the output of the plugin preference page for the test perl scripts: <a href="http://gaim.sourceforge.net/summerofcode/john/2005-07-27_gtk_screen.png>Full Screen (166K)</a> | <a href="http://gaim.sourceforge.net/summerofcode/john/2005-07-27_gtk_window.png">Preference Frame (15K)</a>