简体   繁体   中英

GTK 2 gtk_widget_add_accelerator error: ‘GDK_Z’ undeclared

I'm trying to assign an accelerator to a GTK menu item:

group = gtk_accel_group_new();

item = gtk_image_menu_item_new_from_stock(GTK_STOCK_UNDO, group);

gtk_widget_add_accelerator(item, "activate", group, GDK_Z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

But when I compile I get the following error:

./src/main.c:171:55: error: ‘GDK_Z’ undeclared (first use in this function)
   gtk_widget_add_accelerator(item, "activate", group, GDK_Z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
                                                       ^

This is the output from pkg-config --cflags gtk+-2.0 :

-pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2

How can I make the GDK_Z identifier available to my program?

You did not included gdkkeysyms.h :

#include <gdk/gdkkeysyms.h>

Which contains GDK_Z needed for your program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM