set default font from the desktop default

application font setting (only Gnome for now)
This commit is contained in:
Dimitur Kirov 2005-08-11 22:06:26 +00:00
parent 0d68d8152a
commit ead3e5557e
3 changed files with 17 additions and 1 deletions

View File

@ -128,7 +128,7 @@ class Config:
'confirm_close_muc': [opt_bool, True], # confirm closing MUC window
'notify_on_file_complete': [opt_bool, True], # notif. on file complete
'file_transfers_port': [opt_int, 28011], # port, used for file transfers
'conversation_font': [opt_str, 'Sans 10'],
'conversation_font': [opt_str, ''],
# IEC standard says KiB = 1024 bytes KB = 1000 bytes
'use_kib_mib': [opt_bool, False],
'notify_on_all_muc_messages': [opt_bool, False],

View File

@ -239,6 +239,12 @@ class PreferencesWindow:
#Font for messages
font = gajim.config.get('conversation_font')
# try to set default font for the current desktop env
if font == '':
font = gtkgui_helpers.get_default_font()
if font is None:
font = 'Sans 10'
gajim.config.set('conversation_font', font)
self.xml.get_widget('conversation_fontbutton').set_font_name(font)
# on new message

View File

@ -28,6 +28,16 @@ i18n.init()
_ = i18n._
from common import gajim
def get_default_font():
''' Get the desktop setting for application font.
(Currently it works only for Gnome) '''
try:
import gconf
client = gconf.client_get_default()
except:
return None
return client.get_string('/desktop/gnome/interface/font_name')
def reduce_chars_newlines(text, max_chars = 0, max_lines = 0,
widget = None):
''' Cut the chars after 'max_chars' on each line