[Spice-devel] [spicy PATCH 6/7 v4] spicy: Changed duplicit lines to for loop

Lukas Venhoda lvenhoda at redhat.com
Tue Jun 16 02:41:56 PDT 2015


Changed piece of code working with fixed size array into a for loop.
---
Changes since v3
 - New patch
---
 src/spicy-connect.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/spicy-connect.c b/src/spicy-connect.c
index c5f1dfb..7834e3a 100644
--- a/src/spicy-connect.c
+++ b/src/spicy-connect.c
@@ -111,6 +111,7 @@ static void recent_selection_changed_dialog_cb(GtkRecentChooser *chooser, gpoint
     gchar *txt = NULL;
     const gchar *uri;
     SpiceSession *session = data;
+    int i;

     info = gtk_recent_chooser_get_current_item(chooser);
     if (info == NULL)
@@ -121,17 +122,11 @@ static void recent_selection_changed_dialog_cb(GtkRecentChooser *chooser, gpoint

     g_object_set(session, "uri", uri, NULL);

-    g_object_get(session, "host", &txt, NULL);
-    gtk_entry_set_text(GTK_ENTRY(connect_entries[0].entry), txt ? txt : "");
-    g_free(txt);
-
-    g_object_get(session, "port", &txt, NULL);
-    gtk_entry_set_text(GTK_ENTRY(connect_entries[1].entry), txt ? txt : "");
-    g_free(txt);
-
-    g_object_get(session, "tls-port", &txt, NULL);
-    gtk_entry_set_text(GTK_ENTRY(connect_entries[2].entry), txt ? txt : "");
-    g_free(txt);
+    for (i = 0; i < SPICE_N_ELEMENTS(connect_entries); i++) {
+        g_object_get(session, connect_entries[i].prop, &txt, NULL);
+        gtk_entry_set_text(GTK_ENTRY(connect_entries[i].entry), txt ? txt : "");
+        g_free(txt);
+    }

     gtk_recent_info_unref(info);
 }
--
2.4.2



More information about the Spice-devel mailing list