gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15472 - gnunet-setup/src


From: gnunet
Subject: [GNUnet-SVN] r15472 - gnunet-setup/src
Date: Wed, 8 Jun 2011 16:37:07 +0200

Author: grothoff
Date: 2011-06-08 16:37:07 +0200 (Wed, 08 Jun 2011)
New Revision: 15472

Modified:
   gnunet-setup/src/gnunet-setup-options.c
   gnunet-setup/src/gnunet-setup.c
Log:
towards editable tree views

Modified: gnunet-setup/src/gnunet-setup-options.c
===================================================================
--- gnunet-setup/src/gnunet-setup-options.c     2011-06-08 13:51:54 UTC (rev 
15471)
+++ gnunet-setup/src/gnunet-setup-options.c     2011-06-08 14:37:07 UTC (rev 
15472)
@@ -544,13 +544,13 @@
 
 
 /**
- * Create an option string by merging strings from
- * a GtkListStore.
+ * The GtkCellRenderer has emmited the 'edited' signal.
+ * 
  *
  * @param cls closure (unused)
- * @param section section with the value
- * @param option option name
- * @param widget widget to initialize
+ * @param section section with the value (NULL)
+ * @param option option name (NULL)
+ * @param widget the cell renderer
  * @param cfg configuration handle to update
  * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
  */
@@ -608,6 +608,121 @@
 
 
 /**
+ * Check if the section represents a DNS entry and then update the
+ * GtkListStore accordingly.
+ *
+ * @param cls the list store to modify
+ * @param section name of the section
+ */
+static void
+add_dns_entry_to_list_store (void *cls,
+                            const char *section)
+{
+  GtkListStore *ls = cls;
+  
+  /* rest of configuration in global 'cfg' */
+  /* gtk_list_store_insert_with_values () --- append */
+  /* FIXME */
+}
+
+
+/**
+ * Initialize the GtkListModel with the VPN's DNS service specification.
+ *
+ * @param cls NULL
+ * @param section section with the value (NULL)
+ * @param option option name (NULL)
+ * @param value value as a string (NULL)
+ * @param widget widget to initialize (the GtkTreeView)
+ * @param cfg configuration handle
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ */
+static int
+load_vpn_dns_configuration (const void *cls,
+                           const char *section,
+                           const char *option,
+                           const char *value,
+                           GObject *widget,
+                           const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GtkTreeView *tv;
+  GtkListStore *ls;
+
+  tv = GTK_TREE_VIEW (widget);
+  if (tv == NULL)
+    return GNUNET_SYSERR;
+  ls = GTK_LIST_STORE (gtk_tree_view_get_model (tv));
+  GNUNET_CONFIGURATION_iterate_sections (cfg,
+                                        &add_dns_entry_to_list_store,
+                                        ls);
+  /* finally, add empty entry */
+  add_dns_entry_to_list_store (ls, "");
+  return GNUNET_OK;
+}
+
+
+/**
+ * The user has edited the DNS name of a service we're offering.
+ * Update the GtkTreeModel (at the given path) and update the
+ * respective service entry in the configuration file.  Finally,
+ * if the edited path is for a "fresh" entry, create another empty
+ * one at the bottom.  If the hostname was set to empty, remove
+ * the entire entry from the configuration and the model.
+ *
+ * @param renderer GtkCellRendererText that changed
+ * @param path GtkTreePath identifying where in the Model the change is
+ * @param new_text the new text that was stored in the line
+ * @param user_data NULL
+ */
+static void
+save_vpn_dns_service_dnsname (GtkCellRendererText *renderer,
+                             gchar *path,
+                             gchar *new_text,
+                             gpointer user_data) 
+{
+
+  
+  
+}
+
+
+/**
+ * Initialize the GtkListModel with the VPN's DNS service specification.
+ *
+ * @param cls NULL
+ * @param section section with the value (NULL)
+ * @param option option name (NULL)
+ * @param widget widget to initialize (the GtkTreeView)
+ * @param cfg configuration handle
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ */
+static int
+vpn_dns_service_dnsname_install_edited_handler (const void *cls,
+                                               const char *section,
+                                               const char *option,
+                                               GObject *widget,
+                                               const struct 
GNUNET_CONFIGURATION_Handle *cfg)
+{
+  static int once;
+  GtkCellRendererText *rt;
+
+  rt = GTK_CELL_RENDERER_TEXT(widget);
+  if (NULL == rt)
+    return GNUNET_SYSERR;
+  if (0 != once++)
+    return GNUNET_OK;
+  g_signal_connect (rt,
+                   "edited",
+                   G_CALLBACK (&save_vpn_dns_service_dnsname),
+                   NULL);
+  return GNUNET_OK;
+}
+
+
+
+
+
+/**
  * Hide "min connected friends" option if in F2F-only mode.
  */
 static struct GNUNET_SETUP_VisibilitySpecification 
