[Glade-users] configurable accelerators




Hi again.  I am trying to add configurable accelerators to the menus of
my program.  Currently, I am only interested in menu accelerators, I
have no toolbars or global buttons, though I may want to add those
later.  When I say "configurable accelerators" I mean I want to read a
configuration file at startup _at runtime_ and read the accelerator keys
from there.

I am very confused by the various accelerator related classes in the Gtk
documentation (and pygtk, since I'm writing the program in python).  The
most relevant one for my purpose seems to be AccelMap.  I constructed a
keymap configuration file with accel_map_save() and now I'm trying to
load it back with accel_map_load().  The documentation for the latter
function says:

 The gtk.accel_map_load() function parses the file (specified by
 file_name) previously saved with the gtk.accel_map_save() function for
 accelerator specifications, and propagates them accordingly.

The "propagates" part sounds like it should automatically set the
accelerators of the menu items with the right accelerator paths - but
that is not happening.  Here's the part of the code:

        builder = G.Builder()
        builder.add_from_file(os.path.join(libpath, 'spadeful.glade'))
        builder.connect_signals(self)
        defkeymap = os.path.join(libpath, 'keymap')
        if os.access(defkeymap, os.F_OK):
            G.accel_map_load(defkeymap)

(I also attach the whole glade file and the saved keymap below.)

Beyond this, I am confused by the role of AccelGroup.  I looked at the
source of another pygtk program (zenmap from the nmap package) and all
it does with AccelGroup is create one instance of it with the trivial
constructor, then add it to its main window and also to each of its
"actions".  (It uses actions and the UI manager, which is yet another can
of worms that I don't want to open as yet - can I just use menu items
without actions?)  But if creating an AccelGroup is necessary for
accelerators to work, how come it all worked with static accelerators
(those set in glade)?

And to top off my confusion, the glade tool for toplevels has a widget
to select an accelerator group - but there is no way (that I can see) to
actually create an accelerator group inside glade, so naturally there is
nothing to select from when I push the selection widget.

Thanks for any help direct or indirect.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: spadeful.glade
Type: application/octet-stream
Size: 38995 bytes
Desc: Glade XML file
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20120621/14091f35/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keymap
Type: application/octet-stream
Size: 881 bytes
Desc: Keymap for accel_map_save and accel_map_load
URL: <http://lists.ximian.com/pipermail/glade-users/attachments/20120621/14091f35/attachment-0003.obj>
-------------- next part --------------


-- 
Ian Zimmerman
gpg public key: 1024D/C6FF61AD
fingerprint: 66DC D68F 5C1B 4D71 2EE5  BD03 8A00 786C C6FF 61AD
http://www.gravatar.com/avatar/c66875cda51109f76c6312f4d4743d1e.png
Rule 420: All persons more than eight miles high to leave the court.




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