Re: Issue with Glib 1.260 in Windows 7
On Tue, Jun 19, 2012 at 11:37 AM, Martin Schlemmer martin.schlem...@nwu.ac.za wrote: On 2012/06/16 at 06:14 AM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: On Fri, Jun 15, 2012 at 5:13 PM, Martin Schlemmer martin.schlem...@nwu.ac.za wrote: Might have spoken too soon, or different issue. I get the following backtrace only with 1.260 and not 1.240. To reproduce I simply used the latest Git versions of Glib::Soup and Gtk2::WebKit, and did: $view = Gtk2::WebKit::WebView-new; $session = Gtk2::WebKit-get_default_session; Glib::Soup should not be used. This was my attempt at building bindings by hand until Glib::Object::Introspection was announced. The modules HTTP::Soup and HTTP::Soup::Gnome are the way to go. There's a reason why Glib::Soup is not in CPAN. The module is incomplete. I would suggest that programs using Glib::Soup get migrated to HTTP::Soup and programs using Gtk2::WebKit migrate to load WebKit's bindings through Glib's introspection either through Gtk3::WebKit or Glib::Object::Introspection. Even if you use Gtk2, you can still use Gtk3::WebKit. Simply load the module with: Thanks. G-O-I was a pain on win32 up to now, but I looked around again and found Dieter's patches for it and MinGW, so I will try again to build it. I never tried it under win32. I hope that it works. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Issue with Glib 1.260 in Windows 7
On Fri, Jun 15, 2012 at 5:13 PM, Martin Schlemmer martin.schlem...@nwu.ac.za wrote: Might have spoken too soon, or different issue. I get the following backtrace only with 1.260 and not 1.240. To reproduce I simply used the latest Git versions of Glib::Soup and Gtk2::WebKit, and did: $view = Gtk2::WebKit::WebView-new; $session = Gtk2::WebKit-get_default_session; Glib::Soup should not be used. This was my attempt at building bindings by hand until Glib::Object::Introspection was announced. The modules HTTP::Soup and HTTP::Soup::Gnome are the way to go. There's a reason why Glib::Soup is not in CPAN. The module is incomplete. I would suggest that programs using Glib::Soup get migrated to HTTP::Soup and programs using Gtk2::WebKit migrate to load WebKit's bindings through Glib's introspection either through Gtk3::WebKit or Glib::Object::Introspection. Even if you use Gtk2, you can still use Gtk3::WebKit. Simply load the module with: # Backward compatible mode with Gtk2 using glib introspection use Gtk3::WebKit version = '1.0', package = 'Gtk2::WebKit'; The above code snippet will do this (which is how to load a glib introspection library): # Load Gtk2::WebKit through glib introspection use Glib::Object::Introspection; Glib::Object::Introspection-setup( basename = 'WebKit', version = '1.0', package = 'Gtk2::WebKit', ); -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Installing perl-Gtk3 under OS X
On Mon, Mar 19, 2012 at 23:30, Alejandro Imass a...@p2ee.org wrote: On Mon, Mar 19, 2012 at 4:30 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: On Sun, Mar 18, 2012 at 21:03, Alejandro Imass a...@p2ee.org wrote: On Sun, Mar 18, 2012 at 3:27 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: Hi, [...] Is there an easy way to install perl-Gtk3 under OS X? MacPorts? MacPorts managed to install gtk3 but it's compiled without introspection. I tried enabling it by hacking the ports file but then I got this error: :info:build Couldn't find include 'GdkPixbuf-2.0.gir' (search path: ['../gdk', 'gir-1.0', '/opt/local/share/gir-1.0', '/usr/share/gir-1.0', '/opt/local/share/gir-1.0']) :info:build make[4]: *** [Gdk-3.0.gir] Error Yeah, I fugured as much. I mean I wa confident that GTK3 would work but perhaps no good for devel. Getting gtk3 and all its dependencies installed is of great help. So MacPorts did help. This is not going to be an easy task :( Probably not, bu I think it's a lot easier to hack the MacPort rather than build your own... well who knows really.. This is exactly what I did yesterday but I didn't had the time to email my results. I know have perl-Gtk3 working under OS X :) Here's what I did: First install MacPorts, i followed the instructions from their web site [1] and I downloaded the dmg installer and executed: sudo port -v selfupdate The set your environment properly, add this to your shell and your ~/.bash_profile export PATH=/opt/local/bin:/opt/local/sbin:$PATH export MANPATH=/opt/local/share/man:$MANPATH export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig export LD_LIBRARY_PATH=/opt/local/lib export GI_TYPELIB_PATH=/opt/local/lib/girepository-1.0 If you change your default ports folder you're on your own and you should be able to figure out what to change (replace /opt/local with your port's installation folder). Now the fun begins. Installing gtk3 is as easy as: sudo port install gtk3 The problem is that gtk3 and a few libraries are compiled without introspection. Fire up your editor skills because we need to edit a few files. You'll find the files here: cd /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports sudo nano -w gnome/gtk3/Portfile sudo nano -w graphics/gdk-pixbuf2/Portfile sudo nano -w x11/pango/Portfile sudo nano -w devel/atk/Portfile Look for the word introspection and replace the flag with --enable-introspection. Then uninstall and reinstall these ports: sudo port -f uninstall gdk-pixbuf2 sudo port install gdk-pixbuf2 sudo port -f uninstall pango sudo port install pango sudo port -f uninstall atk sudo port install atk sudo port -f uninstall gtk3 sudo port install gkt3 If I didn't forget a single command then gtk3 would be built and installed with introspection support. Installing perl-Gtk3 is now an easier task since all that's needed is to install the introspection library: sudo port install gobject-introspection That's it the rest should be a normal CPAN installation procedure. I still have to try compile WebKitGtk+'s port with gtk3 and introspection. I haven't even tried this step yet. [1] http://www.macports.org/install.php I hope that this helps someone else. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Installing perl-Gtk3 under OS X
On Tue, Mar 20, 2012 at 17:05, Brian Manning elspicyj...@gmail.com wrote: On Mon, Mar 19, 2012 at 11:21 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: The problem is that gtk3 and a few libraries are compiled without introspection. Fire up your editor skills because we need to edit a few files. You'll find the files here: cd /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports sudo nano -w gnome/gtk3/Portfile sudo nano -w graphics/gdk-pixbuf2/Portfile sudo nano -w x11/pango/Portfile sudo nano -w devel/atk/Portfile Look for the word introspection and replace the flag with --enable-introspection. Then uninstall and reinstall these ports: Another way to do this is to use the 'sudo port edit' command for each of the above ports prior to installing them. This will allow you to make changes directly to the correct portfiles, regardless of what path you used when installing MacPorts. If you do make changes to the Portfiles, it's recommended that you save them in a different location, a local Portfile repository, so that subsequent calls to 'port sync' or 'port selfupdate' will not overwrite your customized Portfiles. If you do save your custom Portfiles to a different path, you can add that path to /opt/local/etc/macports/sources.conf so that your directory of Portfiles is listed ahead of/before the system path of sync://rsync.macports.org/release/ports/ [default]; I have my Portfiles stored in a tree structure below /opt/ports, so my sources.conf looks like: file:///opt/ports rsync://rsync.macports.org/release/ports/ [default] You would then use the 'sudo portindex' command in /opt/ports to generate an updated list of available ports. I do this often with Perl modules that are not part of the MacPorts tree, i.e. generate an updated Portfile for the module, then run 'portindex' to get MacPorts to see the new Portfile. The downside to this is more manual maintenance, i.e. when the MacPorts team upgrades a Portfile I've made a custom version of, the corresponding changes won't be seen until I make new copies of them. If you would like more info about local Portfile repositories, they are described in detail at [1]. Thanks, Brian [1] http://guide.macports.org/#development.local-repositories Thanks, I was missing this bit: how to use my own custom Portfile. I did a port selfupdate and all my changes where gone. I'll try to add a separator port folder this way I can keep my changes/tweaks. I'm wondering why some ports are compiled with introspection and others aren't. Life would be much more easy if all ports would be compiled with introspection :) Cheers, -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Installing perl-Gtk3 under OS X
On Tue, Mar 20, 2012 at 18:50, Brian Manning elspicyj...@gmail.com wrote: On Tue, Mar 20, 2012 at 10:27 AM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: I'm wondering why some ports are compiled with introspection and others aren't. Life would be much more easy if all ports would be compiled with introspection :) (sorry for the duplicate e-mails Emmanuel) Probably because the port maintainer(s) don't know to turn it on. I would say file bugs against those packages and let them give you a yes or no answer. I found an existing ticket [1] and works seems to be in progress! [1] https://trac.macports.org/ticket/33054 Thanks guys for the help! -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Installing perl-Gtk3 under OS X
On Sun, Mar 18, 2012 at 21:03, Alejandro Imass a...@p2ee.org wrote: On Sun, Mar 18, 2012 at 3:27 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: Hi, [...] Is there an easy way to install perl-Gtk3 under OS X? MacPorts? MacPorts managed to install gtk3 but it's compiled without introspection. I tried enabling it by hacking the ports file but then I got this error: :info:build Couldn't find include 'GdkPixbuf-2.0.gir' (search path: ['../gdk', 'gir-1.0', '/opt/local/share/gir-1.0', '/usr/share/gir-1.0', '/opt/local/share/gir-1.0']) :info:build make[4]: *** [Gdk-3.0.gir] Error This is not going to be an easy task :( -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Installing perl-Gtk3 under OS X
Hi, I was asked if I knew how to install the perl binding for Gtk3 under OS X. I figured out the hardest part would be to install gtk3. I tried to do so with jhbuild by following the web instructions[1] and no luck. A few sub modules (freetype and pango-gtk3) failed to build but I was able to fix them somehow, but gtk3 just doesn't build. gtkprintbackendcups.c: In function 'cups_request_printer_list_cb': gtkprintbackendcups.c:1801: error: 'reasons' undeclared (first use in this function) gtkprintbackendcups.c:1801: error: (Each undeclared identifier is reported only once gtkprintbackendcups.c:1801: error: for each function it appears in.) gtkprintbackendcups.c:1896: error: 'info' undeclared (first use in this function) make[3]: *** [gtkprintbackendcups.lo] Error 1 make[2]: *** [install-recursive] Error 1 make[1]: *** [install-recursive] Error 1 make: *** [install-recursive] Error 1 Is there an easy way to install perl-Gtk3 under OS X? [1] https://live.gnome.org/GTK%2B/OSX/Building -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk3: How to invoke gtk_stock_list_ids? - SOLVED
On Fri, Jan 6, 2012 at 23:28, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 15.12.2011 15:54, Hubert Mauchle wrote: Is it always this way when there is no object available: Prepend the function with Gtk3:: ? Yes, basically. If you want to check, look into prefix/share/gir-1.0/Gtk-3.**0.gir. You can also browse the documentation online http://www.roojs.org/seed/gir-1.2-gtk-3.0/seed/Gtk.html Of course this might not be corresponding to your exact version of gtk3 installed, but GTK3 is quite stable so the API should match quite well. Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can't call soup_cookie_parse() through GIR
On Sat, Dec 3, 2011 at 15:39, Torsten Schoenfeld kaffeeti...@gmx.de wrote: This is not set it stone yet, though. So if anyone sees good reasons to prefer the '-' route, now is the time to present them. I would say that this is convenient for inheritance. This way the package names can be avoided by simply using $class or $self and to let perl dispatch to the right package. For instance if someone would like to provide a different cookie implementation and that their code would do inherit from the main class then the could do: use lib 'HTTP::Soup::Cookie'; # Avoids the HTTP::Soup::Cookie limitation to parse 1 single cookie per header. sub parse_multiple { my $class = shift; my ($raw, $url) = @_; return map { $class-parse($_, $url); } get_parts($raw); } This way the package name is referred only once, when the inheritance link is done. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Can't call soup_cookie_parse() through GIR
Hi, I wanted to parse a cookie with libsoup from Perl via HTTP::Soup and I can't find a wait to call soup_cookie_parse(). I always get an error. I tried: HTTP::Soup::Cookie-parse($value, undef); HTTP::Soup::Cookie-parse($value, HTTP::Soup::URI-new('/')); and even this out of desperation: my $parser = bless {}, 'HTTP::Soup::Cookie'; my $cookie = $parser-parse($value, HTTP::Soup::URI-new('/')); bless $parser, __PACKAGE__; I always get this error: expected a blessed reference at /usr/local/lib/perl/5.12.4/Glib/Object/Introspection.pm line 58. libsoup documentation says that soup_cookie_parse is a function and that the URI parameter can be NULL. I don't understand where the blessed reference is supposed to go. Here's a trimmed down dump of my /usr/share/gir-1.0/Soup-2.4.gir function name=parse c:identifier=soup_cookie_parse version=2.24 return-value transfer-ownership=full doc xml:whitespace=preservea new #SoupCookie, or %NULL if it could not be/doc type name=Cookie c:type=SoupCookie*/ /return-value parameters parameter name=header transfer-ownership=none doc xml:whitespace=preservea cookie string (eg, the value of a Set-Cookie header)/doc type name=utf8 c:type=char*/ /parameter parameter name=origin transfer-ownership=none doc xml:whitespace=preserveorigin of the cookie, or %NULL/doc type name=URI c:type=SoupURI*/ /parameter /parameters /function I'm probably doing something wrong but I don't see what. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Glib::Introspection 0.04: t/enums.t fails
On Fri, Nov 25, 2011 at 13:33, Jörn Reder jo...@zyn.de wrote: Hiho, I am trying to make my first steps with Gtk3::WebKit but I fail already on the prerequisites ;) For Glib::Introspection 0.04 I get this error message on make test: t/enums.t . 1/3 # Failed test at t/enums.t line 12. # got: '[ flag1 flag3 ]' # expected: 'ARRAY(0x9322c68)' # Looks like you failed 1 test of 3. t/enums.t . Dubious, test returned 1 (wstat 256, 0x100) All other tests pass, but I think this one should do as well ;) I am on a freshly updated Ubuntu 11.10 (Perl 5.12.4), I'm using messy Linux Mint 11 with lots of packages installed by hand and it works there. with Glib 1.21 and I couldn't get tin install Glib::Introspection 0.04 with my version of Glib, which was newer than yours. This is the error that I got: Glib version 1.24 required--this is only version 1.232 at (eval 6) line 3. BEGIN failed--compilation aborted at (eval 6) line 3. Can you try to see what happens if your update perl-Glib? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Replacing Test::WWW::Selenium::Catalyst with Gtk3::WebKit
On Tue, Nov 22, 2011 at 16:49, Stefan Seifert n...@detonation.org wrote: Hi! Hi, I'm trying to replace Test::WWW::Selenium::Catalyst using Gtk3::Webkit and Test::WWW::Mechanize::Catalyst. Main goal is to avoid the lengthy Selenium Server and Firefox startup when running tests but it would also be nice to be able to run tests in parallel more easily. Even with randomized port numbers, the Selenium server fails to start up sometimes. I got asked a few times about replacing Selenium with Gtk3::WebKit, so your efforts will be appreciated. A quick hack got me pretty far but now I'm stuck trying to get AJAX requests to work. I'm able to satisfy all other requests by hooking into the 'resource- request-starting' signal, getting the result with Test::WWW::Mechanize::Catalyst and give it back to WebKit as a data: URI. I think that you should be able to rewrite the contents of the soup message or at least you should be able to do a redirect if you can to a different URL. For this you will need to load HTTP::Soup so that you have libsoup bindings loaded through introspection. Unfortunately, one cannot make AJAX requests to data: URIs. Instead I tried to change the request to a POST to a simple HTTP Echo service, but for example I cannot find out how to set the content-type of the HTTP request. There does not seem to be a write accessor for that property. Can you give me more info/input on what's happening and what your program is trying to accomplish? So does anyone have ideas, advice or experience in this area? I guess as a last resort, I will fork out and answer requests in a separate process via a real HTTP request. But doing it in-process would let us get rid of quite a few difficulties in writing tests for asynchronous interfaces... I think that what's needed is to play with Soup messages and to swap their content or do a proper redirect. I believe that libsoup allows us to do this kind of things. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Passing a GType to a native function from Perl
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 ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Passing a GType to a native function from Perl
On Mon, Nov 14, 2011 at 11:33, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 14.11.2011 09:23, Emmanuel Rodriguez wrote: 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? G:O:Introspection has code to handle this in exactly the way you do in the xsub: http://git.gnome.org/browse/perl-Glib-Object-Introspection/tree/gperl-i11n-marshal-arg.c#n83 http://git.gnome.org/browse/perl-Glib-Object-Introspection/tree/gperl-i11n-marshal-arg.c#n195 Does that not work for you? Now it does! I had a typo in the class name Gtk3::WebKitSoupAuthDialog (bad) vs Gtk3::WebKit::SoupAuthDialog (Good) Thanks, -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GType GString is not registered with gperl at Glib/Object/Introspection.pm
On Sun, Nov 6, 2011 at 22:36, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 06.11.2011 22:18, Emmanuel Rodriguez wrote: On Sun, Nov 6, 2011 at 21:44, Torsten Schoenfeldkaffeeti...@gmx.de wrote: On 06.11.2011 21:25, Emmanuel Rodriguez wrote: *** unhandled exception in callback: *** GType GString (156083704) is not registered with gperl at /usr/local/lib/perl/5.12.4/Glib/Object/Introspection.pm line 57. *** ignoring at /usr/local/share/perl/5.12.4/Gtk3.pm line 104. This comes from the code in Glib that handles boxed types. It turns out that we don't have a boxed wrapper for G_TYPE_GSTRING. (To our defense, this WebKit API is the first instance of GString occurring in an API that I've seen.) The boxed wrapper would most likely be a very thin shell around newSVpv and SvPV. The G_TYPE_STRV wrapper might serve as an example. (this time with a *reply to all*, sorry Torsten for the spam) I can add the box type to Gtk3::WebKit but shouldn't it be better to add it to Glib? Yes, it should live in Glib. I have a basic implementation based on your input [1]. Can you review my patch? I don't know if I have to add a 'GPerlBoxedDestroyFunc', I'm guessing that Perl's standard SV free should do fine. I looked at the documentation of GString [2] and I don't see when GString was first added to Glib which makes me guess that it has always existed so there's no need of a #if GLIB_CHECK_VERSION() check. [1] https://github.com/potyl/perl-Glib/commit/a69fb0dfa1e6c9e393949618d7a77a3cf913bc22 [2] http://developer.gnome.org/glib/2.30/glib-Strings.html What I don't get is that it was working fine previously. I was able to do $data-{str} to access the content of the string. That sounds like GString was handled as a bare struct back then, not as a boxed type. Maybe g-ir-scanner changed in the meantime, or maybe the Perl bindings. Yes, I don't recall exactly when things changed I've upgraded all my packages (webkit, perl-Glib, perl-Glib-Object-Introspection) and suddenly the errors started to appear. I downgraded the perl packages but the errors still remained. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Will Gtk3 land on CPAN soon?
Hi, Is there a plan to release Gtk3 into CPAN soon? I have released Gtk3::WebKit which based on Glib::GObject::Introspection and it could really use to have Gtk3 loaded into CPAN. Of course someone can still use Gtk3 directly through GIR, but I think that it would be nicer if Gtk3 makes its way to CPAN. I've been playing with Glib::GObject::Introspection and it's really a wonderful module. I hope that it lands in linux distributions soon so that more people can use it. In fact, I have uploaded already 2 modules to CPAN that are based on GIR (Gtk3::WebKit and HTTP::Soup based on libsoup) and I didn't had too many problems. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Cairo::Surface-create_for_rectangle vs. $surf-create_similar
On Wed, Aug 3, 2011 at 16:12, Torsten Schoenfeld kaffeeti...@gmx.de wrote: b) wrap cairo_surface_create_for_rectangle as Cairo::Surface-create_for_rectangle($target, ...) and make it possible to use Cairo::Surface-create_similar($old, ...)¹ +1 -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GTK2::Button retrieved from Tie::IxHash hash value does not render
On Fri, Jul 22, 2011 at 08:45, Roderich Schupp roderich.sch...@googlemail.com wrote: On Thu, Jul 21, 2011 at 7:29 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: It seems that Tie::IxHash is storing the string representation of the buttons instead of the real values. No. Otherwise $button{qbimport}-signal_connect( clicked = \qbimport ); would already have died. And your workaround wouldn't work either. Right :) I didn't had the chance to try the code that I posted earlier. I played with your sample now and it seems that the culprit is then: $vbox-add($button{$_}) for (keys %button); There's something odd going on there with the reference to the button. This code works, so $_ is a valid object (no runtime error). $_-show() for (values %button); This works too: my $copy; $vbox-add($copy = $_) for (values %button); This fails as described in the original emails: $vbox-add($_) for (values %button); -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GTK2::Button retrieved from Tie::IxHash hash value does not render
On Thu, Jul 21, 2011 at 16:59, Terrence Brannon scheme...@gmail.com wrote: The simple program below: use Gtk2 -init; use Tie::IxHash; # Gtk2-init; works if you didn't use -init on use my $window = Gtk2::Window-new('toplevel'); my $vbox = Gtk2::VBox-new (FALSE, 0); $window-add($vbox); #tie my %button, Tie::IxHash; $button{qbimport} = Gtk2::Button-new('Quickbooks Import'); $button{qbimport}-signal_connect( clicked = \qbimport ); $button{quit} = Gtk2::Button-new('Quit'); $button{quit}-signal_connect( clicked = sub { Gtk2-main_quit } ); $vbox-add($button{$_}) for (keys %button); $window-show_all; Gtk2-main; sub qbimport { } works just fine if you dont tie the %button hash with Tie::IxHash. However, if you do, then it fails with the error: Gtk2::Button=HASH(0x29b317c) is not of type Gtk2::Widget at v2.pl line 19. It seems that Tie::IxHash is storing the string representation of the buttons instead of the real values. Try the following: $button{qbimport} = [ Gtk2::Button-new('Quickbooks Import') ]; $button{qbimport}[0]-signal_connect( clicked = \qbimport ); $vbox-add($button{$_}[0]) for (keys %button); -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcing: Perl bindings for LibSoup
On Thu, Jun 23, 2011 at 22:47, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 22.06.2011 23:05, Emmanuel Rodriguez wrote: Is it possible to use Cairo with the introspection framework? This is not specific to introspection even, but applies to the whole Glib world. Try http://home.arcor.de/kaffeetisch/tmp/Cairo-GObject-1.000-UNRELEASED.tar.gz, which I recently mentioned here but got no response on. The run time error goes away with that module. This is great! I do have other errors, but that's because I assume that the widget is already allocated which is not always true. What's the best way to detect if a widget is displayed and rendered so I can grab a screenshot? Thanks for the help. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcing: Perl bindings for LibSoup
On Wed, May 25, 2011 at 00:14, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 24.05.2011 22:54, Emmanuel Rodriguez wrote: But since WebKit also supports gobject-introspection, why not use it that way as well? It's still a little rough around the edges, but here's your browser.pl example ported to use the introspection stuff. I've been playing a bit with the introspection and with the sample browser. It does make things easier, that's nice. One thing that I've not been able to do is to use Cairo with the introspection framework. For instance if I take your example and load cairo and I can't use it. use Cairo; $view-signal_connect('notify::load-status' = sub { my $uri = $view-get_uri or return; return unless $view-get_load_status eq 'finished'; my ($width, $height) = ($view-get_allocated_width, $view-get_allocated_height); # Save a screenshot as Pdf my $surface = Cairo::PdfSurface-create(a.pdf, 1.0 * $width, 1.0 * $height); my $cr = Cairo::Context-create($surface); $view-draw($cr); }); This code always gives me: *** unhandled exception in callback: *** internal problem: GType CairoContext (146796864) has not been registered with GPerl at /usr/local/lib/perl/5.10.1/Glib/Object/Introspection.pm line 62. *** ignoring at /usr/local/lib/perl/5.10.1/Glib/Object/Introspection.pm line 62. Is it possible to use Cairo with the introspection framework? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcing: Perl bindings for LibSoup
On Wed, May 25, 2011 at 23:51, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 25.05.2011 23:18, Emmanuel Rodriguez wrote: Is there a way to provide custom made XS methods to an introspection perl package? For instance, SoupMessageBody is defined as: typedef struct { const char *data; goffset length; } SoupMessageBody; And provides no accessor for data or length. Is there a way to complete the introspection binding with extra XS methods? If so do you know of an existing cpan package that does this? Adding custom XS methods is no problem: just write them as you normally would. But in the case you mention, that's not necessary. gobject-introspection provides the means to get and set public fields of boxed types. How do we access public fields of boxed types? I tried $body-data and $body-get_data without success. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcing: Perl bindings for LibSoup
On Wed, May 25, 2011 at 00:14, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 24.05.2011 22:54, Emmanuel Rodriguez wrote: Thanks, it works with the most recent version that's in git. Good to hear. Is it possible to mix Introspection bindings with perl module that has hand made bindings? Good question. As you mention, the problem will be the lack of typemaps and converter macros. But Glib::Object::Introspection uses the normal Glib mechanisms to convert objects to and from Perl land. So I think the easiest way would indeed be to add libsoup typemaps to your XS module (simply put corresponding entries into your 'maps' file). Adding the type libsoup maps into the webkit bindings works as expected. What also works, at least if GObject types are involved, is to substitute the original object by a GObject in the XS signature. If the library using introspection is loaded the glib introspection will be used to construct the right instances. This is a poor man's hack and I doubt that it will work with boxed types. But since WebKit also supports gobject-introspection, why not use it that way as well? It's still a little rough around the edges, but here's your browser.pl example ported to use the introspection stuff. The introspection framework really looks nice. Your examples show that it's very easy to write the bindings for arbitrary C C libraries quite easily. What's the catch? ;) Are there bugs or unimplemented parts? This is too nice to be true. Is there a way to provide custom made XS methods to an introspection perl package? For instance, SoupMessageBody is defined as: typedef struct { const char *data; goffset length; } SoupMessageBody; And provides no accessor for data or length. Is there a way to complete the introspection binding with extra XS methods? If so do you know of an existing cpan package that does this? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcing: Perl bindings for LibSoup
On Mon, May 23, 2011 at 23:15, Torsten Schoenfeld kaffeeti...@gmx.de wrote: On 23.05.2011 09:56, Emmanuel Rodriguez wrote: I'm starting by implementing the minimum by hand in order to support my talk hoping that the introspection framework will be mature soon and will take over my work. It seems that Glib::Object::Introspection is already capable of handling a reasonable portion of libsoup's API. Attached is a simple HTTP response printer. Your sample code looks very promising. I'm not able to run any introspection module on my computer. I tried to compile the latest perl-Glib-Object-Introspection found on git and the unit tests fail: PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_harness(0, 'blib/lib', 'blib/arch') t/*.t t/00-basic-types.t .. Can't load '/home/emmanuel/Projects/perl-Glib-Object-Introspection/blib/arch/auto/Glib/Object/Introspection/Introspection.so' for module Glib::Object::Introspection: /home/emmanuel/Projects/perl-Glib-Object-Introspection/blib/arch/auto/Glib/Object/Introspection/Introspection.so: undefined symbol: gperl_hv_take_sv at /usr/lib/perl/5.10/DynaLoader.pm line 192. at ./t/inc/setup.pl line 1 Compilation failed in require at ./t/inc/setup.pl line 1. BEGIN failed--compilation aborted at ./t/inc/setup.pl line 1. Compilation failed in require at t/00-basic-types.t line 3. BEGIN failed--compilation aborted at t/00-basic-types.t line 3. t/00-basic-types.t .. Dubious, test returned 2 (wstat 512, 0x200) No subtests run This is un VM running ubuntu 11.04 with all dependencies taking for the official ubuntu repos and perl-Glib-Object-Introspection straight from the git repo. What should I do in order to have the introspection framework working? I do have a question: which namespace should I use for the perl bindings? As for names: since libsoup seems to be HTTP-centric, maybe HTTP::Soup or HTTP::LibSoup. Good suggestion, I already rushed into renaming to Glib::Soup. I'll do it once more :) -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Announcing: Perl bindings for LibSoup
Hi, I'm preparing a talk for the French Workshop about Gtk2::WebKit and after playing with the perl bindings I noticed that the C WebKit API exposes some LibSoup objects (SoupSession and SoupMessage) and that we don't have their bindings for Perl. LibChamplain is also based on LibSoup but its objects where never exposed through the C champlain API so I was able to avoid the libsoup bindings. That was until now as I'm planning on using the Libsoup objects for doing things like resource tracking, therefore I need the Perl bindings. I'm starting by implementing the minimum by hand in order to support my talk hoping that the introspection framework will be mature soon and will take over my work. I do have a question: which namespace should I use for the perl bindings? Soup is a bit too hight level, Gtk2::Soup seems a bit strange as there's no widget involved in LibSoup (but that's what I picked for now as I recycled Gtk2::Champlain to bootstrap my work). I was thinking of leaving Gnome::Soup for the gnome part of the bindings. For now the tentative project (a starter) is in github [1] with a fork of Gtk2::WebKit [2] that will suport the library as an optional dependency (for now the dependency is mandatory). [1] https://github.com/potyl/Gtk2-Soup [2] https://github.com/potyl/gtk2-webkit -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcing: Perl bindings for LibSoup
On Mon, May 23, 2011 at 11:24, Grant McLean gr...@mclean.net.nz wrote: On Mon, 2011-05-23 at 09:56 +0200, Emmanuel Rodriguez wrote: I do have a question: which namespace should I use for the perl bindings? Soup is a bit too hight level, Gtk2::Soup seems a bit strange as there's no widget involved in LibSoup (but that's what I picked for now as I recycled Gtk2::Champlain to bootstrap my work). I was thinking of leaving Gnome::Soup for the gnome part of the bindings. How about Glib::Soup ? I like it. Thanks. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: formatted HTML in a gtksourceview widget
On Wed, May 26, 2010 at 5:03 PM, Dirk Koopman d...@tobit.co.uk wrote: I have some (pre-parsed) HTML as a string (actually generated from a browser DOM). I wish to display this as nice formatted and highlighted HTML in a gtk-perl window. Tried plain Gtk2::SourceView, but that seems to give me one long line. HTML::Tidy seems only to do checking. Gtk2::SourceView is very old, try to use Gtk2::SourView2 [1] instead. Regarding the one long line, you will need to format it your self. I'm afraid that no editor widget will do this for you as they will want to respect the initial formatting. I think that the easiest is to simply use XML::LibXML: use XML::LibXML; $string = XML::LibXML-new()-parse_string($string)-toString(1); # Or try with 2 You can also take a look at Xacobeo [2], which is written in Perl, feel free to rip the peaces from it but the main formatting logic is now in XS due to speed constraints. If you want a pure Perl implementation take a look at this old branch [3]. [1] http://search.cpan.org/perldoc?Gtk2::SourceView2 [2] http://code.google.com/p/xacobeo/ [3] http://github.com/potyl/xacobeo/blob/0.04/bin/xacobeo#L367 -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: String Encocoding in Gtk-Perl: Hoping for Clarification
On Sat, May 8, 2010 at 7:42 PM, Peter Daum gator...@yahoo.de wrote: Using some little test programs, I verified, that Gtk2 still returns everything in utf8, so the change must be somewhere in Gtk2-Perl or in Perl. When I run the following code snippet: Gtk2-Perl also returns all strings in UTF-8. If you want to see if a string is in UTF-8 or not I suggest that you use Devel::Peek [1] my $button = new Gtk2::Button( print ); my $entry = new Gtk2::Entry; $button-signal_connect( clicked,sub {print $entry-get_text,\n} ); I'm certain that $entry-get_text returns an UTF-8 string. I'm guessing that the problem lies on the encoding of STDOUT. You should set explicitly the encoding of the STDOUT otherwise you can endup with broken characters on the console. Try to set encoding of STDOUT to UTF-8. You can do this with: binmode STDOUT, :utf8; or with the pragma open, which will change STDOUT, STDERR and STDIN: use open :utf8, :std; [1] http://search.cpan.org/perldoc?Devel::Peek -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Clutter::Gst::Audio
Hi, Have you initialized Clutter so that it can use gstreamer? use Clutter '-gst-init'; You might want to upgrade to Clutter 1.0, I think that you are using Clutter 0.8 which is no longer maintained. Cheers, Emmanuel On Sun, May 9, 2010 at 12:16 PM, Grant McLean gr...@mclean.net.nz wrote: I've been playing around with Clutter and have mostly been successful with the simple animations etc. However I've had no luck with playing sound. I have a sound file in OGG format (I also tried WAV) and from my script I tried this: my $audio = Clutter::Gst::Audio-new; # This is line 27 $audio-set_filename('bell.ogg'); But the first line emits the following warnings: Clutter-Gst-WARNING **: Unable to create playbin GST element. at ./05_image.pl line 27. Clutter-Gst-WARNING **: Failed to initiate suitable playback pipeline. at ./05_image.pl line 27. I tried the playbin.pl example script from the GStreamer distribution and it was happy to play the OGG file. It seems like there's something basic missing - did I need to load some module first? The libclutter-gst library is installed. Any suggestions gratefully received. Cheers Grant ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: multiple handlers binded to one signal don't work
2010/5/7 Xi Yang jianding...@msn.com The second handler just won't work. The C documentation [1] tells that you have to return TRUE to stop the signal emission. That's what you are doing and you're doing :) Return FALSE and you will have your expected behavior. [1] http://library.gnome.org/devel/goocanvas/unstable/goocanvas-goocanvasitem.html#GooCanvasItem-button-press-event sub on_press_1 { print on press 1\n; return TRUE; return FALSE; } sub on_press_2 { print on press 2\n; return TRUE; return FALSE } -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: when should I create child objects?
2010/4/16 Xi Yang jianding...@msn.com I'm attempting to build a Goo::Canvas::Group subclass. It has a 'displayName' property, and would show the displayName using a Goo::Canvas::Text object. ## in CanvasExpand.pm ## package CanvasExpand; use Glib::Object::Subclass('Goo::Canvas::Group', properties = [ Glib::ParamSpec-string( 'displayName','','', 'default_value', [qw/readable writable/] ) ], ); sub INIT_INSTANCE { my $self = shift; my $name = $self-get('displayName'); # here gots 'default_value' Goo::Canvas::Text-new($self,$name,0,0,-1,'center'); } ## However, while creating the Text object in INIT_INSTANCE function, the displayName property remains to be uninitialized: the default value is retrieved, rather than the value provided in constructor. So, when should I build all children? Good question! What I do is that I provide my own new and call the parent's new first. I then build my properties there. sub new { my $class = shift; my $self = $class-SUPER::new(@_); $self-set_XXX($xxx); return $self; } I'm wondering if there's a better way too. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How to store perl object in GObject's property?
2010/4/15 Xi Yang jianding...@msn.com For example: ## in Extended.pm ## package Extended; use strict; use test::Foo; use Glib::Object::Subclass 'Goo::Canvas::Rect', properties = [ Glib::ParamSpec-object( 'foo','','', 'Foo', [qw/readable writable/] ) ] ; Glib::ParamSpec-object is for GObject and derivatives, since you just want to pass a pure perl object use Glib::ParamSpec-scalar ($name, $nick, $blurb, $flags) instead. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Clutter: missing pkgconfig information
2010/4/9 Xi Yang jianding...@msn.com While installing clutter perl binding using cpan, it says: But I have clutter.x86_64 installed (using yum, Fedora 12). Is that a error of yum installation progress? How can I add required information to pkgconfig? You might need to install the clutter devel package. I haven't used a RPM distro in a long time but if I recall well you should be able to find a package named clutter-devel. Install it and you should have the missing files. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Custom TreeModel
On Sun, Jan 17, 2010 at 11:03 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: On Sun, Jan 17, 2010 at 5:44 PM, Aristotle Pagaltzis pagalt...@gmx.dewrote: * Emmanuel Rodriguez emmanuel.rodrig...@gmail.com [2010-01-14 08:35]: I could rewrite this tree model with a pure Perl tree model (HTML::Tree) and add it to the Gtk2-Perl examples. It sounds to me like what you want is to store some kind of pointer in the iter (eg. an XPath) whereby the same node can be re-requested from XML::LibXML in the event that it has to. I did implement this stragey too but the XPath string was being lost once inserted into the TreeIter. Dumping the TreeIter received and returned by all methods shows that the incoming iters lose the value returned by the previous method. I'm guessing that the problem occurs because there's no other variable that holds a reference to the values stored in TreeIter. Once the method that builds the TreeIter returns the Perl scalars stored in the iter get reclaimed. This is why I tend to believe that with a pure Perl tree things will work better as the nodes will still have a refcount of 1. Hopefully this week I will have the time to test this. I managed to find the time to implement a Gtk2::TreeModel that's backed by a pure Perl tree [1]. Things work as expected and as long as the tree nodes are in the main Perl structure there's no problem with the TreeIters. [1] https://bugzilla.gnome.org/show_bug.cgi?id=608730 -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Custom TreeModel
On Mon, Jan 18, 2010 at 1:10 AM, Aristotle Pagaltzis pagalt...@gmx.dewrote: * Emmanuel Rodriguez emmanuel.rodrig...@gmail.com [2010-01-17 23:00]: I'm guessing that the problem occurs because there's no other variable that holds a reference to the values stored in TreeIter. Once the method that builds the TreeIter returns the Perl scalars stored in the iter get reclaimed. What prevents you from holding onto the strings you pass into the TreeIter yourself? Holding to the strings has the same issue as holding to the XmlNodes. I endup duplicating the model in memory and I don't know when you release them. This is why I tend to believe that with a pure Perl tree things will work better as the nodes will still have a refcount of 1. You’re going to swap out the entire DOM, and go to a more memory- hungry and slower approach, just because the strings aren’t held onto, and you aren’t willing to hold onto them yourself? That’s not what I’d do… but suit yourself I guess… Not only that but I will be swapping an XML DOM for an HTML tree! Rest reassured I haven't gone mad :) What's happening is that I wanted was to implement a TreeModel for an XML::LibXML DOM tree. I need this for my XML application Xacobeo [1] [2] which uses XML::LibXML as it source. My first intention was to do this is in Perl. As you can see from my previous emails I failed. At first I wasn't able to implement such a TreeModel in Perl, so I reverted to C for the same backend (libxml2). Once I saw that the C version worked I gave a second try to the Perl version and managed to do what I posted. I now have 2 implementations of the same TreeModel in C and Perl. I will try to use the C version for my application as XML documents can have easily millions of nodes and C will be very useful here for its speed. So the Perl version is a bit useless for me at the moment. I figured that I didn't do this in vain and that I could share it with others. My intention is now to understand what I did wrong in the script and to refactor it into a decent implementation of a TreeModel that can serve as an inspiration for any other Perl application. So far this mailing list has been of great help and I think that I understand what's going on. Now that I know that's happening with the memory management I will rewrite the script so that the tree uses as it base a real Perl tree model. The choice of HTML is ramdon and I could use something else: files, perl data, JSON export, as long as there's a valid parent/child relationship and that the model is in pure Perl. I'm assuming that if someone else will use a custom TreeModel in a Gtk2-Perl application that it will be for a pure Perl tree and not for a tree that's implemented in C. If that's the case the new Perl example or this thread might be of some help. [1] Xacobeo git http://github.com/potyl/xacobeo [2] Xacobeo Screenshots http://code.google.com/p/xacobeo/ -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Custom TreeModel
On Sun, Jan 17, 2010 at 5:44 PM, Aristotle Pagaltzis pagalt...@gmx.dewrote: * Emmanuel Rodriguez emmanuel.rodrig...@gmail.com [2010-01-14 08:35]: I see that there's not way to avoid the cache. It's a bit of a pity that I can't detect when an iter is no longer needed as eventually all nodes will be duplicated into the cache. I'm guessing that with a normal (pure Perl) tree model this will not be the case as nodes will be already in the model. Using XML::LibXML nodes is a bit peculiar as the memory management is a bit different. If I'm not mistaken XML::LibXML assumes that nodes are attached to the underlying C model and that the SVs wrapping them can be easily discarded at anytime as long as the original C structure lives. I could rewrite this tree model with a pure Perl tree model (HTML::Tree) and add it to the Gtk2-Perl examples. It sounds to me like what you want is to store some kind of pointer in the iter (eg. an XPath) whereby the same node can be re-requested from XML::LibXML in the event that it has to. I did implement this stragey too but the XPath string was being lost once inserted into the TreeIter. Dumping the TreeIter received and returned by all methods shows that the incoming iters lose the value returned by the previous method. I'm guessing that the problem occurs because there's no other variable that holds a reference to the values stored in TreeIter. Once the method that builds the TreeIter returns the Perl scalars stored in the iter get reclaimed. This is why I tend to believe that with a pure Perl tree things will work better as the nodes will still have a refcount of 1. Hopefully this week I will have the time to test this. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Custom TreeModel
On Thu, Jan 14, 2010 at 12:05 AM, Torsten Schoenfeld kaffeeti...@gmx.dewrote: On 09.01.2010 16:08, Emmanuel Rodriguez wrote: What I've noticed is that the data stored in the Gtk2::TreeIter is really volatile and that it doesn't survive too long after a method returns. Furthermore, only the 2 first elements of the TreeIter make it back to the TreeModel methods intact. I also noticed that setting references into the last 2 fields can yield strange situations. As Kevin said, tree iters don't keep stuff you put into them alive for you. If you want to put any non-integer thing into an iter, you need to keep it alive some other way, for example by also storing it in a cache inside the tree model. This is also shortly explained in perldoc Gtk2::TreeModel / CREATING A CUSTOM TREE MODEL. I see that there's not way to avoid the cache. It's a bit of a pity that I can't detect when an iter is no longer needed as eventually all nodes will be duplicated into the cache. I'm guessing that with a normal (pure Perl) tree model this will not be the case as nodes will be already in the model. Using XML::LibXML nodes is a bit peculiar as the memory management is a bit different. If I'm not mistaken XML::LibXML assumes that nodes are attached to the underlying C model and that the SVs wrapping them can be easily discarded at anytime as long as the original C structure lives. I could rewrite this tree model with a pure Perl tree model (HTML::Tree) and add it to the Gtk2-Perl examples. Here's a patch against your program that implements this. It also fixes an unrelated typo. Thanks. Is the Perl sample code wrong? Maybe I missed something.. Would it make sense to add it to the Gtk2-Perl examples, perhaps someone could find it useful. The customlist.pl example does this in GET_ITER: my $record = $self-{rows}[$n]; ... return [ $self-{stamp}, $n, $record, undef ]; So the reference it puts into the iter is kept alive by $self-{rows}. I guess a better explanation in the example and maybe also in the Gtk2::TreeModel docs would be useful. Care to write something up? I will do it. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Custom TreeModel
Hi, I tried implementing a custom Gtk2::TreeModel in Perl and my results are not quite as expected. I followed the advice from the Gtk2-Perl recipes [1] and the example customlist.pl [2]. My intent is to create a mode that wraps a real tree and not a flat list. My strategy was to use a DOM tree as the real source of my model and to it implement the methods of TreeModel on top of the existing xml node hierarchy (XML::LibXML DOM nodes). I've attached the code of my implementation to this email. What I've noticed is that the data stored in the Gtk2::TreeIter is really volatile and that it doesn't survive too long after a method returns. Furthermore, only the 2 first elements of the TreeIter make it back to the TreeModel methods intact. I also noticed that setting references into the last 2 fields can yield strange situations. So far the only way that I found in Perl for passing my elements into the TreeIters and to get them back is to pass a unique number that will help me find back the corresponding node. This way the code works but it's far from being optimal as each DOM node has to be assigned to an internal hash in order to persist between the subsequent method calls of the model. The main problem here is that I don't know when I can remove elements from the hash and I endup copying all DOM objects into the hash. Here's how I pass the elements into the tree iter my $address = refaddr $node; $self-{iters}{$address} = $node; return [ $self-{stamp}, $address, undef, undef ]; # The TreeIter Ideally I would insert the XML node into the iter and get it back at each method, but this results a segmentation fault later on in the program: return [ $self-{stamp}, 0, $node, undef ]; # Crash latter on If I try to pass to path to the node (XPath expression as a string), I receive undef. return [ $self-{stamp}, 0, $node-nodePath, undef ]; # The string is lost in the next calls If I pass a reference just as customlist.pl does I endup with an reference too but pointing to the wrong place: return [ $self-{stamp}, 0, [ $xpath ], undef ]; # Next calls receive [0,0,\$VAR1-[1],undef]; It seems that implementing a real tree model (and not a flat list) with Gtk2 is not so trivial. It's either that or I failed miserably :) I implemented the same code in C and it works fine as the TreeIter is not losing the data that gets inserted and calls to the model methods get the proper values. Is the Perl sample code wrong? Maybe I missed something.. Would it make sense to add it to the Gtk2-Perl examples, perhaps someone could find it useful. [1] http://live.gnome.org/GTK2-Perl/Recipes#Why_not_cook_up_a_TreeStore_from_scratch_.3F_Like_in_olden_times. .. [2] http://git.gnome.org/browse/perl-Gtk2/tree/examples/customlist.pl -- Emmanuel Rodriguez dom.pl Description: Perl program ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: searching text
On Jan 5, 2010, at 20:50, Chris Bare ch...@bareflix.com wrote: I'm working on porting a simple text note taking application from motif to gtk. The basics were very easy to get working, but I'm a little stuck on how to implement search. In the old implementation, I got the text data, got the curser offset and did the search with regex. Looking through the gtk docs, I see there are GtkTextView and GtkSourceView widgets with corresponding Buffer objects. TextBuffer lists insensitive search as a possible future feature, while SourceBuffer implements insensitive search, but still lists regex as possible future. I don't need most of what SourceView does, I'm only dealing with plain text. 2 questions. #1 if I have: GtkTextMark *mark; GtkTextBuffer *bf; data = gtk_text_buffer_get_text (bf, start, end, FALSE); mark = gtk_text_buffer_get_insert (bf); is there a simple way to convert mark into an offset into data? I realize that won't work right with non-ascii characters. #2 is there yet another set of gtk objects that will give me regex and case insensitive searches using an official api? Glib has regular expressions and you can always transform an iter/mark to a string position. Take a look at this demo: http://github.com/potyl/gtk2-sourceview2/blob/master/examples/perl-editor.pl#L261 It was my attempt to mimic nedit (a great motif editor) in gtk2. I have there support for detach with regexpes event if gtkdourceview doest provide it. -- Chris Bare ch...@bareflix.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_editable_get_position
On Tue, Dec 22, 2009 at 11:47 AM, maxim maxim look200...@gmail.com wrote: Hi to all, I have a following question, I try to receive a cursor position in GtkEntry by function gtk_editable_get_position (GTK_EDITABLE (entry)), but the function returns a correct position only at expose-event, in all other cases it returns a zero, how to solve this problem? You can try to access directly the property cursor-position: gint position = -1; g_object_get(G_OBJECT(entry), cursor-position, position, NULL); -- Emmanuel Rodriguez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Memory leak in gtk label?
On Tue, Dec 22, 2009 at 3:47 AM, Liu, Raymond raymond@intel.com wrote: you should read: http://live.gnome.org/Valgrind before using Valgrind with GLib or GTK+ based applications. Thanks a lot ;) With the gtk.suppression file for 2.12, 30% of the fake memory leak issues are gone. While, still quite many of them remain. I can add more suppress rules, but I am not sure whether they are real of fake memory leak issues. So is there any latest suppression files for gtk / glib? You can always build your own suppression file. Follow the instructions provided by libchamplain [1] in the section Valgrind error suppression. The idea is to make a short hello world program that has no code leak (from the developer point of view) and to tell valgrind to build an error supression list. Then you can use that list with your programs. [1] http://live.gnome.org/libchamplain/contributor -- Emmanuel Rodriguez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Execute associated image viewer or media player on button click
On Tue, Dec 8, 2009 at 3:38 PM, Dov Grobgeld dov.grobg...@gmail.com wrote: You don't say under what system you need this. On windows you would simply do: system(foo.png) and you would call the viewer associated with .png files. (This works for url's as well as just running it through system, runs the prefered user browser). On Linux there is no such system default, but the specifics depend on your desktop. In linux you can do: xdg-open file or gnome-open file -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Execute associated image viewer or media player on button click
On Tue, Dec 8, 2009 at 10:04 PM, Zettai Muri zettaim...@ymail.com wrote: And thanks for the linux information. Is xdg-open file the best way to go rather than checking whether or not the user is using KDE/Gnome? xdg-open is by far the easiest way to open a file no matter which desktop the user is running. In old linuxes that command wasn't available but today it seems to be available. This is also why I posted the alternative gnome-open which is always available but is desktop specific. Just out of interest is there a way to confirm which desktop they are using? Some clever variable like the $^O one for checking the OS? xdg-open is a shell script so you an peek and see how they do to detect which desktop is running. But why going through all the hassle when xdg-open does everything? :) -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Embedding the VTE Virtual Terminal
On Thu, Nov 26, 2009 at 3:07 PM, Stevenix steve.gnuli...@gmail.com wrote: Hi, I'm writing a Gui+Terminal application, where VTE is embedded on window, and the GUI Menu Items. And i'm trying to call this action... ... calls to this action from the menu... (just fork a 'ls' command) But i'm unable to get the 'ls' listing ... void VimWindow (GtkWidget *widget, gpointer gdata) { GtkWidget *vte; vte = vte_terminal_new(); [b]vte_terminal_fork_command(VTE_TERMINAL(vte), ls, NULL, NULL, ., FALSE, FALSE, FALSE);[/b] } Try something like this (untested): char [][] argv = { ls, NULL }; vte_terminal_fork_command(VTE_TERMINAL(vte), ls, argv, NULL, ., FALSE, FALSE, FALSE); If I recall well the first ls is actually the name you want the users to see when they run ps while argv[0] has the name of the program to execute. -- Emmanuel Rodriguez ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Gtk2::FileFilter by mime type
On Sat, Nov 28, 2009 at 12:18 AM, Emmanuele Bassi eba...@gmail.com wrote: you can add multiple rules to a filter, but in this case I'd check the OS you're running on to decide what to use, e.g.: if ($^O eq 'MSWin32') { $filter-add_pattern('*.mp3'); } else { $filter-add_mime_type('audio/mp3'); } This is probably the best solution. or, since add_mime_type() is ignored on Windows: # default to MIME type... $filter-add_mime_type('audio/mp3'); # ... and add the extension matching on Windows $filter-add_pattern('*.mp3') if $^O eq 'MSWin32'; From what I've seen mime-type rules are not ignored in windows[1] , instead they get stored and processed as if there was no difference [2] (but there's a difference). What happens later is that g_content_type_is_a will assumes that it's arguments are not mime-types under windows. In the case of Gtk2::FileFilter this results in no matches under windows as g_content_type_is_a is expecting extensions and gets mime-types which don't match. At the end this is not too intuitive as the documentation of gtk_file_chooser_add_mime_type doesn't warn us about this behaviour. [1] http://git.gnome.org/cgit/gtk+/tree/gtk/gtkfilefilter.c#n217 [2] http://git.gnome.org/cgit/gtk+/tree/gtk/gtkfilefilter.c#n378 -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::FileFilter by mime type
On Thu, Nov 26, 2009 at 11:28 AM, Zettai Muri zettaim...@ymail.com wrote: Hi All, I am trying to use the following filters: my $sound_filter = Gtk2::FileFilter-new; $sound_filter-add_mime_type(audio/*); my $image_filter = Gtk2::FileFilter-new; $image_filter-add_mime_type(image/*); Because I read here: http://library.gnome.org/devel/gtk/stable/gtk-gtkfilefilter.html#gtk-file-filter-add-mime-typethat 'GtkFileFilter allows wildcards for the subtype of a mime type, so you can e.g. filter for image/*.' Is this also possible with the Perl bindings? I've checked the C implementation of GtkFileFilter and mime types rules are processed with g_content_type_is_a[1] which has different implementations for Unix/Linux and Windows. In Linux g_content_type_is_a behaves as you expect so 'text/png' is considered a 'text/*'. I haven't tried with a GtkFileFilter yet. Are you running your program in Linux/Unix or in Windows? [1] http://library.gnome.org/devel/gio/stable/gio-GContentType.html -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Capture console app output into texview?
On Thu, Nov 19, 2009 at 10:11 PM, Till Harbaum / Lists li...@harbaum.orgwrote: Hi, i am trying to run a text mode application in the background of my gtk one and display its output in a textview. I know this is supposed to be done using g_spawn_async_with_pipes and then link to the output via g_io_add_watch. I even got something that sort of works, but the output is very much delayed and comes in chunks and worse, the CPU load is at max while and after i run my code. Are there any examples for doing this? There must be many programs doing something similar to run e.g. some little helper program or similar. Can you consider using the VteTerminal[1] widget? This is the same terminal widget used in gnome-terminal and in Ubuntu/Debian graphical frontends to dpkg. It lets you embed a ternimal that you can bind to any program, you're not forced to bind it to a shell. VteTerminal will take care of monitoring your process and grabbing all output for you. The only drawback is that the widget doesn't work on win32. [1] http://library.gnome.org/devel/vte/unstable/VteTerminal.html Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: using doxygen to document gobject/gtk classes?
On Tue, Nov 17, 2009 at 3:22 AM, Brian J. Tarricone bj...@cornell.eduwrote: Hi all, I'm in a situation where I'd like to use doxygen (and not gtk-doc) to document some GObject-derived classes. Does anyone have any experience with this and knows of any tricks to use to make the output more useful? I found one link via google[1] that referred to this, but it didn't have much useful info. Take a look at Pidgin's documentation [1] they use Doxygen. You might get some hints on how to proceed. I got somehow used to browse gtk-doc pages and find Doxygen quite annoying, but it's your project so you know what's best for it! ;) [1] http://developer.pidgin.im/doxygen/dev/html/main.html -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Ctrl-Click keyboard mouse event
On Tue, Nov 10, 2009 at 10:56 PM, Carlos Pereira jose.carlos.pere...@ist.utl.pt wrote: Hi list, When a button press event is triggered, what is the proper way to know if the user is pressing down the Ctrl key? Tipically I would want to know this inside a button press event callback: int handle_button_press (GtkWidget *widget, GdkEventButton *event, void *data) { mouse button has been clicked: is Ctrl key down??? ... } I think that this is what you need: if (event-button == 1 (event-state GDK_CONTROL_MASK) != 0) { /* Button 1 with contro clicked */ } -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problems with GHashTable in signal handler
On Sun, Oct 25, 2009 at 10:40 PM, muppet sc...@asofyet.org wrote: On Oct 25, 2009, at 8:55 AM, Jörn Reder wrote: Hi, I try to use the create-plugin-widget signal of Gtk2::WebKit::WebView, which passes a GHashTable to the callback. Here it's signature from the docs: GtkWidget* user_function (WebKitWebView *web_view, gchar *mime_type, gchar *uri, GHashTable*param, gpointer user_data) : Run Last / Action (from http://webkitgtk.org/reference/webkitgtk-WebKitWebView.html#WebKitWebView-create-plugin-widget ) Perl dies with this error message when my signal handler is called: GType GHashTable (146176672) is not registered with gperl Since signal handling is completely covered on Glib level I don't think this problem is related to Gtk2::WebKit. The Glib perldoc says GHashTable is bound to the native Perl hash datatype. I grep'ed the sources of Glib and Gtk2 to find any examples of passing GHashTables to Perl - with no luck. Any help on this is appreciated ;) Actually, the docs say The GLib types GList (a doubly-linked list), GSList (singly-linked list), GHashTable, GArray, etc have all been replaced by native Perl datatypes. That is, replace by, not bound to. GHashTable is not really bindable, because it is a generic mapping of arbitrary pointer to arbitrary pointer; you must know something about what is in it in order to use it, and we can't create a generic wrapper for that. Therefore, for each function that passes a hash table, we map that by hand to a perl hash. However, it's not actually very common for the gnome APIs to pass GHashTables around -- they're normally used for implementation. In fact, i can't really think of where we've had to do this... libgobject started registering a GType for GHashTable in 2.10, to make it possible to say this signal argument is a hash table instead of this signal argument is a pointer. However, as the gobject-introspection guys pointed out, this isn't terribly useful; you need to know more information, like this object is a hash table whose keys are strings and whose values are gobjects. We don't have that at a generic level. So the only real option that you have is to create a custom marshaller for this signal, implemented in Gtk2::WebKit::WebView. This marshaller would be used only for this signal, where we know that the hash table is supposed to be a map of strings to strings. You'd do something like call g_hash_table_foreach() to push all the keys and values in the hash table into a new hash, and pass a reference to that new hash to perl in place of the hash table. (The closer you stick to the C api, the fewer problems people will have here.) If you're supposed to allow the callback to modify the hash, then you'll have to push those changes back the other way when the callback returns. Read gperl_marshal.h for a template and helpers. There are a few examples of custom marshallers in Gtk2, nearly all used for arguments that are unfriendly to non-C languages (e.g. write-through integer parameters, C arrays, and G_TYPE_POINTER args that you're supposed to cast to something else). Search Gtk2 for gperl_signal_set_marshaller_for and follow where that takes you. From Glib::xsapi: void gperl_signal_set_marshaller_for (GType instance_type, char * detailed_signal, GClosureMarshal marshaller) You need this function only in rare cases, usually as workarounds for bad signal parameter types or to implement writable arguments. Use the given marshaller to marshal all handlers for detailed_sig- nal on instance_type. gperl_signal_connect will look for mar- shallers registered here, and apply them to the GPerlClosure it creates for the given callback being connected. Use the helper macros in gperl_marshal.h to help write your mar- shaller function. That header, which is installed with the Glib module but not #included through gperl.h, includes commentary and examples which you should follow closely to avoid nasty bugs. Use the Source, Luke. Thanks for the explanation! This has come very handy as I was wondering how this could be done. I always wanted to change a parameter in Gtk2::Unique and didn't knew that it was even possible until you wrote this :) I've now implemented this for Gtk2::Unique which now looks more Perl-ish than ever! Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Announce - Bindings for Gtk2::SourceView2
Hi, I wrote the bindings for GtkSourceView 2 [1] and they are now in CPAN under the name Gtk2::SourceView2 [2]. GtkSourceView is a portable C library that extends the standard GTK+http://www.gtk.org/framework for multiline text editing with support for configurable syntax highlighting, unlimited undo/redo, UTF-8 compliant caseless searching, printing and other features typical of a source code editor. It is currently being used by gedit, MonoDevelop, Anjuta and several other projects. [1] http://projects.gnome.org/gtksourceview/ [2] http://search.cpan.org/perldoc?Gtk2::SourceView2 -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Application Crashed When require/use Gtk2 in A Perl Plugin of Pidgin
On Mon, Oct 5, 2009 at 2:39 AM, Leno Lin leno@gmail.com wrote: Hi, Emmanuel: Yeah, I've read this article before and imported Gtk2 by using require Gtk2. My script used to worked fine in Pidgin 2.5.x, but keep crashing Pidgin after upgrading to 2.6.x. either require or use And yes, I think the support to Perl API is indeed weaker than native C API. Sad :( I have a feeling that the Perl bindings for Pidgin are not supported. For example, I originally wanted to call some of my callback functions through the conversation menu items, but since Perl API hasn't support it yet, I had to move this to slash command. However, using Perl still takes advantage of easy installation and at least supports the basic functions that I need. That's the reason I still stick on Perl. You can still try to write a Perl script that would use Pidgin's D-Bus API. It exposes a lot of functions, but not all. Take a look at the scripts that I have here: http://bratislava.pm.org/presentation/dbus/index.html The script dbus-pidgin.pl should help you getting started. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: undo in textview
On Wed, Sep 23, 2009 at 10:39 PM, Yann Leboulanger aste...@lagaule.orgwrote: Hi, It seems GTK have no feature to undo in a gtkTextview / gtTextBuffer. Am I wrong? It doesn't but gtksourceview does. You can download it from here: http://projects.gnome.org/gtksourceview/ -- Emmanuel Rodriguez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: all about gobject references
On Sat, Aug 22, 2009 at 3:12 PM, Tadej Borovšak tadeb...@gmail.com wrote: Hi but when i put it throught valgrind tool it says 156 bytes loss in memory Analyzing glib code with valgrind requires some preparation or false positives are reported. Ask your favorite search engine about this and you should be able to find some documentation. Libchamplain's wiki [1] has a section named Valgrind error suppression that shows how to prepare valgrind to behave better with glib. The instructions should be easy to adapt to any project. [1] http://live.gnome.org/libchamplain/contributor -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: all about gobject references
On Sat, Aug 22, 2009 at 3:12 PM, Tadej Borovšak tadeb...@gmail.com wrote: Hi but when i put it throught valgrind tool it says 156 bytes loss in memory Analyzing glib code with valgrind requires some preparation or false positives are reported. Ask your favorite search engine about this and you should be able to find some documentation. Libchamplain's wiki [1] has a section named Valgrind error suppression that shows how to prepare valgrind to behave better with glib. The instructions should be easy to adapt to any project. [1] http://live.gnome.org/libchamplain/contributor -- Emmanuel Rodriguez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GDK + GLib main loop
On Wed, Aug 12, 2009 at 5:09 AM, Mihai Draghicioiu mihai.draghici...@gmail.com wrote: I have found the way. Here is my code. Any idea where I can post it as a tutorial? You can submit your code to be included with the examples of gtkglarea or use the GNOME wiki (http://live.gnome.org/). -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: treeview looks like a list not as a tree
On Thu, Jul 23, 2009 at 9:46 PM, anguila angu...@gmail.com wrote: Hi I dont understand why in my treeview looks like a list and not as a tree, i have added a parent in each set and the child doesnt added: and there in a piece of code i use that: ... my $obj= $tree_store-append(undef); $tree_store-set($obj,0=$def_link, 1=$logo_server); my $child= $tree_store-append($obj); Try to see if you replace this line: $tree_store-set($fill,0=CHILD,1=$logo_server); With : $tree_store-set($child,0=CHILD,1=$logo_server); -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: treeview looks like a list not as a tree
On Fri, Jul 24, 2009 at 1:17 AM, anguila angu...@gmail.com wrote: Yes, in my code was here, sry, I traduced the variables to b more readable. So the problem still exist, i defined relation with child and parent and doesnt looks like a tree.. Could you try to isolate the code in a small working program that demonstrates the problem? Otherwise it will be very hard for us to find what's going wrong. Here's how I was once filling a tree: http://code.google.com/p/xacobeo/source/browse/tags/0.04/lib/Xacobeo/DomModel.pm#90 The important part is to call $child = $model-append($parent); and to keep $child as the parent iter whenn adding it's children. If you fail to keep $child (if it's set to undef) you will be simply adding elements to the top of the tree and creating a flat list. Perhaps your $iter is always undef? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GDK + GLib main loop
On Thu, Jul 23, 2009 at 5:33 AM, Mihai Draghicioiu mihai.draghici...@gmail.com wrote: Hi all! I'm making an OpenGL application based on GDK + GtkGLArea. My code so far works, but it has two issues: Do you really need to have your application based on GDK? Can't you use GTK instead? By using GTK you can simply connect to the wanted signals and start a main loop. This is going to be easier. The tar.gz of gtkglext has an examples directory and you should be able to start from one of their sample programs. You should consider modifying your code to use GTK instead of GDK: #include stdlib.h #include gtk/gtk.h #include gtk/gtkgl.h #include GL/gl.h static void realize (GtkWidget *widget, gpointer data) { GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) { return; } glClearColor(1.0, .5, .2, 1.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, widget-allocation.width, widget-allocation.height, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(0.0, 1.0, 0.0); glBegin(GL_QUADS); glVertex2i(100, 100); glVertex2i(400, 100); glVertex2i(400, 500); glVertex2i(100, 500); glEnd(); /* swap backbuffer to front */ if (gdk_gl_drawable_is_double_buffered(gldrawable)) gdk_gl_drawable_swap_buffers(gldrawable); else glFlush(); gdk_gl_drawable_gl_end (gldrawable); } static gboolean configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer data) { GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); /*** OpenGL BEGIN ***/ if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) return FALSE; glViewport (0, 0, widget-allocation.width, widget-allocation.height); gdk_gl_drawable_gl_end (gldrawable); /*** OpenGL END ***/ return TRUE; } static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event, gpointerdata) { GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); /*** OpenGL BEGIN ***/ if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) return FALSE; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glCallList (1); if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); else glFlush (); gdk_gl_drawable_gl_end (gldrawable); /*** OpenGL END ***/ return TRUE; } int main(int argc, char **argv) { gtk_init(argc, argv); gtk_gl_init(argc, argv); int config_attributes[] = { GDK_GL_DOUBLEBUFFER, GDK_GL_RGBA, GDK_GL_RED_SIZE,1, GDK_GL_GREEN_SIZE, 1, GDK_GL_BLUE_SIZE, 1, GDK_GL_DEPTH_SIZE, 12, GDK_GL_ATTRIB_LIST_NONE }; GdkGLConfig *glconfig = gdk_gl_config_new(config_attributes); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); g_signal_connect (G_OBJECT (window), delete_event, G_CALLBACK (gtk_main_quit), NULL); // Get automatically redrawn if any of their children changed allocation gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE); // The widget where the OpenGL drawing will be done GtkWidget *drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, 200, 200); gtk_widget_set_gl_capability(drawing_area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_widget_add_events(GTK_WIDGET(drawing_area), GDK_CONFIGURE); gtk_widget_add_events(GTK_WIDGET(drawing_area), GDK_KEY_PRESS_MASK); gtk_widget_add_events(GTK_WIDGET(drawing_area), GDK_STRUCTURE_MASK); gtk_widget_add_events(GTK_WIDGET(drawing_area), GDK_EXPOSURE_MASK); g_signal_connect_after (G_OBJECT (drawing_area), realize, G_CALLBACK (realize), NULL); g_signal_connect (G_OBJECT (drawing_area), configure_event, G_CALLBACK (configure_event), NULL); g_signal_connect (G_OBJECT (drawing_area), expose_event, G_CALLBACK (expose_event), NULL); gtk_container_add (GTK_CONTAINER (window), drawing_area); gtk_widget_show_all(window); gtk_main(); return 0; } This is a merge of your code and the example simple.c provided by gtkglext.tar.gz. Your current drawing method doesn't work but I'm not that good with OpenGL. Although if I substitue your drawing by the one of simple.c it works. I'm sure that you will be able to figure this bit out for me :) -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GDK + GLib main loop
On Thu, Jul 23, 2009 at 7:34 AM, Mihai Draghicioiu mihai.draghici...@gmail.com wrote: I'd rather avoid the overhead of GTK+. My other choices were SDL and glut (and maybe others), but none of those offer the features of GDK (and GLib!). I have thought about using GTK+, and it's just pointless overhead, because I'm going to use my own (OpenGL-based) UI library. Besides, it's more fun this way :) I see. You like it the hard way ;) Emmanuel: yes, i know about the examples directory, and I checked there for a GDK-only example, but didn't find one... Thanks for the code, but it's not what I need :P Try to see if you can register the same callbacks to the GDK objects. Then you can still use the glib even loop. Instead of doing gtk_main() you will need to create an event loop your self: GMainLoop *loop = g_main_loop_new (NULL, FALSE); g_main_loop_run(loop); -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to find out the API coverage of Perl bindings
On Mon, Jul 13, 2009 at 8:49 AM, Torsten Schoenfeld kaffeeti...@gmx.dewrote: On 13.07.2009 06:04, muppet wrote: Have you considered the glib introspection repository stuff? I recall that Torsten had some success a while back, but haven't heard anything since... I'm not too familiar with the glib introspection. Although from what I understood the C library that will be binded needs to support the introspection framework, right? The introspection stuff lives at http://git.gnome.org/cgit/gnome-perl-introspection; a slightly outdated description is at http://live.gnome.org/GTK2-Perl/Introspection. I haven't tried it lately, but it should be in good shape. All the pieces for dynamically wrapping entire libraries are there; gio, for example, should be completely doable. Unfortunately, I haven't been able to get round to finishing this stuff up. Does this means that we no longer need to write bindings by hand? If all we need is to provide a .typelib file to Glib::Object::Introspection things are going to become easier! -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: gtk gis
On Thu, Jun 11, 2009 at 3:36 PM, Andrea Zagli aza...@inwind.it wrote: do you know some widget that can display maps (from shp or postgis) and also allows very simple editing? Libchamplain (http://projects.gnome.org/libchamplain/) can render maps from various public sources. There's a route branch that should be merged before the end of the week that will allow for basic drawing. The current version allows markers to be added to an existing maps and markers can be rendered with cairo. -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GstXOverlay interface methods not available
On Mon, May 25, 2009 at 8:28 PM, Torsten Schoenfeld kaffeeti...@gmx.dewrote: Emmanuel Rodriguez wrote: Thanks! I assumed that all gst API was under one CPAN module. Well, then the GStreamer Perl module would have to depend on gst-plugins-base, as that's where libgstinterfaces comes from. Would you accept the sample script, once finished, as an example to include in the module? Sure. I've attached a working version of the script. Feel free to adapt the source code to your liking or to point me to the coding standards that you would like me to adopt. Thanks for the help. -- Emmanuel Rodriguez gst-video-sample.pl Description: Perl program ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Stop alt-spacebar window menu
On Wed, May 27, 2009 at 9:04 PM, Brian J. Tarricone bj...@cornell.eduwrote: Bill Farmer wrote: I am porting a native windows application to linux gtk. I want to stop the alt-spacebar key combination popping up the application window menu. This can be done in windows by capturing the WM_SYSCHAR message. After searching though the gtk documentation and sources, the only way I can see to do this is by copying a file from the gdk sources, modifying it, and compiling it with the application. You probably will not have any success doing this unless you are able to control the user's environment. Things work differently on X11 than on Windows. The alt+space key combo is likely handled by the window manager, which will eat the key and react to it and not even pass it on to your application. I'd suggest not using shortcuts that use only alt as the modifier. While there's no standard relating to this, usually those end up getting reserved for use by the window manager, or for accessing menus via the keyboard. Gnome-terminal allows the user to map keyboard shortcuts using the alt key. You could take a look at their code an see how they do it Emmanuel ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GstXOverlay interface methods not available
Hi, Is it possible that the GstXOverlay interface is not available in the Gstreamer Perl bindings? I was playing around with Gstreamer's Perl API and I tried to port the Vala example Vala GStreamer Video Example [1]. In that example a xvimagesink is embedded in a Gtk2 window, or so I think as I don't have vala. This is acheived through the following Vala code: private void on_play () { ((XOverlay) this.sink).set_xwindow_id ( Gdk.x11_drawable_get_xid (this.drawing_area.window)); this.pipeline.set_state (State.PLAYING); } When I run the corresponding Perl code (I've attached a sample script showing the problem): $sink-set_xwindow_id($canvas-window-get_xid); I get the following error: Can't locate object method set_xwindow_id via package Glib::Object::_Unregistered::GstXvImageSink at ./gst-video-sample.pl line 48. Is there another way to do the same? Maybe I'm not using the right function calls. [1] http://live.gnome.org/Vala/GStreamerSample -- Emmanuel Rodriguez gst-video-sample.pl Description: Perl program ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GstXOverlay interface methods not available
On Mon, May 25, 2009 at 7:52 PM, Torsten Schoenfeld kaffeeti...@gmx.dewrote: Emmanuel Rodriguez wrote: Is it possible that the GstXOverlay interface is not available in the Gstreamer Perl bindings? GstXOverlay is part of the libgstinterfaces library, not of libgstreamer, so the GStreamer Perl module does not and cannot wrap it. But the GStreamer::Interfaces module does! http://search.cpan.org/~tsch/GStreamer-Interfaces-0.04/ Thanks! I assumed that all gst API was under one CPAN module. Would you accept the sample script, once finished, as an example to include in the module? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: install problem: undefined symbol: gtk_binding_entry_skip
Sorry, my previous reply was done only to Kevin by mistake. I added the list on this one. On 5/23/09, Kevin Ryde use...@zip.com.au wrote: Emmanuel Rodriguez emmanuel.rodrig...@gmail.com writes: Is there an advantage to combine multiple functions under a single XS definition? There's a lot of bloat in an xsub with FREETMPS, and getting things from the stack and putting them back for the return, and whatnot. Most of it's due to perl doing too much inlining. A threaded build comes out particularly bad. Some combining saves code space when it can be done conveniently. The difference between one or two funcs in this case won't be huge, but the same in lots of places will add up. Nice to know! I will start to apply your advice to my bindings. from what I recall there where no unit tets for this function. There are actually :-). I assume the original poster either didn't get to the stage of running them, or didn't run them in an X display session. Sorry, my bad! I can submit a new patch as soon as I get back home from my vacation, unless if someone corrects it before I get home. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Is there anyone out there?
On Wed, May 13, 2009 at 2:39 PM, Cowley Harris warewo...@gmail.com wrote: Hi all, A few things, 1) Is this project still going? Doesn't seem to be much (any) emails coming through on the mailing list. The list is not too verbose, but it is alive. I'm migrating from Perl-Tk because it seems like a dying project. If this project is in a similar state could somebody please turn off the lights so others like myself don't end up wasting time working through the tutorials, 2) If the Gtk2-perl project still has some life in it, what work is ongoing for the tutorial? It seems to stop half-way through it. I've emailed the two guys listed a few days ago, one email seems defunct, the other is yet to reply. The tutorial is based on the C version that is about 6-7 years old. If I'm not mistaken the C tutorial is not too far developed neither. But other alternatives are available! Perlmonks has a lot of examples using Gtk2. CPAN has a lot of modules and some programs using Gtk2. A lot of CPAN bundles come with examples, Gtk2 also does. Some of us hang in the IRC channel. 3)If work is still ongoing on the tutorial, is there a date for an update?, If not, does anybody mind if I continue where the others left off? Who would I contact to send an updated version? 4)The last notice said that the project has been switch to svn. However svn has been depreciated on sourceforge. Is there a plan to change to git? The project is hosted in gnome's git repository. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: About Treeview update with thread
2009/5/13 唐瑞博 ruibot...@gmail.com hi, muppet, Many thanks for your suggestion, sorry for late to response. I have tried the three methods you mentioned (gdk lock; Glib::Idle and a variant technique), and found an alternative solution for my issue. But there still exist other unsolved issues, as below For the gdk lock method, I have used Gtk2::Gdk::Threads-enter and Gtk2::Gdk::Threads-leave in my background thread, it seem that it can update all the widgets(like button, labes) correctly excepte the Gtk2::TreeModel(I used a Gtk2::ListStore actually). when i use the Gtk2::TreeModel-set() method, it will fail and says Usage: Gtk2::TreeModel-set($liststore, $iter, $col.) , and then the exit. I checked my code and found that I have a column with type Glib::Scalar in my treemodel, in this column i assign a pointer to an new constructed object ( the object is not a subclass of Glib::Object, and have not decleared as shared), I do not know if the fail have relationship with this object? From what I understood perl has a lot of troubles with threads and objects (blessed references). I recall when threads where first available in Perl that sharing blessed references will loose the blessing. The data is passed intact to the other thread but the blessing is lost, this makes calling methods on objects useless. I'm not sure if this is the issue with your program but your should keep it in mind. CPAN seems to be having a few modules that should help passing blessed instances between threads. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Label entries
On Fri, May 1, 2009 at 6:52 AM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: On Fri, May 1, 2009 at 5:37 AM, Matthew Braid ptkp...@mdb.id.au wrote: Hi again, although I had to change line 430 from: $attributes = Gtk2::Pango::AttrList-new(); to: ($attributes) = Gtk2::Pango-parse_markup(''); because the ye-ancient version of Gtk2 we have installed is obviously not up to scratch. I will upload the module and take this into account. It's a pity that people with an old version of Gtk2 can't use because of a missing function. $e-signal_connect(focus-in-event = sub {$e-set_empty_markup(b/b)}); I will try to take a look at this. I have released a new developer release (0.06_02) of Gtk2::Ex::Entry::Pango. It removes the default Pango markup when the entry is focused and it should also fix the dependencies problems with old versions of Gtk2 that are missing full Pango support. In the case where you are writing your own widget that mimics this functionality take a look at the function set_layout_attributes you will see a if with $self-has_focus it should allow you to implement an entry that has it's default Pango text removed once the widget gains focus without the need to add listeners. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Binding for a function receiving a C callback without arguments
Hi, I need to write the bindings for a C function that receives a callback which has to arguments. Here's the C declaration: typedef ChamplainMapSource * (*ChamplainMapSourceConstructor) (); #define CHAMPLAIN_MAP_SOURCE_CONSTRUCTOR (f) ((ChamplainMapSourceConstructor) (f)) gboolean champlain_map_source_factory_register (ChamplainMapSourceFactory *factory, const gchar *id, ChamplainMapSourceConstructor callback); I've been reading the perldoc of GClosure.xs ( http://search.cpan.org/~tsch/Glib-1.221/GClosure.xs) and I've peeked a ClutterEffect.xs which has also some closures and tried to implement this by my self but I'm stock. From what I understand the magic of GPerlCallback requires that the C callback accepts a gpointer data. At least, this is how all examples that I've seen so far are doing it. Since my C callback has no argumetns I don't see how I can get it to work. Furthermore the library that I'm binding doesn't have a method that lets me register the C callback with a (GDestroyNotify) so even if I succeed I will be leaking some memory. Note that this isn't so critical as the fuction that I try to bind registers a global factory method which should persist forever unitil the program finishes. Someome knows of an exisinting C API that has a similar callback and how I can overcome this? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: install problem: undefined symbol: gtk_binding_entry_skip
On Mon, May 4, 2009 at 10:58 PM, Daemmon Hughes dhug...@bear-code.comwrote: Hello, I am having trouble installing Gtk2 and hoping this is the correct place to find help. A snipped version of my install output which may or may not contain useful info: ... [ XS xs/GtkBindings.xs ] [ CC xs/GtkBindings.c ] GtkBindings.xs: In function ‘XS_Gtk2__BindingSet_entry_skip’: GtkBindings.xs:386: warning: implicit declaration of function ‘gtk_binding_entry_skip’ This usually happens when an old version of gtk2 (the C library) is installed. Your version of gtk2 doesn't have the function gtk_binding_entry_skip. Normally this is not a problem as the Perl bindings try to be backward compatible, but in this particular case this very function escaped the maintainers vigilance and you are paying the consequences. Can anyone help? Try applying the patch that I've attached to this mail. Save the attachement to the to the main folder (where the Makefile.PL file is) and go inside the folder. Once there run patch -p0 GtkBindings-2.12.patch. If the patch doesn't work simply edit the file xs/GtkBindings.xs and replace: void gtk_binding_entry_skip (binding_set, keyval, modifiers) GtkBindingSet *binding_set guint keyval GdkModifierType modifiers ALIAS: entry_remove = 1 CODE: if (ix == 0) gtk_binding_entry_skip (binding_set, keyval, modifiers); else gtk_binding_entry_remove (binding_set, keyval, modifiers); by: gtk_binding_entry_remove (binding_set, keyval, modifiers) GtkBindingSet *binding_set guint keyval GdkModifierType modifiers This should be enough for your system. It's hackish but it should let you compile the module. PS: Can someone review my patch and apply it upstream? -- Emmanuel Rodriguez Index: xs/GtkBindings.xs === --- xs/GtkBindings.xs (revision 2163) +++ xs/GtkBindings.xs (working copy) @@ -375,18 +375,23 @@ ## guint keyval, ## GdkModifierType modifiers); void +gtk_binding_entry_remove (binding_set, keyval, modifiers) + GtkBindingSet *binding_set + guint keyval + GdkModifierType modifiers + + +#if GTK_CHECK_VERSION (2, 12, 0) + +void gtk_binding_entry_skip (binding_set, keyval, modifiers) GtkBindingSet *binding_set guint keyval GdkModifierType modifiers -ALIAS: - entry_remove = 1 -CODE: - if (ix == 0) - gtk_binding_entry_skip (binding_set, keyval, modifiers); - else - gtk_binding_entry_remove (binding_set, keyval, modifiers); +#endif /* 2.12 */ + + MODULE = Gtk2::BindingSet PACKAGE = Gtk2::Object PREFIX = gtk_ =for apidoc ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Label entries
On Tue, May 5, 2009 at 3:25 AM, Matthew Braid ptkp...@mdb.id.au wrote: Hi again, Wow, thanks for that! _Almost_ works like a charm, but there is one little bug. Line 145: my $EMPTY_ATTRLIST = ($Gtk2::VERSION = 1.160) ? Gtk2::Pango::AttrList-new() : Gtk2::Pango-parse_markup('') ; doesn't work for versions below 1.160 since Gtk2::Pango-parse_markup('') returns a list, and the last item of the list is not the AttrList - it's the first. Needs to change to: my ($EMPTY_ATTRLIST) = ($Gtk2::VERSION = 1.160) ? (Gtk2::Pango::AttrList-new()) : Gtk2::Pango-parse_markup('') ; Thanks for testing and pointing this one. I've applied your patch and made a new release (0.07). You might need to give CPAN some time to properly mirror the new bundle everywhere. Once that change is made all is good. Of course, people using up to date Gtk2 installs won't notice at all :) Guilty! -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Label entries
On Thu, Apr 30, 2009 at 8:55 AM, Matthew Braid ptkp...@mdb.id.au wrote: Hi, I'm trying to create an entry that acts a bit like the entries found in vista and on some websites - where if no data has been entered some text is displayed in the entry, usually greyed out. I did the same for my XML application (xacobeo). I've extracted the code and released it as a CPAN module Gtk2::Ex::Entry::Pango (see http://search.cpan.org/perldoc?Gtk2::Ex::Entry::Pango). Take a look at the examples that I've provided with the CPAN bundle. I've got the focus-in and focus-out actions working fine, and I'm now working on a subclass so that the get_text function will return '' if nothing has been entered even if there is 'grey text' displayed, but so far I can't see a way of making the text inside the entry grey (or in fact making it change in any way). Gtk2::Ex::Entry::Pango looks promising, but installing new packages is...problematic... in my current environment. Can't you just copy the perl module in your application? The CPAN bundle has only a single perl module. Otherwise take a look at xacobeo (see http://search.cpan.org/perldoc?Xacobeo) it uses glade for the UI and has a plain simple Gtk::Entry created by glade that's pimped to become a pangofied entry just by adding some signal handlers. I thought about doing some messing around by setting the entry to be insensitive when unedited (looks greyed out), and putting an event box over it to catch focus events (or in fact _any_ event), but this: use Gtk2 -init; $mw = Gtk2::Window-new; $e = Gtk2::Entry-new; $e-set_text(TEXT); $e-set_sensitive(0); $f = Gtk2::EventBox-new; $f-signal_connect(event = sub {print HIT}); $mw-add($f); $f-add($e); $f-set_above_child(1); # Even with this! $mw-show_all; Gtk2-main doesn't work. Does anyone have any helpful ideas? I'm continuing on without the colouring anyway in the hopes that a solution can just be added in. If you really want to write your's from scratch I will strongly suggest that you read the source code of Gtk2::Ex::Entry::Pango I've added a lot of comments for the developers that peek inside because this was a bit tricky. A Gtk2::Entry is a small MVC (model/view/controler) and has a model (the data stored) and a view the data to display. Most of the type the data stored is the same as the data displayed, the main exception is with the passwords fields where a strange character is displayed instead. You can modify the data displayed by using pango. The problem with pango is that the display string is quite volatile each graphical update of the widget (after a redraw) will loose your display string and the widget will revert to it's default data display. This doesn't seem too tricky but a Gtk2::Entry has a curson blinking! This is a lot of redraws. The trick is to connect your own signals that will redisplay your default string when the widget gets redrawn. TIA, MB ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Label entries
On Fri, May 1, 2009 at 5:37 AM, Matthew Braid ptkp...@mdb.id.au wrote: Hi again, I did the same for my XML application (xacobeo). I've extracted the code and released it as a CPAN module Gtk2::Ex::Entry::Pango (see http://search.cpan.org/perldoc?Gtk2::Ex::Entry::Pango). Take a look at the examples that I've provided with the CPAN bundle. Can't you just copy the perl module in your application? The CPAN bundle has only a single perl module. Otherwise take a look at xacobeo (see http://search.cpan.org/perldoc?Xacobeo) it uses glade for the UI and has a plain simple Gtk::Entry created by glade that's pimped to become a pangofied entry just by adding some signal handlers. Yes. Yes I can. Sorry, this was written after a lot of fnargling of another (quite horrible) package that refused to install anywhere but the core libs, so my brain was slightly asleep. It works quite well Ouf! I was starting to wonder what I messed up in the installation :) (using only set_empty_markup), although I had to change line 430 from: $attributes = Gtk2::Pango::AttrList-new(); to: ($attributes) = Gtk2::Pango-parse_markup(''); because the ye-ancient version of Gtk2 we have installed is obviously not up to scratch. I will upload the module and take this into account. It's a pity that people with an old version of Gtk2 can't use because of a missing function. It works _almost_ exactly as I want - I'm just going to add in the bits that hide the empty markup when focus comes in and restores it if necessary when focus goes out. Turns out there's a little gotcha there too. This: I never though of erasing the default text when the widget has it's focus. I should add this to the widget. use Gtk2 -init; use Gtk2::Ex::Entry::Pango; $m = Gtk2::Window-new; $e = Gtk2::Ex::Entry::Pango-new; $e-set_empty_markup(bEMPTY/b); $e-signal_connect(focus-in-event = sub {$e-set_empty_markup()}); ### HERE! $e-signal_connect(focus-out-event = sub {$e-set_empty_markup(bEMPTY/b) if $e-get_text eq }); $f = Gtk2::Entry-new; $v = Gtk2::VBox-new; $v-add($e); $v-add($f); $m-add($v); $m-show_all; Gtk2-main; Doesn't update the empty markup until the entry is edited on focus in, but if you change the ### HERE! line to: $e-signal_connect(focus-in-event = sub {$e-set_empty_markup(b/b)}); I will try to take a look at this. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Display Japanese Characters in GtkComboBox
On Mon, Apr 27, 2009 at 7:34 AM, Peter E Dennis peter.edwin.den...@gmail.com wrote: Modify your program and add use warnings; and check if perl complains about wide characters in print. Did this but no warnings about 'wide characters in print'. Add the following to your loop: use Endode; print is kanji in UTF-8? , (is_utf8($ref-{'kanji'}, 1) ? 'YES' : 'NO'), \n; This was interesting. It says that all of the kanji: is kanji in UTF-8? NO Is there a way I can determine what encoding they are in? I'm afraid that there's no way to tell that's why a program has to decode the strings for perl. The reason is that the programmer should know where the input came from and the encoding. In this particular case mysql might be able to tell your in which encoding the strings are. I don't use mysql so I can't tell you if it's possible. I'm afraid that this will only affect the low level communication between the mysql.so library and the server. What's important for your application is that the perl string are marked as being valid UTF-8 (perl strings have an internal flag for this purpose). Thanks for this info. Wasn't really sure if it would have any relevance but thought I should include it. Apart from finding out what the actual encoding is I have been able to display the kanji in the GtkComboBox by doing the following: while (my $ref = $sth-fetchrow_hashref) { my $string = decode(utf8, $ref-{'kanji'}); . } Although I'd much prefer to know what encoding it actually is in, as no doubt I'll hit similar problems when I start trying to insert data... In theory inserting data shouldn't cause a problem because you are inserting a perl string which is either utf8 or not (perl knows). In practice, your string came mostlikely from an external source (file, URL, database) in that case when the input as read perl wasn't aware of the input type (binrary string? utf8?). The best is to always encode/decode all I/O, if you are dealing with text perl will want to store the data as UTF-8 so it needs to be instructed how to do it. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Display Japanese Characters in GtkComboBox
2009/4/26 Peter E Dennis peter.edwin.den...@gmail.com Thanks for the reply. You get this strange squares because your strings don't seem to be having valid UTF-8 characters. Gtk2 is expecting to get UTF-8 strings and what has been provided doesn't seem to be too valid. Your perl strings are probably not valid UTF-8. This can happen if the mysql driver fails to return proper UTF-8 data. If you know the encoding of the database then decode each string to UTF-8 as soon as you read them from the mysql database. I thought my data was already in utf8 format. I had similar issues when connecting with a Perl script from the shell. But if I do the following: #!/usr/bin/perl use strict; use DBI(); Modify your program and add use warnings; and check if perl complains about wide characters in print. # Connect to the database. my $dbh = DBI-connect(DBI:mysql:database=japanese;host=localhost, root, root, {'RaiseError' = 1}); # Without this kanji appear as '?' marks. my $sth_unicode = $dbh-prepare(SET NAMES utf8); $sth_unicode-execute(); # Now retrieve data from the table. my $sth = $dbh-prepare(SELECT * FROM vocab LIMIT 5); $sth-execute(); while (my $ref = $sth-fetchrow_hashref()) { print id = $ref-{'id'}, eng = $ref-{'english'} ; print kanji = $ref-{'kanji'}\n; } Add the following to your loop: use Endode; print is kanji in UTF-8? , (is_utf8($ref-{'kanji'}, 1) ? 'YES' : 'NO'), \n; Again I initially had issues trying to get the data into the database. I found it was necessary to have the server and the client speaking utf8 to each other. So I have in my /etc/my.conf file: [client] default-character-set=utf8 [mysqld] default-character-set=utf8 I'm afraid that this will only affect the low level communication between the mysql.so library and the server. What's important for your application is that the perl string are marked as being valid UTF-8 (perl strings have an internal flag for this purpose). You can rule out if it's a font issue by copy pasting a valid japanese character into a gtk application (gedit). If you can see the character then it's probably not a font issue. I can type Japanese characters and copy and paste them into a number of different apps including gedit. So it's not a font issue :) -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Problems binding a struct that's not a GObject
Hi, I'm writing the bindings for libunique (http://live.gnome.org/LibUnique) so far everything works fine except for the marshaling of the struct UniqueMessageData. This type is a normal struct and not a GObject documented as follows: typedef struct _UniqueMessageData UniqueMessageData; I added a typemap file to the project with the following lines: TYPEMAP UniqueMessageData* T_GPERL_GENERIC_WRAPPER UniqueMessageData_ornull* T_GPERL_GENERIC_WRAPPER And created newSVUniqueMessageData() and SvUniqueMessageData() in the corresponding XS file. The idea is to convert the struct into a perl hash and vice-versa. So far the XS module compiles and can be loaded, but when I run the example application (from 2 different shells): shell1$ perl -Mblib examples/sample.pl Hello world shell2$ perl -Mblib examples/sample.pl It works I get in the first shell: GType UniqueMessageData (138666312) is not registered with gperl at examples/sample.pl line 40. This bug only happens if I connect the signal 'message-received' and if the main application receives a message. If the signal handler is not connected and a message is sent there will be no crash. This leads me to suppose that the marshaling of the struct UniqueMessageData to a Perl hash ref is not done properly. I seem to know what's the issue but I don't know how to fix it. The module is hosted here: http://github.com/potyl/gtk2-unique/tree/master -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Segfault in Gtk2::Ex::Simple::List 0.50
On Tue, Apr 21, 2009 at 2:42 PM, Torsten Schoenfeld kaffeeti...@gmx.dewrote: Torsten Schoenfeld wrote: On my machine, this only segfaults on perl 5.10.0. It works fine (i.e. it throws an exception but continues to work) on 5.8.9 and on blead. So apparently, this is a bug introduced in 5.10.0 that has since been fixed. And the segfault doesn't occur with the maint-5.10 branch either, so 5.10.1 will be fine too. Sadly the bug affects the standard Perl distributed in Debian Lenny :( -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: resize bar
On Sun, Apr 12, 2009 at 9:55 PM, Zane C.B. v.ve...@vvelox.net wrote: How would one go about implementing one of those widgets that allow one to resize two different box widgets? I'm not sure if I understood the question properly. Are you talking about a Gtk2::Paned? Take a look at this page http://library.gnome.org/devel/gtk/unstable/GtkPaned.html, there's a screenshot that shows the widget. If that's the widget that you want then play with the sample program that's attached to this mail. -- Emmanuel Rodriguez #!/usr/bin/perl use strict; use warnings; use Glib qw(TRUE FALSE); use Gtk2 '-init'; exit main(); sub main { my $window = Gtk2::Window-new(); $window-set_title('Resize'); $window-set_default_size(640, 480); $window-signal_connect(destroy = sub { Gtk2-main_quit(); }); # A text widget my $textview = Gtk2::TextView-new(); my $scroll = Gtk2::ScrolledWindow-new(); $scroll-set_policy('automatic', 'always'); $scroll-set_shadow_type('out'); $scroll-add($textview); my $buffer = $textview-get_buffer; load_text($buffer, $0); # Add buttons to one of the panels my $clipboard = Gtk2::Clipboard-get(Gtk2::Gdk-SELECTION_CLIPBOARD); my $buttons = Gtk2::VBox-new(TRUE); add_button($buttons, Clear = sub { $buffer-delete($buffer-get_start_iter, $buffer-get_end_iter); }); add_button($buttons, Cut = sub { $buffer-cut_clipboard($clipboard, TRUE); }); add_button($buttons, Copy = sub { $buffer-copy_clipboard($clipboard); }); add_button($buttons, Paste = sub { $buffer-paste_clipboard($clipboard, $buffer-get_end_iter, TRUE); }); # Pack the widgets together in a resizable vertical panel my $vpane = Gtk2::HPaned-new(); $vpane-add1($buttons); $vpane-add2($scroll); $window-add($vpane); $window-show_all(); Gtk2-main(); return 0; } sub add_button { my ($parent, $text, $callback) = @_; my $button = Gtk2::Button-new($text); $button-signal_connect(clicked = $callback) if $callback; $parent-add($button); } sub load_text { my ($buffer, $file) = @_; open my $handle, $file or die Can't read $file because $!; local $/ = undef; my $text = $handle; close $handle; $buffer-set_text($text); } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How can I draw colorful characters on Gtk2::Button?
On Thu, Mar 26, 2009 at 7:02 AM, xu zhou redic...@gmail.com wrote: Hi all, I am quite a new for Perl-Gtk2. I am tring to put some colorful numbers on the button widget. $button-set_label($style) dose not seem to work this way, it only receive a string as the parameter, not a Gtk2::Lable. The Gtk2::Button is a Gtk2::Bin which means you can call get_child() on a button and get the button's label. Once you get the label you can use set_markup() to colorize your text. To add a label to the button either use the constructor new_with_label() or create the label manually and add it with add(). I've attached a sample perl program that shows how to colorize a button. -- Emmanuel Rodriguez #!/usr/bin/perl # # Create a button with colorized text # use strict; use warnings; use Glib qw(TRUE FALSE); use Gtk2 '-init'; use Data::Dumper; exit main(); sub main { my $window = Gtk2::Window-new(); my $vbox = Gtk2::VBox-new(FALSE, 10); my $button_plain = Gtk2::Button-new_with_label(Plain); # Create a color with an empty label and replace the label's text with our own # pretty colored text. my $button_color = Gtk2::Button-new_with_label(''); $button_color-get_child-set_markup( span color='red'Color/span span color='blue'button/span ); $vbox-pack_start($button_plain, FALSE, FALSE, 10); $vbox-pack_start($button_color, FALSE, FALSE, 10); $window-add($vbox); $window-signal_connect(destroy = sub { Gtk2-main_quit(); }); $window-show_all(); Gtk2-main(); return 0; } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Announce - First release of libchamplain's bindings
Hi, I finally released to CPAN the first release of libchamplain's bindings (Download here http://search.cpan.org/perldoc?Champlain). Libchamplain consists of a Clutter actor (a canvas) that supports numerous free map sources such as OpenStreetMap http://www.openstreetmap.org/, OpenArialMaphttp://www.openaerialmap.org/and Maps for free http://www.maps-for-free.com/. Even though I made an official release, I still have some troubles with the CPAN module and I seek some help. The C API defines the following function: ChamplainView* champlain_view_embed_get_view (ChamplainViewEmbed *embed); For a reason beyond my comprehension I can't binding this particular function. At first, the compilation of the C generated code issues this warning: xs/Gtk2ChamplainViewEmbed.c: In function 'XS_Gtk2__Champlain__ViewEmbed_get_view': xs/Gtk2ChamplainViewEmbed.c:56: warning: initialization makes pointer from integer without a cast And the unit tests fail with this error: undefined symbol: SvChamplainViewEmbed It looks like if the Gtk2/Glib helper methods don't pickup ChamplainViewEmbed as a valid GType but I don't know how to fix this. Another question, are the Perl bindings making a difference for functions that return gchar * instead of const gchar *? From my understading any function returning a gchar * should have the string freed by the invoker while a const gchar * should never be freed. Is the bindings code performing the free for me or should I do it? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announce - First release of libchamplain's bindings
Thanks for the help. I will try to fix the issues as soon as possible. On Mon, Mar 16, 2009 at 9:58 AM, Torsten Schoenfeld kaffeeti...@gmx.dewrote: Emmanuel Rodriguez wrote: I finally released to CPAN the first release of libchamplain's bindings (Download here http://search.cpan.org/perldoc?Champlain). Libchamplain consists of a Clutter actor (a canvas) that supports numerous free map sources such as OpenStreetMap http://www.openstreetmap.org/, OpenArialMaphttp://www.openaerialmap.org/and Maps for free http://www.maps-for-free.com/. A few other things that caught my eye: • gperl_croak_gerror ignores its first argument (for historical reasons), so the convention is to simply pass in NULL. I'm taking note. • You have no tests. libchamplain's API appears to be very well designed, so the wrappers are mostly trivial. But still, writing good bindings blindly, i.e. without tests, is error-prone. Don't worry I will add unit test coverage in the next days. I'm also missing a lot of documentation and some examples. I really wanted to make the code public as we where lagging behind python and C# :) Once more, thanks for the help. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Designing a 'console' with GtkTextViewer
Take a look at libvte it's the Gtk widget used by gnome-terminal. It can be embedded easily in any application. http://library.gnome.org/devel/vte/unstable/VteTerminal.html On Sat, Mar 7, 2009 at 3:50 PM, Dutta, Seemanta seema...@qualcomm.com wrote: Hi, I want to design a console based interface to my application. The console would enable the user to manually give commands to my application. Something akin to the python console that you get in RhythmBox. I am planning to use GtkTextViewer widget for this. My main requirement for the console is that It should not allow the user to 'scroll-back' and edit past commands, which would be very inconsistent. In other words it should behave just like a terminal command line, allowing line editing for the current line only. I am not thinking of readline support right now but that can be added later as an enhancement. My question: Is that possible in GtkTextViewer? I always thought that I can set the entire widget as editable or non editable. But if I set it as editable, then I don't want the user to be able to scroll up and fiddle with text that is present above. Can anyone please advise? regards, Seemanta ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list -- Emmanuel Rodriguez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Segmentation fault debug help needed
I think that you want to connect to the signal destroy-event of GtkWidget instead of destroy of GObject. See: http://library.gnome.org/devel/gtk/unstable/GtkObject.html#GtkObject-destroy http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#GtkWidget-destroy-event On Fri, Feb 27, 2009 at 10:41 PM, Josh Roesslein jroessl...@gmail.com wrote: Here is a snippet of code part of my application's UI toolkit abstraction layer. For some reason the line of code I've marked is throwing a segmentation fault and I'm a bit stumped as to why. I'm thinking the way I'm passing the this pointer might have something to do with the error. If you need to see additional code to help debug this issue, let me know. Thanks! Code -- http://pastebin.com/m6c7c97c1 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Perl bindings for libchamplain
On Wed, Mar 4, 2009 at 2:39 PM, muppet sc...@asofyet.org wrote: On Mar 4, 2009, at 3:11 AM, Emmanuel Rodriguez wrote: Which one you use depends on how the enum is used. If it's used as an object property, the C library really ought to have the GType. Thanks, muppet. This was the case: the enum was in deed used in a property but wasn't registered as a GType. The problem is now fixed in upstream and it all works. I have other questions regarding the name of the Perl bindings. The C library is based on Clutter and provides an optional Gtk widget. I've still haven't selected a final name for the Perl modules. I'm thinking of naming the Gtk2 widget Gtk2::Champlain::ViewEmbed but what about the Clutter actors? Should I call them Champlain::? By the way this is exactly what the python and C# bindings did. I'm also thinking of providing a single Perl package that will generate both bindings (Gtk2::Champlain::ViewEmbed will be an optional build detected at install time). The libchamplain C library defines the following classes: ChamplainView extends ClutterGroup ChamplainLayer extends ClutterGroup ChamplainMarker extends ClutterGroup ChamplainViewEmbed extends GtkWidget -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Perl bindings for libchamplain
On Wed, Mar 4, 2009 at 2:39 PM, muppet sc...@asofyet.org wrote: On Mar 4, 2009, at 3:11 AM, Emmanuel Rodriguez wrote: The maps file assumes you want to generate all these macros for each thing in the maps file. If the C library does not define a GType for this enum, then either 1. remove it from the maps file 2. provide your own conversion function with this name 3. provide your own GType mapping Which one you use depends on how the enum is used. If it's used as an object property, the C library really ought to have the GType. I assumed that the maps would work magically on all enums. Libchamplain seems to be in it's infancy and it could be that the enum is not registered with Glib's object system. Thanks! -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Changing Text Color for GTK_ENTRY Widgets
2009/2/26 r.richardpar...@comcast.net: I have several top-level windows which contain fill-in forms designed with GLADE 3 that contain GtkTextEntry Widgets for data to be stored in a PostgreSQL database. I'm validating the entries and when I find one that's invalid, I'd like to change its text color to red and then post a message box indicating that there were errors on the form. How do I change the text color in these GTK_ENTRY widgets? These are not labels, but single-line text entry fields. I'm guessing that Pango would be involved, but how? As it is, a section of my validation code is as follows: Here's a derived GtkEntry (in Perl) that can use Pango markup: http://cpansearch.perl.org/src/POTYL/Gtk2-Ex-Entry-Pango-0.04/lib/Gtk2/Ex/Entry/Pango.pm If you download the bundle you will see some sample code how I use it. The code should be straight easily portable to any language. All the code is in C, using Gtk+. The forms (windows) were designed with GLADE 3, but GLADE doesn't offer a way to markup GtkEntry widgets, so I don't think I can just store markup code into the erroneous entries. If you are using glade you will need to either create the entry fields that will use Pango as custom widgets or simply merge the code yourself. I have an application where the GUI is made through Glade and I found it easier to use a generic GtkEntry created by Glade and to simply add the proper callbacks to the widget. Any suggestions? Using Pango in a GtkEntry is tricky. This is because the GtkEntry uses the MVC pattern. The text in the field is handled by Model but the text displayed is handled by the view. GtkEntry makes a distinction between both. If you change the data displayed through Pango it will not be permanent. The next redraw will erase your changes because the widget will simply perform the redraw based on the data stored. This problem can be easily be addressed by adding our own callback that will ensure that the widget is always drawn using Pango when needed. -- Emmanuel Rodriguez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: questions on gtk icon view
2009/2/11 lfeng lf...@neusoft.com: I create a gtk icon view in scrolled window, using list store to saving the data. Sometimes, I use gtk_store_clear to clear the data, then I set new data to iconview. However, the text under the icon in iconview displays wrongly, as accessory. I'm experiencing the same problem with a small perl Gtk2 script that I made. In the old times the text in the icon view was rendered properly and after I updated my Linux distribution to the newest release I started to experience the same glitches as you. The same script running on windows has no rendering problems, neither it did with the previous version of my OS. What I've realized is that the bug manifests it self only when displaying the same data twice. The second time the text labels under the icons will be mangled, just like in your picture. If the dataset is changed then the text labels are find, but if the same dataset is submitted twice then the layout will be destroyed. I have no solution for this problem. -- Emmanuel ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Gtk2::GladeXML and i18n
Hi, I'm trying to use i18n with glade and all strings used in my glade file aren't translated when the application is running. Although, if I use gettext() directly from my application with one of the i18n strings from the glade file I can see the translation printed at the console. I know that the .mo files are generated properly and that the adequate translations are there. I'm using the following code snippet (this is a simplification): use Locale::Messages qw (:locale_h :libintl_h); my $DOMAIN = 'xacobeo'; textdomain($DOMAIN); bindtextdomain($DOMAIN, './share/locale'); my $glade = Gtk2::GladeXML-new('xacobeo.glade', undef, $DOMAIN); I think that the problem is with the fact that my localization files are not in /usr/share/locale but in another folder. I've used strace -e file with my perl script and it shows that glade doesn't look at my folder for the .mo files, it only takes /usr/share/locale into account. Is there a way to tell glade where to look for translations? Or perhaps is there a better way for using i18n in perl with glade? -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can't add new GTK 2.16 methods to GtkStyle
On Wed, Jan 28, 2009 at 12:11 AM, Kevin Ryde use...@zip.com.au wrote: Torsten Schoenfeld kaffeeti...@gmx.de writes: The other method, Gtk2::Style::get_property(), also clashes with Glib::Object. The question is whether this is acceptable in the same way as it is acceptable for Gtk2::TreeModel::get(), ... I think it would make sense to let Gtk2::Style::get() and get_property() be the same method Actually, letting get_property shadow the GObject method is a bit unlike TreeModel. With the treemodels the get() varies but you can you can confidently use get_property() for the object properties in whatever generic code might operate on Glib::Object descendants. How about leaving get_property as the GObject property accessor and give the style accessor another name? But which name? This has to be picked with care because a subsequent release of GTK could introduce new methods. I was thinking of using something like get_style_property. This name seems unique enough, after all what are the odds of seeing gtk_style_get_style_property land in GTK? If you don't mind I will wait until we have reached a consensus until a submit a next patch for this last module. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can't add new GTK 2.16 methods to GtkStyle
On Wed, Jan 21, 2009 at 9:15 PM, Kevin Ryde use...@zip.com.au wrote: Emmanuel Rodriguez emmanuel.rodrig...@gmail.com writes: +=for apidoc Gtk2::Style::get +=for signature $style-get (widget_package, ...) If both gobject get and get_property are hidden perhaps the pod could have a crib that GtkStyle doesn't have any GObject properties to get or set, though if a subclass did you can always $style-Glib::Object::get to access them (assuming that's true). Tested and it's true. I added a comment and unit tests to prove that it works. +=for apidoc Gtk2::Style::get_property +=for arg widget_package (__hide__) There's some trick to get the two docs together isn't there? Well I just copied from other classes. But if you write Alias for Cmethod you assume that the user will search for the doc of method :) +warn (Invalid property `%s' used, returning undef, name); Should that croak the way g_object_get does on an unknown property? When in doubt you could either eval to trap, or ask find_style_property() what's available (if that's wrapped). The code dies and the unit test check for this. -- Emmanuel Rodriguez Index: xs/GtkStyle.xs === --- xs/GtkStyle.xs (revision 2116) +++ xs/GtkStyle.xs (working copy) @@ -572,3 +572,87 @@ RETVAL #endif + +#if GTK_CHECK_VERSION (2, 15, 0) /* FIXME 2.16 */ + +=for apidoc Gtk2::Style::get +=for signature $style-get (widget_package, ...) +=for arg widget_package (string) widget package name (ex: 'Gtk2::TreeView') +=for arg ... (list) list of property names + +Fetch and return the values for the style properties named in I... for a +widget of type Iwidget_package. + +BNOTE: The methods Gtk2::Style::get() and Gtk2::Style::get_property() override +respectively Glib::Gobject::get() and Glib::Gobject::get_property(). This +shouldn't be a problem as Gtk2::Style defines no properties (as of gtk 2.16). +Nevertheless in the case where an class will derive Gtk2::Style and adds a +property or that a new version of gtk adds a property the property can be +accessed with the following code: + + my $value = $style-Glib::Object::get_property('property'); + +=cut + +=for apidoc Gtk2::Style::get_property +=for arg widget_package (__hide__) +=for arg ... (__hide__) + +Alias for Cget. + +=cut + +void +gtk_style_get (style, widget_package, ...) +GtkStyle*style +const char *widget_package +ALIAS: +Gtk2::Style::get = 0 +Gtk2::Style::get_property = 1 +PREINIT: +int i; +GType widget_type; +gpointer class_peek; +GValue value = {0,}; + +CODE: +/* Use CODE: instead of PPCODE: so we can handle the stack ourselves in + * order to avoid that xsubs called by gtk_style_get_property overwrite + * what we put on the stack. */ +PERL_UNUSED_VAR (ix); + +widget_type = gperl_type_from_package(widget_package); +if (widget_type == 0) +croak(package %s is not registered with GPerl, widget_package); + +if (! g_type_is_a (widget_type, GTK_TYPE_WIDGET)) +croak(%s is not a subclass of Gtk2::Widget, widget_package); + + +class_peek = g_type_class_ref(widget_type); +if (class_peek == NULL) +croak(can't find class %s, widget_package); + + + +for (i = 2 ; i items ; i++) { +GValue value = {0, }; +gchar *name = SvGChar(ST(i)); +GParamSpec *pspec = pspec = gtk_widget_class_find_style_property(class_peek, name); +if (pspec) { +g_value_init(value, G_PARAM_SPEC_VALUE_TYPE(pspec)); +gtk_style_get_property(style, widget_type, name, value); +ST (i - 2) = sv_2mortal (gperl_sv_from_value(value)); +g_value_unset(value); +} +else { +g_type_class_unref(class_peek); +croak(type %s does not support style property '%s', widget_package, name); +} +} + +g_type_class_unref(class_peek); + +XSRETURN (items - 2); + +#endif Index: t/GtkStyle.t === --- t/GtkStyle.t (revision 2116) +++ t/GtkStyle.t (working copy) @@ -1,7 +1,8 @@ #!/usr/bin/perl -w # vim: set ft=perl expandtab shiftwidth=2 softtabstop=2 : use strict; -use Gtk2::TestHelper tests = 113; +use Gtk2::TestHelper tests = 125; +use Carp; # $Id$ @@ -133,6 +134,129 @@ ok (1); } +SKIP: { + skip(get_property is new in 2.16, 12) +unless (Gtk2-CHECK_VERSION(2, 15, 0)); # FIXME 2.16 + + # Test different properties (gint, gboolean, gchar* and GObject) + my $treeview = Gtk2::TreeView - new(); + + # get gboolean + is ( +$style - get_property('Gtk2::TreeView', 'allow-rules'), +$treeview - style_get_property('allow-rules'), +get_property gboolean + ); + + # get gint
Re: Can't add new GTK 2.16 methods to GtkStyle
On Wed, Jan 21, 2009 at 7:47 AM, muppet sc...@asofyet.org wrote: On Jan 20, 2009, at 2:13 PM, Emmanuel Rodriguez wrote: Here's a new version of the patch with the fixes requested. GtkStyle.patch Comment suffers cut and paste bug -- refers to g_object_get_property(), i think you mean gtk_style_get_property(). Bad copy/paste that's now fixed. Don't need braces around C if blocks with only one statement in them. Removed. Indentation on g_type_class_unref() is wonky. s/\t/ /g; If we actually hit the warn (Invalid property ...) case, i think that the return list will contain the property name instead of the value. Should that case include ST (i - 2) = newSV (PL_sv_undef) so that we give back undef for bad property names? Or should we croak on bad property names, flagging that as programmer error? I'm not setting undef and issuing a warning. Note that newSV () expects a length as argument, so I've changed the code to ST (i - 2) = newSVsv (PL_sv_undef);. Question do I actually need to wrap PL_sv_undef with a SV? Can't I just do ST (i - 2) = PL_sv_undef; ? I've tried both solutions and the unit tests work. I've also tried fetching properties that don't exist and I got no segmentation fault. -- Emmanuel Rodriguez Index: xs/GtkStyle.xs === --- xs/GtkStyle.xs (revision 2116) +++ xs/GtkStyle.xs (working copy) @@ -572,3 +572,78 @@ RETVAL #endif + +#if GTK_CHECK_VERSION (2, 15, 0) /* FIXME 2.16 */ + +=for apidoc Gtk2::Style::get +=for signature $style-get (widget_package, ...) +=for arg widget_package (string) widget package name (ex: 'Gtk2::TreeView') +=for arg ... (list) list of property names + +Fetch and return the values for the style properties named in I... for a +widget of type Iwidget_package. + +=cut + +=for apidoc Gtk2::Style::get_property +=for arg widget_package (__hide__) +=for arg ... (__hide__) + +Alias for Cget. + +=cut + +void +gtk_style_get (style, widget_package, ...) +GtkStyle*style +const char *widget_package +ALIAS: +Gtk2::Style::get = 0 +Gtk2::Style::get_property = 1 +PREINIT: +int i; +GType widget_type; +gpointer class_peek; +GValue value = {0,}; + +CODE: +/* Use CODE: instead of PPCODE: so we can handle the stack ourselves in + * order to avoid that xsubs called by gtk_style_get_property overwrite + * what we put on the stack. */ +PERL_UNUSED_VAR (ix); + +widget_type = gperl_type_from_package(widget_package); +if (widget_type == 0) +croak(package %s is not registered with GPerl, widget_package); + +if (! g_type_is_a (widget_type, GTK_TYPE_WIDGET)) +croak(%s is not a subclass of Gtk2::Widget, widget_package); + + +class_peek = g_type_class_ref(widget_type); +if (class_peek == NULL) +croak(Can't find class %s, widget_package); + + + +for (i = 2 ; i items ; i++) { +GValue value = {0, }; +gchar *name = SvGChar(ST(i)); +GParamSpec *pspec = pspec = gtk_widget_class_find_style_property(class_peek, name); +if (pspec) { +g_value_init(value, G_PARAM_SPEC_VALUE_TYPE(pspec)); +gtk_style_get_property(style, widget_type, name, value); +ST (i - 2) = sv_2mortal (gperl_sv_from_value(value)); +g_value_unset(value); +} +else { +warn (Invalid property `%s' used, returning undef, name); +ST (i - 2) = newSVsv (PL_sv_undef); +} +} + +g_type_class_unref(class_peek); + +XSRETURN (items - 2); + +#endif Index: t/GtkStyle.t === --- t/GtkStyle.t (revision 2116) +++ t/GtkStyle.t (working copy) @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # vim: set ft=perl expandtab shiftwidth=2 softtabstop=2 : use strict; -use Gtk2::TestHelper tests = 113; +use Gtk2::TestHelper tests = 118; # $Id$ @@ -133,6 +133,55 @@ ok (1); } +SKIP: { + skip(get_property is new in 2.16, 5) +unless (Gtk2-CHECK_VERSION(2, 15, 0)); # FIXME 2.16 + + # Test different properties (gint, gboolean, gchar* and GObject) + my $treeview = Gtk2::TreeView - new(); + + # get gboolean + is ( +$style - get_property('Gtk2::TreeView', 'allow-rules'), +$treeview - style_get_property('allow-rules'), +get_property gboolean + ); + + # get gint + is ( +$style - get_property('Gtk2::TreeView', 'expander-size'), +$treeview - style_get_property('expander-size'), +get_property gint + ); + + # get gchar* + is ( +$style - get_property('Gtk2::TreeView', 'grid_line-pattern'), +$treeview - style_get_property('grid_line-pattern'), +get_property gchar* + ); + + # get GObject (a color) + is ( +$style - get_property('Gtk2
Re: g_malloc overhead
On Tue, Jan 20, 2009 at 12:48 PM, Larry Reaves la...@yrral.net wrote: On Tue, 2009-01-20 at 09:01 +0100, Martín Vales wrote: BJörn Lindqvist escribió: Actually, a custom allocator could be useful even in the general case. Malloc is a system call and has quite bad performance on certain platforms (windows in particular i think). Something like the gslice allocator could Probably improve performance a bit. gslice i believe use malloc internally. I believe you always need malloc/new-(C/C++) because you depend on ms Windows API. I am not sure if you can build your own malloc because you depend on the operating system. Sure, you must malloc to get new memory, but you can malloc bigger than what you need and hand out the extra memory later at a much lower cost. I recall reading somewhere that mmap can be used to build custom memory allocators. If that's true than one can bypass malloc. I think that you can request memory through mmap by using MAP_ANONYMOUS. Emmanuel Rodriguez ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Fwd: bug on TextBuffer and TextView
2009/1/20 Dafna Hirschfeld daf...@gmail.com: Hi, I attached a file tmp_xc4.pl, and a gif icon with a code with the bug, It's wearied, the bug doesn't always appear. and when I comment (remove) the lines lines 51,52 my $image = Gtk2::Image-new_from_file (ch_scaled.gif); $run_button-set_image($image); or line 78 add_to_history(($wed_arr-[0])-get_model,$cmd); the program works fine. It looks like those lines make the program a bit heavier, though they shouldn't effect the printing on the textview directly -- Thanks for the example, this helps us more. I confirm that I can reproduce your bug. It seems as if the GtkTextView isn't refreshed soon enough. The refresh of the animated gif appears to be having a higher priority than the text view. I don't know if this is somehow related: http://library.gnome.org/devel/gtk/stable/GtkTextView.html#GTK-TEXT-VIEW-PRIORITY-VALIDATE--CAPS. You can force a redraw of the widget your self, in my case it fixed the issue. Try the following: Line 76: $view-scroll_mark_onscreen($textmark); $view-queue_draw(); Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can't add new GTK 2.16 methods to GtkStyle
Here's a new version of the patch with the fixes requested. +class_peek = g_type_class_peek(widget_type); g_type_class_peek might return NULL, so we need to guard against this here by croak()ing in this case. But I think just using g_type_class_ref() and later _unref() is better still. Done. + my $property = $style - get_property('Gtk2::TreeView', 'expander-size'); I don't think this variable is used anywhere. Removed. -- Emmanuel Rodriguez Index: xs/GtkStyle.xs === --- xs/GtkStyle.xs (revision 2116) +++ xs/GtkStyle.xs (working copy) @@ -572,3 +572,78 @@ RETVAL #endif + +#if GTK_CHECK_VERSION (2, 15, 0) /* FIXME 2.16 */ + +=for apidoc Gtk2::Style::get +=for signature $style-get (widget_package, ...) +=for arg widget_package (string) widget package name (ex: 'Gtk2::TreeView') +=for arg ... (list) list of property names + +Fetch and return the values for the style properties named in I... for a +widget of type Iwidget_package. + +=cut + +=for apidoc Gtk2::Style::get_property +=for arg widget_package (__hide__) +=for arg ... (__hide__) + +Alias for Cget. + +=cut + +void +gtk_style_get (style, widget_package, ...) +GtkStyle*style +const char *widget_package +ALIAS: +Gtk2::Style::get = 0 +Gtk2::Style::get_property = 1 +PREINIT: +int i; +GType widget_type; +gpointer class_peek; +GValue value = {0,}; + +CODE: +/* Use CODE: instead of PPCODE: so we can handle the stack ourselves in + * order to avoid that xsubs called by g_object_get_property overwrite + * what we put on the stack. */ +PERL_UNUSED_VAR (ix); + +widget_type = gperl_type_from_package(widget_package); +if (widget_type == 0) { +croak(package %s is not registered with GPerl, widget_package); +} +if (! g_type_is_a (widget_type, GTK_TYPE_WIDGET)) { +croak(%s is not a subclass of Gtk2::Widget, widget_package); +} + +class_peek = g_type_class_ref(widget_type); +if (class_peek == NULL) { +croak(Can't find class %s, widget_package); +} + + +for (i = 2 ; i items ; i++) { +GValue value = {0, }; +gchar * name = SvGChar(ST(i)); +GParamSpec * pspec; +pspec = gtk_widget_class_find_style_property(class_peek, name); +if (pspec) { +g_value_init(value, G_PARAM_SPEC_VALUE_TYPE(pspec)); +gtk_style_get_property(style, widget_type, name, value); +ST (i - 2) = sv_2mortal (gperl_sv_from_value(value)); +g_value_unset(value); +} +else { +warn (Invalid property `%s' used, name); +} +} + +g_type_class_unref(class_peek); + +XSRETURN (items - 2); + +#endif Index: t/GtkStyle.t === --- t/GtkStyle.t (revision 2116) +++ t/GtkStyle.t (working copy) @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # vim: set ft=perl expandtab shiftwidth=2 softtabstop=2 : use strict; -use Gtk2::TestHelper tests = 113; +use Gtk2::TestHelper tests = 118; # $Id$ @@ -133,6 +133,55 @@ ok (1); } +SKIP: { + skip(get_property is new in 2.16, 5) +unless (Gtk2-CHECK_VERSION(2, 15, 0)); # FIXME 2.16 + + # Test different properties (gint, gboolean, gchar* and GObject) + my $treeview = Gtk2::TreeView - new(); + + # get gboolean + is ( +$style - get_property('Gtk2::TreeView', 'allow-rules'), +$treeview - style_get_property('allow-rules'), +get_property gboolean + ); + + # get gint + is ( +$style - get_property('Gtk2::TreeView', 'expander-size'), +$treeview - style_get_property('expander-size'), +get_property gint + ); + + # get gchar* + is ( +$style - get_property('Gtk2::TreeView', 'grid_line-pattern'), +$treeview - style_get_property('grid_line-pattern'), +get_property gchar* + ); + + # get GObject (a color) + is ( +$style - get_property('Gtk2::TreeView', 'even-row-color'), +$treeview - style_get_property('even-row-color'), +get_property GObject* + ); + + + # Get multiple properties simultaneously + my @properties = $style - get('Gtk2::TreeView', 'expander-size', 'even-row-color', 'grid_line-pattern'); + is_deeply ( +\...@properties, +[ + $treeview - style_get_property('expander-size'), + $treeview - style_get_property('even-row-color'), + $treeview - style_get_property('grid_line-pattern'), +], +'get multiple properties', + ); +} + __END__ Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for the ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::Entry with Pango markup
On Tue, Jan 20, 2009 at 11:08 PM, Kevin Ryde use...@zip.com.au wrote: Torsten Schoenfeld kaffeeti...@gmx.de writes: Or cheat and ask another Gtk2::Entry for its height via get_size_request(). Stick one line in the TextView and ask it how big it wants to be :-). ($widget-size_request is the one to ask, I think.) If it's for a dialog box I've had success forcing the size of sub-widgets, then asking the dialog how big it would like to be, and setting that size in as its $window-set_default_size (followed by undoing the sub-widget forcing). You can then still grow or shrink the dialog, but the initial size is sensible. Nice tricks. I have modified the sample script that I've posted previously and made it into a CPAN module (Gtk2::Ex::Entry::Pango). This module allows one to use Pango for a Gtk2 entry widget. -- Emmanuel Rodriguez ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: bug on TextBuffer and TextView
2009/1/19 Dafna Hirschfeld daf...@gmail.com: I have a textView with a textBuffer associated with it. When I start running my program and insert text to the buffer, it doesn't appear on the textView, only after I click the textView with the mouse or add another text, it appears. That's a strange behaviour. I don't know why is it, maybe its a problem of the buffering, I thought maybe there is a flush function, to flush the buffer to the view but I didn't find one, does anyone can help me? Could you share some code? Emmanuel ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: bug on TextBuffer and TextView
Sorry for the double spam. I forgot to include the mailing list on the first mail. On Mon, Jan 19, 2009 at 4:19 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: On Mon, Jan 19, 2009 at 3:51 PM, Dafna Hirschfeld daf...@gmail.com wrote: the code is very simple, copied from the tutorials of gtk in one place of the program I declare the textView and the associated buffer: my $view = Gtk2::TextView-new(); my $buffer = $view-get_buffer(); $view-set_size_request(850,500); $view-set_editable (FALSE); our $textmark = $buffer-create_mark('end_mark',$buffer-get_end_iter,FALSE); my $scrolls = Gtk2::ScrolledWindow-new(); $scrolls-set_policy('automatic','always'); $scrolls-set_shadow_type('in'); $scrolls-add ($view); on a function that run according to a specific button click I insert the text: #printing the output on textview my $text_tag = $buffer-create_tag(undef,'font',Sans Italic 12,'foreground','#68'); $buffer-insert_with_tags($buffer-get_end_iter,$command_num\n,$text_tag); $buffer-insert ($buffer-get_end_iter,$out); $view-scroll_mark_onscreen($textmark); On Mon, Jan 19, 2009 at 12:34 PM, Emmanuel Rodriguez emmanuel.rodrig...@gmail.com wrote: 2009/1/19 Dafna Hirschfeld daf...@gmail.com: I have a textView with a textBuffer associated with it. When I start running my program and insert text to the buffer, it doesn't appear on the textView, only after I click the textView with the mouse or add another text, it appears. That's a strange behaviour. That's very strange. I've complete your test and it works as expected. Can you execute my script and confirm that if you click the 'Write' button that you have the same behavior? On my computer this test works as expected: once the button is clicked the text is added to the textview. -- Emmanuel Rodriguez t.pl Description: Perl program ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can't add new GTK 2.16 methods to GtkStyle
On Sun, Jan 18, 2009 at 9:55 PM, Torsten Schoenfeld kaffeeti...@gmx.de wrote: muppet wrote: Careful --- that will most definitely be a naming conflict with Glib::Object::get(). $style-get (...);- should that be Glib::Object::get() or Gtk2::Style::get() ? I tried to how the C++ and D bindings where doing with gtk_style_get and gtk_style_get_property and they didn't implement it yet. I was finding odd that no one implemented gtk_style_get yet, but I think that this is a 2.16 method that not marked as 'since 2.16'. Can some one confirm this? The other method, Gtk2::Style::get_property(), also clashes with Glib::Object. The question is whether this is acceptable in the same way as it is acceptable for Gtk2::TreeModel::get(), i.e. are people more likely to mean Gtk2::Style::get() rather than Glib::Object::get() when they call $style-get()? Also, Emmanuel, I think it would make sense to let Gtk2::Style::get() and get_property() be the same method (i.e. one is the alias of the other), and to let that one method accept multiple arguments. Just like Glib::Object::get() and get_property() (in Glib/GObject.xs line 1257). I have implemented Torsten's proposal. -- Emmanuel Rodriguez Index: xs/GtkStyle.xs === --- xs/GtkStyle.xs (revision 2116) +++ xs/GtkStyle.xs (working copy) @@ -21,6 +21,7 @@ #include gtk2perl.h + MODULE = Gtk2::Style PACKAGE = Gtk2::Style PREFIX = gtk_style_ BOOT: @@ -572,3 +573,72 @@ RETVAL #endif + +#if GTK_CHECK_VERSION (2, 15, 0) /* FIXME 2.16.0 */ + +=for apidoc Gtk2::Style::get +=for signature $style-get (widget_package, ...) +=for arg widget_package (string) widget package name (ex: 'Gtk2::TreeView') +=for arg ... (list) list of property names + +Fetch and return the values for the style properties named in I... for a +widget of type Iwidget_package. + +=cut + +=for apidoc Gtk2::Style::get_property +=for arg widget_package (__hide__) +=for arg ... (__hide__) + +Alias for Cget. + +=cut + +void +gtk_style_get (style, widget_package, ...) +GtkStyle*style +const char *widget_package +ALIAS: +Gtk2::Style::get = 0 +Gtk2::Style::get_property = 1 +PREINIT: +int i; +GType widget_type; +gpointer class_peek; +GValue value = {0,}; + +CODE: +/* Use CODE: instead of PPCODE: so we can handle the stack ourselves in + * order to avoid that xsubs called by g_object_get_property overwrite + * what we put on the stack. */ +PERL_UNUSED_VAR (ix); + +widget_type = gperl_type_from_package(widget_package); +if (widget_type == 0) { +croak(package %s is not registered with GPerl, widget_package); +} +if (! g_type_is_a (widget_type, GTK_TYPE_WIDGET)) { +croak(%s is not a subclass of Gtk2::Widget, widget_package); +} + +class_peek = g_type_class_peek(widget_type); + + +for (i = 2 ; i items ; i++) { +GValue value = {0, }; +gchar * name = SvGChar(ST(i)); +GParamSpec * pspec; +pspec = gtk_widget_class_find_style_property(class_peek, name); +if (pspec) { +g_value_init(value, G_PARAM_SPEC_VALUE_TYPE(pspec)); +gtk_style_get_property(style, widget_type, name, value); +ST (i - 2) = sv_2mortal (gperl_sv_from_value(value)); +g_value_unset(value); +} +else { +warn (Invalid property `%s' used, name); +} +} +XSRETURN (items - 2); + +#endif Index: t/GtkStyle.t === --- t/GtkStyle.t (revision 2116) +++ t/GtkStyle.t (working copy) @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # vim: set ft=perl expandtab shiftwidth=2 softtabstop=2 : use strict; -use Gtk2::TestHelper tests = 113; +use Gtk2::TestHelper tests = 118; # $Id$ @@ -133,6 +133,56 @@ ok (1); } +SKIP: { + skip(get_property is new in 2.16, 5) +unless (Gtk2-CHECK_VERSION(2, 15, 0)); # FIXME 2.16 + + # Test different properties (gint, gboolean, gchar* and GObject) + my $property = $style - get_property('Gtk2::TreeView', 'expander-size'); + my $treeview = Gtk2::TreeView - new(); + + # get gboolean + is ( +$style - get_property('Gtk2::TreeView', 'allow-rules'), +$treeview - style_get_property('allow-rules'), +get_property gboolean + ); + + # get gint + is ( +$style - get_property('Gtk2::TreeView', 'expander-size'), +$treeview - style_get_property('expander-size'), +get_property gint + ); + + # get gchar* + is ( +$style - get_property('Gtk2::TreeView', 'grid_line-pattern'), +$treeview - style_get_property('grid_line-pattern'), +get_property gchar* + ); + + # get GObject (a color) + is ( +$style - get_property('Gtk2::TreeView', 'even-row-color