[spicy PATCH 5/6 v5] spicy: Replace duplicated code with a for loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changed piece of code working with fixed size array into a for loop.
---
Changes since v4
 - Reworded shortlog

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 12c3a01..a3a22d3 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.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]