mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
host: Remember window dimensions
Like we do for details and manager windows, save window size in gsettings and remember it across app runs
This commit is contained in:
parent
3784864e10
commit
de773179ef
@ -35,6 +35,12 @@
|
||||
<summary>Custom connection description</summary>
|
||||
<description>Custom connection description, used in the manager window. If empty, the app generates a default on demand.</description>
|
||||
</key>
|
||||
|
||||
<key name="window-size" type="(ii)">
|
||||
<default>(-1, -1)</default>
|
||||
<summary>Conn details window dimensions</summary>
|
||||
<description>Connection details window dimensions</description>
|
||||
</key>
|
||||
</schema>
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
<accel-groups>
|
||||
<group name="accelgroup1"/>
|
||||
</accel-groups>
|
||||
<signal name="configure-event" handler="on_vmm_host_configure_event" swapped="no"/>
|
||||
<signal name="delete-event" handler="on_vmm_host_delete_event" swapped="no"/>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
|
@ -1523,3 +1523,9 @@ class vmmConnection(vmmGObject):
|
||||
*args, **kwargs)
|
||||
def _config_pretty_name_changed_cb(self):
|
||||
self.emit("state-changed")
|
||||
|
||||
def set_details_window_size(self, w, h):
|
||||
self.config.set_perconn(self.get_uri(), "/window-size", (w, h))
|
||||
def get_details_window_size(self):
|
||||
ret = self.config.get_perconn(self.get_uri(), "/window-size")
|
||||
return ret
|
||||
|
@ -51,6 +51,15 @@ class vmmHost(vmmGObjectUI):
|
||||
self.ICON_RUNNING = "state_running"
|
||||
self.ICON_SHUTOFF = "state_shutoff"
|
||||
|
||||
# Set default window size
|
||||
w, h = self.conn.get_details_window_size()
|
||||
if w <= 0:
|
||||
w = 800
|
||||
if h <= 0:
|
||||
h = 600
|
||||
self.topwin.set_default_size(w, h)
|
||||
self._window_size = None
|
||||
|
||||
self.addnet = None
|
||||
|
||||
self.active_edits = []
|
||||
@ -68,6 +77,7 @@ class vmmHost(vmmGObjectUI):
|
||||
"on_menu_file_quit_activate": self.exit_app,
|
||||
"on_menu_file_close_activate": self.close,
|
||||
"on_vmm_host_delete_event": self.close,
|
||||
"on_vmm_host_configure_event": self._window_resized_cb,
|
||||
"on_host_page_switch": self.page_changed,
|
||||
|
||||
"on_net_add_clicked": self.add_network,
|
||||
@ -195,6 +205,9 @@ class vmmHost(vmmGObjectUI):
|
||||
return 1
|
||||
|
||||
def _cleanup(self):
|
||||
if self._window_size:
|
||||
self.conn.set_details_window_size(*self._window_size)
|
||||
|
||||
self.conn = None
|
||||
|
||||
self.storagelist.cleanup()
|
||||
@ -217,6 +230,11 @@ class vmmHost(vmmGObjectUI):
|
||||
def exit_app(self, _src):
|
||||
vmmEngine.get_instance().exit_app()
|
||||
|
||||
def _window_resized_cb(self, ignore, ignore2):
|
||||
if not self.is_visible():
|
||||
return
|
||||
self._window_size = self.topwin.get_size()
|
||||
|
||||
|
||||
def page_changed(self, src, child, pagenum):
|
||||
ignore = src
|
||||
|
Loading…
Reference in New Issue
Block a user