Get ProfileEditor to the barest state of functionality possible

This commit is contained in:
Chris Jones 2009-12-27 02:32:16 +00:00
parent 4c025273c9
commit f690cd6e5f
2 changed files with 397 additions and 397 deletions

View File

@ -9,18 +9,16 @@ from keybindings import Keybindings
from version import APP_NAME, APP_VERSION
from translation import _
class ProfileEditor:
# lists of which settings to put in which tabs
appearance = ['titlebars', 'zoomedtitlebar', 'titletips', 'allow_bold', 'audible_bell', 'visible_bell', 'urgent_bell', 'force_no_bell', 'background_darkness', 'background_type', 'background_image', 'cursor_blink', 'cursor_shape', 'font', 'scrollbar_position', 'scroll_background', 'use_system_font', 'use_theme_colors', 'enable_real_transparency']
appearance = ['titlebars', 'zoomedtitlebar', 'allow_bold', 'audible_bell', 'visible_bell', 'urgent_bell', 'force_no_bell', 'background_darkness', 'background_type', 'background_image', 'cursor_blink', 'cursor_shape', 'font', 'scrollbar_position', 'scroll_background', 'use_system_font', 'use_theme_colors', 'enable_real_transparency']
colours = ['foreground_color','background_color', 'cursor_color', 'palette', 'title_tx_txt_color', 'title_tx_bg_color', 'title_rx_txt_color', 'title_rx_bg_color', 'title_ia_txt_color', 'title_ia_bg_color']
behaviour = ['backspace_binding', 'delete_binding', 'emulation', 'scroll_on_keystroke', 'scroll_on_output', 'alternate_screen_scroll', 'scrollback_lines', 'focus', 'focus_on_close', 'exit_action', 'word_chars', 'mouse_autohide', 'use_custom_command', 'custom_command', 'http_proxy', 'encoding']
globals = ['fullscreen', 'maximise', 'borderless', 'handle_size', 'cycle_term_tab', 'close_button_on_tab', 'tab_position', 'copy_on_selection', 'extreme_tabs', 'try_posix_regexp']
globals = ['fullscreen', 'maximise', 'borderless', 'handle_size', 'cycle_term_tab', 'close_button_on_tab', 'tab_position', 'copy_on_selection', 'try_posix_regexp']
# metadata about the settings
data = {'titlebars': ['Show titlebars', 'This places a bar above each terminal which displays its title.'],
'zoomedtitlebar': ['Show titlebar when zoomed', 'This places an informative bar above a zoomed terminal to indicate there are hidden terminals.'],
'titletips': ['Show title tooltips', 'This adds a tooltip to each terminal which contains its title'],
'allow_bold': ['Allow bold text', 'Controls whether or not the terminals will honour requests for bold text'],
'silent_bell': ['', 'When enabled, bell events will generate a flash. When disabled, they will generate a beep'],
'background_darkness': ['', 'Controls how much the background will be tinted'],
@ -64,7 +62,10 @@ class ProfileEditor:
tab_position_gtk = {'top' : gtk.POS_TOP, 'bottom' : gtk.POS_BOTTOM, 'left' : gtk.POS_LEFT, 'right' : gtk.POS_RIGHT}
cursor_shape = ['block', 'ibeam', 'underline']
config = None
def __init__ (self, term):
self.config = config.Config()
self.term = term
self.window = gtk.Window ()
self.notebook = gtk.Notebook()
@ -76,7 +77,6 @@ class ProfileEditor:
self.cancelbut = gtk.Button(stock=gtk.STOCK_CLOSE)
self.cancelbut.connect ("clicked", self.cancel)
self.box.pack_start(self.warning, False, False)
self.box.pack_start(self.notebook, False, False)
self.box.pack_end(self.butbox, False, False)
@ -91,25 +91,24 @@ class ProfileEditor:
self.notebook.append_page (self.auto_add (gtk.Table (), self.colours), gtk.Label ("Colours"))
self.notebook.append_page (self.auto_add (gtk.Table (), self.behaviour), gtk.Label ("Behaviour"))
def go (self):
self.window.show_all ()
self.window.show_all()
def source_get_type (self, key):
if DEFAULTS.has_key (key):
return DEFAULTS[key].__class__.__name__
elif DEFAULTS['keybindings'].has_key (key):
return DEFAULTS['keybindings'][key].__class__.__name__
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 source_get_value (self, key):
try:
return self.term.conf.__getattr__(key)
except AttributeError:
try:
return self.term.conf.keybindings[key]
except AttributeError:
pass
return self.config[key]
def source_get_keyname (self, key):
if self.data.has_key (key) and self.data[key][0] != '':
@ -229,9 +228,10 @@ class ProfileEditor:
if value in self.cursor_shape:
widget.set_active (self.cursor_shape.index (value))
else:
print "doing %s automagically" % key
if type == "bool":
widget = gtk.CheckButton ()
widget.set_active (value)
widget.set_active (value == 'True')
elif type in ["str", "int", "float"]:
widget = gtk.Entry ()
widget.set_text (str(value))
@ -308,7 +308,7 @@ class ProfileEditor:
has_changed = False
changed = []
for source in self.term.conf.sources:
for source in self.config.sources:
if isinstance (source, TerminatorConfValuestoreRC):
for property in values:
try:
@ -347,7 +347,7 @@ class ProfileEditor:
if isinstance (notebook, gtk.Notebook):
for i in xrange(0,notebook.get_n_pages()):
notebook.get_tab_label(notebook.get_nth_page(i)).update_closebut()
# FIXME: which others? cycle_term_tab, copy_on_selection, extreme_tabs, try_posix_regexp
# FIXME: which others? cycle_term_tab, copy_on_selection, try_posix_regexp
self.term.reconfigure_vtes()
@ -382,12 +382,12 @@ class ProfileEditor:
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)
self.tkbobj = TerminatorKeybindings()
self.tkbobj = Keybindings()
keyval = None
mask = None
for binding in DEFAULTS['keybindings']:
value = self.term.conf.keybindings[binding]
for binding in config.DEFAULTS['keybindings']:
value = self.config['keybindings'][binding]
keyval = 0
mask = 0
if isinstance (value, tuple):

View File

@ -11,6 +11,7 @@ from translation import _
from encoding import TerminatorEncoding
from util import err
from config import Config
from profileeditor import ProfileEditor
import plugin
class TerminalPopupMenu(object):
@ -151,8 +152,7 @@ class TerminalPopupMenu(object):
submenu.append(gtk.MenuItem())
item = gtk.MenuItem(_('Ed_it profiles'))
item.connect('activate', lambda x:
terminal.terminator.edit_profile(terminal))
item.connect('activate', lambda x: ProfileEditor(self.terminal))
submenu.append(item)
self.add_encoding_items(menu)