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'],
|
||||
},
|
||||
'keybindings': {
|
||||
'zoom_in' : '<Ctrl>plus',
|
||||
'zoom_out' : '<Ctrl>minus',
|
||||
'zoom_normal' : '<Ctrl>0',
|
||||
'new_root_tab' : '<Ctrl><Shift><Alt>T',
|
||||
'new_tab' : '<Ctrl><Shift>T',
|
||||
'go_next' : ('<Ctrl><Shift>N','<Ctrl>Tab'),
|
||||
'go_prev' : ('<Ctrl><Shift>P','<Ctrl><Shift>Tab'),
|
||||
'zoom_in' : '<Control>plus',
|
||||
'zoom_out' : '<Control>minus',
|
||||
'zoom_normal' : '<Control>0',
|
||||
'new_tab' : '<Shift><Control>t',
|
||||
'go_next' : '<Shift><Control>n', # FIXME: Define ctrl-tab
|
||||
'go_prev' : '<Shift><Control>p', #FIXME: ctrl-shift-tab
|
||||
'go_up' : '<Alt>Up',
|
||||
'go_down' : '<Alt>Down',
|
||||
'go_left' : '<Alt>Left',
|
||||
'go_right' : '<Alt>Right',
|
||||
'split_horiz' : '<Ctrl><Shift>O',
|
||||
'split_vert' : '<Ctrl><Shift>E',
|
||||
'close_term' : '<Ctrl><Shift>W',
|
||||
'copy' : '<Ctrl><Shift>C',
|
||||
'paste' : '<Ctrl><Shift>V',
|
||||
'toggle_scrollbar' : '<Ctrl><Shift>S',
|
||||
'search' : '<Ctrl><Shift>F',
|
||||
'close_window' : '<Ctrl><Shift>Q',
|
||||
'resize_up' : '<Ctrl><Shift>Up',
|
||||
'resize_down' : '<Ctrl><Shift>Down',
|
||||
'resize_left' : '<Ctrl><Shift>Left',
|
||||
'resize_right' : '<Ctrl><Shift>Right',
|
||||
'move_tab_right' : '<Ctrl><Shift>Page_Down',
|
||||
'move_tab_left' : '<Ctrl><Shift>Page_Up',
|
||||
'toggle_zoom' : '<Ctrl><Shift>X',
|
||||
'scaled_zoom' : '<Ctrl><Shift>Z',
|
||||
'next_tab' : '<Ctrl>Page_Down',
|
||||
'prev_tab' : '<Ctrl>Page_Up',
|
||||
'switch_to_tab_1' : None,
|
||||
'switch_to_tab_2' : None,
|
||||
'switch_to_tab_3' : None,
|
||||
'switch_to_tab_4' : None,
|
||||
'switch_to_tab_5' : None,
|
||||
'switch_to_tab_6' : None,
|
||||
'switch_to_tab_7' : None,
|
||||
'switch_to_tab_8' : None,
|
||||
'switch_to_tab_9' : None,
|
||||
'switch_to_tab_10' : None,
|
||||
'split_horiz' : '<Shift><Control>o',
|
||||
'split_vert' : '<Shift><Control>e',
|
||||
'close_term' : '<Shift><Control>w',
|
||||
'copy' : '<Shift><Control>c',
|
||||
'paste' : '<Shift><Control>v',
|
||||
'toggle_scrollbar' : '<Shift><Control>s',
|
||||
'search' : '<Shift><Control>f',
|
||||
'close_window' : '<Shift><Control>q',
|
||||
'resize_up' : '<Shift><Control>Up',
|
||||
'resize_down' : '<Shift><Control>Down',
|
||||
'resize_left' : '<Shift><Control>Left',
|
||||
'resize_right' : '<Shift><Control>Right',
|
||||
'move_tab_right' : '<Shift><Control>Page_Down',
|
||||
'move_tab_left' : '<Shift><Control>Page_Up',
|
||||
'toggle_zoom' : '<Shift><Control>x',
|
||||
'scaled_zoom' : '<Shift><Control>z',
|
||||
'next_tab' : '<Control>Page_Down',
|
||||
'prev_tab' : '<Control>Page_Up',
|
||||
'switch_to_tab_1' : '',
|
||||
'switch_to_tab_2' : '',
|
||||
'switch_to_tab_3' : '',
|
||||
'switch_to_tab_4' : '',
|
||||
'switch_to_tab_5' : '',
|
||||
'switch_to_tab_6' : '',
|
||||
'switch_to_tab_7' : '',
|
||||
'switch_to_tab_8' : '',
|
||||
'switch_to_tab_9' : '',
|
||||
'switch_to_tab_10' : '',
|
||||
'full_screen' : 'F11',
|
||||
'reset' : '<Ctrl><Shift>R',
|
||||
'reset_clear' : '<Ctrl><Shift>G',
|
||||
'hide_window' : '<Ctrl><Shift><Alt>a',
|
||||
'reset' : '<Shift><Control>r',
|
||||
'reset_clear' : '<Shift><Control>g',
|
||||
'hide_window' : '<Shift><Control><Alt>a',
|
||||
'group_all' : '<Super>g',
|
||||
'ungroup_all' : '<Super><Shift>g',
|
||||
'ungroup_all' : '<Shift><Super>g',
|
||||
'group_tab' : '<Super>t',
|
||||
'ungroup_tab' : '<Super><Shift>T',
|
||||
'new_window' : '<Ctrl><Shift>I',
|
||||
'ungroup_tab' : '<Shift><Super>t',
|
||||
'new_window' : '<Shift><Control>i',
|
||||
},
|
||||
'profiles': {
|
||||
'default': {
|
||||
|
@ -8,16 +8,6 @@
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</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">
|
||||
<columns>
|
||||
<!-- column-name focustype -->
|
||||
@ -189,6 +179,18 @@
|
||||
</row>
|
||||
</data>
|
||||
</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">
|
||||
<property name="border_width">5</property>
|
||||
<property name="type_hint">normal</property>
|
||||
@ -2046,40 +2048,56 @@
|
||||
</packing>
|
||||
</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="model">KeybindingsListStore</property>
|
||||
<property name="vadjustment">adjustment4</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
||||
<property name="title">Name</property>
|
||||
<object class="GtkTreeView" id="keybindingtreeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">KeybindingsListStore</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<property name="search_column">0</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext10"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
||||
<property name="title">Name</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext10"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
|
||||
<property name="title">Action</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext11"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
|
||||
<property name="title">Action</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext11"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
||||
<property name="title">Keybinding</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererAccel" id="cellrendereraccel1"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
||||
<property name="title">Keybinding</property>
|
||||
<child>
|
||||
<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>
|
||||
<attribute name="accel-key">2</attribute>
|
||||
<attribute name="accel-mods">3</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
@ -2202,4 +2220,10 @@
|
||||
<property name="page_increment">10</property>
|
||||
<property name="page_size">10</property>
|
||||
</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>
|
||||
|
@ -6,12 +6,13 @@ import gobject
|
||||
|
||||
from util import dbg, err
|
||||
import config
|
||||
from keybindings import Keybindings
|
||||
from keybindings import Keybindings, KeymapError
|
||||
from version import APP_NAME, APP_VERSION
|
||||
from translation import _
|
||||
|
||||
class PrefsEditor:
|
||||
config = None
|
||||
keybindings = None
|
||||
window = None
|
||||
builder = None
|
||||
previous_selection = None
|
||||
@ -27,6 +28,7 @@ class PrefsEditor:
|
||||
self.config = config.Config()
|
||||
self.term = term
|
||||
self.builder = gtk.Builder()
|
||||
self.keybindings = Keybindings()
|
||||
try:
|
||||
# Figure out where our library is on-disk so we can open our
|
||||
(head, tail) = os.path.split(config.__file__)
|
||||
@ -123,7 +125,20 @@ class PrefsEditor:
|
||||
# FIXME: Implement this
|
||||
|
||||
## 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
|
||||
# FIXME: Implement this
|
||||
@ -184,10 +199,15 @@ class PrefsEditor:
|
||||
# FIXME: Implement this
|
||||
|
||||
## 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
|
||||
# FIXME: Implement this
|
||||
|
||||
def set_profile_values(self, profile):
|
||||
"""Update the profile values for a given profile"""
|
||||
self.config.set_profile(profile)
|
||||
@ -690,22 +710,14 @@ class PrefsEditor:
|
||||
scheme.set_sensitive(True)
|
||||
self.on_color_scheme_combobox_changed(scheme)
|
||||
|
||||
def source_get_type (self, key):
|
||||
if config.DEFAULTS['global_config'].has_key (key):
|
||||
print "found %s in global_config" % key
|
||||
return config.DEFAULTS['global_config'][key].__class__.__name__
|
||||
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 on_cellrenderer_accel_edited(self, liststore, path, key, mods, code):
|
||||
"""Handle an edited keybinding"""
|
||||
celliter = liststore.get_iter_from_string(path)
|
||||
liststore.set(celliter, 2, key, 3, mods)
|
||||
|
||||
def source_get_value (self, key):
|
||||
return self.config[key]
|
||||
def on_cellrenderer_accel_cleared(self, liststore, path):
|
||||
celliter = liststore.get_iter_from_string(path)
|
||||
liststore.set(celliter, 2, 0, 3, 0)
|
||||
|
||||
def source_get_keyname (self, key):
|
||||
if self.data.has_key (key) and self.data[key][0] != '':
|
||||
@ -714,14 +726,6 @@ class PrefsEditor:
|
||||
label_text = key.replace ('_', ' ').capitalize ()
|
||||
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):
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user