diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-05-26 13:46:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-05-26 13:46:08 +0000 |
commit | 597510a370e10e4f3afd3347aee0f3a27a397ba7 (patch) | |
tree | 5294b040e4e937bd487a4e8160b4324e0f5149c9 | |
parent | 17b52d57b13216000a5b321132e72d2554d76724 (diff) | |
download | gnunet-gtk-597510a370e10e4f3afd3347aee0f3a27a397ba7.tar.gz gnunet-gtk-597510a370e10e4f3afd3347aee0f3a27a397ba7.zip |
-finish update logic
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_contacts.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_contacts.c b/src/conversation/gnunet-conversation-gtk_contacts.c index aee03604..76be3909 100644 --- a/src/conversation/gnunet-conversation-gtk_contacts.c +++ b/src/conversation/gnunet-conversation-gtk_contacts.c | |||
@@ -365,6 +365,8 @@ display_record (void *cls, | |||
365 | GtkTreeIter iter; | 365 | GtkTreeIter iter; |
366 | gboolean do_display; | 366 | gboolean do_display; |
367 | const char *type; | 367 | const char *type; |
368 | gchar *lname; | ||
369 | gboolean update; | ||
368 | 370 | ||
369 | if (NULL == zone_key) | 371 | if (NULL == zone_key) |
370 | { | 372 | { |
@@ -390,14 +392,45 @@ display_record (void *cls, | |||
390 | break; | 392 | break; |
391 | } | 393 | } |
392 | } | 394 | } |
393 | /* FIXME: check if exists, if so, update or delete */ | ||
394 | 395 | ||
396 | /* check if exists, if so, update or remove */ | ||
397 | update = FALSE; | ||
398 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (contacts_liststore), | ||
399 | &iter)) | ||
400 | { | ||
401 | do | ||
402 | { | ||
403 | gtk_tree_model_get (GTK_TREE_MODEL(contacts_liststore), | ||
404 | &iter, | ||
405 | CONTACTS_LS_NAME, &lname, | ||
406 | -1); | ||
407 | if (0 == strcmp (lname, | ||
408 | rname)) | ||
409 | { | ||
410 | if (! do_display) | ||
411 | { | ||
412 | /* remove */ | ||
413 | gtk_list_store_remove (contacts_liststore, | ||
414 | &iter); | ||
415 | g_free (lname); | ||
416 | return; | ||
417 | } | ||
418 | /* update */ | ||
419 | update = TRUE; | ||
420 | break; | ||
421 | } | ||
422 | g_free (lname); | ||
423 | } | ||
424 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL(contacts_liststore), | ||
425 | &iter)); | ||
426 | } | ||
395 | 427 | ||
396 | /* insert new record */ | 428 | /* insert new record */ |
397 | if (! do_display) | 429 | if (! do_display) |
398 | return; | 430 | return; |
399 | gtk_list_store_append (contacts_liststore, | 431 | if (! update) |
400 | &iter); | 432 | gtk_list_store_append (contacts_liststore, |
433 | &iter); | ||
401 | gtk_list_store_set (contacts_liststore, | 434 | gtk_list_store_set (contacts_liststore, |
402 | &iter, | 435 | &iter, |
403 | CONTACTS_LS_NAME, rname, | 436 | CONTACTS_LS_NAME, rname, |