diff options
author | Lukas Venhoda <lvenhoda@redhat.com> | 2015-06-16 16:23:33 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2015-06-18 17:06:42 +0200 |
commit | af145bc0de97fb28e75a29e13404b3f3fc5bbb17 (patch) | |
tree | 22ae7ee7cccc3b1fd2c6f03a4efb457eb73f9ba4 | |
parent | d28dfda35e1c1e6d1da42fef42e8831b24167cfb (diff) |
spicy: Replace duplicated code with a for loop
Changed piece of code working with fixed size array into a for loop.
-rw-r--r-- | src/spicy-connect.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/spicy-connect.c b/src/spicy-connect.c index 767ad06..3eee40f 100644 --- a/src/spicy-connect.c +++ b/src/spicy-connect.c @@ -106,6 +106,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) @@ -116,17 +117,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); } |