Merge lp:~pitti/software-center/gi-fixes into lp:software-center

Proposed by Martin Pitt
Status: Merged
Merged at revision: 2113
Proposed branch: lp:~pitti/software-center/gi-fixes
Merge into: lp:software-center
Diff against target: 728 lines (+131/-61)
41 files modified
debian/changelog (+10/-0)
software-center (+2/-2)
softwarecenter/backend/reviews.py (+15/-5)
softwarecenter/backend/spawn_helper.py (+5/-1)
softwarecenter/backend/transactionswatcher.py (+6/-1)
softwarecenter/db/database.py (+6/-1)
softwarecenter/db/pkginfo.py (+5/-1)
softwarecenter/db/pkginfo_impl/aptcache.py (+16/-6)
softwarecenter/netstatus.py (+6/-1)
softwarecenter/ui/gtk/app.py (+2/-1)
softwarecenter/ui/gtk/appdetailsview.py (+1/-1)
softwarecenter/ui/gtk/appdetailsview_gtk.py (+1/-1)
softwarecenter/ui/gtk/appdetailsview_webkit.py (+1/-1)
softwarecenter/ui/gtk/appview.py (+1/-1)
softwarecenter/ui/gtk/availablepane.py (+1/-1)
softwarecenter/ui/gtk/catview_gtk.py (+1/-1)
softwarecenter/ui/gtk/catview_webkit.py (+1/-1)
softwarecenter/ui/gtk/channelpane.py (+1/-1)
softwarecenter/ui/gtk/historypane.py (+1/-1)
softwarecenter/ui/gtk/installedpane.py (+1/-1)
softwarecenter/ui/gtk/logindialog.py (+1/-1)
softwarecenter/ui/gtk/models/appstore.py (+1/-1)
softwarecenter/ui/gtk/models/viewswitcherlist.py (+1/-1)
softwarecenter/ui/gtk/navhistory.py (+1/-1)
softwarecenter/ui/gtk/pendingview.py (+1/-1)
softwarecenter/ui/gtk/purchaseview.py (+1/-1)
softwarecenter/ui/gtk/softwarepane.py (+1/-1)
softwarecenter/ui/gtk/viewswitcher.py (+1/-1)
softwarecenter/ui/gtk/widgets/actionbar.py (+1/-1)
softwarecenter/ui/gtk/widgets/animatedimage.py (+1/-1)
softwarecenter/ui/gtk/widgets/backforward.py (+1/-1)
softwarecenter/ui/gtk/widgets/carousel.py (+1/-1)
softwarecenter/ui/gtk/widgets/description.py (+1/-1)
softwarecenter/ui/gtk/widgets/mkit.py (+1/-1)
softwarecenter/ui/gtk/widgets/pathbar_gtk_atk.py (+1/-1)
softwarecenter/ui/gtk/widgets/reviews.py (+1/-1)
softwarecenter/ui/gtk/widgets/searchentry.py (+1/-1)
softwarecenter/ui/gtk/widgets/thumbnail.py (+1/-1)
softwarecenter/ui/gtk/widgets/videoplayer.py (+1/-1)
softwarecenter/ui/gtk/widgets/wkwidget.py (+1/-1)
softwarecenter/utils.py (+28/-12)
To merge this branch: bzr merge lp:~pitti/software-center/gi-fixes
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+71854@code.launchpad.net

Description of the change

