[virt-tools-list] [PATCHv3 virt-viewer 02/12] Define the min/max zoom levels, so all values are sync

Marc-André Lureau marcandre.lureau at gmail.com
Tue Aug 20 12:19:52 UTC 2013


---
 src/virt-viewer-app.c     |  4 ++--
 src/virt-viewer-display.c | 12 ++++++------
 src/virt-viewer-window.h  |  3 +++
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 637896e..06a443b 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1430,8 +1430,8 @@ virt_viewer_app_init (VirtViewerApp *self)
 
     g_clear_error(&error);
 
-    if (opt_zoom < 10 || opt_zoom > 200) {
-        g_printerr(_("Zoom level must be within 10-200\n"));
+    if (opt_zoom < MIN_ZOOM_LEVEL || opt_zoom > MAX_ZOOM_LEVEL) {
+        g_printerr(_("Zoom level must be within %d-%d\n"), MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL);
         opt_zoom = 100;
     }
 
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 8810254..efae385 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -144,8 +144,8 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
                                     g_param_spec_int("zoom-level",
                                                      "Zoom",
                                                      "Zoom level",
-                                                     10,
-                                                     400,
+                                                     MIN_ZOOM_LEVEL,
+                                                     MAX_ZOOM_LEVEL,
                                                      100,
                                                      G_PARAM_READWRITE));
 
@@ -577,10 +577,10 @@ void virt_viewer_display_set_zoom_level(VirtViewerDisplay *display,
 {
     VirtViewerDisplayPrivate *priv = display->priv;
 
-    if (zoom < 10)
-        zoom = 10;
-    if (zoom > 400)
-        zoom = 400;
+    if (zoom < MIN_ZOOM_LEVEL)
+        zoom = MIN_ZOOM_LEVEL;
+    if (zoom > MAX_ZOOM_LEVEL)
+        zoom = MAX_ZOOM_LEVEL;
     priv->zoom_level = zoom;
 
     virt_viewer_display_queue_resize(display);
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 41ac5e2..5066dbf 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -30,6 +30,9 @@
 
 G_BEGIN_DECLS
 
+#define MIN_ZOOM_LEVEL 10
+#define MAX_ZOOM_LEVEL 400
+
 #define VIRT_VIEWER_TYPE_WINDOW virt_viewer_window_get_type()
 
 #define VIRT_VIEWER_WINDOW(obj)                                                \
-- 
1.8.3.rc1.49.g8d97506




More information about the virt-tools-list mailing list