gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22292 - in gnunet-gtk: contrib src/setup


From: gnunet
Subject: [GNUnet-SVN] r22292 - in gnunet-gtk: contrib src/setup
Date: Tue, 26 Jun 2012 14:56:11 +0200

Author: grothoff
Date: 2012-06-26 14:56:11 +0200 (Tue, 26 Jun 2012)
New Revision: 22292

Modified:
   gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade
   gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-misc fixes towards integration gnunet-gns-gtk with gnunet-setup

Modified: gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade       2012-06-26 
11:55:39 UTC (rev 22291)
+++ gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade       2012-06-26 
12:56:11 UTC (rev 22292)
@@ -4453,6 +4453,7 @@
                                 <property 
name="secondary_icon_activatable">False</property>
                                 <property 
name="primary_icon_sensitive">True</property>
                                 <property 
name="secondary_icon_sensitive">True</property>
+                                <signal name="changed" 
handler="GNUNET_setup_gns_pseu_entry_changed_cb" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -4469,6 +4470,7 @@
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">True</property>
                                 <property name="use_stock">True</property>
+                                <signal name="clicked" 
handler="GNUNET_setup_gns_public_key_copy_button_clicked_cb" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -4510,6 +4512,7 @@
                                 <property 
name="receives_default">True</property>
                                 <property name="tooltip_text" 
translatable="yes">Save QR code to file</property>
                                 <property name="use_stock">True</property>
+                                <signal name="clicked" 
handler="GNUNET_setup_gns_qr_saveas_button_clicked_cb" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -4562,6 +4565,9 @@
                         <property name="can_focus">True</property>
                         <property 
name="model">GNUNET_setup_gns_treestore</property>
                         <property name="search_column">0</property>
+                        <signal name="button-press-event" 
handler="GNUNET_setup_gns_main_treeview_button_press_event_cb" swapped="no"/>
+                        <signal name="key-press-event" 
handler="GNUNET_setup_gns_main_treeview_key_press_event_cb" swapped="no"/>
+                        <signal name="popup-menu" 
handler="GNUNET_setup_gns_main_treeview_popup_menu_cb" swapped="no"/>
                         <child>
                           <object class="GtkTreeViewColumn" 
id="GNUNET_setup_gns_name_treeviewcolumn">
                             <property name="title">Name</property>
@@ -4570,7 +4576,9 @@
                             <property name="sort_indicator">True</property>
                             <property name="sort_column_id">0</property>
                             <child>
-                              <object class="GtkCellRendererText" 
id="GNUNET_setup_gns_name_cellrenderertext"/>
+                              <object class="GtkCellRendererText" 
id="GNUNET_setup_gns_name_cellrenderertext">
+                                <signal name="edited" 
handler="GNUNET_setup_gns_name_cellrenderertext_edited_cb" swapped="no"/>
+                              </object>
                               <attributes>
                                 <attribute name="visible">9</attribute>
                                 <attribute name="background">13</attribute>
@@ -4587,9 +4595,12 @@
                             <property name="title">Public</property>
                             <property name="clickable">True</property>
                             <child>
-                              <object class="GtkCellRendererToggle" 
id="GNUNET_setup_gns_ispublic_cellrenderertoggle"/>
+                              <object class="GtkCellRendererToggle" 
id="GNUNET_setup_gns_ispublic_cellrenderertoggle">
+                                <signal name="toggled" 
handler="GNUNET_setup_gns_ispublic_cellrenderertoggle_toggled_cb" swapped="no"/>
+                              </object>
                               <attributes>
-                                <attribute name="visible">10</attribute>
+                                <attribute name="sensitive">11</attribute>
+                                <attribute name="visible">11</attribute>
                                 <attribute name="active">1</attribute>
                               </attributes>
                             </child>
@@ -4607,10 +4618,12 @@
                             <child>
                               <object class="GtkCellRendererCombo" 
id="GNUNET_setup_gns_type_cellrenderercombo">
                                 <property name="editable">True</property>
+                                <property 
name="model">GNUNET_setup_gns_type_liststore</property>
                                 <property name="text_column">1</property>
+                                <signal name="changed" 
handler="GNUNET_setup_gns_type_cellrenderercombo_changed_cb" swapped="no"/>
                               </object>
                               <attributes>
-                                <attribute name="visible">11</attribute>
+                                <attribute name="visible">10</attribute>
                                 <attribute name="text">3</attribute>
                               </attributes>
                             </child>
@@ -4625,11 +4638,13 @@
                             <property name="sort_column_id">4</property>
                             <child>
                               <object class="GtkCellRendererText" 
