diff options
Diffstat (limited to 'src/gns/gnunet-gns-gtk_zone.c')
-rw-r--r-- | src/gns/gnunet-gns-gtk_zone.c | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/src/gns/gnunet-gns-gtk_zone.c b/src/gns/gnunet-gns-gtk_zone.c index 10d52dbb..39f6f6ef 100644 --- a/src/gns/gnunet-gns-gtk_zone.c +++ b/src/gns/gnunet-gns-gtk_zone.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "gnunet_gtk.h" | 26 | #include "gnunet_gtk.h" |
27 | #include "gnunet-gns-gtk.h" | 27 | #include "gnunet-gns-gtk.h" |
28 | 28 | ||
29 | #define NEW_NAME_STR "<new name>" | ||
29 | #define NEW_RECORD_STR "<new record>" | 30 | #define NEW_RECORD_STR "<new record>" |
30 | 31 | ||
31 | enum | 32 | enum |
@@ -40,7 +41,8 @@ enum | |||
40 | TREE_COL_VAL_AS_STR, | 41 | TREE_COL_VAL_AS_STR, |
41 | TREE_COL_VAL_COLOR, | 42 | TREE_COL_VAL_COLOR, |
42 | TREE_COL_NAME_IS_EDITABLE, | 43 | TREE_COL_NAME_IS_EDITABLE, |
43 | TREE_COL_IS_RECORD_ROW = 10 | 44 | TREE_COL_IS_RECORD_ROW, |
45 | TREE_COL_NOT_DUMMY_ROW | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | enum | 48 | enum |
@@ -67,36 +69,48 @@ GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
67 | { | 69 | { |
68 | struct GNUNET_GNS_Context *gns = user_data; | 70 | struct GNUNET_GNS_Context *gns = user_data; |
69 | GtkTreeIter it; | 71 | GtkTreeIter it; |
72 | GtkTreeIter child; | ||
70 | GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts); | 73 | GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts); |
71 | guint type; | 74 | guint type; |
72 | // int is_row; | 75 | int record_row; |
73 | char *type_str; | 76 | char *type_str; |
74 | char *value_str; | 77 | char *value_str; |
78 | char *name_str; | ||
75 | void *data; | 79 | void *data; |
76 | size_t data_size; | 80 | size_t data_size; |
77 | 81 | ||
82 | gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, 0, &type, -1); | ||
83 | gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, TYPE_LIST_TYPENAME, &type_str, -1); | ||
84 | |||
85 | |||
78 | /* check if this is a new record */ | 86 | /* check if this is a new record */ |
79 | /* | 87 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
80 | gtk_tree_model_get(tm, &it, TREE_COL_IS_NAME_ROW, &is_row, -1); | 88 | gtk_tree_model_get(tm, &it, TREE_COL_IS_RECORD_ROW, &record_row, -1); |
89 | gtk_tree_model_get(tm, &it, TREE_COL_NAME, &name_str, -1); | ||
81 | 90 | ||
82 | if (0 == is_row) | 91 | if (GNUNET_YES == record_row) |
83 | { | 92 | { |
84 | 93 | /* Updating an existing record */ | |
94 | gtk_tree_store_set(gns->ts, &it, | ||
95 | TREE_COL_RECORD_TYPE, type, | ||
96 | TREE_COL_RECORD_TYPE_AS_STR, type_str, | ||
97 | -1); | ||
85 | } | 98 | } |
86 | else | 99 | else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str))) |
87 | { | 100 | { |
101 | /* Adding a new record */ | ||
102 | GNUNET_break (0); | ||
103 | gtk_tree_store_insert_with_values(gns->ts, &child , &it, 0, | ||
104 | TREE_COL_RECORD_TYPE, type, | ||
105 | TREE_COL_RECORD_TYPE_AS_STR, type_str, | ||
106 | TREE_COL_IS_RECORD_ROW, GNUNET_YES, | ||
107 | TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, | ||
108 | -1); | ||
88 | 109 | ||
89 | } | 110 | } |
90 | */ | ||
91 | gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, 0, &type, -1); | ||
92 | gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, TYPE_LIST_TYPENAME, &type_str, -1); | ||
93 | |||
94 | gtk_tree_model_get_iter_from_string(tm, &it, path); | ||
95 | gtk_tree_store_set(gns->ts, &it, | ||
96 | TREE_COL_RECORD_TYPE, type, | ||
97 | TREE_COL_RECORD_TYPE_AS_STR, type_str, | ||
98 | -1); | ||
99 | GNUNET_free (type_str); | 111 | GNUNET_free (type_str); |
112 | GNUNET_free_non_null (name_str); | ||
113 | |||
100 | 114 | ||
101 | /* check if value is still valid */ | 115 | /* check if value is still valid */ |
102 | gtk_tree_model_get(tm, &it, TREE_COL_VAL_AS_STR, &value_str, -1); | 116 | gtk_tree_model_get(tm, &it, TREE_COL_VAL_AS_STR, &value_str, -1); |
@@ -109,8 +123,18 @@ GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
109 | gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, "red", -1); | 123 | gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, "red", -1); |
110 | else | 124 | else |
111 | gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, NULL, -1); | 125 | gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, NULL, -1); |
126 | GNUNET_free (value_str); | ||
127 | } | ||
128 | else if (NULL == value_str) | ||
129 | { | ||
130 | /* Empty value field */ | ||
131 | GNUNET_break (0); | ||
132 | if (GNUNET_YES == record_row) | ||
133 | gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, "red", -1); | ||
134 | else | ||
135 | gtk_tree_store_set (gns->ts, &child, TREE_COL_VAL_COLOR, "red", -1); | ||
112 | } | 136 | } |
113 | GNUNET_free (value_str); | 137 | |
114 | } | 138 | } |
115 | 139 | ||
116 | 140 | ||
@@ -222,32 +246,23 @@ GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
222 | GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts); | 246 | GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts); |
223 | 247 | ||
224 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New text for `%s' is `%s'\n", path, new_text); | 248 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New text for `%s' is `%s'\n", path, new_text); |
225 | if ((0 == strcmp (path, "0")) && (0 != strcmp (new_text, NEW_RECORD_STR)) ) | 249 | if ((0 == strcmp (path, "0")) && (0 != strcmp (new_text, NEW_NAME_STR)) ) |
226 | { | 250 | { |
227 | GNUNET_break (0); | 251 | GNUNET_break (0); |
228 | /* update name */ | 252 | /* update name */ |
229 | gtk_tree_model_get_iter_from_string(tm, &it, path); | 253 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
230 | gtk_tree_store_set (gns->ts, &it, TREE_COL_NAME, new_text, -1); | 254 | gtk_tree_store_set (gns->ts, &it, TREE_COL_NAME, new_text, -1); |
255 | gtk_tree_store_set (gns->ts, &it, TREE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR), -1); | ||
256 | gtk_tree_store_set (gns->ts, &it, TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, -1); | ||
231 | 257 | ||
232 | /* add a new dummy line */ | 258 | /* add a new dummy line */ |
233 | gtk_tree_store_insert_with_values (gns->ts, &it,NULL, 0, | 259 | gtk_tree_store_insert_with_values (gns->ts, &it,NULL, 0, |
234 | TREE_COL_NAME, _(NEW_RECORD_STR), | 260 | TREE_COL_NAME, _(NEW_NAME_STR), |
235 | TREE_COL_RECORD_TYPE, 1, | 261 | TREE_COL_RECORD_TYPE, 1, |
236 | TREE_COL_NAME_IS_EDITABLE, 1, | 262 | TREE_COL_NAME_IS_EDITABLE, 1, |
237 | //TREE_COL_IS_NAME_ROW, 1 | 263 | TREE_COL_NOT_DUMMY_ROW, GNUNET_NO, |
264 | TREE_COL_IS_RECORD_ROW, GNUNET_NO, | ||
238 | -1); | 265 | -1); |
239 | #if 0 | ||
240 | gtk_tree_store_append(gns->ts, &it, NULL); | ||
241 | gtk_tree_store_set(gns->ts, &it, | ||
242 | TREE_COL_NAME, new_text, | ||
243 | TREE_COL_RECORD_TYPE, 1, | ||
244 | -1); | ||
245 | /* add a new name */ | ||
246 | gtk_tree_store_append(gns->ts, &it, NULL); | ||
247 | gtk_tree_store_set(gns->ts, &it, | ||
248 | TREE_COL_NAME, new_text, | ||
249 | TREE_COL_RECORD_TYPE, 1, -1); | ||
250 | #endif | ||
251 | } | 266 | } |
252 | else | 267 | else |
253 | { | 268 | { |
@@ -323,7 +338,9 @@ void zone_iteration_proc (void *cls, | |||
323 | gtk_tree_store_set(zc_ctx->gns->ts, &iter_name, | 338 | gtk_tree_store_set(zc_ctx->gns->ts, &iter_name, |
324 | TREE_COL_NAME, name, | 339 | TREE_COL_NAME, name, |
325 | TREE_COL_NAME_IS_EDITABLE, 1, | 340 | TREE_COL_NAME_IS_EDITABLE, 1, |
341 | TREE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR), | ||
326 | TREE_COL_IS_RECORD_ROW, GNUNET_NO, | 342 | TREE_COL_IS_RECORD_ROW, GNUNET_NO, |
343 | TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, | ||
327 | -1); | 344 | -1); |
328 | 345 | ||
329 | 346 | ||
@@ -363,6 +380,7 @@ void zone_iteration_proc (void *cls, | |||
363 | TREE_COL_EXP_TIME_IS_REL, time_is_relative, | 380 | TREE_COL_EXP_TIME_IS_REL, time_is_relative, |
364 | TREE_COL_VAL_AS_STR, val, | 381 | TREE_COL_VAL_AS_STR, val, |
365 | TREE_COL_IS_RECORD_ROW, GNUNET_YES, | 382 | TREE_COL_IS_RECORD_ROW, GNUNET_YES, |
383 | TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, | ||
366 | -1); | 384 | -1); |
367 | 385 | ||
368 | GNUNET_free (exp); | 386 | GNUNET_free (exp); |
@@ -387,10 +405,11 @@ GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget, | |||
387 | 405 | ||
388 | /* Append a top level row and leave it empty */ | 406 | /* Append a top level row and leave it empty */ |
389 | gtk_tree_store_insert_with_values(gns->ts, &toplevel, NULL, 0, | 407 | gtk_tree_store_insert_with_values(gns->ts, &toplevel, NULL, 0, |
390 | TREE_COL_NAME, _(NEW_RECORD_STR), | 408 | TREE_COL_NAME, _(NEW_NAME_STR), |
391 | TREE_COL_RECORD_TYPE, 1, | 409 | TREE_COL_RECORD_TYPE, 1, |
392 | TREE_COL_NAME_IS_EDITABLE, 1, | 410 | TREE_COL_NAME_IS_EDITABLE, 1, |
393 | TREE_COL_IS_RECORD_ROW, GNUNET_NO, | 411 | TREE_COL_IS_RECORD_ROW, GNUNET_NO, |
412 | TREE_COL_NOT_DUMMY_ROW, GNUNET_NO, | ||
394 | -1); | 413 | -1); |
395 | 414 | ||
396 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); | 415 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); |