[Vala] Question about vapi and CCode attributes
- From: Tomasz Jankowski <tomcioj gmail com>
- To: vala-list gnome org
- Subject: [Vala] Question about vapi and CCode attributes
- Date: Wed, 13 Oct 2010 21:14:16 +0200
Hello!
II'm working on GTK+ based application and I decided to use Vala to make my
life easier. I was wrong (partly)...
I design windows in Glade and then load created XML files GTK+ Builder.
According to samples at Vala's homepage I added additional attributes to my
code to used callbacks autoconnect:
[CCode (instance_pos = -1)]
public void on_about_menu_item_activate (Gtk.MenuItem menu_item)
{
AboutDialog dialog = new AboutDialog ();
dialog.display ();
}
Later I decided to add internationalization support and because I use
Autotools I looked how it's done in http://github.com/tadeboro/Sampala . My
config.vapi:
[CCode (prefix = "", lower_case_cprefix = "", cheader_filename =
"config.h")]
namespace Foo
{
/* Package information */
public const string PACKAGE_NAME;
public const string PACKAGE_STRING;
public const string PACKAGE_VERSION;
/* Gettext package */
public const string GETTEXT_PACKAGE;
/* Configured paths - these variables are not present in config.h, they are
* passed to underlying C code as cmd line macros. */
public const string LOCALEDIR; /* /usr/local/share/locale */
public const string PKGDATADIR; /* /usr/local/share/sampala */
}
I also added flags: "--vapidir=. --pkg=config" to Vala compiler (config.vapi
is placed in the same directory that source code files are) and flags to
GCC: -include
$(top_srcdir)/config.h -DLOCALEDIR=\""$(localedir)"\"
-DPKGDATADIR=\""$(datadir)"\"
When I added config.vapi to my project it broke callbacks autoconnect (but
localization works fine), runtime errors:
(foo-gtk:24482): Gtk-WARNING **: Could not find signal handler
'foo_on_quit_menu_item_activate'
(foo-gtk:24482): Gtk-WARNING **: Could not find signal
handler foo_on_about_menu_item_activate'
etc.
I stared reading Vala documentation, searching web and finally I figured
out, that this construction works fine for me:
[CCode (instance_pos = -1, cname = "foo_on_about_menu_item_activate")]
public void on_about_menu_item_activate (Gtk.MenuItem menu_item)
{
AboutDialog dialog = new AboutDialog ();
dialog.display ();
}
Questions:
1. Why config.vapi addition broke callbacks autoconnecting?
2. Is there any other way to achieve the same result
without writing cname attribute for each callback?
3. What does instance_pos attribute?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]