Skip to content

Allow arbitrary values for the GSettings key org.gnome.builder.editor.keybindings

user n requested to merge user17/gnome-builder:user17-master-patch-97741 into master

Enables third party plugins to install keybindings.

I made a simple keybinding plugin and the only thing holding it back is an error which says:

GLib-GIO[ 29529]:  WARNING: g_settings_set_value: value for key 'keybindings' in schema 'org.gnome.builder.editor' is outside of valid range

The plugin files are:

  • file: test.plugin
[Plugin]
Name=test
Description=A sample key binding plugin in python
Authors=Example
Copyright=Copyright © 2021 Example
Loader=python3
Module=plugin
X-Has-Resources=true
X-Builder-ABI=3.40
  • file: plugin.py
from gi.repository import GObject
from gi.repository import Ide

class MyAppAddin(GObject.Object, Ide.PreferencesAddin):
    def do_load(self, preferences):
        self.keybinding_id = preferences.add_radio("keyboard",
                                                   "mode",
                                                   "org.gnome.builder.editor",
                                                   "keybindings",
                                                   None,
                                                   "\"test\"",
                                                   _("Test"),
                                                   _("Testing keybinding plugin"),
                                                   None,
                                                   100)
    def do_unload(self, preferences):
        preferences.remove_id(self.keybinding_id)
  • file: test.gresource.xml
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
  <gresource prefix="/plugins/test">
    <file>keybindings/test.css</file>
  </gresource>
</gresources>
  • file: keybindings/test.css
@import url("resource:///plugins/sublime/keybindings/sublime.css");
@binding-set test-ide-source-view
{
  bind "<alt>Left" { "action" ("history", "move-previous-edit", "") };
  bind "<alt>Right" { "action" ("history", "move-next-edit", "") };
}
@binding-set test-ide-source-view-no-selection {}
@binding-set test-ide-source-view-has-selection {}
@binding-set test-workbench-bindings {}

window.workbench {
  -gtk-key-bindings: test-workbench-bindings,
                     sublime-workbench-bindings;
}

.sourceview,
idesourceviewmode.default {
  -gtk-key-bindings: test-ide-source-view-no-selection,
                     test-ide-source-view,
                     test-workbench-bindings,
                     sublime-ide-source-view-no-selection,
                     sublime-ide-source-view,
                     sublime-workbench-bindings;
}

idesourceviewmode.default.has-selection {
  -gtk-key-bindings: test-ide-source-view-has-selection,
                     test-ide-source-view,
                     test-workbench-bindings,
                     sublime-ide-source-view-has-selection,
                     sublime-ide-source-view,
                     sublime-workbench-bindings;
}
Edited by user n

Merge request reports