Add global option for VNC scaling: vm details defaults to that.

This commit is contained in:
Cole Robinson 2009-02-23 18:50:47 -05:00
parent 7ce13ad36a
commit f5448f87e7
5 changed files with 204 additions and 150 deletions

View File

@ -221,6 +221,19 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/::PACKAGE::/console/scaling</key>
<applyto>/apps/::PACKAGE::/console/scaling</applyto>
<owner>::PACKAGE::</owner>
<type>int</type>
<default>1</default>
<locale name="C">
<short>When to scale the VM graphical console</short>
<long>When to scale the VM graphical console. 0 = never, 1 = only when in full screen mode, 2 = Always</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/::PACKAGE::/details/show-toolbar</key>
<applyto>/apps/::PACKAGE::/details/show-toolbar</applyto>

View File

@ -42,7 +42,13 @@ DEFAULT_VIRT_IMAGE_DIR = "/var/lib/libvirt/images"
DEFAULT_VIRT_SAVE_DIR = "/var/lib/libvirt"
class vmmConfig:
def __init__(self, appname, appversion, gconf_dir, glade_dir, icon_dir, data_dir):
CONSOLE_SCALE_NEVER = 0
CONSOLE_SCALE_FULLSCREEN = 1
CONSOLE_SCALE_ALWAYS = 2
def __init__(self, appname, appversion, gconf_dir, glade_dir, icon_dir,
data_dir):
self.appname = appname
self.appversion = appversion
self.conf_dir = gconf_dir
@ -226,31 +232,36 @@ class vmmConfig:
# VM Console preferences
def on_console_popup_changed(self, callback):
self.conf.notify_add(self.conf_dir + "/console/popup", callback)
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_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 on_console_scaling_changed(self, callback):
self.conf.notify_add(self.conf_dir + "/console/scaling", callback)
def get_console_scaling(self):
console_pref = self.conf.get_int(self.conf_dir + "/console/scaling")
if console_pref == None:
console_pref = 0
return console_pref
def set_console_scaling(self, pref):
self.conf.set_int(self.conf_dir + "/console/scaling", pref)
def show_console_grab_notify(self):
return self.conf.get_bool(self.conf_dir + "/console/grab-notify")
def set_console_grab_notify(self, state):
self.conf.set_bool(self.conf_dir + "/console/grab-notify", state)

View File

@ -40,11 +40,6 @@ from virtManager import util as util
import virtinst
# Different scaling values
SCALE_ALWAYS = 0
SCALE_FULLSCREEN = 1
SCALE_NEVER = 2
# Columns in hw list model
HW_LIST_COL_LABEL = 0
HW_LIST_COL_STOCK_ID = 1
@ -228,15 +223,12 @@ class vmmDetails(gobject.GObject):
else:
self.vncViewer.set_keyboard_grab(False)
self.vncViewer.set_pointer_grab(True)
if not topwin.is_composited():
# XXX: When we have per VM prefs, this will need to be smarter
self.scale_type = SCALE_ALWAYS
else:
self.scale_type = SCALE_NEVER
self.window.get_widget("details-menu-view-scale-always").set_active(self.scale_type == SCALE_ALWAYS)
self.window.get_widget("details-menu-view-scale-never").set_active(self.scale_type == SCALE_NEVER)
self.window.get_widget("details-menu-view-scale-fullscreen").set_active(self.scale_type == SCALE_FULLSCREEN)
self.scale_type = self.config.get_console_scaling()
self.window.get_widget("details-menu-view-scale-always").set_active(self.scale_type == self.config.CONSOLE_SCALE_ALWAYS)
self.window.get_widget("details-menu-view-scale-never").set_active(self.scale_type == self.config.CONSOLE_SCALE_NEVER)
self.window.get_widget("details-menu-view-scale-fullscreen").set_active(self.scale_type == self.config.CONSOLE_SCALE_FULLSCREEN)
self.update_scaling()
self.vncViewer.connect("vnc-pointer-grab", self.notify_grabbed)
@ -444,11 +436,11 @@ class vmmDetails(gobject.GObject):
return
if src == self.window.get_widget("details-menu-view-scale-always"):
self.scale_type = SCALE_ALWAYS
self.scale_type = self.config.CONSOLE_SCALE_ALWAYS
elif src == self.window.get_widget("details-menu-view-scale-fullscreen"):
self.scale_type = SCALE_FULLSCREEN
self.scale_type = self.config.CONSOLE_SCALE_FULLSCREEN
elif src == self.window.get_widget("details-menu-view-scale-never"):
self.scale_type = SCALE_NEVER
self.scale_type = self.config.CONSOLE_SCALE_NEVER
self.update_scaling()
@ -456,11 +448,14 @@ class vmmDetails(gobject.GObject):
curscale = self.vncViewer.get_scaling()
fs = self.window.get_widget("control-fullscreen").get_active()
if self.scale_type == SCALE_NEVER and curscale == True:
if (self.scale_type == self.config.CONSOLE_SCALE_NEVER
and curscale == True):
self.vncViewer.set_scaling(False)
elif self.scale_type == SCALE_ALWAYS and curscale == False:
elif (self.scale_type == self.config.CONSOLE_SCALE_ALWAYS
and curscale == False):
self.vncViewer.set_scaling(True)
elif self.scale_type == SCALE_FULLSCREEN and curscale != fs:
elif (self.scale_type == self.config.CONSOLE_SCALE_FULLSCREEN
and curscale != fs):
self.vncViewer.set_scaling(fs)
def control_fullscreen(self, src):

View File

