gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20576 - in gnunet-gtk: contrib src/gns


From: gnunet
Subject: [GNUnet-SVN] r20576 - in gnunet-gtk: contrib src/gns
Date: Fri, 16 Mar 2012 17:22:01 +0100

Author: wachs
Date: 2012-03-16 17:22:00 +0100 (Fri, 16 Mar 2012)
New Revision: 20576

Modified:
   gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade
   gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
Log:
- mods


Modified: gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade 2012-03-16 16:21:08 UTC 
(rev 20575)
+++ gnunet-gtk/contrib/gnunet_gns_gtk_main_window.glade 2012-03-16 16:22:00 UTC 
(rev 20576)
@@ -2,56 +2,6 @@
 <interface>
   <requires lib="gtk+" version="2.20"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkListStore" id="GNUNET_GNS_GTK_type_liststore">
-    <columns>
-      <!-- column-name type -->
-      <column type="guint"/>
-      <!-- column-name typename -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0">1</col>
-        <col id="1" translatable="yes">A</col>
-      </row>
-      <row>
-        <col id="0">2</col>
-        <col id="1" translatable="yes">NS</col>
-      </row>
-      <row>
-        <col id="0">5</col>
-        <col id="1" translatable="yes">CNAME</col>
-      </row>
-      <row>
-        <col id="0">6</col>
-        <col id="1" translatable="yes">SOA</col>
-      </row>
-      <row>
-        <col id="0">12</col>
-        <col id="1" translatable="yes">PTR</col>
-      </row>
-      <row>
-        <col id="0">15</col>
-        <col id="1" translatable="yes">MX</col>
-      </row>
-      <row>
-        <col id="0">16</col>
-        <col id="1" translatable="yes">TXT</col>
-      </row>
-      <row>
-        <col id="0">28</col>
-        <col id="1" translatable="yes">AAAA</col>
-      </row>
-      <row>
-        <col id="0">65536</col>
-        <col id="1" translatable="yes">PKEY</col>
-      </row>
-      <row>
-        <col id="0">65537</col>
-        <col id="1" translatable="yes">PSEU</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkWindow" id="GNUNET_GNS_GTK_main_window">
     <property name="can_focus">False</property>
     <property name="default_height">500</property>
@@ -312,8 +262,8 @@
                 </child>
                 <child>
                   <object class="GtkTreeViewColumn" 
id="GNUNET_GNS_GTK_type_treeviewcolumn">
-                    <property name="sizing">fixed</property>
-                    <property name="fixed_width">59</property>
+                    <property name="sizing">autosize</property>
+                    <property name="fixed_width">90</property>
                     <property name="title">Type</property>
                     <property name="clickable">True</property>
                     <property name="reorderable">True</property>
@@ -327,6 +277,7 @@
                         <signal name="changed" 
handler="GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb" swapped="no"/>
                       </object>
                       <attributes>
+                        <attribute name="visible">11</attribute>
                         <attribute name="text">3</attribute>
                       </attributes>
                     </child>
@@ -405,6 +356,58 @@
       <column type="gboolean"/>
       <!-- column-name name_is_row -->
       <column type="gboolean"/>
+      <!-- column-name not_dummy_row -->
+      <column type="gboolean"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="GNUNET_GNS_GTK_type_liststore">
+    <columns>
+      <!-- column-name type -->
+      <column type="guint"/>
+      <!-- column-name typename -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0">1</col>
+        <col id="1" translatable="yes">A</col>
+      </row>
+      <row>
+        <col id="0">2</col>
+        <col id="1" translatable="yes">NS</col>
+      </row>
+      <row>
+        <col id="0">5</col>
+        <col id="1" translatable="yes">CNAME</col>
+      </row>
+      <row>
+        <col id="0">6</col>
+        <col id="1" translatable="yes">SOA</col>
+      </row>
+      <row>
+        <col id="0">12</col>
+        <col id="1" translatable="yes">PTR</col>
+      </row>
+      <row>
+        <col id="0">15</col>
+        <col id="1" translatable="yes">MX</col>
+      </row>
+      <row>
+        <col id="0">16</col>
+        <col id="1" translatable="yes">TXT</col>
+      </row>
+      <row>
+        <col id="0">28</col>
+        <col id="1" translatable="yes">AAAA</col>
+      </row>
+      <row>
+        <col id="0">65536</col>
+        <col id="1" translatable="yes">PKEY</col>
+      </row>
+      <row>
+        <col id="0">65537</col>
+        <col id="1" translatable="yes">PSEU</col>
+      </row>
+    </data>
+  </object>
 </interface>

