diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-26 14:57:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-26 14:57:33 +0000 |
commit | 5f7ec4146b7f6ad8feb2dbf1cfbffdb1477ce428 (patch) | |
tree | 39752ca21008a6bf7eb1d7fe558ac420079dc88b | |
parent | 23d09c46314c5fd1fb024f05489514a57d7813a5 (diff) | |
download | gnunet-gtk-5f7ec4146b7f6ad8feb2dbf1cfbffdb1477ce428.tar.gz gnunet-gtk-5f7ec4146b7f6ad8feb2dbf1cfbffdb1477ce428.zip |
-fixes
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index f1956e27..874f145d 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -508,8 +508,8 @@ struct RemoveContext | |||
508 | */ | 508 | */ |
509 | static void | 509 | static void |
510 | update_treemodel_after_remove (void *cls, | 510 | update_treemodel_after_remove (void *cls, |
511 | int32_t success, | 511 | int32_t success, |
512 | const char *emsg) | 512 | const char *emsg) |
513 | { | 513 | { |
514 | struct RemoveContext *rcc = cls; | 514 | struct RemoveContext *rcc = cls; |
515 | GtkTreeIter it; | 515 | GtkTreeIter it; |
@@ -540,7 +540,7 @@ update_treemodel_after_remove (void *cls, | |||
540 | * @param path | 540 | * @param path |
541 | */ | 541 | */ |
542 | static void | 542 | static void |
543 | check_name_validity_and_remove (gchar *path) | 543 | check_name_validity_and_remove (const gchar *path) |
544 | { | 544 | { |
545 | GtkTreeIter it; | 545 | GtkTreeIter it; |
546 | GtkTreeIter parent; | 546 | GtkTreeIter parent; |
@@ -656,34 +656,47 @@ GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
656 | GtkTreeIter it; | 656 | GtkTreeIter it; |
657 | GtkTreeIter child; | 657 | GtkTreeIter child; |
658 | guint type; | 658 | guint type; |
659 | int record_row; | ||
660 | char *type_str; | 659 | char *type_str; |
661 | char *value_str; | 660 | gboolean not_dummy_row; |
662 | char *name_str; | 661 | char *name_str; |
662 | char *value_str; | ||
663 | int is_valid; | ||
663 | void *data; | 664 | void *data; |
664 | size_t data_size; | 665 | size_t data_size; |
665 | 666 | ||
666 | gtk_tree_model_get(GTK_TREE_MODEL(ls), new_iter, 0, &type, -1); | 667 | gtk_tree_model_get (GTK_TREE_MODEL(ls), new_iter, |
667 | gtk_tree_model_get(GTK_TREE_MODEL(ls), new_iter, GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME, &type_str, -1); | 668 | GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPE, &type, |
668 | 669 | GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME, &type_str, | |
669 | 670 | -1); | |
670 | /* check if this is a new record */ | 671 | /* check if this is a new record */ |
671 | gtk_tree_model_get_iter_from_string(tm, &it, path); | 672 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
672 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_IS_RECORD_ROW, &record_row, -1); | 673 | gtk_tree_model_get(tm, &it, |
673 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NAME, &name_str, -1); | 674 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy_row, |
674 | 675 | GNS_TREESTORE_COL_NAME, &name_str, | |
675 | if (GNUNET_YES == record_row) | 676 | GNS_TREESTORE_COL_VAL_AS_STR, &value_str, |
677 | -1); | ||
678 | is_valid = GNUNET_NO; | ||
679 | if ( (NULL != value_str) && | ||
680 | (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (type, | ||
681 | value_str, | ||
682 | &data, | ||
683 | &data_size)) ) | ||
684 | { | ||
685 | is_valid = GNUNET_YES; | ||
686 | GNUNET_free_non_null (data); | ||
687 | } | ||
688 | if (not_dummy_row) | ||
676 | { | 689 | { |
677 | /* Updating an existing record */ | 690 | /* Updating an existing record */ |
678 | gtk_tree_store_set(ts, &it, | 691 | gtk_tree_store_set(ts, &it, |
679 | GNS_TREESTORE_COL_RECORD_TYPE, type, | 692 | GNS_TREESTORE_COL_RECORD_TYPE, type, |
680 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, | 693 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, |
694 | GNS_TREESTORE_COL_VAL_COLOR, (GNUNET_NO == is_valid) ? "red" : NULL, | ||
681 | -1); | 695 | -1); |
682 | } | 696 | } |
683 | else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str))) | 697 | else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str))) |
684 | { | 698 | { |
685 | /* Adding a new record */ | 699 | /* Adding a new record */ |
686 | |||
687 | gtk_tree_store_insert_with_values(ts, &child , &it, 0, | 700 | gtk_tree_store_insert_with_values(ts, &child , &it, 0, |
688 | GNS_TREESTORE_COL_NAME, name_str, | 701 | GNS_TREESTORE_COL_NAME, name_str, |
689 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, | 702 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, |
@@ -694,36 +707,19 @@ GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
694 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE, | 707 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE, |
695 | GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE, | 708 | GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE, |
696 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, | 709 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, |
697 | -1); | 710 | GNS_TREESTORE_COL_VAL_COLOR, "red", |
711 | -1); | ||
698 | gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0); | 712 | gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0); |
699 | |||
700 | } | 713 | } |
701 | GNUNET_free (type_str); | 714 | else |
702 | |||
703 | /* check if value is still valid */ | ||
704 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_VAL_AS_STR, &value_str, -1); | ||
705 | if (NULL != value_str) | ||
706 | { | ||
707 | if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value (type, | ||
708 | value_str, | ||
709 | &data, | ||
710 | &data_size)) | ||
711 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | ||
712 | else | ||
713 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); | ||
714 | GNUNET_free (value_str); | ||
715 | } | ||
716 | else if (NULL == value_str) | ||
717 | { | 715 | { |
718 | /* Empty value field */ | 716 | /* type should not have been editable! */ |
719 | if (GNUNET_YES == record_row) | 717 | GNUNET_break (0); |
720 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | ||
721 | else | ||
722 | gtk_tree_store_set (ts, &child, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | ||
723 | } | 718 | } |
724 | 719 | GNUNET_free (type_str); | |
725 | check_name_validity_and_commit (path, NULL); | 720 | GNUNET_free (value_str); |
726 | GNUNET_free_non_null (name_str); | 721 | GNUNET_free_non_null (name_str); |
722 | check_name_validity_and_commit (path, NULL); | ||
727 | } | 723 | } |
728 | 724 | ||
729 | 725 | ||