hide_min_connected_friends[] =
@@ -1728,18 +1843,33 @@
       &save_yes_no, NULL,
       NULL
     },
+
+    /* DNS treeview */
     
     {
       "GNUNET_setup_vpn_dns_service_treeview",
-      "Xchanged",
-      "vpn",
-      "IFNAME",
+      NULL,
+      NULL,
+      NULL,
       gettext_noop ("Specification of .gnunet hostnames and services offered 
by this peer"),
       "https://gnunet.org/configuration-dns";,
-      &load_text,
-      &save_text, NULL,
+      &load_vpn_dns_configuration,
+      NULL, NULL,
       NULL
     },
+        
+    {
+      "GNUNET_setup_vpn_dns_service_dnsname_cellrenderertext",
+      "editing-started",
+      NULL,
+      NULL,
+      NULL,
+      "https://gnunet.org/configuration-dns";,
+      NULL,
+      &vpn_dns_service_dnsname_install_edited_handler,
+      NULL,
+      NULL
+    },
     
     /* END of list */
 

Modified: gnunet-setup/src/gnunet-setup.c
===================================================================
--- gnunet-setup/src/gnunet-setup.c     2011-06-08 13:51:54 UTC (rev 15471)
+++ gnunet-setup/src/gnunet-setup.c     2011-06-08 14:37:07 UTC (rev 15472)
@@ -339,36 +339,53 @@
        }
       if (os->load_function != NULL) 
        {
-         if (GNUNET_OK !=
-             GNUNET_CONFIGURATION_get_value_string (cfg,
-                                                    os->section,
-                                                    os->option,
-                                                    &value))
+         if ( (NULL == os->section) || 
+              (NULL == os->option) )
            {
-             GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                         _("No default value known for option `%s' in section 
`%s'\n"),
-                         os->option,
-                         os->section);
-           }
-         else
-           {
              if (GNUNET_OK != 
                  os->load_function (os->load_save_cls,
-                                    os->section, os->option,
-                                    value,
+                                    NULL, NULL, NULL,
                                     widget,
                                     cfg)) 
                {
                  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                             _("Failed to initialize widget `%s' with value 
`%s'\n"),
-                             os->widget_name,
-                             value);
+                             _("Failed to initialize widget `%s'\n"),
+                             os->widget_name);
                }
+           }
+         else
+           {
+             if (GNUNET_OK !=
+                 GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                        os->section,
+                                                        os->option,
+                                                        &value))
+               {
+                 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                             _("No default value known for option `%s' in 
section `%s'\n"),
+                             os->option,
+                             os->section);
+               }
              else
                {
-                 update_visibility (os, value);
+                 if (GNUNET_OK != 
+                     os->load_function (os->load_save_cls,
+                                        os->section, os->option,
+                                        value,
+                                        widget,
+                                        cfg)) 
+                   {
+                     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                                 _("Failed to initialize widget `%s' with 
value `%s'\n"),
+                                 os->widget_name,
+                                 value);
+                   }
+                 else
+                   {
+                     update_visibility (os, value);
+                   }
+                 GNUNET_free (value);
                }
-             GNUNET_free (value);
            }
        }
       if (os->help_text != NULL)
@@ -384,7 +401,7 @@
          g_signal_connect_swapped (widget,
                                    os->change_signal,
                                    G_CALLBACK (&widget_state_change_callback),
-                                   (void*) os);
+                                   (void*) os);            
        }
       i++;
     }




reply via email to

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