Modified: gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c    2012-03-16 16:21:08 UTC (rev 
20575)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c    2012-03-16 16:22:00 UTC (rev 
20576)
@@ -26,6 +26,7 @@
 #include "gnunet_gtk.h"
 #include "gnunet-gns-gtk.h"
 
+#define NEW_NAME_STR "<new name>"
 #define NEW_RECORD_STR "<new record>"
 
 enum
@@ -40,7 +41,8 @@
   TREE_COL_VAL_AS_STR,
   TREE_COL_VAL_COLOR,
   TREE_COL_NAME_IS_EDITABLE,
-  TREE_COL_IS_RECORD_ROW = 10
+  TREE_COL_IS_RECORD_ROW,
+  TREE_COL_NOT_DUMMY_ROW
 };
 
 enum
@@ -67,37 +69,49 @@
 {
   struct GNUNET_GNS_Context *gns = user_data;
   GtkTreeIter it;
+  GtkTreeIter child;
   GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts);
   guint type;
-//  int is_row;
+  int record_row;
   char *type_str;
   char *value_str;
+  char *name_str;
   void *data;
   size_t data_size;
 
+  gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, 0, &type, -1);
+  gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, TYPE_LIST_TYPENAME, 
&type_str, -1);
+
+
   /* check if this is a new record */
-  /*
-  gtk_tree_model_get(tm, &it, TREE_COL_IS_NAME_ROW, &is_row, -1);
+  gtk_tree_model_get_iter_from_string(tm, &it, path);
+  gtk_tree_model_get(tm, &it, TREE_COL_IS_RECORD_ROW, &record_row, -1);
+  gtk_tree_model_get(tm, &it, TREE_COL_NAME, &name_str, -1);
 
-  if (0 == is_row)
+  if (GNUNET_YES == record_row)
   {
-
+    /* Updating an existing record */
+    gtk_tree_store_set(gns->ts, &it,
+                       TREE_COL_RECORD_TYPE, type,
+                       TREE_COL_RECORD_TYPE_AS_STR, type_str,
+                       -1);
   }
-  else
+  else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str)))
   {
+    /* Adding a new record */
+    GNUNET_break (0);
+    gtk_tree_store_insert_with_values(gns->ts, &child , &it, 0,
+        TREE_COL_RECORD_TYPE, type,
+        TREE_COL_RECORD_TYPE_AS_STR, type_str,
+        TREE_COL_IS_RECORD_ROW, GNUNET_YES,
+        TREE_COL_NOT_DUMMY_ROW, GNUNET_YES,
+        -1);
 
   }
-*/
-  gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, 0, &type, -1);
-  gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, TYPE_LIST_TYPENAME, 
&type_str, -1);
-
-  gtk_tree_model_get_iter_from_string(tm, &it, path);
-  gtk_tree_store_set(gns->ts, &it,
-                     TREE_COL_RECORD_TYPE, type,
-                     TREE_COL_RECORD_TYPE_AS_STR, type_str,
-                     -1);
   GNUNET_free (type_str);
+  GNUNET_free_non_null (name_str);
 
+
   /* check if value is still valid */
   gtk_tree_model_get(tm, &it, TREE_COL_VAL_AS_STR, &value_str, -1);
   if (NULL != value_str)
@@ -109,8 +123,18 @@
       gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, "red", -1);
     else
       gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, NULL, -1);
+    GNUNET_free (value_str);
   }
