Re: How to use gtk-can-change-accels




On Oct 21, 2007, at 2:03 PM, Tian wrote:

On Sun, 21 Oct 2007 18:14:13 +0200
Tian <tian-ml c-sait net> wrote:

I am trying to change an application so users will be able to define their own accelerators for menus. I tried to use set_accel_path for this. But there is something I should do the wrong way. So i attach a small test
program that doesn't work as I expect.


By the way, you have

my $fileItem = Gtk2::MenuItem->new_with_mnemonic('File');

but the label string does not contain a mnemonic. Also, Gtk2 binds the "new_with_mnemonic" constructor variants as "new" by default, so you can do simply

my $fileItem = Gtk2::MenuItem->new('_File');



What I would like is that if the user press on some keys while an item has
the focus, the accelerators is replaced by the one pressed.

It seems I have correct settins on my side:

cat ~/.gtkrc-2.0
gtk-can-change-accels = 1


So something should be wrong in the code. But I can't figure what after many
tests.

Works for me.

1. perl menu.pl
2. use mouse to open File menu
3. hover mouse over "_New  Ctrl+N"
4. press Ctrl+G
5. press Ctrl+G again, get a bell meaning "you can't do that" (because it is now taken)
6. press Esc to close menu
7. press Ctrl+G, message box pops up.
8. use mouse to open File menu, still says "_New  Ctrl+N"
9. press Esc
10. press Ctrl+N, message box pops up.

Basically, what i see is that you can add the new accelerator key, and it doesn't remove the old one or change what the menu says.


I searched the web, but didn't any example for this made using Gtk2-Perl.

It should be all within gtk+ itself...


--
The Master in the art of living makes little distinction between his work and his play, his labor and his leisure, his mind and his body, his education and his recreation, his love and his religion. He hardly knows which is which. He simply pursues his vision of excellence in whatever he does, leaving others to decide whether he is working or playing. To him he is always doing both.

  -- Zen Philosophy






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