From 6208d67129219b608d959c56390c1279b757e999 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 16 Feb 2013 14:03:30 -0500 Subject: [PATCH] Fix GObject deprecation warnings with latest pygobject --- src/virtManager/asyncjob.py | 8 ++++---- src/virtManager/autodrawer.py | 18 +++++++++--------- src/virtManager/baseclass.py | 11 ++++++----- src/virtManager/connectauth.py | 4 ++-- src/virtManager/engine.py | 5 +++-- src/virtManager/migrate.py | 6 +++--- src/virtManager/serialcon.py | 12 ++++++------ 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/virtManager/asyncjob.py b/src/virtManager/asyncjob.py index 084f4664d..d1e1be15f 100644 --- a/src/virtManager/asyncjob.py +++ b/src/virtManager/asyncjob.py @@ -22,9 +22,9 @@ import logging import threading import traceback -from gi.repository import GObject -from gi.repository import Gtk from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import Gtk import libvirt import urlgrabber @@ -252,7 +252,7 @@ class vmmAsyncJob(vmmGObjectUI): ########### def run(self): - timer = GObject.timeout_add(100, self.exit_if_necessary) + timer = GLib.timeout_add(100, self.exit_if_necessary) if self.show_progress: self.topwin.present() @@ -266,7 +266,7 @@ class vmmAsyncJob(vmmGObjectUI): else: self.bg_thread.run() - GObject.source_remove(timer) + GLib.source_remove(timer) if self.bg_thread.isAlive(): # This can happen if the user closes the whole app while the diff --git a/src/virtManager/autodrawer.py b/src/virtManager/autodrawer.py index 9f5507ec3..da0192dca 100644 --- a/src/virtManager/autodrawer.py +++ b/src/virtManager/autodrawer.py @@ -22,10 +22,10 @@ # MA 02110-1301 USA. # -from gi.repository import GObject -from gi.repository import Gtk -from gi.repository import Gdk from gi.repository import cairo +from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import Gtk class OverBox(Gtk.Box): """ @@ -341,8 +341,8 @@ class Drawer(OverBox): self.period = period if self.timer_pending: - GObject.source_remove(self.timer_id) - self.timer_id = GObject.timeout_add(self.period, self._on_timer) + GLib.source_remove(self.timer_id) + self.timer_id = GLib.timeout_add(self.period, self._on_timer) self.step = step @@ -350,7 +350,7 @@ class Drawer(OverBox): self.goal = goal if not self.timer_pending: - self.timer_id = GObject.timeout_add(self.period, self._on_timer) + self.timer_id = GLib.timeout_add(self.period, self._on_timer) self.timer_pending = True def get_close_time(self): @@ -485,7 +485,7 @@ class AutoDrawer(Drawer): self.opened = True if self.delayConnection: - GObject.source_remove(self.delayConnection) + GLib.source_remove(self.delayConnection) if self.forceClosing: @@ -493,7 +493,7 @@ class AutoDrawer(Drawer): elif do_immediate: self._enforce(False) else: - self.delayConnection = GObject.timeout_add(self.delayValue, + self.delayConnection = GLib.timeout_add(self.delayValue, self._on_enforce_delay) @@ -608,7 +608,7 @@ class AutoDrawer(Drawer): toplevel.set_focus(None) self.forceClosing = True - self.closeConnection = GObject.timeout_add( + self.closeConnection = GLib.timeout_add( self.get_close_time() + self.delayValue, self._on_close_delay) diff --git a/src/virtManager/baseclass.py b/src/virtManager/baseclass.py index f5ae356b3..2d36fa9e1 100644 --- a/src/virtManager/baseclass.py +++ b/src/virtManager/baseclass.py @@ -25,13 +25,14 @@ import logging import virtManager import virtManager.guidiff +from gi.repository import GLib from gi.repository import GObject if virtManager.guidiff.is_gui(): from gi.repository import Gtk from gi.repository import Gdk -class vmmGObject(GObject.GObject): +class vmmGObject(GObject.GObject): _leak_check = True def __init__(self): @@ -88,7 +89,7 @@ class vmmGObject(GObject.GObject): def add_gobject_timeout(self, handle): self._gobject_timeouts.append(handle) def remove_gobject_timeout(self, handle): - GObject.source_remove(handle) + GLib.source_remove(handle) self._gobject_timeouts.remove(handle) def _logtrace(self, msg=""): @@ -136,7 +137,7 @@ class vmmGObject(GObject.GObject): def idle_emit(self, signal, *args): """ - Safe wrapper for using 'self.emit' with GObject.idle_add + Safe wrapper for using 'self.emit' with GLib.idle_add """ def emitwrap(_s, *_a): self.emit(_s, *_a) @@ -148,13 +149,13 @@ class vmmGObject(GObject.GObject): """ Make sure idle functions are run thread safe """ - return GObject.idle_add(func, *args) + return GLib.idle_add(func, *args) def timeout_add(self, timeout, func, *args): """ Make sure timeout functions are run thread safe """ - return GObject.timeout_add(timeout, func, *args) + return GLib.timeout_add(timeout, func, *args) def emit(self, signal_name, *args): return GObject.GObject.emit(self, signal_name, *args) diff --git a/src/virtManager/connectauth.py b/src/virtManager/connectauth.py index eb6113de0..be098d483 100644 --- a/src/virtManager/connectauth.py +++ b/src/virtManager/connectauth.py @@ -18,7 +18,7 @@ # MA 02110-1301 USA. # -from gi.repository import GObject +from gi.repository import GLib import logging import os @@ -112,7 +112,7 @@ def creds_dialog(creds): ret = -1 retipc.append(ret) - GObject.idle_add(wrapper, creds_dialog_main, creds) + GLib.idle_add(wrapper, creds_dialog_main, creds) while not retipc: time.sleep(.1) diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py index dc48fa9c7..0d2e9ce75 100644 --- a/src/virtManager/engine.py +++ b/src/virtManager/engine.py @@ -18,6 +18,7 @@ # MA 02110-1301 USA. # +from gi.repository import GLib from gi.repository import GObject from gi.repository import Gtk @@ -298,7 +299,7 @@ class vmmEngine(vmmGObject): return 1 def change_timer_interval(self, ignore1, ignore2, ignore3, ignore4): - GObject.source_remove(self.timer) + GLib.source_remove(self.timer) self.schedule_timer() def increment_window_counter(self, src): @@ -326,7 +327,7 @@ class vmmEngine(vmmGObject): self.inspection = None if self.timer is not None: - GObject.source_remove(self.timer) + GLib.source_remove(self.timer) if self.systray: self.systray.cleanup() diff --git a/src/virtManager/migrate.py b/src/virtManager/migrate.py index 0b52930c3..10bfb1620 100644 --- a/src/virtManager/migrate.py +++ b/src/virtManager/migrate.py @@ -22,9 +22,9 @@ import traceback import logging import threading -from gi.repository import GObject -from gi.repository import Gtk from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import Gtk import virtinst import libvirt @@ -553,4 +553,4 @@ class vmmMigrateDialog(vmmGObjectUI): vm.migrate(dstconn, migrate_uri, rate, live, secure, meter=meter) if timer: - self.idle_add(GObject.source_remove, timer) + self.idle_add(GLib.source_remove, timer) diff --git a/src/virtManager/serialcon.py b/src/virtManager/serialcon.py index d64c899e2..63ce005c4 100644 --- a/src/virtManager/serialcon.py +++ b/src/virtManager/serialcon.py @@ -25,9 +25,9 @@ import pty import fcntl import logging -from gi.repository import GObject -from gi.repository import Gtk from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import Gtk from gi.repository import Vte import libvirt @@ -79,8 +79,8 @@ class LocalConsoleConnection(ConsoleConnection): self.fd = pty.slave_open(ipty) fcntl.fcntl(self.fd, fcntl.F_SETFL, os.O_NONBLOCK) - self.source = GObject.io_add_watch(self.fd, - GObject.IO_IN | GObject.IO_ERR | GObject.IO_HUP, + self.source = GLib.io_add_watch(self.fd, + GLib.IO_IN | GLib.IO_ERR | GLib.IO_HUP, self.display_data, terminal) # Save term settings & set to raw mode @@ -102,7 +102,7 @@ class LocalConsoleConnection(ConsoleConnection): os.close(self.fd) self.fd = None - GObject.source_remove(self.source) + GLib.source_remove(self.source) self.source = None self.origtermios = None @@ -119,7 +119,7 @@ class LocalConsoleConnection(ConsoleConnection): def display_data(self, src, cond, terminal): ignore = src - if cond != GObject.IO_IN: + if cond != GLib.IO_IN: self.close() return False