mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-16 18:25:02 -06:00
Move connect helpers from util to baseclass
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
ad8060d191
commit
b7de618897
@ -265,8 +265,7 @@ def show_engine(engine, show, uri, uuid, no_conn_auto):
|
|||||||
conn = engine.add_connection(uri)
|
conn = engine.add_connection(uri)
|
||||||
|
|
||||||
if conn and show:
|
if conn and show:
|
||||||
import virtManager.util as util
|
conn.connect_opt_out("state-changed",
|
||||||
util.connect_opt_out(conn, "state-changed",
|
|
||||||
_conn_state_changed,
|
_conn_state_changed,
|
||||||
engine, show, uri, uuid)
|
engine, show, uri, uuid)
|
||||||
|
|
||||||
|
@ -95,6 +95,33 @@ class vmmGObject(gobject.GObject):
|
|||||||
from virtManager import halhelper
|
from virtManager import halhelper
|
||||||
return halhelper.get_hal_helper()
|
return halhelper.get_hal_helper()
|
||||||
|
|
||||||
|
def connect_once(self, signal, func, *args):
|
||||||
|
id_list = []
|
||||||
|
|
||||||
|
def wrap_func(*wrapargs):
|
||||||
|
if id_list:
|
||||||
|
self.disconnect(id_list[0])
|
||||||
|
|
||||||
|
return func(*wrapargs)
|
||||||
|
|
||||||
|
conn_id = self.connect(signal, wrap_func, *args)
|
||||||
|
id_list.append(conn_id)
|
||||||
|
|
||||||
|
return conn_id
|
||||||
|
|
||||||
|
def connect_opt_out(self, signal, func, *args):
|
||||||
|
id_list = []
|
||||||
|
|
||||||
|
def wrap_func(*wrapargs):
|
||||||
|
ret = func(*wrapargs)
|
||||||
|
if ret and id_list:
|
||||||
|
self.disconnect(id_list[0])
|
||||||
|
|
||||||
|
conn_id = self.connect(signal, wrap_func, *args)
|
||||||
|
id_list.append(conn_id)
|
||||||
|
|
||||||
|
return conn_id
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if hasattr(gobject.GObject, "__del__"):
|
if hasattr(gobject.GObject, "__del__"):
|
||||||
getattr(gobject.GObject, "__del__")(self)
|
getattr(gobject.GObject, "__del__")(self)
|
||||||
|
@ -1691,8 +1691,8 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
else:
|
else:
|
||||||
# Register a status listener, which will restart the
|
# Register a status listener, which will restart the
|
||||||
# guest after the install has finished
|
# guest after the install has finished
|
||||||
util.connect_opt_out(vm, "status-changed",
|
vm.connect_opt_out("status-changed",
|
||||||
self.check_install_status, guest)
|
self.check_install_status, guest)
|
||||||
|
|
||||||
|
|
||||||
def check_install_status(self, vm, ignore1, ignore2, virtinst_guest=None):
|
def check_install_status(self, vm, ignore1, ignore2, virtinst_guest=None):
|
||||||
@ -1714,8 +1714,8 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
# will force one final restart.
|
# will force one final restart.
|
||||||
virtinst_guest.continue_install()
|
virtinst_guest.continue_install()
|
||||||
|
|
||||||
util.connect_opt_out(vm, "status-changed",
|
vm.connect_opt_out("status-changed",
|
||||||
self.check_install_status, None)
|
self.check_install_status, None)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if vm.get_install_abort():
|
if vm.get_install_abort():
|
||||||
|
@ -1100,7 +1100,7 @@ class vmmDomain(vmmDomainBase):
|
|||||||
# Request a shutdown
|
# Request a shutdown
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
self.reboot_listener = util.connect_opt_out(self, "status-changed",
|
self.reboot_listener = self.connect_opt_out("status-changed",
|
||||||
reboot_listener, self)
|
reboot_listener, self)
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
@ -305,33 +305,6 @@ def pretty_hv(gtype, domtype):
|
|||||||
|
|
||||||
return label
|
return label
|
||||||
|
|
||||||
def connect_once(obj, signal, func, *args):
|
|
||||||
id_list = []
|
|
||||||
|
|
||||||
def wrap_func(*wrapargs):
|
|
||||||
if id_list:
|
|
||||||
obj.disconnect(id_list[0])
|
|
||||||
|
|
||||||
return func(*wrapargs)
|
|
||||||
|
|
||||||
conn_id = obj.connect(signal, wrap_func, *args)
|
|
||||||
id_list.append(conn_id)
|
|
||||||
|
|
||||||
return conn_id
|
|
||||||
|
|
||||||
def connect_opt_out(obj, signal, func, *args):
|
|
||||||
id_list = []
|
|
||||||
|
|
||||||
def wrap_func(*wrapargs):
|
|
||||||
ret = func(*wrapargs)
|
|
||||||
if ret and id_list:
|
|
||||||
obj.disconnect(id_list[0])
|
|
||||||
|
|
||||||
conn_id = obj.connect(signal, wrap_func, *args)
|
|
||||||
id_list.append(conn_id)
|
|
||||||
|
|
||||||
return conn_id
|
|
||||||
|
|
||||||
def idle_emit(self, signal, *args):
|
def idle_emit(self, signal, *args):
|
||||||
"""
|
"""
|
||||||
Safe wrapper for using 'self.emit' with gobject.idle_add
|
Safe wrapper for using 'self.emit' with gobject.idle_add
|
||||||
|
Loading…
Reference in New Issue
Block a user