id="GNUNET_setup_gns_expiration_cellrenderertext">
-                                <property name="editable">True</property>
+                                <signal name="edited" 
handler="GNUNET_setup_gns_expiration_cellrenderertext_edited_cb" swapped="no"/>
                               </object>
                               <attributes>
+                                <attribute name="sensitive">11</attribute>
                                 <attribute name="visible">10</attribute>
                                 <attribute name="background">12</attribute>
+                                <attribute name="editable">11</attribute>
                                 <attribute name="text">6</attribute>
                               </attributes>
                             </child>
@@ -4644,11 +4659,13 @@
                             <property name="sort_column_id">7</property>
                             <child>
                               <object class="GtkCellRendererText" 
id="GNUNET_setup_gns_value_cellrenderertext">
-                                <property name="editable">True</property>
+                                <signal name="edited" 
handler="GNUNET_setup_gns_value_cellrenderertext_edited_cb" swapped="no"/>
                               </object>
                               <attributes>
+                                <attribute name="sensitive">11</attribute>
                                 <attribute name="visible">10</attribute>
                                 <attribute name="background">8</attribute>
+                                <attribute name="editable">11</attribute>
                                 <attribute name="text">7</attribute>
                               </attributes>
                             </child>
@@ -4758,6 +4775,7 @@
         <property name="can_focus">False</property>
         <property name="tooltip_text" translatable="yes">Delete GNS 
entry</property>
         <property name="label" translatable="yes">Delete</property>
+        <signal name="activate" 
handler="GNUNET_setup_gns_popup_delete_button_activate_cb" swapped="no"/>
       </object>
     </child>
     <child>
@@ -4781,6 +4799,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label" translatable="yes">1 week</property>
+        <signal name="activate" 
handler="GNUNET_setup_gns_popup_1w_exp_button_activate_cb" swapped="no"/>
       </object>
     </child>
     <child>
@@ -4789,6 +4808,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label" translatable="yes">1 year</property>
+        <signal name="activate" 
handler="GNUNET_setup_gns_popup_1y_exp_button_activate_cb" swapped="no"/>
       </object>
     </child>
     <child>
@@ -4797,6 +4817,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label" translatable="yes">never</property>
+        <signal name="activate" 
handler="GNUNET_setup_gns_popup_forever_exp_button_activate_cb" swapped="no"/>
       </object>
     </child>
   </object>
@@ -4834,11 +4855,11 @@
       <column type="gchararray"/>
       <!-- column-name name_is_editable -->
       <column type="gboolean"/>
-      <!-- column-name name_is_row -->
+      <!-- column-name name_is_record_row -->
       <column type="gboolean"/>
       <!-- column-name not_dummy_row -->
       <column type="gboolean"/>
-      <!-- column-name expiration_time_as_color -->
+      <!-- column-name expiration_time_color -->
       <column type="gchararray"/>
       <!-- column-name name_color -->
       <column type="gchararray"/>

Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c     2012-06-26 11:55:39 UTC (rev 
22291)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c     2012-06-26 12:56:11 UTC (rev 
22292)
@@ -26,36 +26,40 @@
 #include "gnunet_gtk.h"
 #include "gnunet-setup-gns.h"
 #include <gnunet/gnunet_namestore_service.h>
+#include <gnunet/gnunet_dnsparser_lib.h>
 
+
 /**
- * FIXME.  Also: i18n?
+ * Text we use for the 'name' entry for the user to select
+ * for creating a new name.
  */
-#define NEW_NAME_STR "<new name>"
+#define NEW_NAME_STR gettext_noop ("<new name>")
 
 /**
- * FIXME.  Also: i18n?
+ * Text we use for the 'type' selection for the user to
+ * select when adding a new record.
  */
-#define NEW_RECORD_STR "<new record>"
+#define NEW_RECORD_STR gettext_noop ("<new record>")
 
 /**
- * FIXME.  Also: i18n?
+ * Text we use for 'our own zone'.  FIXME: define as constant in GNS?
  */
 #define ROOT_STR "+"
 
 /**
- * FIXME.  Also: i18n?
+ * Text we use for the expiration to mean 'never expires'.
  */
-#define EXPIRE_NEVER_STRING "never"
+#define EXPIRE_NEVER_STRING gettext_noop ("never")
 
 /**
- * FIXME.  Also: i18n?
+ * Text we use for invalid values.
  */
-#define EXPIRE_INVALID_STRING "invalid"
+#define EXPIRE_INVALID_STRING gettext_noop ("invalid")
 
 /**
- * FIXME.  Also: i18n?
+ * Text we use for values that have not been set.
  */
-#define PSEU_EMPTY_STR "<empty>"
+#define PSEU_EMPTY_STR gettext_noop ("<not set>")
 
 
 
@@ -65,72 +69,79 @@
 enum GNSTreestoreColumn
 {
   /**
-   * A gchararray
+   * A gchararray with the value for the 'name' column.
    */
   GNS_TREESTORE_COL_NAME = 0,
 
   /**
-   * A gboolean
+   * A gboolean, TRUE if the record is public, FALSE if it is private.
    */
   GNS_TREESTORE_COL_IS_PUBLIC,
 
   /**
-   * A guint
+   * A guint with the record type (numeric value)
    */
   GNS_TREESTORE_COL_RECORD_TYPE,
 
   /**
-   * A gchararray
+   * A gchararray with the record type (human-readable string)
    */
   GNS_TREESTORE_COL_RECORD_TYPE_AS_STR,
 
   /**
-   * A guint64
+   * A guint64 with the expiration time (relative or absolute)
    */
   GNS_TREESTORE_COL_EXP_TIME,
 
   /**
-   * A gboolean
+   * A gboolean, TRUE if the expiration time is relative.
    */
   GNS_TREESTORE_COL_EXP_TIME_IS_REL,
 
   /**
-   * A gchararray
+   * A gchararray with the expiration time as a human-readable string.
    */
   GNS_TREESTORE_COL_EXP_TIME_AS_STR,
 
   /**
-   * A gchararray
+   * A gchararray with the value of the record as a human-readable string.
    */
   GNS_TREESTORE_COL_VAL_AS_STR,
 
   /**
-   * A gchararray
+   * A gchararray with the background color to use for the value.
    */
   GNS_TREESTORE_COL_VAL_COLOR,
 
   /**
-   * A gboolean
+   * A gboolean; TRUE if the 'name' column should be shown, 
+   * FALSE for the lines with the individual records under a name.
    */
   GNS_TREESTORE_COL_NAME_IS_VISIBLE,
 
   /**
-   * A gboolean
+   * A gboolean, TRUE if this row is for editing a record,
+   * FALSE if the 'public', 'type', 'expiration' and 'value'
+   * columns should be hidden.
    */
   GNS_TREESTORE_COL_IS_RECORD_ROW,
 
   /**
-   * A gboolean
+   * A gboolean, FALSE if this is one of our 'dummy' rows that
+   * is used to create a new name or record, TRUE if this is
+   * a normal row with either a name or a record.
    */
   GNS_TREESTORE_COL_NOT_DUMMY_ROW,
 
   /**
-   * A gchararray
+   * A gchararray with the name of the color to use for the
+   * expiration column.
    */
   GNS_TREESTORE_COL_EXP_TIME_COLOR,
 
   /**
-   * A gchararray
+   * A gchararray with the name of the color to use for the
+   * name column.
    */
   GNS_TREESTORE_COL_NAME_COLOR
 };
@@ -235,7 +246,9 @@
 
 
 
-
+/**
+ *
+ */
 static void
 check_name_validity_and_commit_remove_proc (void *cls,
                                             int32_t success,
@@ -272,6 +285,9 @@
 }
 
 
+/**
+ *
+ */
 static void
 check_name_validity_and_commit (gchar *path, char * oldname)
 {
@@ -286,7 +302,6 @@
   void * data;
   size_t data_size;
   const gchar * pseu;
-
   char          *n_name;
   int           n_type;
   gboolean      n_public;
@@ -297,7 +312,6 @@
   char          *n_value;
   char          *n_value_color;
 
-
   gtk_tree_model_get_iter_from_string(tm, &it, path);
 
   if (FALSE == gtk_tree_model_iter_parent (tm, &parent, &it))
@@ -456,6 +470,9 @@
 };
 
 
+/**
+ *
+ */
 static void
 check_name_validity_and_remove_proc (void *cls,
                                     int32_t success,
@@ -492,6 +509,9 @@
 }
 
 
