gtk accelerator problems



Hi,

I'm porting an application to GTK+2.

I have some code like this:

        item = gtk_menu_item_new_with_mnemonic ("_Entry");
        g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (activate_cb), NULL);
        gtk_menu_item_set_accel_path (GTK_MENU_ITEM (item), "<MyApp>/menu/entry");
        gtk_accel_map_add_entry ("<MyApp>/menu/entry", 'E', GDK_CONTROL_MASK);
        gtk_widget_show (item);
        gtk_menu_shell_append (GTK_MENU_SHELL (item_holder), item);

etc.

When running the application, neither the accelerator label is shown in the
menu, nor does the accelerator (ctrl+E) actually work.

I can't find anything in the API reference or in the tutorial which I might
have missed.
I tried using gtk_window_add_accel_group () on the top level window, using a
freshly created GtkAccelGroup but it doesn't change anything. Not that I
expected it to, since I'm not passing on the accelgroup anywhere to the menu
item related accel calls.

Can someone tell me what I have done wrong, if anything? And wouldn't this
be a nice addition to the tutorial?

BTW. one other, slightly related issue:
In the GtkImageMenuItem reference, in the description for
gtk_image_menu_item_new_from_stock (), there is this blurb:

/*
If you want this menu item to have changeable accelerators, then pass in
NULL for accel_group call gtk_menu_item_set_accel_path() with an appropriate
path for the menu item, then use gtk_stock_lookup() too look up the standard
accelerator for the stock item and if one is found, call
gtk_accel_map_add_entry() to register it.
*/

A bit hard to read, and not entirely correct grammar I believe.


Regards,

Filip

-- 
"The world is coming to an end ... SAVE YOUR BUFFERS!!!"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]