mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-26 10:03:54 +03:00
storagebrowse: Standardize on set_finish_cb
Instead of gobject signals
This commit is contained in:
parent
464ebabc5a
commit
9552afcc92
@ -40,7 +40,6 @@ class vmmAddStorage(vmmGObjectUI):
|
||||
vmmGObjectUI.__init__(self, "addstorage.ui", None,
|
||||
builder=builder, topwin=topwin)
|
||||
self.conn = conn
|
||||
self.storage_browser = None
|
||||
|
||||
self.builder.connect_signals({
|
||||
"on_config_storage_browse_clicked": self._browse_storage,
|
||||
|
@ -149,8 +149,7 @@ class vmmChooseCD(vmmGObjectUI):
|
||||
def _browse_file(self):
|
||||
if self.storage_browser is None:
|
||||
self.storage_browser = vmmStorageBrowser(self.conn)
|
||||
self.storage_browser.connect("storage-browse-finish",
|
||||
self.set_storage_path)
|
||||
self.storage_browser.set_finish_cb(self.set_storage_path)
|
||||
|
||||
self.storage_browser.stable_defaults = self.vm.stable_defaults()
|
||||
|
||||
|
@ -834,6 +834,6 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
|
||||
if self.storage_browser is None:
|
||||
self.storage_browser = vmmStorageBrowser(self.conn)
|
||||
self.storage_browser.connect("storage-browse-finish", callback)
|
||||
self.storage_browser.set_finish_cb(callback)
|
||||
|
||||
self.storage_browser.show(self.topwin, self.conn)
|
||||
|
@ -344,7 +344,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
|
||||
from .storagebrowse import vmmStorageBrowser
|
||||
self.storage_browser = vmmStorageBrowser(self.conn)
|
||||
self.storage_browser.connect("storage-browse-finish", cb)
|
||||
self.storage_browser.set_finish_cb(cb)
|
||||
self.storage_browser.topwin.set_modal(self.topwin.get_modal())
|
||||
self.storage_browser.can_new_volume = False
|
||||
self.storage_browser.set_browse_reason(
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
|
||||
from . import host
|
||||
@ -31,18 +30,14 @@ from . import uiutil
|
||||
|
||||
|
||||
class vmmStorageBrowser(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"storage-browse-finish": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
||||
}
|
||||
|
||||
def __init__(self, conn):
|
||||
vmmGObjectUI.__init__(self, "storagebrowse.ui", "vmm-storage-browse")
|
||||
self.conn = conn
|
||||
|
||||
self.conn_signal_ids = []
|
||||
self.finish_cb_id = None
|
||||
self.can_new_volume = True
|
||||
self._first_run = False
|
||||
self._finish_cb = None
|
||||
|
||||
# Add Volume wizard
|
||||
self.addvol = None
|
||||
@ -103,9 +98,7 @@ class vmmStorageBrowser(vmmGObjectUI):
|
||||
self.conn.disconnect(i)
|
||||
|
||||
def set_finish_cb(self, callback):
|
||||
if self.finish_cb_id:
|
||||
self.disconnect(self.finish_cb_id)
|
||||
self.finish_cb_id = self.connect("storage-browse-finish", callback)
|
||||
self._finish_cb = callback
|
||||
|
||||
def set_browse_reason(self, reason):
|
||||
self.browse_reason = reason
|
||||
@ -376,7 +369,8 @@ class vmmStorageBrowser(vmmGObjectUI):
|
||||
def _do_finish(self, path=None):
|
||||
if not path:
|
||||
path = self.current_vol().get_target_path()
|
||||
self.emit("storage-browse-finish", path)
|
||||
if self._finish_cb:
|
||||
self._finish_cb(self, path)
|
||||
self.close()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user