diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-26 15:28:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-26 15:28:30 +0000 |
commit | df73ea25148645c15b095abe1ead5289fc2a4f98 (patch) | |
tree | bc17f3bcf18761cd5c1ee2ed3a38221abe04f835 | |
parent | 102b87c5b1805d8778604a7e95011ff2221336d7 (diff) | |
download | gnunet-gtk-df73ea25148645c15b095abe1ead5289fc2a4f98.tar.gz gnunet-gtk-df73ea25148645c15b095abe1ead5289fc2a4f98.zip |
-more cleanup
-rw-r--r-- | contrib/gnunet_setup_gtk_main_window.glade | 2 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 53 |
2 files changed, 32 insertions, 23 deletions
diff --git a/contrib/gnunet_setup_gtk_main_window.glade b/contrib/gnunet_setup_gtk_main_window.glade index ab699f1c..a0307c3a 100644 --- a/contrib/gnunet_setup_gtk_main_window.glade +++ b/contrib/gnunet_setup_gtk_main_window.glade | |||
@@ -4620,7 +4620,7 @@ | |||
4620 | <property name="editable">True</property> | 4620 | <property name="editable">True</property> |
4621 | <property name="model">GNUNET_setup_gns_type_liststore</property> | 4621 | <property name="model">GNUNET_setup_gns_type_liststore</property> |
4622 | <property name="text_column">1</property> | 4622 | <property name="text_column">1</property> |
4623 | <signal name="changed" handler="GNUNET_setup_gns_type_cellrenderercombo_changed_cb" swapped="no"/> | 4623 | <signal name="edited" handler="GNUNET_setup_gns_type_cellrenderercombo_edited_cb" swapped="no"/> |
4624 | </object> | 4624 | </object> |
4625 | <attributes> | 4625 | <attributes> |
4626 | <attribute name="visible">10</attribute> | 4626 | <attribute name="visible">10</attribute> |
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index fe7ba60b..78aa3a0c 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -182,22 +182,17 @@ static char *zonekey_directory; | |||
182 | static struct GNUNET_NAMESTORE_Handle *namestore; | 182 | static struct GNUNET_NAMESTORE_Handle *namestore; |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * FIXME... | 185 | * Tree store with all of the values we're modifying for GNS. |
186 | */ | 186 | */ |
187 | static GtkTreeStore *ts; | 187 | static GtkTreeStore *ts; |
188 | 188 | ||
189 | /** | 189 | /** |
190 | * FIXME... | 190 | * Tree model (same object as 'ts', just different type). |
191 | */ | ||
192 | static GtkListStore *ls; | ||
193 | |||
194 | /** | ||
195 | * FIXME... | ||
196 | */ | 191 | */ |
197 | static GtkTreeModel *tm; | 192 | static GtkTreeModel *tm; |
198 | 193 | ||
199 | /** | 194 | /** |
200 | * FIXME... | 195 | * The main tree view for 'gns' that shows the records. |
201 | */ | 196 | */ |
202 | static GtkTreeView *tv; | 197 | static GtkTreeView *tv; |
203 | 198 | ||
@@ -648,26 +643,32 @@ check_name_validity_and_remove (const gchar *path) | |||
648 | * @param user_data unused | 643 | * @param user_data unused |
649 | */ | 644 | */ |
650 | void | 645 | void |
651 | GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | 646 | GNUNET_setup_gns_type_cellrenderercombo_edited_cb (GtkCellRendererCombo *combo, |
652 | gchar *path, | 647 | gchar *path, |
653 | GtkTreeIter *new_iter, | 648 | gchar *new_text, |
654 | gpointer user_data) | 649 | gpointer user_data) |
655 | { | 650 | { |
651 | GtkTreeSelection *sel; | ||
656 | GtkTreeIter it; | 652 | GtkTreeIter it; |
657 | GtkTreeIter child; | 653 | GtkTreeIter child; |
658 | guint type; | 654 | guint type; |
659 | char *type_str; | ||
660 | gboolean not_dummy_row; | 655 | gboolean not_dummy_row; |
661 | char *name_str; | 656 | char *name_str; |
662 | char *value_str; | 657 | char *value_str; |
663 | int is_valid; | 658 | int is_valid; |
664 | void *data; | 659 | void *data; |
665 | size_t data_size; | 660 | size_t data_size; |
661 | GtkTreePath *tp; | ||
662 | GtkTreeViewColumn *value_column; | ||
666 | 663 | ||
667 | gtk_tree_model_get (GTK_TREE_MODEL(ls), new_iter, | 664 | type = GNUNET_NAMESTORE_typename_to_number (new_text); |
668 | GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPE, &type, | 665 | if (UINT32_MAX == type) |
669 | GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME, &type_str, | 666 | { |
670 | -1); | 667 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
668 | "Invalid or unsupported record type `%s'\n", | ||
669 | new_text); | ||
670 | return; | ||
671 | } | ||
671 | /* check if this is a new record */ | 672 | /* check if this is a new record */ |
672 | gtk_tree_model_get_iter_from_string(tm, &it, path); | 673 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
673 | gtk_tree_model_get(tm, &it, | 674 | gtk_tree_model_get(tm, &it, |
@@ -690,18 +691,18 @@ GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
690 | /* Updating an existing record */ | 691 | /* Updating an existing record */ |
691 | gtk_tree_store_set(ts, &it, | 692 | gtk_tree_store_set(ts, &it, |
692 | GNS_TREESTORE_COL_RECORD_TYPE, type, | 693 | GNS_TREESTORE_COL_RECORD_TYPE, type, |
693 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, | 694 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, new_text, |
694 | GNS_TREESTORE_COL_VAL_COLOR, (GNUNET_NO == is_valid) ? "red" : NULL, | 695 | GNS_TREESTORE_COL_VAL_COLOR, (GNUNET_NO == is_valid) ? "red" : NULL, |
695 | -1); | 696 | -1); |
696 | } | 697 | } |
697 | else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str))) | 698 | else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str))) |
698 | { | 699 | { |
699 | /* Adding a new record */ | 700 | /* Adding a new record */ |
700 | gtk_tree_store_insert_with_values(ts, &child , &it, 0, | 701 | gtk_tree_store_insert_with_values(ts, &child , &it, -1, |
701 | GNS_TREESTORE_COL_NAME, name_str, | 702 | GNS_TREESTORE_COL_NAME, name_str, |
702 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, | 703 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, |
703 | GNS_TREESTORE_COL_RECORD_TYPE, type, | 704 | GNS_TREESTORE_COL_RECORD_TYPE, type, |
704 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, | 705 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, new_text, |
705 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, EXPIRE_NEVER_STRING, | 706 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, EXPIRE_NEVER_STRING, |
706 | GNS_TREESTORE_COL_EXP_TIME, GNUNET_TIME_UNIT_FOREVER_ABS, | 707 | GNS_TREESTORE_COL_EXP_TIME, GNUNET_TIME_UNIT_FOREVER_ABS, |
707 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE, | 708 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE, |
@@ -709,14 +710,23 @@ GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
709 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, | 710 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, |
710 | GNS_TREESTORE_COL_VAL_COLOR, "red", | 711 | GNS_TREESTORE_COL_VAL_COLOR, "red", |
711 | -1); | 712 | -1); |
713 | /* select new row and start editing 'value' */ | ||
712 | gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0); | 714 | gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0); |
715 | sel = gtk_tree_view_get_selection (tv); | ||
716 | gtk_tree_selection_select_iter (sel, &child); | ||
717 | value_column = GTK_TREE_VIEW_COLUMN (GNUNET_SETUP_get_object ("GNUNET_setup_gns_value_treeviewcolumn")); | ||
718 | tp = gtk_tree_model_get_path (tm, &child); | ||
719 | gtk_tree_view_set_cursor (tv, | ||
720 | tp, | ||
721 | value_column, | ||
722 | TRUE); | ||
723 | gtk_tree_path_free (tp); | ||
713 | } | 724 | } |
714 | else | 725 | else |
715 | { | 726 | { |
716 | /* type should not have been editable! */ | 727 | /* type should not have been editable! */ |
717 | GNUNET_break (0); | 728 | GNUNET_break (0); |
718 | } | 729 | } |
719 | GNUNET_free (type_str); | ||
720 | GNUNET_free_non_null (value_str); | 730 | GNUNET_free_non_null (value_str); |
721 | GNUNET_free_non_null (name_str); | 731 | GNUNET_free_non_null (name_str); |
722 | check_name_validity_and_commit (path, NULL); | 732 | check_name_validity_and_commit (path, NULL); |
@@ -1602,7 +1612,6 @@ GNUNET_SETUP_gns_init () | |||
1602 | return; | 1612 | return; |
1603 | } | 1613 | } |
1604 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); | 1614 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); |
1605 | ls = GTK_LIST_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_type_liststore")); | ||
1606 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); | 1615 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); |
1607 | tm = GTK_TREE_MODEL(ts); | 1616 | tm = GTK_TREE_MODEL(ts); |
1608 | zone_as_string = GNUNET_strdup ((char *) &shenc); | 1617 | zone_as_string = GNUNET_strdup ((char *) &shenc); |