[virt-tools-list] [virt-viewer v3 01/10] vv-file: Move version checking code in its own function

Christophe Fergeau cfergeau at redhat.com
Tue Jun 9 10:38:12 UTC 2015


This moves the version checking code in a
virt_viewer_file_check_min_version helper so that it can be
reused/extended more easily.
---
 src/virt-viewer-file.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 69b6531..8b732a3 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -707,12 +707,9 @@ spice_hotkey_set_accel(const gchar *accel_path, const gchar *key)
     gtk_accel_map_change_entry(accel_path, accel_key, accel_mods, TRUE);
 }
 
-gboolean
-virt_viewer_file_fill_app(VirtViewerFile* self, VirtViewerApp *app, GError **error)
+static gboolean
+virt_viewer_file_check_min_version(VirtViewerFile *self, GError **error)
 {
-    g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), FALSE);
-    g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
-
     if (virt_viewer_file_is_set(self, "version")) {
         gchar *val = virt_viewer_file_get_version(self);
 
@@ -730,6 +727,19 @@ virt_viewer_file_fill_app(VirtViewerFile* self, VirtViewerApp *app, GError **err
         g_free(val);
     }
 
+    return TRUE;
+}
+
+gboolean
+virt_viewer_file_fill_app(VirtViewerFile* self, VirtViewerApp *app, GError **error)
+{
+    g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), FALSE);
+    g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
+
+    if (!virt_viewer_file_check_min_version(self, error)) {
+        return FALSE;
+    }
+
     if (virt_viewer_file_is_set(self, "title")) {
         char *title = virt_viewer_file_get_title(self);
         g_object_set(app, "title", title, NULL);
-- 
2.4.2




More information about the virt-tools-list mailing list