Stop TerminatorTerm from failing when the correct gnome-terminal profile was not found.

This commit is contained in:
Thomas Meire 2008-01-06 10:31:37 +01:00
parent 67d4fd2585
commit 5590e21225
1 changed files with 17 additions and 18 deletions

View File

@ -85,6 +85,7 @@ class TerminatorTerm:
'link_userchars' : '-A-Za-z0-9', 'link_userchars' : '-A-Za-z0-9',
'link_passchars' : '-A-Za-z0-9,?;.:/!%$^*&~"#\'', 'link_passchars' : '-A-Za-z0-9,?;.:/!%$^*&~"#\'',
'_palette' : '%s/palette', '_palette' : '%s/palette',
'default_palette' : '',
'word_chars' : '-A-Za-z0-9,./?%&#:_', 'word_chars' : '-A-Za-z0-9,./?%&#:_',
'mouse_autohide' : True, 'mouse_autohide' : True,
} }
@ -98,23 +99,23 @@ class TerminatorTerm:
self.term = term self.term = term
self.gconf_client = gconf.client_get_default () self.gconf_client = gconf.client_get_default ()
self.profile = None self.profile = ""
profiles = self.gconf_client.get_list (self.defaults['gt_dir'] + '/global/profile_list', 'string') profiles = self.gconf_client.get_list (self.defaults['gt_dir'] + '/global/profile_list', 'string')
for item in profiles: if profile in profiles:
if item == profile: self.profile = '%s/%s'%(self.defaults['profile_dir'], profile)
self.profile = '%s/%s'%(self.defaults['profile_dir'], item)
break
if self.profile == None: if not self.profile:
print "Error, unable to find profile " + profile print >> sys.stderr, _("Warning: unable to find profile %s. Continue with default values...") % profile
# FIXME: This absolutely should not be an exit, the terminal should fail to spawn. If they all fail, it should exit from the mainloop or something.
sys.exit (2)
self.defaults['palette'] = self.defaults['_palette']%(self.profile) self.defaults['palette'] = self.defaults['_palette']%(self.profile)
self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE) if self.profile:
self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE)
self.gconf_client.notify_add (self.profile, self.on_gconf_notification)
self.gconf_client.add_dir ('/apps/metacity/general', gconf.CLIENT_PRELOAD_RECURSIVE) self.gconf_client.add_dir ('/apps/metacity/general', gconf.CLIENT_PRELOAD_RECURSIVE)
self.gconf_client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notification)
self.clipboard = gtk.clipboard_get (gtk.gdk.SELECTION_CLIPBOARD) self.clipboard = gtk.clipboard_get (gtk.gdk.SELECTION_CLIPBOARD)
@ -131,9 +132,6 @@ class TerminatorTerm:
self._box.pack_start (self._vte) self._box.pack_start (self._vte)
self._box.pack_start (self._scrollbar, False) self._box.pack_start (self._scrollbar, False)
self.gconf_client.notify_add (self.profile, self.on_gconf_notification)
self.gconf_client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notification)
self._vte.connect ("key-press-event", self.on_vte_key_press) self._vte.connect ("key-press-event", self.on_vte_key_press)
self._vte.connect ("button-press-event", self.on_vte_button_press) self._vte.connect ("button-press-event", self.on_vte_button_press)
self._vte.connect ("popup-menu", self.on_vte_popup_menu) self._vte.connect ("popup-menu", self.on_vte_popup_menu)
@ -172,7 +170,7 @@ class TerminatorTerm:
self._vte.set_emulation (self.defaults['emulation']) self._vte.set_emulation (self.defaults['emulation'])
# Set our wordchars # Set our wordchars
word_chars = self.gconf_client.get_string (self.profile + "/word_chars" or self.defaults['word_chars']) word_chars = self.gconf_client.get_string (self.profile + "/word_chars") or self.defaults['word_chars']
self._vte.set_word_chars (word_chars) self._vte.set_word_chars (word_chars)
# Set our mouselation # Set our mouselation
@ -215,8 +213,8 @@ class TerminatorTerm:
self._vte.set_allow_bold (self.gconf_client.get_bool (self.profile + "/allow_bold") or self.defaults['allow_bold']) self._vte.set_allow_bold (self.gconf_client.get_bool (self.profile + "/allow_bold") or self.defaults['allow_bold'])
# Set our color scheme, preferably from gconf settings # Set our color scheme, preferably from gconf settings
palette = self.gconf_client.get_string (self.profile + "/palette") or self.defaults['palette'] palette = self.gconf_client.get_string (self.profile + "/palette") or self.defaults['default_palette']
if self.gconf_client.get_bool (self.profile + "/use_theme_colors") == True: if (not self.profile) or self.gconf_client.get_bool (self.profile + "/use_theme_colors"):
fg_color = self._vte.get_style ().text[gtk.STATE_NORMAL] fg_color = self._vte.get_style ().text[gtk.STATE_NORMAL]
bg_color = self._vte.get_style ().base[gtk.STATE_NORMAL] bg_color = self._vte.get_style ().base[gtk.STATE_NORMAL]
else: else:
@ -240,7 +238,8 @@ class TerminatorTerm:
colors = palette.split (':') colors = palette.split (':')
palette = [] palette = []
for color in colors: for color in colors:
palette.append (gtk.gdk.color_parse (color)) if color:
palette.append (gtk.gdk.color_parse (color))
self._vte.set_colors (fg_color, bg_color, palette) self._vte.set_colors (fg_color, bg_color, palette)
# Set our cursor blinkiness # Set our cursor blinkiness