+/**
+ *
+ */
 static void
 check_name_validity_and_remove (gchar *path)
 {
@@ -601,10 +621,10 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo 
*combo,
-                                                 gchar *path,
-                                                 GtkTreeIter *new_iter,
-                                                 gpointer user_data)
+GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo 
*combo,
+                                                   gchar *path,
+                                                   GtkTreeIter *new_iter,
+                                                   gpointer user_data)
 {
   GtkTreeIter it;
   GtkTreeIter child;
@@ -638,15 +658,15 @@
     /* Adding a new record */
 
     gtk_tree_store_insert_with_values(ts, &child , &it, 0,
-        GNS_TREESTORE_COL_NAME, name_str,
-        GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE,
-        GNS_TREESTORE_COL_RECORD_TYPE, type,
-        GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str,
-        GNS_TREESTORE_COL_EXP_TIME_AS_STR, EXPIRE_NEVER_STRING,
-       GNS_TREESTORE_COL_EXP_TIME, GNUNET_TIME_UNIT_FOREVER_ABS,
-        GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE,
-        GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_YES,
-        GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES,
+                                     GNS_TREESTORE_COL_NAME, name_str,
+                                     GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE,
+                                     GNS_TREESTORE_COL_RECORD_TYPE, type,
+                                     GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, 
type_str,
+                                     GNS_TREESTORE_COL_EXP_TIME_AS_STR, 
EXPIRE_NEVER_STRING,
+                                     GNS_TREESTORE_COL_EXP_TIME, 
GNUNET_TIME_UNIT_FOREVER_ABS,
+                                     GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE,
+                                     GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
+                                     GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE,
         -1);
     gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0);
 
@@ -689,9 +709,9 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle 
*cell_renderer,
-                                                      gchar *path,
-                                                      gpointer user_data)
+GNUNET_setup_gns_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle 
*cell_renderer,
+                                                        gchar *path,
+                                                        gpointer user_data)
 {
   GtkTreeIter it;
   gboolean value;
@@ -704,6 +724,10 @@
 }
 
 
+/**
+ * FIXME: should use routines from gnunet-util (or move this to
+ * gnunet-util if it doesn't exist there!).
+ */
 static char * 
 convert_time_to_string (struct GNUNET_TIME_Absolute t)
 {
@@ -724,6 +748,9 @@
 }
 
 
+/**
+ *
+ */
 static int 
 check_time (const char * text)
 {
@@ -750,6 +777,9 @@
 }
 
 
