aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-16 16:22:00 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-16 16:22:00 +0000
commit59498b0d3a3370b440d7e6a499fc2d3219d9fc54 (patch)
treebbd0e5802773827b1ae6771f78b71acc08c2866c
parent6dd3df4d8ee1c394a79f3440811abd558551fc27 (diff)
downloadgnunet-gtk-59498b0d3a3370b440d7e6a499fc2d3219d9fc54.tar.gz
gnunet-gtk-59498b0d3a3370b440d7e6a499fc2d3219d9fc54.zip
- mods
-rw-r--r--contrib/gnunet_gns_gtk_main_window.glade107
-rw-r--r--src/gns/gnunet-gns-gtk_zone.c85
2 files changed, 107 insertions, 85 deletions
diff --git a/contrib/gnunet_gns_gtk_main_window.glade b/contrib/gnunet_gns_gtk_main_window.glade
index 2ce2dc29..079c9966 100644
--- a/contrib/gnunet_gns_gtk_main_window.glade
+++ b/contrib/gnunet_gns_gtk_main_window.glade
@@ -2,56 +2,6 @@
2<interface> 2<interface>
3 <requires lib="gtk+" version="2.20"/> 3 <requires lib="gtk+" version="2.20"/>
4 <!-- interface-naming-policy project-wide --> 4 <!-- interface-naming-policy project-wide -->
5 <object class="GtkListStore" id="GNUNET_GNS_GTK_type_liststore">
6 <columns>
7 <!-- column-name type -->
8 <column type="guint"/>
9 <!-- column-name typename -->
10 <column type="gchararray"/>
11 </columns>
12 <data>
13 <row>
14 <col id="0">1</col>
15 <col id="1" translatable="yes">A</col>
16 </row>
17 <row>
18 <col id="0">2</col>
19 <col id="1" translatable="yes">NS</col>
20 </row>
21 <row>
22 <col id="0">5</col>
23 <col id="1" translatable="yes">CNAME</col>
24 </row>
25 <row>
26 <col id="0">6</col>
27 <col id="1" translatable="yes">SOA</col>
28 </row>
29 <row>
30 <col id="0">12</col>
31 <col id="1" translatable="yes">PTR</col>
32 </row>
33 <row>
34 <col id="0">15</col>
35 <col id="1" translatable="yes">MX</col>
36 </row>
37 <row>
38 <col id="0">16</col>
39 <col id="1" translatable="yes">TXT</col>
40 </row>
41 <row>
42 <col id="0">28</col>
43 <col id="1" translatable="yes">AAAA</col>
44 </row>
45 <row>
46 <col id="0">65536</col>
47 <col id="1" translatable="yes">PKEY</col>
48 </row>
49 <row>
50 <col id="0">65537</col>
51 <col id="1" translatable="yes">PSEU</col>
52 </row>
53 </data>
54 </object>
55 <object class="GtkWindow" id="GNUNET_GNS_GTK_main_window"> 5 <object class="GtkWindow" id="GNUNET_GNS_GTK_main_window">
56 <property name="can_focus">False</property> 6 <property name="can_focus">False</property>
57 <property name="default_height">500</property> 7 <property name="default_height">500</property>
@@ -312,8 +262,8 @@
312 </child> 262 </child>
313 <child> 263 <child>
314 <object class="GtkTreeViewColumn" id="GNUNET_GNS_GTK_type_treeviewcolumn"> 264 <object class="GtkTreeViewColumn" id="GNUNET_GNS_GTK_type_treeviewcolumn">
315 <property name="sizing">fixed</property> 265 <property name="sizing">autosize</property>
316 <property name="fixed_width">59</property> 266 <property name="fixed_width">90</property>
317 <property name="title">Type</property> 267 <property name="title">Type</property>
318 <property name="clickable">True</property> 268 <property name="clickable">True</property>
319 <property name="reorderable">True</property> 269 <property name="reorderable">True</property>
@@ -327,6 +277,7 @@
327 <signal name="changed" handler="GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb" swapped="no"/> 277 <signal name="changed" handler="GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb" swapped="no"/>
328 </object> 278 </object>
329 <attributes> 279 <attributes>
280 <attribute name="visible">11</attribute>
330 <attribute name="text">3</attribute> 281 <attribute name="text">3</attribute>
331 </attributes> 282 </attributes>
332 </child> 283 </child>
@@ -405,6 +356,58 @@
405 <column type="gboolean"/> 356 <column type="gboolean"/>
406 <!-- column-name name_is_row --> 357 <!-- column-name name_is_row -->
407 <column type="gboolean"/> 358 <column type="gboolean"/>
359 <!-- column-name not_dummy_row -->
360 <column type="gboolean"/>
408 </columns> 361 </columns>
409 </object> 362 </object>
363 <object class="GtkListStore" id="GNUNET_GNS_GTK_type_liststore">
364 <columns>
365 <!-- column-name type -->
366 <column type="guint"/>
367 <!-- column-name typename -->
368 <column type="gchararray"/>
369 </columns>
370 <data>
371 <row>
372 <col id="0">1</col>
373 <col id="1" translatable="yes">A</col>
374 </row>
375 <row>
376 <col id="0">2</col>
377 <col id="1" translatable="yes">NS</col>
378 </row>
379 <row>
380 <col id="0">5</col>
381 <col id="1" translatable="yes">CNAME</col>
382 </row>
383 <row>
384 <col id="0">6</col>
385 <col id="1" translatable="yes">SOA</col>
386 </row>
387 <row>
388 <col id="0">12</col>
389 <col id="1" translatable="yes">PTR</col>
390 </row>
391 <row>
392 <col id="0">15</col>
393 <col id="1" translatable="yes">MX</col>
394 </row>
395 <row>
396 <col id="0">16</col>
397 <col id="1" translatable="yes">TXT</col>
398 </row>
399 <row>
400 <col id="0">28</col>
401 <col id="1" translatable="yes">AAAA</col>
402 </row>
403 <row>
404 <col id="0">65536</col>
405 <col id="1" translatable="yes">PKEY</col>
406 </row>
407 <row>
408 <col id="0">65537</col>
409 <col id="1" translatable="yes">PSEU</col>
410 </row>
411 </data>
412 </object>
410</interface> 413</interface>
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
31enum 32enum
@@ -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
46enum 48enum
@@ -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));