-  GNUNET_free (value_str);
+  else if (NULL == value_str)
+  {
+    /* Empty value field */
+    GNUNET_break (0);
+    if (GNUNET_YES == record_row)
+      gtk_tree_store_set (gns->ts, &it, TREE_COL_VAL_COLOR, "red", -1);
+    else
+      gtk_tree_store_set (gns->ts, &child, TREE_COL_VAL_COLOR, "red", -1);
+  }
+
 }
 
 
@@ -222,32 +246,23 @@
   GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts);
 
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New text for `%s' is `%s'\n", path, 
new_text);
-  if ((0 == strcmp (path, "0")) && (0 != strcmp (new_text, NEW_RECORD_STR)) )
+  if ((0 == strcmp (path, "0")) && (0 != strcmp (new_text, NEW_NAME_STR)) )
   {
     GNUNET_break (0);
     /* update name */
     gtk_tree_model_get_iter_from_string(tm, &it, path);
     gtk_tree_store_set (gns->ts, &it, TREE_COL_NAME, new_text, -1);
+    gtk_tree_store_set (gns->ts, &it, TREE_COL_RECORD_TYPE_AS_STR, 
_(NEW_RECORD_STR), -1);
+    gtk_tree_store_set (gns->ts, &it, TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, -1);
 
     /* add a new dummy line */
     gtk_tree_store_insert_with_values (gns->ts, &it,NULL, 0,
-        TREE_COL_NAME, _(NEW_RECORD_STR),
+        TREE_COL_NAME, _(NEW_NAME_STR),
         TREE_COL_RECORD_TYPE, 1,
         TREE_COL_NAME_IS_EDITABLE, 1,
-        //TREE_COL_IS_NAME_ROW, 1
+        TREE_COL_NOT_DUMMY_ROW, GNUNET_NO,
+        TREE_COL_IS_RECORD_ROW, GNUNET_NO,
         -1);
-#if 0
-    gtk_tree_store_append(gns->ts, &it, NULL);
-    gtk_tree_store_set(gns->ts, &it,
-                       TREE_COL_NAME, new_text,
-                       TREE_COL_RECORD_TYPE, 1,
-                       -1);
-    /* add a new name */
-    gtk_tree_store_append(gns->ts, &it, NULL);
-    gtk_tree_store_set(gns->ts, &it,
-                       TREE_COL_NAME, new_text,
-                       TREE_COL_RECORD_TYPE, 1, -1);
-#endif
   }
   else
   {
@@ -323,7 +338,9 @@
   gtk_tree_store_set(zc_ctx->gns->ts, &iter_name,
                      TREE_COL_NAME, name,
                      TREE_COL_NAME_IS_EDITABLE, 1,
+                     TREE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR),
                      TREE_COL_IS_RECORD_ROW, GNUNET_NO,
+                     TREE_COL_NOT_DUMMY_ROW, GNUNET_YES,
                      -1);
 
 
@@ -363,6 +380,7 @@
                                        TREE_COL_EXP_TIME_IS_REL, 
time_is_relative,
                                        TREE_COL_VAL_AS_STR, val,
                                        TREE_COL_IS_RECORD_ROW, GNUNET_YES,
+                                       TREE_COL_NOT_DUMMY_ROW, GNUNET_YES,
                                        -1);
 
     GNUNET_free (exp);
@@ -387,10 +405,11 @@
 
   /* Append a top level row and leave it empty */
   gtk_tree_store_insert_with_values(gns->ts, &toplevel, NULL, 0,
-                                     TREE_COL_NAME, _(NEW_RECORD_STR),
+                                     TREE_COL_NAME, _(NEW_NAME_STR),
                                      TREE_COL_RECORD_TYPE, 1,
                                      TREE_COL_NAME_IS_EDITABLE, 1,
                                      TREE_COL_IS_RECORD_ROW, GNUNET_NO,
+                                     TREE_COL_NOT_DUMMY_ROW, GNUNET_NO,
                                      -1);
 
   zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]