Global setting for changing the titlebar font (partially from Eli Zor branch), but expanded and improved (docs/GUI), plus some minor fixup from this.

This commit is contained in:
Stephen Boddy 2015-07-10 21:36:33 +02:00
parent d015e3f0ca
commit da4db8b9c2
7 changed files with 170 additions and 12 deletions

View File

@ -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. 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 Default value: \fB'#C0BEBF'\fR
.TP .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 .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 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 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 .TP
.B font .B font
An Pango font name. Examples are "Sans 12" or "Monospace Bold 14". An Pango font name. Examples are "Sans 12" or "Monospace Bold 14".
Default value: \fBMono 8\fR Default value: \fBMono 10\fR
.TP .TP
.B foreground_color .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. 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.

View File

@ -117,8 +117,10 @@ DEFAULTS = {
'enabled_plugins' : ['LaunchpadBugURLHandler', 'enabled_plugins' : ['LaunchpadBugURLHandler',
'LaunchpadCodeURLHandler', 'LaunchpadCodeURLHandler',
'APTURLHandler'], 'APTURLHandler'],
'suppress_multiple_term_dialog': False, 'suppress_multiple_term_dialog': False,
'always_split_with_profile': False, 'always_split_with_profile': False,
'title_use_system_font' : True,
'title_font' : 'Sans 9',
}, },
'keybindings': { 'keybindings': {
'zoom_in' : '<Control>plus', 'zoom_in' : '<Control>plus',
@ -265,7 +267,8 @@ class Config(object):
base = None base = None
profile = None profile = None
gconf = None gconf = None
system_font = None system_mono_font = None
system_prop_font = None
system_focus = None system_focus = None
inhibited = None inhibited = None
@ -347,10 +350,28 @@ class Config(object):
"""List all configured layouts""" """List all configured layouts"""
return(self.base.layouts.keys()) return(self.base.layouts.keys())
def get_system_font(self): def get_system_prop_font(self):
"""Look up the system font""" """Look up the system font"""
if self.system_font is not None: if self.system_prop_font is not None:
return(self.system_font) 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(): elif 'gconf' not in globals():
return return
else: else:
@ -359,11 +380,11 @@ class Config(object):
value = self.gconf.get( value = self.gconf.get(
'/desktop/gnome/interface/monospace_font_name') '/desktop/gnome/interface/monospace_font_name')
self.system_font = value.get_string() self.system_mono_font = value.get_string()
self.gconf.notify_add( self.gconf.notify_add(
'/desktop/gnome/interface/monospace_font_name', '/desktop/gnome/interface/monospace_font_name',
self.on_gconf_notify) self.on_gconf_notify)
return(self.system_font) return(self.system_mono_font)
def get_system_focus(self): def get_system_focus(self):
"""Look up the system focus setting""" """Look up the system focus setting"""

View File

@ -154,4 +154,9 @@ class EditableLabel(gtk.EventBox):
def set_custom(self): def set_custom(self):
"""Set the customness of the string to True""" """Set the customness of the string to True"""
self._custom = 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) gobject.type_register(EditableLabel)

View File

@ -1214,6 +1214,7 @@
<object class="GtkTable" id="table10"> <object class="GtkTable" id="table10">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">12</property> <property name="column_spacing">12</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
@ -1230,6 +1231,78 @@
</object> </object>
<packing> <packing>
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="title_system_font_checkbutton">
<property name="label" translatable="yes">_Use the system font</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_title_system_font_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="font_hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="font_selector_label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Font:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">font_selector</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFontButton" id="title_font_selector">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="focus_on_click">False</property>
<property name="title" translatable="yes">Choose A Titlebar Font</property>
<property name="use_font">True</property>
<signal name="font-set" handler="on_title_font_selector_font_set" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"/> <property name="y_options"/>
</packing> </packing>
</child> </child>

View File

@ -285,6 +285,19 @@ class PrefsEditor:
#Always split with profile #Always split with profile
widget = guiget('always_split_with_profile') widget = guiget('always_split_with_profile')
widget.set_active(self.config['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 ## Profile tab
# Populate the profile list # Populate the profile list
@ -373,7 +386,7 @@ class PrefsEditor:
widget = guiget('font_selector') widget = guiget('font_selector')
if self.config['use_system_font'] == True: 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: if fontname is not None:
widget.set_font_name(fontname) widget.set_font_name(fontname)
else: else:
@ -944,6 +957,11 @@ class PrefsEditor:
self.config['font'] = widget.get_font_name() self.config['font'] = widget.get_font_name()
self.config.save() 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): def on_title_receive_bg_color_color_set(self, widget):
"""Title receive background colour changed""" """Title receive background colour changed"""
self.config['title_receive_bg_color'] = color2hex(widget) self.config['title_receive_bg_color'] = color2hex(widget)
@ -1163,6 +1181,31 @@ class PrefsEditor:
widget.set_sensitive(not value) widget.set_sensitive(not value)
self.config['use_system_font'] = value self.config['use_system_font'] = value
self.config.save() 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): def on_reset_compatibility_clicked(self, widget):
"""Reset the confusing and annoying backspace/delete options to the """Reset the confusing and annoying backspace/delete options to the

View File

@ -612,7 +612,7 @@ class Terminal(gtk.VBox):
if not self.custom_font_size: if not self.custom_font_size:
try: try:
if self.config['use_system_font'] == True: if self.config['use_system_font'] == True:
font = self.config.get_system_font() font = self.config.get_system_mono_font()
else: else:
font = self.config['font'] font = self.config['font']
self.set_font(pango.FontDescription(font)) self.set_font(pango.FontDescription(font))
@ -1472,7 +1472,7 @@ class Terminal(gtk.VBox):
def zoom_orig(self): def zoom_orig(self):
"""Restore original font size""" """Restore original font size"""
if self.config['use_system_font'] == True: if self.config['use_system_font'] == True:
font = self.config.get_system_font() font = self.config.get_system_mono_font()
else: else:
font = self.config['font'] font = self.config['font']
dbg("Terminal::zoom_orig: restoring font to: %s" % font) dbg("Terminal::zoom_orig: restoring font to: %s" % font)

View File

@ -7,6 +7,7 @@ import gtk
import gobject import gobject
import random import random
import itertools import itertools
import pango
from version import APP_NAME from version import APP_NAME
from util import dbg from util import dbg
@ -105,6 +106,13 @@ class Titlebar(gtk.EventBox):
else: else:
self.label.set_text("%s %s" % (self.termtext, self.sizetext)) 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: if other:
term = self.terminal term = self.terminal
terminator = self.terminator terminator = self.terminator