+/**
+ *
+ */
 static const struct GNUNET_TIME_Absolute
 convert_string_to_abs_time (const char * text)
 {
@@ -805,60 +835,60 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_expiration_cellrenderertext_edited_cb (GtkCellRendererText 
*renderer,
-                                                     gchar *path,
-                                                     gchar *new_text,
-                                                     gpointer user_data)
+GNUNET_setup_gns_expiration_cellrenderertext_edited_cb (GtkCellRendererText 
*renderer,
+                                                       gchar *path,
+                                                       gchar *new_text,
+                                                       gpointer user_data)
 {
   GtkTreeIter it;
   struct GNUNET_TIME_Absolute abstime;
   gboolean is_rel;
   char *old_text;
 
-  if ((NULL != new_text))
+  if (NULL == new_text)
+    return; /* can this happen? */
+  gtk_tree_model_get_iter_from_string(tm, &it, path);
+  gtk_tree_model_get(tm, &it,
+                    GNS_TREESTORE_COL_EXP_TIME_AS_STR, &old_text,
+                    GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_rel,
+                    -1);
+  if ( (NULL != old_text) &&
+       (0 == strcmp(new_text, old_text)) )
+    return;
+  
+  if ((0 == strcmp(new_text,"")) || (0 == 
strcmp(new_text,EXPIRE_NEVER_STRING)))
   {
-    gtk_tree_model_get_iter_from_string(tm, &it, path);
-    gtk_tree_model_get(tm, &it,
-                       GNS_TREESTORE_COL_EXP_TIME_AS_STR, &old_text,
-                       GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_rel,
-                       -1);
-    if (0 == strcmp(new_text, old_text))
+    new_text = EXPIRE_NEVER_STRING;
+    abstime = GNUNET_TIME_UNIT_FOREVER_ABS;
+  }
+  else
+  {
+    if (GNUNET_SYSERR == check_time(new_text))
+    {
+      gtk_tree_store_set (ts, &it,
+                         GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text,
+                         GNS_TREESTORE_COL_EXP_TIME_COLOR, "red",
+                         GNS_TREESTORE_COL_EXP_TIME, 0,
+                         -1);
+      abstime = GNUNET_TIME_UNIT_ZERO_ABS;
       return;
-
-    if ((0 == strcmp(new_text,"")) || (0 == 
strcmp(new_text,EXPIRE_NEVER_STRING)))
+    }
+    /* TODO: fix this when we have relative time */
+    if (TRUE == is_rel)
     {
-      new_text = EXPIRE_NEVER_STRING;
-      abstime = GNUNET_TIME_UNIT_FOREVER_ABS;
+      abstime = convert_string_to_abs_time(new_text);
     }
     else
     {
-      if (GNUNET_SYSERR == check_time(new_text))
-      {
-        gtk_tree_store_set (ts, &it,
-                            GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text,
-                            GNS_TREESTORE_COL_EXP_TIME_COLOR, "red",
-                            GNS_TREESTORE_COL_EXP_TIME, 0,
-                            -1);
-        abstime = GNUNET_TIME_UNIT_ZERO_ABS;
-        return;
-      }
-      /* TODO: fix this when we have relative time */
-      if (TRUE == is_rel)
-      {
-        abstime = convert_string_to_abs_time(new_text);
-      }
-      else
-      {
-        abstime = convert_string_to_abs_time(new_text);
-      }
+      abstime = convert_string_to_abs_time(new_text);
     }
-    gtk_tree_store_set (ts, &it,
-                        GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text,
-                        GNS_TREESTORE_COL_EXP_TIME, abstime.abs_value,
-                        GNS_TREESTORE_COL_EXP_TIME_COLOR, NULL,
-                        -1);
-    check_name_validity_and_commit (path, NULL);
   }
+  gtk_tree_store_set (ts, &it,
+                     GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text,
+                     GNS_TREESTORE_COL_EXP_TIME, abstime.abs_value,
+                     GNS_TREESTORE_COL_EXP_TIME_COLOR, NULL,
+                     -1);
+  check_name_validity_and_commit (path, NULL);
 }
 
 
@@ -873,10 +903,10 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_value_cellrenderertext_edited_cb (GtkCellRendererText 
*renderer,
-                                                gchar *path,
-                                                gchar *new_text,
-                                                gpointer user_data)
+GNUNET_setup_gns_value_cellrenderertext_edited_cb (GtkCellRendererText 
*renderer,
+                                                  gchar *path,
+                                                  gchar *new_text,
+                                                  gpointer user_data)
 {
   GtkTreeModel *tm = GTK_TREE_MODEL(ts);
   GtkTreeIter it;
@@ -931,7 +961,7 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_name_cellrenderertext_edited_cb (GtkCellRendererText 
*renderer,
+GNUNET_setup_gns_name_cellrenderertext_edited_cb (GtkCellRendererText 
*renderer,
                                                gchar *path,
                                                gchar *new_text,
                                                gpointer user_data)
@@ -955,19 +985,21 @@
     /* update name */
     gtk_tree_store_set (ts, &it,
                         GNS_TREESTORE_COL_NAME, new_text,
+                       GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
                         GNS_TREESTORE_COL_RECORD_TYPE, 0,
                         GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, 
_(NEW_RECORD_STR),
-                        GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES,
+                        GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE,
+                       GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
                         -1);
     check_name_validity_and_commit (gtk_tree_model_get_string_from_iter(tm, 
&it), name);
 
     /* add a new dummy line */
     gtk_tree_store_insert_with_values (ts, &it,NULL, 0,
-        GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR),
-        GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
-        GNS_TREESTORE_COL_RECORD_TYPE, 1,
-        GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_NO,
-        GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_NO,
+                                      GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR),
+                                      GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
+                                      GNS_TREESTORE_COL_RECORD_TYPE, 
GNUNET_DNSPARSER_TYPE_A,
+                                      GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
+                                      GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE,
         -1);
   }
   else
@@ -1006,6 +1038,34 @@
 
 
 /**
+ * Create a context (popup) menu for the zone iteration treeview
+ * (if applicable). 
+ *
+ * @return TRUE if a menu was activated
+ */
+static gboolean
+create_popup_menu ()
+{
+  GtkTreeModel *tm;
+  GtkTreeIter it;
+  GtkMenu *popup;
+  GtkTreeSelection * ts;
+  int not_dummy;
+
+  ts = gtk_tree_view_get_selection(tv);
+  if (! gtk_tree_selection_get_selected (ts, &tm, &it))
+    return FALSE;
+  gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, &not_dummy, -1);
+  if (GNUNET_NO == not_dummy)
+    return FALSE;
+  popup  = GTK_MENU (GNUNET_SETUP_get_object 
("GNUNET_setup_gns_delete_popup_menu"));
+  gtk_widget_show_all (GTK_WIDGET(popup));
+  gtk_menu_popup(popup, NULL, NULL, NULL, NULL, 0, 0);
+  return TRUE;
+}
+
+
+/**
  * The zone treeview pop up menu is supposed to be created.
  * (Note: this is not the only method that might need to be
  * written to handle events to create pop up menus; right-clicks
@@ -1016,29 +1076,54 @@
  * @return TRUE if a menu was activated
  */
 gboolean
