specify module version before importing

This commit is contained in:
Yann Leboulanger 2015-08-30 23:23:10 +02:00
parent 2f21fb657a
commit b851177f6a
4 changed files with 14 additions and 10 deletions

View file

@ -29,6 +29,7 @@
import os import os
import time import time
gi.require_version('GdkX11', '3.0')
from gi.repository import GdkX11 from gi.repository import GdkX11
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Gdk from gi.repository import Gdk

View file

@ -177,11 +177,12 @@ def get_default_font():
Xfce and last KDE it returns None on failure or else a string 'Font Size' Xfce and last KDE it returns None on failure or else a string 'Font Size'
""" """
try: try:
gi.require_version('GConf', '2.0')
from gi.repository import GConf from gi.repository import GConf
client = GConf.Client.get_default() client = GConf.Client.get_default()
value = client.get_string("/desktop/gnome/interface/font_name") value = client.get_string("/desktop/gnome/interface/font_name")
return value.decode("utf8") return value.decode("utf8")
except ImportError: except ValueError:
pass pass
# try to get Xfce default font # try to get Xfce default font

View file

@ -18,6 +18,7 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>. ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gtk from gi.repository import Gtk
gi.require_version('GtkSpell', '3.0')
from gi.repository import GtkSpell from gi.repository import GtkSpell
def ensure_attached(func): def ensure_attached(func):

View file

@ -2779,15 +2779,16 @@ class Interface:
gajim.ZEROCONF_ACC_NAME = account gajim.ZEROCONF_ACC_NAME = account
break break
# Is gnome configured to activate row on single click ? # Is gnome configured to activate row on single click ?
try: # try:
from gi.repository import GConf # gi.require_version('GConf', '2.0')
client = GConf.Client.get_default() # from gi.repository import GConf
click_policy = client.get_string( # client = GConf.Client.get_default()
'/apps/nautilus/preferences/click_policy') # click_policy = client.get_string(
if click_policy == 'single': # '/apps/nautilus/preferences/click_policy')
gajim.single_click = True # if click_policy == 'single':
except Exception: # gajim.single_click = True
pass # except Exception:
# pass
# add default status messages if there is not in the config file # add default status messages if there is not in the config file
if len(gajim.config.get_per('statusmsg')) == 0: if len(gajim.config.get_per('statusmsg')) == 0:
default = gajim.config.statusmsg_default default = gajim.config.statusmsg_default