[virt-tools-list] [PATCH 3/4] console: Add a way to hide toolbars and window decorations
Povilas Kanapickas
povilas at radix.lt
Wed Jan 2 00:28:06 UTC 2019
Signed-off-by: Povilas Kanapickas <povilas at radix.lt>
---
ui/details.ui | 9 +++++++++
virtManager/console.py | 42 ++++++++++++++++++++++++++++++++++++++++--
virtManager/details.py | 5 +++++
3 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/ui/details.ui b/ui/details.ui
index c18070c8..d09a692c 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -254,6 +254,15 @@
<signal name="activate" handler="on_details_menu_view_fullscreen_activate" swapped="no"/>
</object>
</child>
+ <child>
+ <object class="GtkCheckMenuItem" id="details-menu-view-hide-decorations">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Hide decorations</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_details_menu_view_hide_decorations_activate" swapped="no"/>
+ </object>
+ </child>
<child>
<object class="GtkMenuItem" id="detains-menu-view-size-to-vm">
<property name="visible">True</property>
diff --git a/virtManager/console.py b/virtManager/console.py
index 34a0447a..0a0469b1 100644
--- a/virtManager/console.py
+++ b/virtManager/console.py
@@ -131,7 +131,7 @@ class vmmOverlayToolbar:
self.send_key_button = None
self.timed_revealer = None
self.keycombo_toolbar = None
- self.toolbar = None
+ self.overlay_toolbar = None
self.send_key_button = None
self.timed_revealer = None
@@ -230,6 +230,16 @@ class vmmConsolePages(vmmGObjectUI):
on_send_key_fn=self._do_send_key)
self.widget("console-overlay").add_overlay(overlay)
+ self._overlay_toolbar_decorations = vmmOverlayToolbar()
+ overlay = self._overlay_toolbar_decorations.create(
+ name="Hidden Decorations Toolbar",
+ tooltip_text=_("Show decorations"),
+ accessible_name="Show Decorations",
+ send_key_accessible_name="Hidden Decorations Send Key",
+ on_leave_fn=self._leave_hidden_decorations,
+ on_send_key_fn=self._do_send_key)
+ self.widget("console-overlay").add_overlay(overlay)
+
# Make viewer widget background always be black
black = Gdk.Color(0, 0, 0)
self.widget("console-gfx-viewport").modify_bg(Gtk.StateType.NORMAL,
@@ -275,6 +285,7 @@ class vmmConsolePages(vmmGObjectUI):
self._viewer = None
self._overlay_toolbar_fullscreen.cleanup()
+ self._overlay_toolbar_decorations.cleanup()
for serial in self._serial_consoles:
serial.cleanup()
@@ -285,7 +296,6 @@ class vmmConsolePages(vmmGObjectUI):
# Initialization helpers #
##########################
-
def _init_menus(self):
# Serial list menu
smenu = Gtk.Menu()
@@ -548,6 +558,8 @@ class vmmConsolePages(vmmGObjectUI):
self.widget("control-fullscreen").set_sensitive(allow_fullscreen)
self.widget("details-menu-view-fullscreen").set_sensitive(
allow_fullscreen)
+ self.widget("details-menu-view-hide-decorations").set_sensitive(
+ allow_fullscreen)
def _leave_fullscreen(self, ignore=None):
self._change_fullscreen(False)
@@ -563,6 +575,8 @@ class vmmConsolePages(vmmGObjectUI):
def _change_fullscreen(self, do_fullscreen):
self.widget("control-fullscreen").set_active(do_fullscreen)
+ self.widget('details-menu-view-hide-decorations').set_sensitive(
+ not do_fullscreen)
if do_fullscreen:
self.topwin.fullscreen()
@@ -574,6 +588,24 @@ class vmmConsolePages(vmmGObjectUI):
self._change_menu_toolbar_hidden(do_fullscreen)
self._sync_scaling_with_display()
+ def _leave_hidden_decorations(self, ignore=None):
+ self._change_hide_decorations(False)
+
+ def _change_hide_decorations(self, do_hide):
+ self.widget('details-menu-view-fullscreen').set_sensitive(not do_hide)
+ # this function may be called from other code, so ensure that widget
+ # state corresponds to the actual situation
+ self.widget('details-menu-view-hide-decorations').set_active(do_hide)
+
+ if do_hide:
+ self.topwin.get_window().set_decorations(0)
+ self._overlay_toolbar_decorations.timed_revealer.force_reveal(True)
+ else:
+ self._overlay_toolbar_decorations.timed_revealer.force_reveal(False)
+ self.topwin.get_window().set_decorations(Gdk.WMDecoration.ALL)
+
+ self._change_menu_toolbar_hidden(do_hide)
+ self._sync_scaling_with_display()
##########################
# State tracking methods #
@@ -595,6 +627,7 @@ class vmmConsolePages(vmmGObjectUI):
self._viewer = None
self._leave_fullscreen()
+ self._leave_hidden_decorations()
for serial in self._serial_consoles:
serial.close()
@@ -696,6 +729,7 @@ class vmmConsolePages(vmmGObjectUI):
for c in self._keycombo_menu.get_children():
c.set_sensitive(can_sendkey)
self._overlay_toolbar_fullscreen.set_sensitive(can_sendkey)
+ self._overlay_toolbar_decorations.set_sensitive(can_sendkey)
self._refresh_can_fullscreen()
@@ -1063,5 +1097,9 @@ class vmmConsolePages(vmmGObjectUI):
do_fullscreen = src.get_active()
self._change_fullscreen(do_fullscreen)
+ def details_toggle_hide_decorations(self, src):
+ do_hide = src.get_active()
+ self._change_hide_decorations(do_hide)
+
def details_auth_login(self, ignore):
self._set_credentials()
diff --git a/virtManager/details.py b/virtManager/details.py
index b7e7fc14..b6a6cab4 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -602,6 +602,8 @@ class vmmDetails(vmmGObjectUI):
# Listeners stored in vmmConsolePages
"on_details_menu_view_fullscreen_activate": (
self.console.details_toggle_fullscreen),
+ "on_details_menu_view_hide_decorations_activate": (
+ self.console.details_toggle_hide_decorations),
"on_details_menu_view_size_to_vm_activate": (
self.console.details_size_to_vm),
"on_details_menu_view_scale_always_toggled": (
@@ -720,6 +722,9 @@ class vmmDetails(vmmGObjectUI):
def _close(self):
fs = self.widget("details-menu-view-fullscreen")
+ if fs.get_active():
+ fs.set_active(False)
+ fs = self.widget("details-menu-view-hide-decorations")
if fs.get_active():
fs.set_active(False)
--
2.17.1
More information about the virt-tools-list
mailing list