@ -39,6 +39,7 @@ class vmmPreferences(gobject.GObject):
self.config.on_console_popup_changed(self.refresh_console_popup)
self.config.on_console_keygrab_changed(self.refresh_console_keygrab)
self.config.on_console_scaling_changed(self.refresh_console_scaling)
self.config.on_stats_update_interval_changed(self.refresh_update_interval)
self.config.on_stats_history_length_changed(self.refresh_history_length)
self.config.on_sound_local_changed(self.refresh_sound_local)
@ -52,6 +53,7 @@ class vmmPreferences(gobject.GObject):
self.refresh_history_length()
self.refresh_console_popup()
self.refresh_console_keygrab()
self.refresh_console_scaling()
self.refresh_sound_local()
self.refresh_sound_remote()
self.refresh_disk_poll()
@ -64,6 +66,7 @@ class vmmPreferences(gobject.GObject):
"on_prefs_stats_history_length_changed": self.change_history_length,
"on_prefs_console_popup_changed": self.change_console_popup,
"on_prefs_console_keygrab_changed": self.change_console_keygrab,
"on_prefs_console_scaling_changed": self.change_console_scaling,
"on_prefs_close_clicked": self.close,
"on_vmm_preferences_delete_event": self.close,
"on_prefs_help_clicked": self.show_help,
@ -92,10 +95,15 @@ class vmmPreferences(gobject.GObject):
def refresh_history_length(self, ignore1=None,ignore2=None,ignore3=None,ignore4=None):
self.window.get_widget("prefs-stats-history-len").set_value(self.config.get_stats_history_length())
def refresh_console_popup(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None):
def refresh_console_popup(self,ignore1=None,ignore2=None,ignore3=None,
ignore4=None):
self.window.get_widget("prefs-console-popup").set_active(self.config.get_console_popup())
def refresh_console_keygrab(self,ignore1=None,ignore2=None,ignore3=None,ignore4=None):
def refresh_console_keygrab(self,ignore1=None,ignore2=None,ignore3=None,
ignore4=None):
self.window.get_widget("prefs-console-keygrab").set_active(self.config.get_console_keygrab())
def refresh_console_scaling(self,ignore1=None,ignore2=None,ignore3=None,
ignore4=None):
self.window.get_widget("prefs-console-scaling").set_active(self.config.get_console_scaling())
def refresh_sound_local(self, ignore1=None, ignore2=None, ignore=None,
ignore4=None):
@ -126,6 +134,8 @@ class vmmPreferences(gobject.GObject):
self.config.set_console_popup(box.get_active())
def change_console_keygrab(self, box):
self.config.set_console_keygrab(box.get_active())
def change_console_scaling(self, box):
self.config.set_console_scaling(box.get_active())
def change_local_sound(self, src):
self.config.set_local_sound(src.get_active())

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Thu Feb 12 11:56:15 2009 -->
<!--Generated with glade3 3.4.5 on Thu Feb 12 14:51:35 2009 -->
<glade-interface>
<widget class="GtkWindow" id="vmm-preferences">
<property name="title" translatable="yes">Preferences</property>
@ -37,34 +37,27 @@
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label6">
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Update status every</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maintain history of</property>
<property name="label" translatable="yes">samples</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="prefs-stats-update-interval">
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 60 1 5 0</property>
<signal name="value_changed" handler="on_prefs_stats_update_interval_changed"/>
<property name="xalign">0</property>
<property name="label" translatable="yes">seconds</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
@ -84,29 +77,36 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<widget class="GtkSpinButton" id="prefs-stats-update-interval">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">seconds</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 60 1 5 0</property>
<signal name="value_changed" handler="on_prefs_stats_update_interval_changed"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label9">
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">samples</property>
<property name="label" translatable="yes">Maintain history of</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Update status every</property>
</widget>
</child>
</widget>
</child>
</widget>
@ -143,79 +143,18 @@
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label11">
<widget class="GtkCheckButton" id="prefs-stats-enable-net">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">CPU Usage</property>
<property name="ellipsize">PANGO_ELLIPSIZE_END</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Memory Usage</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Disk I/O</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Network I/O</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_net_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-cpu">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_cpu_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-mem">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_mem_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
@ -236,19 +175,80 @@
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-net">
<widget class="GtkCheckButton" id="prefs-stats-enable-mem">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_net_toggled"/>
<signal name="toggled" handler="on_prefs_stats_enable_mem_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-cpu">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_cpu_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Network I/O</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_EXPAND</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Disk I/O</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Memory Usage</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">CPU Usage</property>
<property name="ellipsize">PANGO_ELLIPSIZE_END</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
@ -300,39 +300,32 @@
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_rows">6</property>
<property name="n_columns">1</property>
<property name="row_spacing">2</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkComboBox" id="prefs-console-popup">
<widget class="GtkComboBox" id="prefs-console-scaling">
<property name="visible">True</property>
<property name="items" translatable="yes">Never
For all new domains
For all domains</property>
<signal name="changed" handler="on_prefs_console_popup_changed"/>
Fullscreen only
Always</property>
<signal name="changed" handler="on_prefs_console_scaling_changed"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Automatically open consoles:</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grab keyboard input:</property>
<property name="label" translatable="yes">Graphical Console Scaling:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
@ -349,6 +342,38 @@ On mouse over</property>
<property name="x_padding">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grab keyboard input:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Automatically open consoles:</property>
</widget>
</child>
<child>
<widget class="GtkComboBox" id="prefs-console-popup">
<property name="visible">True</property>
<property name="items" translatable="yes">Never
For all new domains
For all domains</property>
<signal name="changed" handler="on_prefs_console_popup_changed"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_padding">5</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -383,13 +408,6 @@ On mouse over</property>
<property name="n_rows">2</property>
<property name="n_columns">1</property>
<property name="column_spacing">8</property>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Install Audio Device:</property>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
@ -428,6 +446,13 @@ On mouse over</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Install Audio Device:</property>
</widget>
</child>
</widget>
</child>
</widget>