[GTK+] AccelMap, AccelKey and ActionGroup



I was trying to use my AccelMap in order to retrieve and launch the action
matching a given accelkey string.

For example, i have an AccelKey defining the shortcut <Control>P for the
method myPrint().

I'd like my method myKey(string) to receive the command as a string
"<Control>P", retrieve in all actions the matching one and launch it (in
this example, launch the myPrint method).

Here is the solution I found :

1) I use the method gtk_accel_group_foreach, and compare the accel_key and
accel_mod values for retrieving the corresponding accel_path.

2) As i can't lookup, in the accelgroup, for an accelpath by giving the
accelkey (the contrary is possible thought), i've been compelled to loop
over all my actionGroups, and all my actions (2 loops, it's ugly), and call
the get_accel_path method on each action to compare with the accelpath
identified in step 1). Once found, I can launch the action.

Is there any other solution to do that ? Because I don't like to loop over
ActionGroups, and then over Actions, it's too long....

Thanks a lot :)



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