mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-03 13:47:18 +03:00
about: Convert to singleton
This commit is contained in:
parent
717ff72684
commit
b6a61818af
@ -24,6 +24,18 @@ from .baseclass import vmmGObjectUI
|
||||
|
||||
|
||||
class vmmAbout(vmmGObjectUI):
|
||||
_instance = None
|
||||
|
||||
@classmethod
|
||||
def show_instance(cls, parentobj):
|
||||
try:
|
||||
if not cls._instance:
|
||||
cls._instance = cls()
|
||||
cls._instance.show(parentobj.topwin)
|
||||
except Exception as e:
|
||||
parentobj.err.show_err(
|
||||
_("Error launching 'About' dialog: %s") % str(e))
|
||||
|
||||
def __init__(self):
|
||||
vmmGObjectUI.__init__(self, "about.ui", "vmm-about")
|
||||
|
||||
@ -32,9 +44,10 @@ class vmmAbout(vmmGObjectUI):
|
||||
"on_vmm_about_response": self.close,
|
||||
})
|
||||
|
||||
def show(self):
|
||||
def show(self, parent):
|
||||
logging.debug("Showing about")
|
||||
self.topwin.set_version(self.config.get_appversion())
|
||||
self.topwin.set_transient_for(parent)
|
||||
self.topwin.present()
|
||||
|
||||
def close(self, ignore1=None, ignore2=None):
|
||||
|
@ -30,7 +30,6 @@ from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
|
||||
from . import packageutils
|
||||
from .about import vmmAbout
|
||||
from .baseclass import vmmGObject
|
||||
from .clone import vmmCloneVM
|
||||
from .connect import vmmConnect
|
||||
@ -71,7 +70,6 @@ class vmmEngine(vmmGObject):
|
||||
|
||||
self.windowConnect = None
|
||||
self.windowPreferences = None
|
||||
self.windowAbout = None
|
||||
self.windowCreate = None
|
||||
self.windowManager = None
|
||||
self.windowMigrate = None
|
||||
@ -418,10 +416,6 @@ class vmmEngine(vmmGObject):
|
||||
self.windowPreferences.cleanup()
|
||||
self.windowPreferences = None
|
||||
|
||||
if self.windowAbout:
|
||||
self.windowAbout.cleanup()
|
||||
self.windowAbout = None
|
||||
|
||||
if self.windowConnect:
|
||||
self.windowConnect.cleanup()
|
||||
self.windowConnect = None
|
||||
@ -689,14 +683,6 @@ class vmmEngine(vmmGObject):
|
||||
# Dialog launchers #
|
||||
####################
|
||||
|
||||
def _do_show_about(self, src):
|
||||
try:
|
||||
if self.windowAbout is None:
|
||||
self.windowAbout = vmmAbout()
|
||||
self.windowAbout.show()
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching 'About' dialog: %s") % str(e))
|
||||
|
||||
def _get_preferences(self):
|
||||
if self.windowPreferences:
|
||||
return self.windowPreferences
|
||||
@ -818,7 +804,6 @@ class vmmEngine(vmmGObject):
|
||||
obj.connect("action-show-domain", self._do_show_vm)
|
||||
obj.connect("action-show-preferences", self._do_show_preferences)
|
||||
obj.connect("action-show-create", self._do_show_create)
|
||||
obj.connect("action-show-about", self._do_show_about)
|
||||
obj.connect("action-show-host", self._do_show_host)
|
||||
obj.connect("action-show-connect", self._do_show_connect)
|
||||
obj.connect("action-exit-app", self.exit_app)
|
||||
|
@ -92,7 +92,6 @@ class vmmManager(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"action-show-connect": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
"action-show-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||
"action-show-about": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
"action-show-host": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
||||
"action-show-preferences": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
"action-show-create": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
||||
@ -469,8 +468,9 @@ class vmmManager(vmmGObjectUI):
|
||||
def new_vm(self, src_ignore=None):
|
||||
self.emit("action-show-create", self.current_conn_uri())
|
||||
|
||||
def show_about(self, src_ignore):
|
||||
self.emit("action-show-about")
|
||||
def show_about(self, _src):
|
||||
from .about import vmmAbout
|
||||
vmmAbout.show_instance(self)
|
||||
|
||||
def show_preferences(self, src_ignore):
|
||||
self.emit("action-show-preferences")
|
||||
|
Loading…
x
Reference in New Issue
Block a user