#15 Write keybindings out to file

Alan Horkan

Another old patch retrieved from the Comix feature request tracker.
2 lines of code, a fairly standard Gnome/GTK thing to write out keybindings to disk as an accels file.
There's probably a better location to write this out to than the one used in the patch, there's probably a cross desktop XDG standard.

It's a relatively simple change (and more signficant with binary apps) but it means that users can change keybindings by editing text file, and not need to have admin or install a modified version to their own home directory. It's also great if you want to keep a custom set of keybindings the developer doesn't like, or you even want to be able to ship a few different sets of keybindings and drop set you like. (It's not particularly discoverable, but it's a really great thing to have.)

Here's a link to the Comix tracker but I've included the essential bit of API below anyhow
# Save keyboard accelerators to ~/.comix/accels.
gtk.accel_map_save(os.path.join(os.environ['HOME'], '.comix/accels'))

# Load keyboard accelerators from ~/.comix/accels.
gtk.accel_map_load(os.path.join(os.environ['HOME'], '.comix/accels'))

I saw a section in main.py about config files so write goes there, not sure about loading.


  • Oddegamra

    Oddegamra - 2011-05-03

    I've seen this patch before, and could not figure out exactly where to load the accelerator map. Apparently, building the actions in ui.py defines and overwrites any changes in the stored configuration. Even if I load the map after building the UI, no changes to the accel keys were noticable.

  • Oddegamra

    Oddegamra - 2011-06-06
    • assigned_to: nobody --> oddegamra
    • status: open --> open-accepted
  • Oddegamra

    Oddegamra - 2012-01-06
    • status: open-accepted --> closed-accepted
  • Oddegamra

    Oddegamra - 2012-01-06

    > When you edit the accels file you must remove the semi-colon at the start of the line to uncomment it and set a keybinding.
    Sigh... I feel like an idiot now. I somehow missed to read this line, and could never get this damn thing to work, no matter how hard I tried. Well, no wonder.

    Additionally, that whole hovering-over-menu stuff must be enabled in either gtk20.rc or directly in program code (gtk.settings_get_default().set_long_property("gtk-can-change-accels", 1, "MComix:Main")).

    Well, better late than never, I guess. Now if I could only come up with some good idea on how to enable customization of all those hardcoded hotkeys in event.py (arrow keys, space bar, and so on).

  • Alan Horkan

    Alan Horkan - 2012-01-31

    oddegamra your annoyance is understanble, I only know this crap from years of tolerating a certain horrible image manipulation program (this formatting only begins to seem slightly less weird after lots and lots of LISP programming but even then it still seems like an odd choice) and I only knew it was worth mentioning because of past struggles I've seen people have with it.

    I wasn't too worried about enabling in program interface customisation, editing a configuration file was enough for my purposes. I think that kind of thing is better left locked by default anyhow so that users cannot accidentally knock out the existing settings by mistake.

    This change is great. It allows quite a bit of extra playing about and custom changes without the need for forking the codebase. There is however a need to clean things up substantially.
    I not sure how exactly to describe this but last I remember from looking at this code the namespacing was an incoherent mess. (It's been so long I'm probably not getting the terminology/nominclature right but each accell has an "event" associated with it, and that event roughly corresponds to a menu item. Things get strange though because we have accell events for the Toolbar menus and the context/right click menu and there might even be yet another for the popup menu in fullscreen. Then it gets weirder still since the Edit archive has multiple popup dialogs depending on what are you click.)

    Way back when I was thinking of in theory copying an accels file and sharing it between MComix and Comix (or more to the point the Hoverhell branch of Comix). In a situation like that a much less messy naming scheme would help, taking the application branding out of the accells file too would held making the toplevel items look something like
    or something along those lines

    I hope you know roughly what I'm getting at, too sleepy to ramble on further ... I'll try to explain again later in the week when I've had too much beer and even less sleep and it wil be clear as mud :P

  • Alan Horkan

    Alan Horkan - 2012-01-31
    • status: closed-accepted --> open-accepted
  • Oddegamra

    Oddegamra - 2012-02-13

    All keybindings used in MComix should now be configurable at least in some way by editing configuration files.

  • Oddegamra

    Oddegamra - 2012-02-13
    • status: open-accepted --> closed-accepted

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks