Make the host details window a first class citizen.

This means the host window can be the only window visible and the app
will still be running.
This commit is contained in:
Cole Robinson 2009-11-17 15:18:38 -05:00
parent f78fe3c089
commit 4ae4c8877e
3 changed files with 43 additions and 2 deletions

View File

@ -298,8 +298,10 @@ class vmmEngine(gobject.GObject):
con = self._lookup_connection(uri)
if self.connections[uri]["windowHost"] == None:
manager = vmmHost(self.get_config(), con)
manager = vmmHost(self.get_config(), con, self)
manager.connect("action-show-help", self._do_show_help)
manager.connect("action-exit-app", self._do_exit_app)
manager.connect("action-view-manager", self._do_show_manager)
self.connections[uri]["windowHost"] = manager
self.connections[uri]["windowHost"].show()

View File

@ -36,12 +36,17 @@ class vmmHost(gobject.GObject):
__gsignals__ = {
"action-show-help": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, [str]),
"action-exit-app": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, []),
"action-view-manager": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, []),
}
def __init__(self, config, conn):
def __init__(self, config, conn, engine):
self.__gobject_init__()
self.window = gtk.glade.XML(config.get_glade_dir() + "/vmm-host.glade", "vmm-host", domain="virt-manager")
self.config = config
self.conn = conn
self.engine = engine
self.PIXBUF_STATE_RUNNING = gtk.gdk.pixbuf_new_from_file_at_size(self.config.get_icon_dir() + "/state_running.png", 18, 18)
self.PIXBUF_STATE_SHUTOFF = gtk.gdk.pixbuf_new_from_file_at_size(self.config.get_icon_dir() + "/state_shutoff.png", 18, 18)
@ -151,8 +156,11 @@ class vmmHost(gobject.GObject):
self.conn.connect("state-changed", self.conn_state_changed)
self.window.signal_autoconnect({
"on_menu_file_view_manager_activate" : self.view_manager,
"on_menu_file_quit_activate" : self.exit_app,
"on_menu_file_close_activate": self.close,
"on_vmm_host_delete_event": self.close,
"on_menu_help_contents_activate": self.show_help,
"on_net_add_clicked": self.add_network,
"on_net_delete_clicked": self.delete_network,
@ -191,6 +199,8 @@ class vmmHost(gobject.GObject):
dialog = self.window.get_widget("vmm-host")
dialog.present()
self.engine.increment_window_counter()
def is_visible(self):
if self.window.get_widget("vmm-host").flags() & gtk.VISIBLE:
return 1
@ -198,11 +208,18 @@ class vmmHost(gobject.GObject):
def close(self,ignore1=None,ignore2=None):
self.window.get_widget("vmm-host").hide()
self.engine.decrement_window_counter()
return 1
def show_help(self, src):
self.emit("action-show-help", "virt-manager-host-window")
def view_manager(self, src):
self.emit("action-view-manager")
def exit_app(self, src):
self.emit("action-exit-app")
def toggle_autoconnect(self, ignore=None):
if self.conn.get_autoconnect() != \
self.window.get_widget("config-autoconnect").get_active():

View File

@ -22,6 +22,19 @@
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menuitem4_menu">
<child>
<widget class="GtkMenuItem" id="menu-file-view-manager">
<property name="visible">True</property>
<property name="label" translatable="yes">_View Manager</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_file_view_manager_activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="menuitem1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menu-file-close">
<property name="label">gtk-close</property>
@ -31,6 +44,15 @@
<signal name="activate" handler="on_menu_file_close_activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menu-file-quit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_menu_file_quit_activate"/>
</widget>
</child>
</widget>
</child>
</widget>