-GNUNET_SETUP_gns_main_treeview_popup_menu_cb (GtkWidget *widget,
-                                           gpointer user_data)
-{  
+GNUNET_setup_gns_main_treeview_popup_menu_cb (GtkWidget *widget,
+                                             gpointer user_data)
+{
+  return create_popup_menu ();
+}
+
+
+/**
+ * Delete the selected row from the GtkTreeView (unless it is a dummy row).
+ */
+static void
+delete_selected_row ()
+{
+  GtkTreeIter it;
   GtkTreeModel *tm;
-  GtkTreeIter it;
-  GtkMenu *popup;
   GtkTreeSelection * ts;
   int not_dummy;
+  char *path;
 
   ts = gtk_tree_view_get_selection(tv);
   if (! gtk_tree_selection_get_selected (ts, &tm, &it))
-    return TRUE;
+    return; /* nothing selected */  
   gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, &not_dummy, -1);
   if (GNUNET_NO == not_dummy)
-    return TRUE;
+    return; /* do not delete the dummy line */
+  path = gtk_tree_model_get_string_from_iter (tm, &it);
+  check_name_validity_and_remove (path);
+  g_free (path);  
+}
 
-  popup  = GTK_MENU (GNUNET_SETUP_get_object 
("GNUNET_SETUP_gns_delete_popup_menu"));
-  gtk_widget_show_all (GTK_WIDGET(popup));
-  gtk_menu_popup(popup, NULL, NULL, NULL, NULL, 0, 0);
-  return TRUE;
+
+/**
+ * User selected 'delete' in the popup menu.  Delete the
+ * selected row.
+ */
+void
+GNUNET_setup_gns_popup_delete_button_activate_cb (GtkWidget *widget,
+                                                 gpointer user_data)
+{
+  delete_selected_row ();
 }
 
 
+/**
+ * Set the expiration time of the selected row to the given value.
+ *
+ * @param reltime relative expiration time to use
+ */ 
 static void
 set_relative_expiration_time (struct GNUNET_TIME_Relative reltime)
 {
@@ -1054,87 +1139,125 @@
 
   if (! gtk_tree_selection_get_selected (ts, &tm, &it))
     return;
-
   gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, &not_dummy, -1);
   if (GNUNET_NO == not_dummy)
     return;
 
   /* Has parent? */
   has_parent = gtk_tree_model_iter_parent (tm, &parent, &it);
-
   if (FALSE == has_parent)
     return;
 
-  abstime = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), reltime);
+  /* FIXME: should keep as relative time! */
+  abstime = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), reltime);
 
   /* this is a single record */
-  renderer = GTK_CELL_RENDERER_TEXT((GNUNET_SETUP_get_object 
("GNUNET_SETUP_gns_name_cellrenderertext")));
+  renderer = GTK_CELL_RENDERER_TEXT((GNUNET_SETUP_get_object 
("GNUNET_setup_gns_name_cellrenderertext")));
   path = gtk_tree_model_get_string_from_iter (tm, &it);
-  GNUNET_SETUP_gns_expiration_cellrenderertext_edited_cb (renderer,
-                                                        path,
-                                                        convert_time_to_string 
(abstime),
-                                                        NULL);
+  GNUNET_setup_gns_expiration_cellrenderertext_edited_cb (renderer,
+                                                         path,
+                                                         
convert_time_to_string (abstime),
+                                                         NULL);
 }
 
 
