Commits

Jaso...@gmail.com  committed 4ee95c7

Random fixes for unit tests

  • Participants
  • Parent commits 689d435
  • Branches gi

Comments (0)

Files changed (6)

File pygtkhelpers/gthreads.py

 import threading, thread
 import Queue as queue
 import subprocess
-from gi.repository import GObject
+import gobject
 import time
 import sys
 from gi.repository import Gdk
     """
     Gdk.threads_init()
     Gdk.threads_enter()
-    GObject.threads_init() #the glib mainloop doesn't love us else
+    gobject.threads_init() #the glib mainloop doesn't love us else
 
 class Lock(object):
     def __enter__(self):
     should stick code that affects the UI.
     """
     def __init__(self, work_callback=None, loop_callback=None, daemon=True):
-        GObject.threads_init() #the glib mainloop doesn't love us else
+        gobject.threads_init() #the glib mainloop doesn't love us else
         self.counter = 0
         self.daemon = daemon
 
     def _work_callback(self, counter, *args, **kwargs):
         ret = self.work_callback(*args, **kwargs)
         #tuple necessary cause idle_add wont allow more args
-        GObject.idle_add(self._loop_callback, (counter, ret))
+        gobject.idle_add(self._loop_callback, (counter, ret))
 
     def _loop_callback(self, vargs):
         counter, ret = vargs
         Gtk.main()
     """
     def __init__(self, work_callback, loop_callback, complete_callback=None,
-                 priority=GObject.PRIORITY_DEFAULT_IDLE,
+                 priority=gobject.PRIORITY_DEFAULT_IDLE,
                  pass_generator=False):
         AsyncTask.__init__(self, work_callback, loop_callback)
         self.priority = priority
             #XXX: what about checking self.counter?
             if self._stopped:
                 thread.exit()
-            GObject.idle_add(self._loop_callback, (counter, ret),
+            gobject.idle_add(self._loop_callback, (counter, ret),
                              priority=self.priority)
         if self._complete_callback is not None:
             def idle(callback=self._complete_callback):
                 with lock:
                     callback()
-            GObject.idle_add(self._complete_callback,
+            gobject.idle_add(self._complete_callback,
                              priority=self.priority)
 
     def stop(self):
     def idle():
         with lock:
             return bool(func(*args, **kwargs))
-    return GObject.idle_add(idle)
+    return gobject.idle_add(idle)
 
 
 def invoke_in_mainloop(func, *args, **kwargs):

File pygtkhelpers/ui/dialogs.py

 #XXX: i18n
 import os
 
-from gi.repository import Gtk
+from gi.repository import Gtk, GObject
 from functools import partial
 
 image_types = {
         assert type in image_types, 'not a valid type'
         assert buttons in button_types, 'not a valid set of buttons'
 
-        GObject.GObject.__init__(self, ' ', parent, flags)
+        Gtk.Dialog.__init__(self, title=' ', parent=parent, flags=flags)
         self.set_border_width(5)
-        self.set_has_separator(False)
         self.set_resizable(False)
         self.set_skip_taskbar_hint(True)
 
             label.set_selectable(True)
             label.set_alignment(0.0, 0.5)
 
-        hbox = Gtk.HBox(False, 12)
+        hbox = Gtk.HBox(homogeneous=False, spacing=12)
         hbox.set_border_width(5)
-        hbox.pack_start(self.image, False, False)
+        hbox.pack_start(self.image, False, False, 0)
 
-        self.label_vbox = vbox = Gtk.VBox(False, 0)
-        hbox.pack_start(vbox, False, False)
-        vbox.pack_start(self.primary, False, False)
-        vbox.pack_start(self.secondary, False, False)
+        self.label_vbox = vbox = Gtk.VBox(homogeneous=False, spacing=0)
+        hbox.pack_start(vbox, False, False, 0)
+        vbox.pack_start(self.primary, False, False, 0)
+        vbox.pack_start(self.secondary, False, False, 0)
 
-        self.expander = Gtk.expander_new_with_mnemonic(
+        self.expander = Gtk.Expander.new_with_mnemonic(
                 'show more _details'
                 )
         self.expander.set_spacing(5)
         self.expander.add(self.details)
-        vbox.pack_start(self.expander, False, False)
-        self.vbox.pack_start(hbox, False, False)
+        vbox.pack_start(self.expander, False, False, 0)
+	self.vbox = self.get_child()
+        self.vbox.pack_start(hbox, False, False, 0)
         hbox.show_all()
         self.expander.hide()
         self._buttons = button_types[buttons]

File pygtkhelpers/ui/objectlist/column.py

             view_cell = cell.create_renderer(self, objectlist)
             view_cell.set_data('pygtkhelpers::column', self)
             #XXX: better control over packing
-            col.pack_start(view_cell, True)
+            col.pack_start(view_cell, True, True, 0)
             col.set_cell_data_func(view_cell, cell.cell_data_func)
         col.set_reorderable(True)
         col.set_sort_indicator(False)

File pygtkhelpers/ui/widgets.py

     gsignal('content-changed')
 
     def __init__(self):
-        GObject.GObject.__init__(self, spacing=3)
+        Gtk.VBox.__init__(self, spacing=3)
         self.set_border_width(6)
         self.set_size_request(0, 150)
 
     __gtype_name__ = 'PyGTKHelpersSimpleComboBox'
 
     def __init__(self, choices=None, default=None):
-        GObject.GObject.__init__(self)
+        Gtk.ComboBox.__init__(self)
         if choices and not default:
             raise ValueError('default choice necessary')
         self.store = Gtk.ListStore(str, str)
     """A evil utility class that hijacks a objectlist and forces ordering onto its model
     """
     def __init__(self, objectlist, attribute_list, default):
-        GObject.GObject.__init__(self, spacing=3)
+        Gtk.HBox.__init__(self, spacing=3)
         self.set_border_width(3)
         from pygtkhelpers.ui.widgets import SimpleComboBox
         from pygtkhelpers.proxy import GtkComboBoxProxy

File tests/test_proxy.py

 
 def test_widget_update_then_read(proxy, widget, attr, value):
     widget.set_property(attr, value)
-    assert proxy.read() == value
+    #for some reason a Gdk.Color.__eq__ function isn't set properly, but a .equal exists...
+    if isinstance(value, Gdk.Color):
+        assert value.equal(proxy.read())
+    else:
+        assert proxy.read() == value
 
 def test_update_internal_wont_emit_changed(proxy, value):
     data = []

File tests/ui/test_dialogs.py

-import glib
+import gobject
 from pygtkhelpers.ui.dialogs import info, error, open, select_folder
 from pygtkhelpers.utils import refresh_gui
 from gi.repository import Gtk
     def before_run(dialog):
         def idle_fun():
             dialog.response(response)
-        glib.idle_add(idle_fun)
+        gobject.idle_add(idle_fun)
 
     return starter(*k, _before_run=before_run, **kw)
 
             assert dialog.select_filename(filename)
             #dialog.set_file(filename
             dialog.get_action_area().get_children()[0].emit('clicked')
-        glib.idle_add(idle_fun)
+        gobject.idle_add(idle_fun)
 
     res = open(_before_run=before_run)
     assert res == filename