Newer pygobject versions are much stricter about not mixing static and dynamic
bindings, for various reasons. It works with 2.28 (although it's brittle), but
is going to fail with newer pygobject versions such as 2.90.1:

$ jhbuild run ./software-center-gtk3
/home/martin-scratch/gnome/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
2011-08-17 13:42:47,746 - softwarecenter - INFO - Using data (UI, xapian) from current dir
2011-08-17 13:42:47,876 - softwarecenter.ui.gtk3.em - INFO - EM's: 17 15 21
Segmentation fault (core dumped)

Please see

  http://mail.gnome.org/archives/python-hackers-list/2011-August/msg00005.html

for some more details.

This branch adds checks whether we use GI or static bindings, and imports just
one or the other.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Conversely, the GTK2 version will crash as well, as it mixes stuff with GObject:

$ software-center
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
Traceback (most recent call last):
  File "/usr/bin/software-center", line 136, in <module>
    from softwarecenter.ui.gtk.app import SoftwareCenterApp
  File "/usr/share/software-center/softwarecenter/ui/gtk/app.py", line 70, in <module>
    from viewswitcher import ViewSwitcher
  File "/usr/share/software-center/softwarecenter/ui/gtk/viewswitcher.py", line 34, in <module>
    from models.viewswitcherlist import ViewSwitcherList
  File "/usr/share/software-center/softwarecenter/ui/gtk/models/viewswitcherlist.py", line 33, in <module>
    from softwarecenter.ui.gtk.widgets.animatedimage import AnimatedImage
  File "/usr/share/software-center/softwarecenter/ui/gtk/widgets/animatedimage.py", line 100, in <module>
    class CellRendererAnimatedImage(gtk.CellRendererPixbuf):
  File "/usr/lib/python2.7/dist-packages/gobject/__init__.py", line 60, in __init__
    cls._type_register(cls.__dict__)
  File "/usr/lib/python2.7/dist-packages/gobject/__init__.py", line 115, in _type_register
    type_register(cls, namespace.get('__gtype_name__'))
TypeError: Error when calling the metaclass bases
    could not get typecode from object

(This is with pygobject 2.90 installed)

lp:~pitti/software-center/gi-fixes updated
2113. By Michael Vogt

merged lp:~pitti/software-center/gi-fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-08-17 09:11:57 +0000
3+++ debian/changelog 2011-08-17 11:47:24 +0000
4@@ -1,3 +1,13 @@
5+software-center (4.1.16) UNRELEASED; urgency=low
6+
7+ * software-center: Import the static gobject, not the GI module, as this
8+ uses pygtk.
9+ * All files: Do not import the gi.repository.GObject module with static
10+ bindings like gtk, and vice versa. It is brittle now, and breaking with
11+ newer pygobject versions like 2.90.1.
12+
13+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 17 Aug 2011 12:37:23 +0200
14+
15 software-center (4.1.15) oneiric; urgency=low
16
17 [ Michael Vogt ]
18
19=== modified file 'software-center'
20--- software-center 2011-08-15 14:53:08 +0000
21+++ software-center 2011-08-17 11:47:24 +0000
22@@ -29,8 +29,8 @@
23 # thread init is also required otherwise both gst and webkit are unhappy
24 import pygtk
25 pygtk.require ("2.0")
26-from gi.repository import GObject
27-GObject.threads_init()
28+import gobject
29+gobject.threads_init()
30 import gtk
31
32 import gettext
33
34=== modified file 'softwarecenter/backend/reviews.py'
35--- softwarecenter/backend/reviews.py 2011-08-13 08:50:01 +0000
36+++ softwarecenter/backend/reviews.py 2011-08-17 11:47:24 +0000
37@@ -18,10 +18,8 @@
38 # this program; if not, write to the Free Software Foundation, Inc.,
39 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
40
41-from gi.repository import GObject
42-
43+import sys
44 import datetime
45-import gio
46 import gzip
47 import logging
48 import operator
49@@ -31,6 +29,15 @@
50 import subprocess
51 import time
52
53+if 'gobject' in sys.modules:
54+ have_gi = False
55+ import gobject as GObject
56+ import gio as Gio
57+else:
58+ have_gi = True
59+ from gi.repository import GObject
60+ from gi.repository import Gio
61+
62 # py3 compat
63 try:
64 import cPickle as pickle
65@@ -739,7 +746,10 @@
66 'version' : 'any',
67 }
68 LOG.debug("looking for review at '%s'" % url)
69- f=gio.File(url)
70+ if have_gi:
71+ f=Gio.File.new_for_uri(url)
72+ else:
73+ f=Gio.File(url)
74 f.set_data("app", app)
75 f.set_data("callback", callback)
76 f.load_contents_async(self._gio_review_download_complete_callback)
77@@ -774,7 +784,7 @@
78
79 def refresh_review_stats(self, callback):
80 """ get the review statists and call callback when its there """
81- f=gio.File(self.distro.REVIEW_STATS_URL)
82+ f=Gio.File(self.distro.REVIEW_STATS_URL)
83 f.set_data("callback", callback)
84 f.load_contents_async(self._gio_review_stats_download_finished_callback)
85
86
87=== modified file 'softwarecenter/backend/spawn_helper.py'
88--- softwarecenter/backend/spawn_helper.py 2011-08-15 14:52:01 +0000
89+++ softwarecenter/backend/spawn_helper.py 2011-08-17 11:47:24 +0000
90@@ -26,11 +26,15 @@
91 except ImportError:
92 import pickle
93
94-from gi.repository import GObject
95 import logging
96 import os
97+import sys
98 import json
99
100+if 'gobject' in sys.modules:
101+ import gobject as GObject
102+else:
103+ from gi.repository import GObject
104
105 LOG = logging.getLogger(__name__)
106
107
108=== modified file 'softwarecenter/backend/transactionswatcher.py'
109--- softwarecenter/backend/transactionswatcher.py 2011-08-10 12:12:09 +0000
110+++ softwarecenter/backend/transactionswatcher.py 2011-08-17 11:47:24 +0000
111@@ -16,7 +16,12 @@
112 # this program; if not, write to the Free Software Foundation, Inc.,
113 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
114
115-from gi.repository import GObject
116+import sys
117+
118+if 'gobject' in sys.modules:
119+ import gobject as GObject
120+else:
121+ from gi.repository import GObject
122
123 class BaseTransaction(GObject.GObject):
124 """
125
126=== modified file 'softwarecenter/db/database.py'
127--- softwarecenter/db/database.py 2011-08-09 08:47:43 +0000
128+++ softwarecenter/db/database.py 2011-08-17 11:47:24 +0000
129@@ -16,16 +16,21 @@
130 # this program; if not, write to the Free Software Foundation, Inc.,
131 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
132
133-from gi.repository import GObject
134 import locale
135 import logging
136 import os
137 import re
138 import string
139 import threading
140+import sys
141 import xapian
142 from softwarecenter.db.application import Application
143
144+if 'gobject' in sys.modules:
145+ import gobject as GObject
146+else:
147+ from gi.repository import GObject
148+
149 #from softwarecenter.utils import *
150 from softwarecenter.enums import (
151 AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME,
152
153=== modified file 'softwarecenter/db/pkginfo.py'
154--- softwarecenter/db/pkginfo.py 2011-08-13 08:50:01 +0000
155+++ softwarecenter/db/pkginfo.py 2011-08-17 11:47:24 +0000
156@@ -16,7 +16,11 @@
157 # this program; if not, write to the Free Software Foundation, Inc.,
158 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
159
160-from gi.repository import GObject
161+import sys
162+if 'gobject' in sys.modules:
163+ import gobject as GObject
164+else:
165+ from gi.repository import GObject
166
167 class _Version:
168 @property
169
170=== modified file 'softwarecenter/db/pkginfo_impl/aptcache.py'
171--- softwarecenter/db/pkginfo_impl/aptcache.py 2011-08-13 08:50:01 +0000
172+++ softwarecenter/db/pkginfo_impl/aptcache.py 2011-08-17 11:47:24 +0000
173@@ -21,10 +21,18 @@
174 import apt
175 import apt_pkg
176 import logging
177-from gi.repository import GObject
178-import gio
179+import sys
180 import os
181
182+if 'gobject' in sys.modules:
183+ have_gi = False
184+ import gobject as GObject
185+ import gio as Gio
186+else:
187+ have_gi = True
188+ from gi.repository import GObject
189+ from gi.repository import Gio
190+
191 from softwarecenter.enums import PkgStates
192
193 from softwarecenter.db.pkginfo import PackageInfo, _Version
194@@ -108,9 +116,11 @@
195 self._ready = False
196 self._timeout_id = None
197 # setup monitor watch for install/remove changes
198- self.apt_finished_stamp=gio.File(self.APT_FINISHED_STAMP)
199- self.apt_finished_monitor = self.apt_finished_stamp.monitor_file(
200- gio.FILE_MONITOR_NONE)
201+ if have_gi:
202+ self.apt_finished_stamp=Gio.File.new_for_path(self.APT_FINISHED_STAMP)
203+ else:
204+ self.apt_finished_stamp=Gio.File(self.APT_FINISHED_STAMP)
205+ self.apt_finished_monitor = self.apt_finished_stamp.monitor_file(0, None)
206 self.apt_finished_monitor.connect(
207 "changed", self._on_apt_finished_stamp_changed)
208 # this is fast, so ok
209@@ -225,7 +235,7 @@
210 def __contains__(self, k):
211 return self._cache.__contains__(k)
212 def _on_apt_finished_stamp_changed(self, monitor, afile, other_file, event):
213- if not event == gio.FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
214+ if not event == Gio.FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
215 return
216 if self._timeout_id:
217 GObject.source_remove(self._timeout_id)
218
219=== modified file 'softwarecenter/netstatus.py'
220--- softwarecenter/netstatus.py 2011-08-09 08:47:43 +0000
221+++ softwarecenter/netstatus.py 2011-08-17 11:47:24 +0000
222@@ -19,11 +19,16 @@
223
224
225 import dbus
226-from gi.repository import GObject
227+import sys
228 import logging
229
230 from dbus.mainloop.glib import DBusGMainLoop
231
232+if 'gobject' in sys.modules:
233+ import gobject as GObject
234+else:
235+ from gi.repository import GObject
236+
237 # enums
238 class NetState(object):
239 """ enums for network manager status """
240
241=== modified file 'softwarecenter/ui/gtk/app.py'
242--- softwarecenter/ui/gtk/app.py 2011-08-11 09:25:56 +0000
243+++ softwarecenter/ui/gtk/app.py 2011-08-17 11:47:24 +0000
244@@ -23,7 +23,7 @@
245 import dbus.service
246 import gettext
247 import logging
248-from gi.repository import GObject
249+import gobject as GObject
250 import gtk
251 import os
252 import subprocess
253@@ -31,6 +31,7 @@
254 import xapian
255 import glob
256
257+
258 # purely to initialize the netstatus
259 import softwarecenter.netstatus
260 from softwarecenter.netstatus import network_state_is_connected
261
262=== modified file 'softwarecenter/ui/gtk/appdetailsview.py'
263--- softwarecenter/ui/gtk/appdetailsview.py 2011-07-14 16:36:07 +0000
264+++ softwarecenter/ui/gtk/appdetailsview.py 2011-08-17 11:47:24 +0000
265@@ -21,7 +21,7 @@
266 import dialogs
267
268 import urllib
269-from gi.repository import GObject
270+import gobject as GObject
271
272 from gettext import gettext as _
273
274
275=== modified file 'softwarecenter/ui/gtk/appdetailsview_gtk.py'
276--- softwarecenter/ui/gtk/appdetailsview_gtk.py 2011-08-16 15:57:51 +0000
277+++ softwarecenter/ui/gtk/appdetailsview_gtk.py 2011-08-17 11:47:24 +0000
278@@ -16,7 +16,7 @@
279 # this program; if not, write to the Free Software Foundation, Inc.,
280 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
281
282-from gi.repository import GObject
283+import gobject as GObject
284
285 import atk
286 import datetime
287
288=== modified file 'softwarecenter/ui/gtk/appdetailsview_webkit.py'
289--- softwarecenter/ui/gtk/appdetailsview_webkit.py 2011-07-15 14:24:08 +0000
290+++ softwarecenter/ui/gtk/appdetailsview_webkit.py 2011-08-17 11:47:24 +0000
291@@ -17,7 +17,7 @@
292 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
293
294 import gio
295-from gi.repository import GObject
296+import gobject as GObject
297 import gtk
298 import json
299 import logging
300
301=== modified file 'softwarecenter/ui/gtk/appview.py'
302--- softwarecenter/ui/gtk/appview.py 2011-08-12 21:50:40 +0000
303+++ softwarecenter/ui/gtk/appview.py 2011-08-17 11:47:24 +0000
304@@ -18,7 +18,7 @@
305
306 from __future__ import with_statement
307
308-from gi.repository import GObject
309+import gobject as GObject
310 import gtk
311 import logging
312 import os
313
314=== modified file 'softwarecenter/ui/gtk/availablepane.py'
315--- softwarecenter/ui/gtk/availablepane.py 2011-08-10 11:23:23 +0000
316+++ softwarecenter/ui/gtk/availablepane.py 2011-08-17 11:47:24 +0000
317@@ -17,7 +17,7 @@
318 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
319
320 import gettext
321-from gi.repository import GObject
322+import gobject as GObject
323 import gtk
324 import logging
325 import os
326
327=== modified file 'softwarecenter/ui/gtk/catview_gtk.py'
328--- softwarecenter/ui/gtk/catview_gtk.py 2011-07-30 12:07:18 +0000
329+++ softwarecenter/ui/gtk/catview_gtk.py 2011-08-17 11:47:24 +0000
330@@ -1,6 +1,6 @@
331 import atk
332 import gtk
333-from gi.repository import GObject
334+import gobject as GObject
335 import gettext
336 import logging
337 import xapian
338
339=== modified file 'softwarecenter/ui/gtk/catview_webkit.py'
340--- softwarecenter/ui/gtk/catview_webkit.py 2011-07-14 16:36:07 +0000
341+++ softwarecenter/ui/gtk/catview_webkit.py 2011-08-17 11:47:24 +0000
342@@ -16,7 +16,7 @@
343 # this program; if not, write to the Free Software Foundation, Inc.,
344 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
345
346-from gi.repository import GObject
347+import gobject as GObject
348 import gtk
349 import logging
350 import os
351
352=== modified file 'softwarecenter/ui/gtk/channelpane.py'
353--- softwarecenter/ui/gtk/channelpane.py 2011-08-10 11:23:23 +0000
354+++ softwarecenter/ui/gtk/channelpane.py 2011-08-17 11:47:24 +0000
355@@ -23,7 +23,7 @@
356 import os
357 import sys
358 import xapian
359-from gi.repository import GObject
360+import gobject as GObject
361
362 from gettext import gettext as _
363
364
365=== modified file 'softwarecenter/ui/gtk/historypane.py'
366--- softwarecenter/ui/gtk/historypane.py 2011-08-10 11:23:23 +0000
367+++ softwarecenter/ui/gtk/historypane.py 2011-08-17 11:47:24 +0000
368@@ -18,7 +18,7 @@
369 # this program. If not, see <http://www.gnu.org/licenses/>.
370
371
372-from gi.repository import GObject
373+import gobject as GObject
374 import gtk
375 import logging
376
377
378=== modified file 'softwarecenter/ui/gtk/installedpane.py'
379--- softwarecenter/ui/gtk/installedpane.py 2011-08-10 11:23:23 +0000
380+++ softwarecenter/ui/gtk/installedpane.py 2011-08-17 11:47:24 +0000
381@@ -22,7 +22,7 @@
382 import os
383 import sys
384 import xapian
385-from gi.repository import GObject
386+import gobject as GObject
387
388 from gettext import gettext as _
389 import dialogs
390
391=== modified file 'softwarecenter/ui/gtk/logindialog.py'
392--- softwarecenter/ui/gtk/logindialog.py 2011-07-14 16:36:07 +0000
393+++ softwarecenter/ui/gtk/logindialog.py 2011-08-17 11:47:24 +0000
394@@ -16,7 +16,7 @@
395 # this program; if not, write to the Free Software Foundation, Inc.,
396 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
397
398-from gi.repository import GObject
399+import gobject as GObject
400 GObject.threads_init()
401 import gtk
402 import logging
403
404=== modified file 'softwarecenter/ui/gtk/models/appstore.py'
405--- softwarecenter/ui/gtk/models/appstore.py 2011-08-05 13:12:19 +0000
406+++ softwarecenter/ui/gtk/models/appstore.py 2011-08-17 11:47:24 +0000
407@@ -17,7 +17,7 @@
408 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
409
410 import copy
411-from gi.repository import GObject
412+import gobject as GObject
413 import gtk
414 import logging
415 import math
416
417=== modified file 'softwarecenter/ui/gtk/models/viewswitcherlist.py'
418--- softwarecenter/ui/gtk/models/viewswitcherlist.py 2011-07-14 17:16:15 +0000
419+++ softwarecenter/ui/gtk/models/viewswitcherlist.py 2011-08-17 11:47:24 +0000
420@@ -17,7 +17,7 @@
421 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
422
423
424-from gi.repository import GObject
425+import gobject as GObject
426 import gtk
427 import logging
428 import xapian
429
430=== modified file 'softwarecenter/ui/gtk/navhistory.py'
431--- softwarecenter/ui/gtk/navhistory.py 2011-07-14 16:36:07 +0000
432+++ softwarecenter/ui/gtk/navhistory.py 2011-08-17 11:47:24 +0000
433@@ -16,7 +16,7 @@
434 # this program; if not, write to the Free Software Foundation, Inc.,
435 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
436
437-from gi.repository import GObject
438+import gobject as GObject
439 import logging
440
441 from softwarecenter.enums import NavButtons
442
443=== modified file 'softwarecenter/ui/gtk/pendingview.py'
444--- softwarecenter/ui/gtk/pendingview.py 2011-07-15 14:24:08 +0000
445+++ softwarecenter/ui/gtk/pendingview.py 2011-08-17 11:47:24 +0000
446@@ -16,7 +16,7 @@
447 # this program; if not, write to the Free Software Foundation, Inc.,
448 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
449
450-from gi.repository import GObject
451+import gobject as GObject
452 import dbus
453 import gtk
454 import logging
455
456=== modified file 'softwarecenter/ui/gtk/purchaseview.py'
457--- softwarecenter/ui/gtk/purchaseview.py 2011-08-09 12:33:44 +0000
458+++ softwarecenter/ui/gtk/purchaseview.py 2011-08-17 11:47:24 +0000
459@@ -17,7 +17,7 @@
460 # this program; if not, write to the Free Software Foundation, Inc.,
461 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
462
463-from gi.repository import GObject
464+import gobject as GObject
465 import gtk
466 import logging
467 import os
468
469=== modified file 'softwarecenter/ui/gtk/softwarepane.py'
470--- softwarecenter/ui/gtk/softwarepane.py 2011-08-01 16:42:21 +0000
471+++ softwarecenter/ui/gtk/softwarepane.py 2011-08-17 11:47:24 +0000
472@@ -21,7 +21,7 @@
473 import dbus
474 import gettext
475 import dialogs
476-from gi.repository import GObject
477+import gobject as GObject
478 import gtk
479 import logging
480 import xapian
481
482=== modified file 'softwarecenter/ui/gtk/viewswitcher.py'
483--- softwarecenter/ui/gtk/viewswitcher.py 2011-08-10 11:23:23 +0000
484+++ softwarecenter/ui/gtk/viewswitcher.py 2011-08-17 11:47:24 +0000
485@@ -16,7 +16,7 @@
486 # this program; if not, write to the Free Software Foundation, Inc.,
487 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
488
489-from gi.repository import GObject
490+import gobject as GObject
491 import gtk
492 import pango
493 import logging
494
495=== modified file 'softwarecenter/ui/gtk/widgets/actionbar.py'
496--- softwarecenter/ui/gtk/widgets/actionbar.py 2011-08-01 16:42:21 +0000
497+++ softwarecenter/ui/gtk/widgets/actionbar.py 2011-08-17 11:47:24 +0000
498@@ -18,7 +18,7 @@
499
500 import gtk
501 import logging
502-from gi.repository import GObject
503+import gobject as GObject
504
505 LOG = logging.getLogger(__name__)
506
507
508=== modified file 'softwarecenter/ui/gtk/widgets/animatedimage.py'
509--- softwarecenter/ui/gtk/widgets/animatedimage.py 2011-07-14 16:36:07 +0000
510+++ softwarecenter/ui/gtk/widgets/animatedimage.py 2011-08-17 11:47:24 +0000
511@@ -17,7 +17,7 @@
512 # this program; if not, write to the Free Software Foundation, Inc.,
513 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
514
515-from gi.repository import GObject
516+import gobject as GObject
517 import gtk
518 import os
519 import glob
520
521=== modified file 'softwarecenter/ui/gtk/widgets/backforward.py'
522--- softwarecenter/ui/gtk/widgets/backforward.py 2011-07-14 16:36:07 +0000
523+++ softwarecenter/ui/gtk/widgets/backforward.py 2011-08-17 11:47:24 +0000
524@@ -19,7 +19,7 @@
525
526 import atk
527 import gtk
528-from gi.repository import GObject
529+import gobject as GObject
530 import mkit
531
532 from gettext import gettext as _
533
534=== modified file 'softwarecenter/ui/gtk/widgets/carousel.py'
535--- softwarecenter/ui/gtk/widgets/carousel.py 2011-08-02 10:17:24 +0000
536+++ softwarecenter/ui/gtk/widgets/carousel.py 2011-08-17 11:47:24 +0000
537@@ -1,7 +1,7 @@
538 import atk
539 import cairo
540 import gtk
541-from gi.repository import GObject
542+import gobject as GObject
543 import logging
544 import pangocairo
545 import random
546
547=== modified file 'softwarecenter/ui/gtk/widgets/description.py'
548--- softwarecenter/ui/gtk/widgets/description.py 2011-07-14 16:36:07 +0000
549+++ softwarecenter/ui/gtk/widgets/description.py 2011-08-17 11:47:24 +0000
550@@ -18,7 +18,7 @@
551
552 import gtk
553 import pango
554-from gi.repository import GObject
555+import gobject as GObject
556
557 from softwarecenter.utils import normalize_package_description
558
559
560=== modified file 'softwarecenter/ui/gtk/widgets/mkit.py'
561--- softwarecenter/ui/gtk/widgets/mkit.py 2011-07-14 16:36:07 +0000
562+++ softwarecenter/ui/gtk/widgets/mkit.py 2011-08-17 11:47:24 +0000
563@@ -23,7 +23,7 @@
564 import gtk
565 import cairo
566 import pango
567-from gi.repository import GObject
568+import gobject as GObject
569 import pangocairo
570 from math import pi, cos, sin
571
572
573=== modified file 'softwarecenter/ui/gtk/widgets/pathbar_gtk_atk.py'
574--- softwarecenter/ui/gtk/widgets/pathbar_gtk_atk.py 2011-07-14 16:36:07 +0000
575+++ softwarecenter/ui/gtk/widgets/pathbar_gtk_atk.py 2011-08-17 11:47:24 +0000
576@@ -17,7 +17,7 @@
577 # along with this program. If not, see <http://www.gnu.org/licenses/>.
578
579 import atk
580-from gi.repository import GObject
581+import gobject as GObject
582 import gtk
583 import logging
584 import mkit
585
586=== modified file 'softwarecenter/ui/gtk/widgets/reviews.py'
587--- softwarecenter/ui/gtk/widgets/reviews.py 2011-07-14 16:36:07 +0000
588+++ softwarecenter/ui/gtk/widgets/reviews.py 2011-08-17 11:47:24 +0000
589@@ -23,7 +23,7 @@
590 import pygtk
591 pygtk.require ("2.0")
592 import datetime
593-from gi.repository import GObject
594+import gobject as GObject
595 import cairo
596 import gtk
597 import mkit
598
599=== modified file 'softwarecenter/ui/gtk/widgets/searchentry.py'
600--- softwarecenter/ui/gtk/widgets/searchentry.py 2011-07-14 16:36:07 +0000
601+++ softwarecenter/ui/gtk/widgets/searchentry.py 2011-08-17 11:47:24 +0000
602@@ -22,7 +22,7 @@
603 # Place, Suite 330, Boston, MA 02111-1307 USA
604
605 import gtk
606-from gi.repository import GObject
607+import gobject as GObject
608
609 from gettext import gettext as _
610
611
612=== modified file 'softwarecenter/ui/gtk/widgets/thumbnail.py'
613--- softwarecenter/ui/gtk/widgets/thumbnail.py 2011-07-14 16:36:07 +0000
614+++ softwarecenter/ui/gtk/widgets/thumbnail.py 2011-08-17 11:47:24 +0000
615@@ -1,7 +1,7 @@
616
617 import atk
618 import gtk
619-from gi.repository import GObject
620+import gobject as GObject
621 import mkit
622 import pangocairo
623 import logging
624
625=== modified file 'softwarecenter/ui/gtk/widgets/videoplayer.py'
626--- softwarecenter/ui/gtk/widgets/videoplayer.py 2011-07-14 16:36:07 +0000
627+++ softwarecenter/ui/gtk/widgets/videoplayer.py 2011-08-17 11:47:24 +0000
628@@ -17,7 +17,7 @@
629 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
630
631 import sys
632-from gi.repository import GObject
633+import gobject as GObject
634 import gtk
635 import logging
636 import pygst
637
638=== modified file 'softwarecenter/ui/gtk/widgets/wkwidget.py'
639--- softwarecenter/ui/gtk/widgets/wkwidget.py 2011-07-15 14:24:08 +0000
640+++ softwarecenter/ui/gtk/widgets/wkwidget.py 2011-08-17 11:47:24 +0000
641@@ -16,7 +16,7 @@
642 # this program; if not, write to the Free Software Foundation, Inc.,
643 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
644
645-from gi.repository import GObject
646+import gobject as GObject
647 import gtk
648 import logging
649 import os
650
651=== modified file 'softwarecenter/utils.py'
652--- softwarecenter/utils.py 2011-08-13 08:50:01 +0000
653+++ softwarecenter/utils.py 2011-08-17 11:47:24 +0000
654@@ -16,12 +16,18 @@
655 # this program; if not, write to the Free Software Foundation, Inc.,
656 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
657
658-from gi.repository import GObject
659-
660 # FIXME: use gmenu GIR instead
661 import gmenu
662 import gettext
663-import gio
664+import sys
665+if 'gobject' in sys.modules:
666+ have_gi = False
667+ import gobject as GObject
668+ import gio as Gio
669+else:
670+ have_gi = True
671+ from gi.repository import GObject
672+ from gi.repository import Gio
673 import logging
674 import math
675 import os
676@@ -526,19 +532,29 @@
677 self.emit("file-download-complete", self.dest_file_path)
678 return
679
680- f = gio.File(url)
681- # first check if the url is reachable
682- f.query_info_async(gio.FILE_ATTRIBUTE_STANDARD_SIZE,
683- self._check_url_reachable_and_then_download_cb)
684+ if have_gi:
685+ f = Gio.File.new_for_uri(url)
686+ # first check if the url is reachable
687+ f.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_SIZE, 0, 0, None,
688+ self._check_url_reachable_and_then_download_cb,
689+ None)
690+ else:
691+ f = Gio.File(url)
692+ # first check if the url is reachable
693+ f.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,
694+ self._check_url_reachable_and_then_download_cb)
695
696- def _check_url_reachable_and_then_download_cb(self, f, result):
697+ def _check_url_reachable_and_then_download_cb(self, f, result, user_data=None):
698 self.LOG.debug("_check_url_reachable_and_then_download_cb: %s" % f)
699 try:
700 result = f.query_info_finish(result)
701 self.emit('file-url-reachable', True)
702 self.LOG.debug("file reachable %s" % self.url)
703 # url is reachable, now download the file
704- f.load_contents_async(self._file_download_complete_cb)
705+ if have_gi:
706+ f.load_contents_async(None, self._file_download_complete_cb, None)
707+ else:
708+ f.load_contents_async(self._file_download_complete_cb)
709 except GObject.GError as e:
710 self.LOG.debug("file *not* reachable %s" % self.url)
711 self.emit('file-url-reachable', False)
712@@ -552,13 +568,13 @@
713 # The first element is the actual content so let's grab that
714 try:
715 content = f.load_contents_finish(result)[0]
716- except gio.Error as e:
717+ except Gio.Error as e:
718 # i witnissed a strange error[1], so make the loader robust in this
719 # situation
720 # 1. content = f.load_contents_finish(result)[0]
721- # gio.Error: DBus error org.freedesktop.DBus.Error.NoReply
722+ # Gio.Error: DBus error org.freedesktop.DBus.Error.NoReply
723 self.LOG.debug(e)
724- self.emit('error', gio.Error, e)
725+ self.emit('error', Gio.Error, e)
726 return
727
728 outputfile = open(self.dest_file_path, "w")