-gboolean
-GNUNET_SETUP_gns_main_treeview_popup_menu_exp1d_cb (GtkWidget *widget,
+/**
+ *
+ */
+void
+GNUNET_setup_gns_popup_1d_exp_button_activate_cb (GtkWidget *widget,
                                             gpointer user_data)
 {
   set_relative_expiration_time (GNUNET_TIME_UNIT_DAYS);
-  return TRUE;
 }
 
 
-gboolean
-GNUNET_SETUP_gns_main_treeview_popup_menu_exp1w_cb (GtkWidget *widget,
+/**
+ *
+ */
+void
+GNUNET_setup_gns_popup_1w_exp_button_activate_cb (GtkWidget *widget,
                                             gpointer user_data)
 {
   set_relative_expiration_time (GNUNET_TIME_UNIT_WEEKS);
-  return TRUE;
 }
 
 
-gboolean
-GNUNET_SETUP_gns_main_treeview_popup_menu_exp1y_cb (GtkWidget *widget,
-                                            gpointer user_data)
+/**
+ *
+ */
+void
+GNUNET_setup_gns_popup_1y_exp_button_activate_cb (GtkWidget *widget,
+                                                 gpointer user_data)
 {
   set_relative_expiration_time (GNUNET_TIME_UNIT_YEARS);
-  return TRUE;
 }
 
 
-gboolean
-GNUNET_SETUP_gns_main_treeview_popup_menu_expinf_cb (GtkWidget *widget,
-                                            gpointer user_data)
+/**
+ *
+ */
+void
+GNUNET_setup_gns_popup_forever_exp_button_activate_cb (GtkWidget *widget,
+                                                 gpointer user_data)
 {
   set_relative_expiration_time (GNUNET_TIME_UNIT_FOREVER_REL);
-  return TRUE;
 }
 
 
+/**
+ * A button was pressed in the GtkTreeView, check for right button and
+ * if applicable create the popup menu.
+ *
+ * @param widget the GtkTreeView
+ * @param event the event
+ * @param user_data unused
+ * @return TRUE if a menu was activated (event was handled)
+ */
 gboolean
-GNUNET_SETUP_gns_main_treeview_button_press_popup_menu_cb (GtkWidget *widget, 
GdkEventButton *event, gpointer user_data)
+GNUNET_setup_gns_main_treeview_button_press_event_cb (GtkWidget *widget, 
GdkEventButton *event, gpointer user_data)
 {
   /* Check for right click*/
   if (NULL == widget)
     return FALSE;
-  if (event->type == GDK_BUTTON_PRESS  &&  event->button == 3)
-    GNUNET_SETUP_gns_main_treeview_popup_menu_cb (widget, user_data);
+  if ( (GDK_BUTTON_PRESS == event->type)  && (3 == event->button) )
+    return create_popup_menu ();
   return FALSE;
 }
 
 
+/**
+ * User pushed a key in the GtkTreeView.  Check for 'del' and if so, delete
+ * the currently selected row.
+ */
 gboolean
-GNUNET_SETUP_gns_main_treeview_key_press_popup_menu_cb (GtkWidget *widget, 
GdkEventKey  *event, gpointer user_data)
+GNUNET_setup_gns_main_treeview_key_press_event_cb (GtkWidget *widget, 
GdkEventKey  *event, gpointer user_data)
 {
   /* Check for delete key */
-  if ((event->type == GDK_KEY_PRESS) && (GDK_KEY_Delete == event->keyval))
-    GNUNET_SETUP_gns_main_treeview_popup_menu_cb (widget, user_data);
+  if ((event->type == GDK_KEY_PRESS) && (GDK_KEY_Delete == event->keyval))  
+  {
+    delete_selected_row ();
+    return TRUE;
+  }
   return FALSE;
 }
 
 
+/**
+ * User clicked on 'save as' to extract the QR code.  Open 'save as'
+ * dialog to get the desired filename and file type.
+ */
+void
+GNUNET_setup_gns_qr_saveas_button_clicked_cb (GtkButton *button,
+                                             gpointer user_data)
+{
+  GNUNET_break (0); // FIXME: not implemented
+}
+
+
+/**
+ * Closure for 'zone_iteration_proc'.
+ */
 struct ZoneIteration_Context
 {
   struct GNUNET_CRYPTO_ShortHashCode zone;
@@ -1143,30 +1266,10 @@
 };
 
 
-void
-GNUNET_SETUP_gns_delete_popup_menu_delete_cb (GtkMenuItem *menuitem,
-                                                 gpointer user_data)
-{
-  GtkTreeIter it;
-  GtkTreeModel *tm;
-  GtkTreeSelection * ts;
-  int not_dummy;
-  char *path;
 
-  ts = gtk_tree_view_get_selection(tv);
-  if (gtk_tree_selection_get_selected (ts, &tm, &it))
-  {
-    gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, &not_dummy, 
-1);
-    if (GNUNET_NO == not_dummy)
-      return; /* do not delete the dummy line */
-
-    path = gtk_tree_model_get_string_from_iter (tm, &it);
-    check_name_validity_and_remove(path);
-    g_free (path);
-  }
-}
-
-
+/**
+ *
+ */
 static void
 zone_iteration_proc (void *cls,
                           const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*zone_key,
@@ -1189,14 +1292,14 @@
   int public;
   guint64 exp_t;
 
-  GNUNET_assert (zc_ctx != NULL);
+  GNUNET_assert (NULL != zc_ctx);
   if ((NULL == zone_key) && (NULL == name))
   {
     GNUNET_CRYPTO_short_hash_to_enc(&zc_ctx->zone, &shenc);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s 'iteration done\n", &shenc);
-    pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object 
("GNUNET_SETUP_gns_pseu_entry")));
-    if (zc_ctx->label == NULL)
-      GNUNET_asprintf(&zc_ctx->label, "%s", PSEU_EMPTY_STR);
+    pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object 
("GNUNET_setup_gns_pseu_entry")));
+    if (NULL == zc_ctx->label)
+      zc_ctx->label = GNUNET_strdup (gettext (PSEU_EMPTY_STR));
     gtk_entry_set_text (pseu_entry, zc_ctx->label);
     iteration = GNUNET_NO;
     GNUNET_free (zc_ctx->label);
