ensure_unicode_string is back
This commit is contained in:
parent
3215a90778
commit
b5c71cd2f2
|
@ -306,3 +306,10 @@ def from_xs_boolean_to_python_boolean(value):
|
||||||
|
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
def ensure_unicode_string(s):
|
||||||
|
# py23 u'abc'.decode('utf-8') raises
|
||||||
|
# python24 does not. is python23 is ooold we can remove this func
|
||||||
|
if isistance(s, str):
|
||||||
|
s = s.decode('utf-8')
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ class PreferencesWindow:
|
||||||
font = gtkgui_helpers.get_default_font()
|
font = gtkgui_helpers.get_default_font()
|
||||||
if font is None:
|
if font is None:
|
||||||
font = 'Sans 10'
|
font = 'Sans 10'
|
||||||
gajim.config.set('conversation_font', font.decode('utf-8'))
|
gajim.config.set('conversation_font', font)
|
||||||
self.xml.get_widget('conversation_fontbutton').set_font_name(font)
|
self.xml.get_widget('conversation_fontbutton').set_font_name(font)
|
||||||
|
|
||||||
# on new message
|
# on new message
|
||||||
|
@ -730,7 +730,7 @@ class PreferencesWindow:
|
||||||
|
|
||||||
def on_preference_widget_font_set(self, widget, text):
|
def on_preference_widget_font_set(self, widget, text):
|
||||||
font = widget.get_font_name()
|
font = widget.get_font_name()
|
||||||
gajim.config.set(text, font.decode('utf-8'))
|
gajim.config.set(text, font)
|
||||||
self.update_text_font()
|
self.update_text_font()
|
||||||
self.plugin.save_config()
|
self.plugin.save_config()
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ from common import i18n
|
||||||
i18n.init()
|
i18n.init()
|
||||||
_ = i18n._
|
_ = i18n._
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import helpers
|
||||||
|
|
||||||
def get_default_font():
|
def get_default_font():
|
||||||
''' Get the desktop setting for application font
|
''' Get the desktop setting for application font
|
||||||
|
@ -38,7 +39,8 @@ def get_default_font():
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
return client.get_string('/desktop/gnome/interface/font_name')
|
return helpers.ensure_unicode_string(
|
||||||
|
client.get_string('/desktop/gnome/interface/font_name'))
|
||||||
|
|
||||||
# try to get xfce default font
|
# try to get xfce default font
|
||||||
# Xfce 4.2 adopts freedesktop.org's Base Directory Specification
|
# Xfce 4.2 adopts freedesktop.org's Base Directory Specification
|
||||||
|
@ -56,7 +58,8 @@ def get_default_font():
|
||||||
for line in file(xfce_config_file):
|
for line in file(xfce_config_file):
|
||||||
if line.find('name="Gtk/FontName"') != -1:
|
if line.find('name="Gtk/FontName"') != -1:
|
||||||
start = line.find('value="') + 7
|
start = line.find('value="') + 7
|
||||||
return line[start:line.find('"', start)]
|
return helpers.ensure_unicode_string(
|
||||||
|
line[start:line.find('"', start)])
|
||||||
except:
|
except:
|
||||||
#we talk about file
|
#we talk about file
|
||||||
print _('error: cannot open %s for reading') % xfce_config_file
|
print _('error: cannot open %s for reading') % xfce_config_file
|
||||||
|
@ -71,7 +74,7 @@ def get_default_font():
|
||||||
font_name = values[0]
|
font_name = values[0]
|
||||||
font_size = values[1]
|
font_size = values[1]
|
||||||
font_string = '%s %s' % (font_name, font_size) # Verdana 9
|
font_string = '%s %s' % (font_name, font_size) # Verdana 9
|
||||||
return font_string
|
return helpers.ensure_unicode_string(font_string)
|
||||||
except:
|
except:
|
||||||
#we talk about file
|
#we talk about file
|
||||||
print _('error: cannot open %s for reading') % kde_config_file
|
print _('error: cannot open %s for reading') % kde_config_file
|
||||||
|
|
Loading…
Reference in New Issue