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 version import APP_NAME, APP_VERSION
from translation import _ from translation import _
class ProfileEditor: class ProfileEditor:
# lists of which settings to put in which tabs # 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'] 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'] 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 # metadata about the settings
data = {'titlebars': ['Show titlebars', 'This places a bar above each terminal which displays its title.'], 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.'], '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'], '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'], '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'], '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} tab_position_gtk = {'top' : gtk.POS_TOP, 'bottom' : gtk.POS_BOTTOM, 'left' : gtk.POS_LEFT, 'right' : gtk.POS_RIGHT}
cursor_shape = ['block', 'ibeam', 'underline'] cursor_shape = ['block', 'ibeam', 'underline']
config = None
def __init__ (self, term): def __init__ (self, term):
self.config = config.Config()
self.term = term self.term = term
self.window = gtk.Window () self.window = gtk.Window ()
self.notebook = gtk.Notebook() self.notebook = gtk.Notebook()
@ -76,7 +77,6 @@ class ProfileEditor:
self.cancelbut = gtk.Button(stock=gtk.STOCK_CLOSE) self.cancelbut = gtk.Button(stock=gtk.STOCK_CLOSE)
self.cancelbut.connect ("clicked", self.cancel) 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_start(self.notebook, False, False)
self.box.pack_end(self.butbox, 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.colours), gtk.Label ("Colours"))
self.notebook.append_page (self.auto_add (gtk.Table (), self.behaviour), gtk.Label ("Behaviour")) 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): def source_get_type (self, key):
if DEFAULTS.has_key (key): if config.DEFAULTS['global_config'].has_key (key):
return DEFAULTS[key].__class__.__name__ print "found %s in global_config" % key
elif DEFAULTS['keybindings'].has_key (key): return config.DEFAULTS['global_config'][key].__class__.__name__
return DEFAULTS['keybindings'][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: else:
print "could not find %s" % key
raise KeyError raise KeyError
def source_get_value (self, key): def source_get_value (self, key):
try: return self.config[key]
return self.term.conf.__getattr__(key)
except AttributeError:
try:
return self.term.conf.keybindings[key]
except AttributeError:
pass
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] != '':
@ -229,9 +228,10 @@ class ProfileEditor:
if value in self.cursor_shape: if value in self.cursor_shape:
widget.set_active (self.cursor_shape.index (value)) widget.set_active (self.cursor_shape.index (value))
else: else:
print "doing %s automagically" % key
if type == "bool": if type == "bool":
widget = gtk.CheckButton () widget = gtk.CheckButton ()
widget.set_active (value) widget.set_active (value == 'True')
elif type in ["str", "int", "float"]: elif type in ["str", "int", "float"]:
widget = gtk.Entry () widget = gtk.Entry ()
widget.set_text (str(value)) widget.set_text (str(value))
@ -308,7 +308,7 @@ class ProfileEditor:
has_changed = False has_changed = False
changed = [] changed = []
for source in self.term.conf.sources: for source in self.config.sources:
if isinstance (source, TerminatorConfValuestoreRC): if isinstance (source, TerminatorConfValuestoreRC):
for property in values: for property in values:
try: try:
@ -347,7 +347,7 @@ class ProfileEditor:
if isinstance (notebook, gtk.Notebook): if isinstance (notebook, gtk.Notebook):
for i in xrange(0,notebook.get_n_pages()): for i in xrange(0,notebook.get_n_pages()):
notebook.get_tab_label(notebook.get_nth_page(i)).update_closebut() 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() self.term.reconfigure_vtes()
@ -382,12 +382,12 @@ class ProfileEditor:
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)
self.tkbobj = TerminatorKeybindings() self.tkbobj = Keybindings()
keyval = None keyval = None
mask = None mask = None
for binding in DEFAULTS['keybindings']: for binding in config.DEFAULTS['keybindings']:
value = self.term.conf.keybindings[binding] value = self.config['keybindings'][binding]
keyval = 0 keyval = 0
mask = 0 mask = 0
if isinstance (value, tuple): if isinstance (value, tuple):

View File

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