1

I am writing a Gtk program in Vala that uses a Gtk.Menu.
I need to use Gtk.Menu.popup_at_pointer() to display a menu when the right mouse button is clicked.

When compiling (with --pkg gtk+-3.0), GCC gives me an error: warning: implicit declaration of function ‘gtk_menu_popup_at_pointer’ [-Wimplicit-function-declaration]

The method exists in /usr/share/vala-0.34/vapi/gtk+-3.0.vapi, but is missing in /usr/include/gtk-3.0/gtk/gtkmenu.h.

Here are the versions of the relevant packages on my system:

$ dpkg -s libgtk-3-dev | grep '^Version:'       
Version: 3.18.9-1ubuntu3.1
$ dpkg -s valac | grep '^Version:'
Version: 0.34.4-0ubuntu1~16.04~valateam1
$ dpkg -s libglib2.0-0 | grep '^Version:'
Version: 2.48.2-0elementary0.4.1

What should I do to be able to use this method?

4

1 回答 1

1

您的 GTK+ 版本太旧。

如果您查看该功能的 GTK+ 文档,您会发现它是在 GTK+ 3.22 中引入的:https ://developer.gnome.org/gtk3/stable/GtkMenu.html#gtk-menu-popup-at-pointer ,而你只安装了 3.18。

另请注意,该方法也被声明为不稳定,这意味着将来它可能会以破坏您的应用程序的方式发生变化,因此您现在最好还是找到替代解决方案。

于 2017-01-19T23:51:15.350 回答