diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index 84a768af..0fa344f9 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -118,6 +118,14 @@ Default value: \fB'#000000'\fR Sets the colour of the background of the titlebar of any terminal that will \fBnot\fR receive input from the active terminal. Default value: \fB'#C0BEBF'\fR .TP +.B title_use_system_font \fR(boolean) +Whether or not to use the GNOME default proportional font for titlebars. +Default value: \fBTrue\fR +.TP +.B title_font \fR(string) +An Pango font name. Examples are "Sans 12" or "Monospace Bold 14". +Default value: \fB"Sans 9"\fR +.TP .B inactive_color_offset Controls how much to reduce the colour values of fonts in terminals that do not have focus. It is a simple multiplication factor. A font colour that was RGB(200,200,200) with an inactive_color_offset of 0.5 would set inactive terminals to @@ -404,7 +412,7 @@ Default value: \fBTrue\fR .TP .B font An Pango font name. Examples are "Sans 12" or "Monospace Bold 14". -Default value: \fBMono 8\fR +Default value: \fBMono 10\fR .TP .B foreground_color Default colour of text in the terminal, as a colour specification (can be HTML-style hex digits, or a colour name such as "red"). \fBNote:\fR You may need to set \fBuse_theme_colors=False\fR to force this setting to take effect. diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 3c1afd69..8af4f75d 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -117,8 +117,10 @@ DEFAULTS = { 'enabled_plugins' : ['LaunchpadBugURLHandler', 'LaunchpadCodeURLHandler', 'APTURLHandler'], - 'suppress_multiple_term_dialog': False, - 'always_split_with_profile': False, + 'suppress_multiple_term_dialog': False, + 'always_split_with_profile': False, + 'title_use_system_font' : True, + 'title_font' : 'Sans 9', }, 'keybindings': { 'zoom_in' : 'plus', @@ -265,7 +267,8 @@ class Config(object): base = None profile = None gconf = None - system_font = None + system_mono_font = None + system_prop_font = None system_focus = None inhibited = None @@ -347,10 +350,28 @@ class Config(object): """List all configured layouts""" return(self.base.layouts.keys()) - def get_system_font(self): + def get_system_prop_font(self): """Look up the system font""" - if self.system_font is not None: - return(self.system_font) + if self.system_prop_font is not None: + return(self.system_prop_font) + elif 'gconf' not in globals(): + return + else: + if self.gconf is None: + self.gconf = gconf.client_get_default() + + value = self.gconf.get( + '/desktop/gnome/interface/font_name') + self.system_prop_font = value.get_string() + self.gconf.notify_add( + '/desktop/gnome/interface/font_name', + self.on_gconf_notify) + return(self.system_prop_font) + + def get_system_mono_font(self): + """Look up the system font""" + if self.system_mono_font is not None: + return(self.system_mono_font) elif 'gconf' not in globals(): return else: @@ -359,11 +380,11 @@ class Config(object): value = self.gconf.get( '/desktop/gnome/interface/monospace_font_name') - self.system_font = value.get_string() + self.system_mono_font = value.get_string() self.gconf.notify_add( '/desktop/gnome/interface/monospace_font_name', self.on_gconf_notify) - return(self.system_font) + return(self.system_mono_font) def get_system_focus(self): """Look up the system focus setting""" diff --git a/terminatorlib/editablelabel.py b/terminatorlib/editablelabel.py index 8928161a..b5bd17ea 100644 --- a/terminatorlib/editablelabel.py +++ b/terminatorlib/editablelabel.py @@ -154,4 +154,9 @@ class EditableLabel(gtk.EventBox): def set_custom(self): """Set the customness of the string to True""" self._custom = True + + def modify_font(self, fontdesc): + """Set the label font using a pango.FontDescription""" + self._label.modify_font(fontdesc) + gobject.type_register(EditableLabel) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index d08db04a..95b87df1 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1214,6 +1214,7 @@ True False + 3 2 12 6 @@ -1230,6 +1231,78 @@ 2 + GTK_FILL + + + + + + _Use the system font + True + True + False + False + True + True + + + + 2 + 1 + 2 + GTK_FILL + + + + + + True + False + 12 + + + True + False + 12 + + + True + False + 0 + _Font: + True + font_selector + + + False + False + 0 + + + + + True + True + True + False + False + Choose A Titlebar Font + True + + + + False + False + 1 + + + + + + + 2 + 2 + 3 diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index c36437a7..53e7bf11 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -285,6 +285,19 @@ class PrefsEditor: #Always split with profile widget = guiget('always_split_with_profile') widget.set_active(self.config['always_split_with_profile']) + #Titlebar font selector + # Use system font + widget = guiget('title_system_font_checkbutton') + widget.set_active(self.config['title_use_system_font']) + self.on_title_system_font_checkbutton_toggled(widget) + # Font selector + widget = guiget('title_font_selector') + if self.config['title_use_system_font'] == True: + fontname = self.config.get_system_prop_font() + if fontname is not None: + widget.set_font_name(fontname) + else: + widget.set_font_name(self.config['title_font']) ## Profile tab # Populate the profile list @@ -373,7 +386,7 @@ class PrefsEditor: widget = guiget('font_selector') if self.config['use_system_font'] == True: - fontname = self.config.get_system_font() + fontname = self.config.get_system_mono_font() if fontname is not None: widget.set_font_name(fontname) else: @@ -944,6 +957,11 @@ class PrefsEditor: self.config['font'] = widget.get_font_name() self.config.save() + def on_title_font_selector_font_set(self, widget): + """Titlebar Font changed""" + self.config['title_font'] = widget.get_font_name() + self.config.save() + def on_title_receive_bg_color_color_set(self, widget): """Title receive background colour changed""" self.config['title_receive_bg_color'] = color2hex(widget) @@ -1163,6 +1181,31 @@ class PrefsEditor: widget.set_sensitive(not value) self.config['use_system_font'] = value self.config.save() + + if self.config['use_system_font'] == True: + fontname = self.config.get_system_mono_font() + if fontname is not None: + widget.set_font_name(fontname) + else: + widget.set_font_name(self.config['font']) + + def on_title_system_font_checkbutton_toggled(self, checkbox): + """Toggling the title_use_system_font checkbox needs to alter the + sensitivity of the font selector""" + guiget = self.builder.get_object + widget = guiget('title_font_selector') + value = checkbox.get_active() + + widget.set_sensitive(not value) + self.config['title_use_system_font'] = value + self.config.save() + + if self.config['title_use_system_font'] == True: + fontname = self.config.get_system_prop_font() + if fontname is not None: + widget.set_font_name(fontname) + else: + widget.set_font_name(self.config['title_font']) def on_reset_compatibility_clicked(self, widget): """Reset the confusing and annoying backspace/delete options to the diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index fbe30a59..47a46832 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -612,7 +612,7 @@ class Terminal(gtk.VBox): if not self.custom_font_size: try: if self.config['use_system_font'] == True: - font = self.config.get_system_font() + font = self.config.get_system_mono_font() else: font = self.config['font'] self.set_font(pango.FontDescription(font)) @@ -1472,7 +1472,7 @@ class Terminal(gtk.VBox): def zoom_orig(self): """Restore original font size""" if self.config['use_system_font'] == True: - font = self.config.get_system_font() + font = self.config.get_system_mono_font() else: font = self.config['font'] dbg("Terminal::zoom_orig: restoring font to: %s" % font) diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 7905a288..cc80e2e4 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -7,6 +7,7 @@ import gtk import gobject import random import itertools +import pango from version import APP_NAME from util import dbg @@ -105,6 +106,13 @@ class Titlebar(gtk.EventBox): else: self.label.set_text("%s %s" % (self.termtext, self.sizetext)) + if (not self.config['title_use_system_font']) and self.config['title_font']: + title_font = pango.FontDescription(self.config['title_font']) + else: + title_font = pango.FontDescription(self.config.get_system_prop_font()) + self.label.modify_font(title_font) + self.grouplabel.modify_font(title_font) + if other: term = self.terminal terminator = self.terminator