mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Added preference for determining when/whether to grab keyboard input. Renamed console popup preference apis a little
This commit is contained in:
@@ -2846,7 +2846,7 @@ Jeremy Katz <katzj@redhat.com>
|
||||
<widget class="GtkLabel" id="label36">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Update status every</property>
|
||||
<property name="label" translatable="yes">Update status every</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
@@ -3055,36 +3055,17 @@ Jeremy Katz <katzj@redhat.com>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table31">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">2</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">0</property>
|
||||
<property name="column_spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="console-pref">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Never
|
||||
For new domains
|
||||
For all domains</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_console_pref_changed" last_modification_time="Mon, 30 Oct 2006 18:11:47 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_padding">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label342">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Automatically open consoles:</property>
|
||||
<property name="label" translatable="yes">Automatically open consoles:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
@@ -3094,7 +3075,6 @@ For all domains</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">console-pref</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
@@ -3109,6 +3089,74 @@ For all domains</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label345">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Grab keyboard input:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="console-keygrab">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Never
|
||||
When fullscreen
|
||||
On mouse over</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_console_keygrab_changed" last_modification_time="Mon, 06 Nov 2006 19:31:31 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_padding">5</property>
|
||||
<property name="x_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="console-popup">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Never
|
||||
For new domains
|
||||
For all domains</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_console_popup_changed" last_modification_time="Mon, 06 Nov 2006 19:41:11 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_padding">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@@ -131,8 +131,8 @@
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/::PACKAGE::/console/popup-pref</key>
|
||||
<applyto>/apps/::PACKAGE::/console/popup-pref</applyto>
|
||||
<key>/schemas/apps/::PACKAGE::/console/popup</key>
|
||||
<applyto>/apps/::PACKAGE::/console/popup</applyto>
|
||||
<owner>::PACKAGE::</owner>
|
||||
<type>int</type>
|
||||
<default>1</default>
|
||||
@@ -143,5 +143,18 @@
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/::PACKAGE::/console/keygrab</key>
|
||||
<applyto>/apps/::PACKAGE::/console/keygrab</applyto>
|
||||
<owner>::PACKAGE::</owner>
|
||||
<type>int</type>
|
||||
<default>2</default>
|
||||
|
||||
<locale name="C">
|
||||
<short>When to grab keyboard input for the console</short>
|
||||
<long>Whether to grab keyboard input for a guest console. 0 = never, 1 = only when in full screen mode, 2 = when mouse is over console</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
</schemalist>
|
||||
</gconfschemafile>
|
||||
|
||||
@@ -24,9 +24,13 @@ import libvirt
|
||||
|
||||
from virtManager.keyring import *
|
||||
|
||||
CONSOLE_NEVER = 0
|
||||
CONSOLE_NEW_ONLY = 1
|
||||
CONSOLE_ALWAYS = 2
|
||||
CONSOLE_POPUP_NEVER = 0
|
||||
CONSOLE_POPUP_NEW_ONLY = 1
|
||||
CONSOLE_POPUP_ALWAYS = 2
|
||||
|
||||
CONSOLE_KEYGRAB_NEVER = 0
|
||||
CONSOLE_KEYGRAB_FULLSCREEN = 1
|
||||
CONSOLE_KEYGRAB_MOUSEOVER = 2
|
||||
|
||||
class vmmConfig:
|
||||
def __init__(self, appname, appversion, gconf_dir, glade_dir, icon_dir):
|
||||
@@ -167,20 +171,33 @@ class vmmConfig:
|
||||
def on_stats_history_length_changed(self, callback):
|
||||
self.conf.notify_add(self.conf_dir + "/stats/history-length", callback)
|
||||
|
||||
def on_console_pref_changed(self, callback):
|
||||
self.conf.notify_add(self.conf_dir + "/console/popup-pref", callback)
|
||||
def on_console_popup_changed(self, callback):
|
||||
self.conf.notify_add(self.conf_dir + "/console/popup", callback)
|
||||
|
||||
def get_console_pref(self):
|
||||
console_pref = self.conf.get_int(self.conf_dir + "/console/popup-pref")
|
||||
def get_console_popup(self):
|
||||
console_pref = self.conf.get_int(self.conf_dir + "/console/popup")
|
||||
if console_pref == None:
|
||||
console_pref = 0
|
||||
return console_pref
|
||||
|
||||
def set_console_pref(self, pref):
|
||||
self.conf.set_int(self.conf_dir + "/console/popup-pref", pref)
|
||||
def set_console_popup(self, pref):
|
||||
self.conf.set_int(self.conf_dir + "/console/popup", pref)
|
||||
|
||||
def on_console_keygrab_changed(self, callback):
|
||||
self.conf.notify_add(self.conf_dir + "/console/keygrab", callback)
|
||||
|
||||
def get_console_keygrab(self):
|
||||
console_pref = self.conf.get_int(self.conf_dir + "/console/keygrab")
|
||||
if console_pref == None:
|
||||
console_pref = 0
|
||||
return console_pref
|
||||
|
||||
def set_console_keygrab(self, pref):
|
||||
self.conf.set_int(self.conf_dir + "/console/keygrab", pref)
|
||||
|
||||
def get_secret_name(self, vm):
|
||||
return "vm-console-" + vm.get_uuid()
|
||||
|
||||
def has_keyring(self):
|
||||
if self.keyring == None:
|
||||
self.keyring = vmmKeyring()
|
||||
|
||||
@@ -47,7 +47,10 @@ class vmmConsole(gobject.GObject):
|
||||
self.window.get_widget("control-shutdown").set_icon_widget(gtk.Image())
|
||||
self.window.get_widget("control-shutdown").get_icon_widget().set_from_file(config.get_icon_dir() + "/icon_shutdown.png")
|
||||
|
||||
self.vncViewer = GRFBViewer(topwin, autograbkey=True)
|
||||
if self.config.get_console_keygrab() == 2:
|
||||
self.vncViewer = GRFBViewer(topwin, autograbkey=True)
|
||||
else:
|
||||
self.vncViewer = GRFBViewer(topwin, autograbkey=False)
|
||||
self.window.get_widget("console-vnc-align").add(self.vncViewer)
|
||||
self.vncViewer.connect("size-request", self.autosize)
|
||||
self.vncViewer.show()
|
||||
@@ -56,6 +59,8 @@ class vmmConsole(gobject.GObject):
|
||||
|
||||
self.window.get_widget("console-pages").set_show_tabs(False)
|
||||
|
||||
self.config.on_console_keygrab_changed(self.keygrab_changed)
|
||||
|
||||
self.ignorePause = False
|
||||
|
||||
self.window.signal_autoconnect({
|
||||
@@ -101,13 +106,19 @@ class vmmConsole(gobject.GObject):
|
||||
|
||||
self.window.get_widget("console-vnc-vp").set_size_request(vncWidth+2, vncHeight+2)
|
||||
|
||||
def keygrab_changed(self, src, ignore1=None,ignore2=None,ignore3=None):
|
||||
if self.config.get_console_keygrab() == 2:
|
||||
self.vncViewer.set_autograb_keyboard(True)
|
||||
else:
|
||||
self.vncViewer.set_autograb_keyboard(False)
|
||||
|
||||
def toggle_fullscreen(self, src):
|
||||
if src.get_active():
|
||||
self.window.get_widget("vmm-console").fullscreen()
|
||||
if not(self.vncViewer.will_autograb_keyboard()):
|
||||
if self.config.get_console_keygrab() == 1:
|
||||
self.vncViewer.grab_keyboard()
|
||||
else:
|
||||
if not(self.vncViewer.will_autograb_keyboard()):
|
||||
if self.config.get_console_keygrab() == 1:
|
||||
self.vncViewer.ungrab_keyboard()
|
||||
self.window.get_widget("vmm-console").unfullscreen()
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ class vmmCreate(gobject.GObject):
|
||||
# Ensure new VM is loaded
|
||||
self.connection.tick(noStatsUpdate=True)
|
||||
|
||||
if self.config.get_console_pref() == 1:
|
||||
if self.config.get_console_popup() == 1:
|
||||
# user has requested console on new created vms only
|
||||
vm = self.connection.get_vm(guest.uuid)
|
||||
(gtype, host, port) = vm.get_graphics_console()
|
||||
|
||||
@@ -220,7 +220,7 @@ class vmmManager(gobject.GObject):
|
||||
model.append([vmuuid, vm.get_name()])
|
||||
vm.connect("status-changed", self.vm_status_changed)
|
||||
vm.connect("resources-sampled", self.vm_resources_sampled)
|
||||
if self.config.get_console_pref() == 2 and range(model.iter_n_children(None)) > 1:
|
||||
if self.config.get_console_popup() == 2 and range(model.iter_n_children(None)) > 1:
|
||||
# user has requested consoles on all vms
|
||||
(gtype, host, port) = vm.get_graphics_console()
|
||||
if gtype == "vnc":
|
||||
|
||||
@@ -24,24 +24,21 @@ class vmmPreferences:
|
||||
self.config = config
|
||||
self.window.get_widget("vmm-preferences").hide()
|
||||
|
||||
# box = self.window.get_widget("console-pref")
|
||||
# model = gtk.ListStore(str)
|
||||
# box.set_model(model)
|
||||
# model.append(["Never"])
|
||||
# model.append(["For new domains"])
|
||||
# model.append(["For all domains"])
|
||||
self.config.on_console_pref_changed(self.refresh_console_pref)
|
||||
self.config.on_console_popup_changed(self.refresh_console_popup)
|
||||
self.config.on_console_keygrab_changed(self.refresh_console_keygrab)
|
||||
self.config.on_stats_update_interval_changed(self.refresh_update_interval)
|
||||
self.config.on_stats_history_length_changed(self.refresh_history_length)
|
||||
|
||||
self.refresh_update_interval()
|
||||
self.refresh_history_length()
|
||||
self.refresh_console_pref()
|
||||
self.refresh_console_popup()
|
||||
self.refresh_console_keygrab()
|
||||
|
||||
self.window.signal_autoconnect({
|
||||
"on_stats_update_interval_changed": self.change_update_interval,
|
||||
"on_stats_history_length_changed": self.change_history_length,
|
||||
"on_console_pref_changed": self.change_console_pref,
|
||||
"on_console_popup_changed": self.change_console_popup,
|
||||
"on_console_keygrab_changed": self.change_console_keygrab,
|
||||
"on_close_clicked": self.close,
|
||||
"on_vmm_preferences_delete_event": self.close,
|
||||
})
|
||||
@@ -61,8 +58,11 @@ class vmmPreferences:
|
||||
def refresh_history_length(self, ignore1=None,ignore2=None,ignore3=None,ignore4=None):
|
||||
self.window.get_widget("stats-history-length").set_value(self.config.get_stats_history_length())
|
||||
|
||||
def refresh_console_pref(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None):
|
||||
self.window.get_widget("console-pref").set_active(self.config.get_console_pref())
|
||||
def refresh_console_popup(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None):
|
||||
self.window.get_widget("console-popup").set_active(self.config.get_console_popup())
|
||||
|
||||
def refresh_console_keygrab(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None):
|
||||
self.window.get_widget("console-keygrab").set_active(self.config.get_console_keygrab())
|
||||
|
||||
def change_update_interval(self, src):
|
||||
self.config.set_stats_update_interval(src.get_value_as_int())
|
||||
@@ -70,5 +70,9 @@ class vmmPreferences:
|
||||
def change_history_length(self, src):
|
||||
self.config.set_stats_history_length(src.get_value_as_int())
|
||||
|
||||
def change_console_pref(self, box):
|
||||
self.config.set_console_pref(box.get_active())
|
||||
def change_console_popup(self, box):
|
||||
self.config.set_console_popup(box.get_active())
|
||||
|
||||
def change_console_keygrab(self, box):
|
||||
self.config.set_console_keygrab(box.get_active())
|
||||
|
||||
|
||||
@@ -382,6 +382,9 @@ class GRFBViewer(gtk.DrawingArea):
|
||||
def will_autograb_keyboard(self):
|
||||
return self.autograbkey
|
||||
|
||||
def set_autograb_keyboard(self, grab):
|
||||
self.autograbkey = grab
|
||||
|
||||
def grab_keyboard(self):
|
||||
gtk.gdk.keyboard_grab(self.window, False, long(0))
|
||||
for g in self.accel_groups:
|
||||
|
||||
Reference in New Issue
Block a user