diff --git a/src/gajim.py b/src/gajim.py
index 3e08f298d664e6324df53af50f1652f601ffb7e8..dab5a4feaea059a87c58a7833c313fee1c5131b9 100644
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -135,6 +135,7 @@ if os.name == 'nt':
 # PyGTK2.10+ only throws a warning
 warnings.filterwarnings('error', module='gtk')
 try:
+    import gobject
     import gtk
 except Warning, msg2:
     if str(msg2) == 'could not open display':
@@ -144,6 +145,8 @@ except Warning, msg2:
     sys.exit()
 warnings.resetwarnings()
 
+gobject.set_prgname('gajim')
+
 if os.name == 'nt':
     warnings.filterwarnings(action='ignore')
 
@@ -218,8 +221,6 @@ if not hasattr(gobject, 'timeout_add_seconds'):
         return gobject.timeout_add(time_sec * 1000, *args)
     gobject.timeout_add_seconds = timeout_add_seconds_fake
 
-gobject.set_prgname('gajim')
-
 import signal
 import gtkgui_helpers