Hook up the keybindings tab in the preferences editor. Loads and saves
This commit is contained in:
parent
2cc76de609
commit
180ccbbf03
|
@ -74,54 +74,53 @@ DEFAULTS = {
|
||||||
'disabled_plugins' : ['TestPlugin', 'CustomCommandsMenu'],
|
'disabled_plugins' : ['TestPlugin', 'CustomCommandsMenu'],
|
||||||
},
|
},
|
||||||
'keybindings': {
|
'keybindings': {
|
||||||
'zoom_in' : '<Ctrl>plus',
|
'zoom_in' : '<Control>plus',
|
||||||
'zoom_out' : '<Ctrl>minus',
|
'zoom_out' : '<Control>minus',
|
||||||
'zoom_normal' : '<Ctrl>0',
|
'zoom_normal' : '<Control>0',
|
||||||
'new_root_tab' : '<Ctrl><Shift><Alt>T',
|
'new_tab' : '<Shift><Control>t',
|
||||||
'new_tab' : '<Ctrl><Shift>T',
|
'go_next' : '<Shift><Control>n', # FIXME: Define ctrl-tab
|
||||||
'go_next' : ('<Ctrl><Shift>N','<Ctrl>Tab'),
|
'go_prev' : '<Shift><Control>p', #FIXME: ctrl-shift-tab
|
||||||
'go_prev' : ('<Ctrl><Shift>P','<Ctrl><Shift>Tab'),
|
|
||||||
'go_up' : '<Alt>Up',
|
'go_up' : '<Alt>Up',
|
||||||
'go_down' : '<Alt>Down',
|
'go_down' : '<Alt>Down',
|
||||||
'go_left' : '<Alt>Left',
|
'go_left' : '<Alt>Left',
|
||||||
'go_right' : '<Alt>Right',
|
'go_right' : '<Alt>Right',
|
||||||
'split_horiz' : '<Ctrl><Shift>O',
|
'split_horiz' : '<Shift><Control>o',
|
||||||
'split_vert' : '<Ctrl><Shift>E',
|
'split_vert' : '<Shift><Control>e',
|
||||||
'close_term' : '<Ctrl><Shift>W',
|
'close_term' : '<Shift><Control>w',
|
||||||
'copy' : '<Ctrl><Shift>C',
|
'copy' : '<Shift><Control>c',
|
||||||
'paste' : '<Ctrl><Shift>V',
|
'paste' : '<Shift><Control>v',
|
||||||
'toggle_scrollbar' : '<Ctrl><Shift>S',
|
'toggle_scrollbar' : '<Shift><Control>s',
|
||||||
'search' : '<Ctrl><Shift>F',
|
'search' : '<Shift><Control>f',
|
||||||
'close_window' : '<Ctrl><Shift>Q',
|
'close_window' : '<Shift><Control>q',
|
||||||
'resize_up' : '<Ctrl><Shift>Up',
|
'resize_up' : '<Shift><Control>Up',
|
||||||
'resize_down' : '<Ctrl><Shift>Down',
|
'resize_down' : '<Shift><Control>Down',
|
||||||
'resize_left' : '<Ctrl><Shift>Left',
|
'resize_left' : '<Shift><Control>Left',
|
||||||
'resize_right' : '<Ctrl><Shift>Right',
|
'resize_right' : '<Shift><Control>Right',
|
||||||
'move_tab_right' : '<Ctrl><Shift>Page_Down',
|
'move_tab_right' : '<Shift><Control>Page_Down',
|
||||||
'move_tab_left' : '<Ctrl><Shift>Page_Up',
|
'move_tab_left' : '<Shift><Control>Page_Up',
|
||||||
'toggle_zoom' : '<Ctrl><Shift>X',
|
'toggle_zoom' : '<Shift><Control>x',
|
||||||
'scaled_zoom' : '<Ctrl><Shift>Z',
|
'scaled_zoom' : '<Shift><Control>z',
|
||||||
'next_tab' : '<Ctrl>Page_Down',
|
'next_tab' : '<Control>Page_Down',
|
||||||
'prev_tab' : '<Ctrl>Page_Up',
|
'prev_tab' : '<Control>Page_Up',
|
||||||
'switch_to_tab_1' : None,
|
'switch_to_tab_1' : '',
|
||||||
'switch_to_tab_2' : None,
|
'switch_to_tab_2' : '',
|
||||||
'switch_to_tab_3' : None,
|
'switch_to_tab_3' : '',
|
||||||
'switch_to_tab_4' : None,
|
'switch_to_tab_4' : '',
|
||||||
'switch_to_tab_5' : None,
|
'switch_to_tab_5' : '',
|
||||||
'switch_to_tab_6' : None,
|
'switch_to_tab_6' : '',
|
||||||
'switch_to_tab_7' : None,
|
'switch_to_tab_7' : '',
|
||||||
'switch_to_tab_8' : None,
|
'switch_to_tab_8' : '',
|
||||||
'switch_to_tab_9' : None,
|
'switch_to_tab_9' : '',
|
||||||
'switch_to_tab_10' : None,
|
'switch_to_tab_10' : '',
|
||||||
'full_screen' : 'F11',
|
'full_screen' : 'F11',
|
||||||
'reset' : '<Ctrl><Shift>R',
|
'reset' : '<Shift><Control>r',
|
||||||
'reset_clear' : '<Ctrl><Shift>G',
|
'reset_clear' : '<Shift><Control>g',
|
||||||
'hide_window' : '<Ctrl><Shift><Alt>a',
|
'hide_window' : '<Shift><Control><Alt>a',
|
||||||
'group_all' : '<Super>g',
|
'group_all' : '<Super>g',
|
||||||
'ungroup_all' : '<Super><Shift>g',
|
'ungroup_all' : '<Shift><Super>g',
|
||||||
'group_tab' : '<Super>t',
|
'group_tab' : '<Super>t',
|
||||||
'ungroup_tab' : '<Super><Shift>T',
|
'ungroup_tab' : '<Shift><Super>t',
|
||||||
'new_window' : '<Ctrl><Shift>I',
|
'new_window' : '<Shift><Control>i',
|
||||||
},
|
},
|
||||||
'profiles': {
|
'profiles': {
|
||||||
'default': {
|
'default': {
|
||||||
|
|
|
@ -8,16 +8,6 @@
|
||||||
<column type="gchararray"/>
|
<column type="gchararray"/>
|
||||||
</columns>
|
</columns>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkListStore" id="KeybindingsListStore">
|
|
||||||
<columns>
|
|
||||||
<!-- column-name Name -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
<!-- column-name Action -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
<!-- column-name Keyboard -->
|
|
||||||
<column type="GtkCellRendererAccelMode"/>
|
|
||||||
</columns>
|
|
||||||
</object>
|
|
||||||
<object class="GtkListStore" id="FocusListStore">
|
<object class="GtkListStore" id="FocusListStore">
|
||||||
<columns>
|
<columns>
|
||||||
<!-- column-name focustype -->
|
<!-- column-name focustype -->
|
||||||
|
@ -189,6 +179,18 @@
|
||||||
</row>
|
</row>
|
||||||
</data>
|
</data>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkListStore" id="KeybindingsListStore">
|
||||||
|
<columns>
|
||||||
|
<!-- column-name Name -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name Action -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name keyval -->
|
||||||
|
<column type="guint"/>
|
||||||
|
<!-- column-name modifiers -->
|
||||||
|
<column type="guint"/>
|
||||||
|
</columns>
|
||||||
|
</object>
|
||||||
<object class="GtkDialog" id="prefswin">
|
<object class="GtkDialog" id="prefswin">
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
<property name="type_hint">normal</property>
|
<property name="type_hint">normal</property>
|
||||||
|
@ -2046,10 +2048,19 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeView" id="treeview2">
|
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="vadjustment">adjustment4</property>
|
||||||
|
<property name="hscrollbar_policy">never</property>
|
||||||
|
<property name="vscrollbar_policy">automatic</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeView" id="keybindingtreeview">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="model">KeybindingsListStore</property>
|
<property name="model">KeybindingsListStore</property>
|
||||||
|
<property name="headers_clickable">False</property>
|
||||||
|
<property name="search_column">0</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
||||||
<property name="title">Name</property>
|
<property name="title">Name</property>
|
||||||
|
@ -2076,14 +2087,21 @@
|
||||||
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
||||||
<property name="title">Keybinding</property>
|
<property name="title">Keybinding</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererAccel" id="cellrendereraccel1"/>
|
<object class="GtkCellRendererAccel" id="cellrendereraccel1">
|
||||||
|
<property name="editable">True</property>
|
||||||
|
<signal name="accel_cleared" handler="on_cellrenderer_accel_cleared" object="KeybindingsListStore"/>
|
||||||
|
<signal name="accel_edited" handler="on_cellrenderer_accel_edited" object="KeybindingsListStore"/>
|
||||||
|
</object>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="text">2</attribute>
|
<attribute name="accel-key">2</attribute>
|
||||||
|
<attribute name="accel-mods">3</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">3</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -2202,4 +2220,10 @@
|
||||||
<property name="page_increment">10</property>
|
<property name="page_increment">10</property>
|
||||||
<property name="page_size">10</property>
|
<property name="page_size">10</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkAdjustment" id="adjustment4">
|
||||||
|
<property name="upper">100</property>
|
||||||
|
<property name="step_increment">1</property>
|
||||||
|
<property name="page_increment">10</property>
|
||||||
|
<property name="page_size">10</property>
|
||||||
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
@ -6,12 +6,13 @@ import gobject
|
||||||
|
|
||||||
from util import dbg, err
|
from util import dbg, err
|
||||||
import config
|
import config
|
||||||
from keybindings import Keybindings
|
from keybindings import Keybindings, KeymapError
|
||||||
from version import APP_NAME, APP_VERSION
|
from version import APP_NAME, APP_VERSION
|
||||||
from translation import _
|
from translation import _
|
||||||
|
|
||||||
class PrefsEditor:
|
class PrefsEditor:
|
||||||
config = None
|
config = None
|
||||||
|
keybindings = None
|
||||||
window = None
|
window = None
|
||||||
builder = None
|
builder = None
|
||||||
previous_selection = None
|
previous_selection = None
|
||||||
|
@ -27,6 +28,7 @@ class PrefsEditor:
|
||||||
self.config = config.Config()
|
self.config = config.Config()
|
||||||
self.term = term
|
self.term = term
|
||||||
self.builder = gtk.Builder()
|
self.builder = gtk.Builder()
|
||||||
|
self.keybindings = Keybindings()
|
||||||
try:
|
try:
|
||||||
# Figure out where our library is on-disk so we can open our
|
# Figure out where our library is on-disk so we can open our
|
||||||
(head, tail) = os.path.split(config.__file__)
|
(head, tail) = os.path.split(config.__file__)
|
||||||
|
@ -123,7 +125,20 @@ class PrefsEditor:
|
||||||
# FIXME: Implement this
|
# FIXME: Implement this
|
||||||
|
|
||||||
## Keybindings tab
|
## Keybindings tab
|
||||||
# FIXME: Implement this
|
widget = guiget('keybindingtreeview')
|
||||||
|
liststore = widget.get_model()
|
||||||
|
liststore.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||||
|
keybindings = self.config['keybindings']
|
||||||
|
for keybinding in keybindings:
|
||||||
|
keyval = 0
|
||||||
|
mask = 0
|
||||||
|
value = keybindings[keybinding]
|
||||||
|
if value is not None and value != '':
|
||||||
|
try:
|
||||||
|
(keyval, mask) = self.keybindings._parsebinding(value)
|
||||||
|
except KeymapError:
|
||||||
|
pass
|
||||||
|
liststore.append([keybinding, 'UNDOCUMENTED', keyval, mask])
|
||||||
|
|
||||||
## Plugins tab
|
## Plugins tab
|
||||||
# FIXME: Implement this
|
# FIXME: Implement this
|
||||||
|
@ -184,10 +199,15 @@ class PrefsEditor:
|
||||||
# FIXME: Implement this
|
# FIXME: Implement this
|
||||||
|
|
||||||
## Keybindings tab
|
## Keybindings tab
|
||||||
# FIXME: Implement this
|
keybindings = self.config['keybindings']
|
||||||
|
liststore = guiget('KeybindingsListStore')
|
||||||
|
for keybinding in liststore:
|
||||||
|
accel = gtk.accelerator_name(keybinding[2], keybinding[3])
|
||||||
|
keybindings[keybinding[0]] = accel
|
||||||
|
|
||||||
## Plugins tab
|
## Plugins tab
|
||||||
# FIXME: Implement this
|
# FIXME: Implement this
|
||||||
|
|
||||||
def set_profile_values(self, profile):
|
def set_profile_values(self, profile):
|
||||||
"""Update the profile values for a given profile"""
|
"""Update the profile values for a given profile"""
|
||||||
self.config.set_profile(profile)
|
self.config.set_profile(profile)
|
||||||
|
@ -690,22 +710,14 @@ class PrefsEditor:
|
||||||
scheme.set_sensitive(True)
|
scheme.set_sensitive(True)
|
||||||
self.on_color_scheme_combobox_changed(scheme)
|
self.on_color_scheme_combobox_changed(scheme)
|
||||||
|
|
||||||
def source_get_type (self, key):
|
def on_cellrenderer_accel_edited(self, liststore, path, key, mods, code):
|
||||||
if config.DEFAULTS['global_config'].has_key (key):
|
"""Handle an edited keybinding"""
|
||||||
print "found %s in global_config" % key
|
celliter = liststore.get_iter_from_string(path)
|
||||||
return config.DEFAULTS['global_config'][key].__class__.__name__
|
liststore.set(celliter, 2, key, 3, mods)
|
||||||
elif config.DEFAULTS['profiles']['default'].has_key (key):
|
|
||||||
print "found %s in profiles" % key
|
|
||||||
return config.DEFAULTS['profiles']['default'][key].__class__.__name__
|
|
||||||
elif config.DEFAULTS['keybindings'].has_key (key):
|
|
||||||
print "found %s in keybindings" % key
|
|
||||||
return config.DEFAULTS['keybindings'][key].__class__.__name__
|
|
||||||
else:
|
|
||||||
print "could not find %s" % key
|
|
||||||
raise KeyError
|
|
||||||
|
|
||||||
def source_get_value (self, key):
|
def on_cellrenderer_accel_cleared(self, liststore, path):
|
||||||
return self.config[key]
|
celliter = liststore.get_iter_from_string(path)
|
||||||
|
liststore.set(celliter, 2, 0, 3, 0)
|
||||||
|
|
||||||
def source_get_keyname (self, key):
|
def source_get_keyname (self, key):
|
||||||
if self.data.has_key (key) and self.data[key][0] != '':
|
if self.data.has_key (key) and self.data[key][0] != '':
|
||||||
|
@ -714,14 +726,6 @@ class PrefsEditor:
|
||||||
label_text = key.replace ('_', ' ').capitalize ()
|
label_text = key.replace ('_', ' ').capitalize ()
|
||||||
return label_text
|
return label_text
|
||||||
|
|
||||||
def apply (self, data):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def cancel (self, data):
|
|
||||||
self.window.destroy()
|
|
||||||
self.term.options = None
|
|
||||||
del(self)
|
|
||||||
|
|
||||||
def prepare_keybindings (self):
|
def prepare_keybindings (self):
|
||||||
self.liststore = gtk.ListStore (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT, gobject.TYPE_UINT, gobject.TYPE_BOOLEAN)
|
self.liststore = gtk.ListStore (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT, gobject.TYPE_UINT, gobject.TYPE_BOOLEAN)
|
||||||
self.liststore.set_sort_column_id (0, gtk.SORT_ASCENDING)
|
self.liststore.set_sort_column_id (0, gtk.SORT_ASCENDING)
|
||||||
|
|
Loading…
Reference in New Issue