@@ -1207,19 +1310,18 @@
     return;
   }
 
-
-  GNUNET_CRYPTO_short_hash_to_enc(&zc_ctx->zone, &shenc);
+  GNUNET_CRYPTO_short_hash_to_enc (&zc_ctx->zone, &shenc);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s' iteration result `%s', %u 
records\n",
       &shenc, name, rd_count);
   gtk_tree_store_append (ts, &iter_name, NULL);
-  gtk_tree_store_set(ts, &iter_name,
-                     GNS_TREESTORE_COL_NAME, name,
-                     GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
-                     GNS_TREESTORE_COL_RECORD_TYPE, 0,
-                     GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR),
-                     GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_NO,
-                     GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES,
-                     -1);
+  gtk_tree_store_set (ts, &iter_name,
+                     GNS_TREESTORE_COL_NAME, name,
+                     GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
+                     GNS_TREESTORE_COL_RECORD_TYPE, GNUNET_NAMESTORE_TYPE_ANY,
+                     GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR),
+                     GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
+                     GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
+                     -1);
 
   if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (name))
   {
@@ -1292,8 +1394,8 @@
                                         GNS_TREESTORE_COL_EXP_TIME_AS_STR, exp,
                                         GNS_TREESTORE_COL_EXP_TIME_IS_REL, 
time_is_relative,
                                         GNS_TREESTORE_COL_VAL_AS_STR, val,
-                                         GNS_TREESTORE_COL_IS_RECORD_ROW, 
GNUNET_YES,
-                                        GNS_TREESTORE_COL_NOT_DUMMY_ROW, 
GNUNET_YES,
+                                         GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
+                                        GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE,
                                          -1);
     }
     GNUNET_free (type_str);
@@ -1305,6 +1407,9 @@
 }
 
 
+/**
+ *
+ */
 static void 
 pseu_change_cont (void *cls,
                  int32_t success,
@@ -1331,23 +1436,6 @@
 }
 
 
-gboolean
-GNUNET_SETUP_gns_pseu_entry_enter_cb (GtkWidget *widget,
-                                    GdkEvent  *event,
-                                    gpointer   user_data)
-{
-  const gchar * pseu;
-
-  pseu = gtk_entry_get_text (GTK_ENTRY(widget));
-
-  if ((pseu == NULL) || (0 == strcmp (pseu, "")))
-  {
-    //gtk_entry_set_text (GTK_ENTRY(widget), PSEU_EMPTY_STR);
-  }
-  return FALSE;
-}
-
-
 /**
  * The user edited the preferred name (PSEU) of this namespace.
  * Push the update to the namestore.
@@ -1356,8 +1444,8 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_pseu_entry_changed_cb (GtkEditable *editable,
-                                     gpointer user_data)
+GNUNET_setup_gns_pseu_entry_changed_cb (GtkEditable *editable,
+                                       gpointer user_data)
 {
   struct GNUNET_NAMESTORE_RecordData rd;
   const gchar * pseu;
@@ -1390,8 +1478,8 @@
  * @param user_data unused
  */
 void
-GNUNET_SETUP_gns_public_key_copy_button_clicked_cb (GtkButton *button,
-                                                 gpointer user_data)
+GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button,
+                                                   gpointer user_data)
 {
   GtkClipboard *cb;
 
@@ -1486,9 +1574,9 @@
   gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0,
                                      GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR),
                                      GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
-                                     GNS_TREESTORE_COL_RECORD_TYPE, 1,
-                                     GNS_TREESTORE_COL_IS_RECORD_ROW, 
GNUNET_NO,
-                                     GNS_TREESTORE_COL_NOT_DUMMY_ROW, 
GNUNET_NO,
+                                     GNS_TREESTORE_COL_RECORD_TYPE, 
GNUNET_DNSPARSER_TYPE_A,
+                                     GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE,
+                                     GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
                                      -1);
 
   zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context));




reply via email to

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