gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13508 - gnunet-setup/src
Date: Tue, 2 Nov 2010 22:47:08 +0100

Author: grothoff
Date: 2010-11-02 22:47:08 +0100 (Tue, 02 Nov 2010)
New Revision: 13508

Modified:
   gnunet-setup/src/gnunet-setup-options.c
   gnunet-setup/src/gnunet-setup.c
Log:
more setup code

Modified: gnunet-setup/src/gnunet-setup-options.c
===================================================================
--- gnunet-setup/src/gnunet-setup-options.c     2010-11-02 21:40:05 UTC (rev 
13507)
+++ gnunet-setup/src/gnunet-setup-options.c     2010-11-02 21:47:08 UTC (rev 
13508)
@@ -99,6 +99,134 @@
 
 
 /**
+ * Initialize a GtkFileChooser based on a filename option.
+ *
+ * @param cls closure
+ * @param section section with the value
+ * @param option option name
+ * @param value value as a string
+ * @param widget widget to initialize
+ * @param cfg configuration handle
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ */
+static int
+load_filename (const void *cls,
+              const char *section,
+              const char *option,
+              const char *value,
+              GtkWidget *widget,
+              const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GtkFileChooser *chooser;
+
+  chooser = GTK_FILE_CHOOSER (widget);
+  if (chooser == NULL)
+    return GNUNET_SYSERR;
+  gtk_file_chooser_set_filename (chooser,
+                                value);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Set filename option based on a file chooser.
+ *
+ * @param cls closure
+ * @param section section with the value
+ * @param option option name
+ * @param widget widget to initialize
+ * @param cfg configuration handle to update
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ */
+static int
+save_filename (const void *cls,
+              const char *section,
+              const char *option,
+              GtkWidget *widget,
+              struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GtkFileChooser *chooser;
+  gchar *fn;
+
+  chooser = GTK_FILE_CHOOSER (widget);
+  if (chooser == NULL)
+    return GNUNET_SYSERR;
+  fn = gtk_file_chooser_get_filename (chooser);
+  if (fn == NULL)
+    fn = g_strdup ("");
+  GNUNET_CONFIGURATION_set_value_string (cfg, 
+                                        section, option,
+                                        fn);
+  g_free (fn);
+  return GNUNET_OK;
+}
+
+
+
+/**
+ * Initialize a GtkSpinButton based on a numeric option.
+ *
+ * @param cls closure
+ * @param section section with the value
+ * @param option option name
+ * @param value value as a string
+ * @param widget widget to initialize
+ * @param cfg configuration handle
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ */
+static int
+load_number (const void *cls,
+            const char *section,
+            const char *option,
+            const char *value,
+            GtkWidget *widget,
+            const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GtkSpinButton *spin;
+  unsigned int number;
+
+  spin = GTK_SPIN_BUTTON (widget);
+  if (spin == NULL)
+    return GNUNET_SYSERR;
+  if (1 != sscanf (value, "%u", &number))
+    return GNUNET_SYSERR;
+  gtk_spin_button_set_value (spin,
+                            number);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Set numeric option based on a spin button.
+ *
+ * @param cls closure
+ * @param section section with the value
+ * @param option option name
+ * @param widget widget to initialize
+ * @param cfg configuration handle to update
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ */
+static int
+save_number (const void *cls,
+            const char *section,
+            const char *option,
+            GtkWidget *widget,
+            struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GtkSpinButton *spin;
+
+  spin = GTK_SPIN_BUTTON (widget);
+  if (spin == NULL)
+    return GNUNET_SYSERR;
+  GNUNET_CONFIGURATION_set_value_number (cfg, 
+                                        section, option,
+                                        gtk_spin_button_get_value_as_int 
(spin));
+  return GNUNET_OK;
+}
+
+
+
+/**
  * Initialize a toggle button based on the existence of a word
  * in an option value.
  *
@@ -217,19 +345,43 @@
       "toggled",
       "topology",
       "FRIENDS-ONLY",
-      gettext_noop ("Should GNUnet exclusively connect to peers in the 
`friends file'"),
+      gettext_noop ("Should GNUnet exclusively connect to friends?"),
       "https://gnunet.org/configuration-f2f";,
       &load_yes_no,
       &save_yes_no, NULL,
       hide_min_connected_friends
     },    
 
+    { 
+      "GNUNET_setup_friends_filechooserbutton",
+      "selection-changed",
+      "topology",
+      "FRIENDS",
+      gettext_noop ("Friends file containing the list of friendly peers"),
+      "https://gnunet.org/configuration-f2f";,
+      &load_filename,
+      &save_filename, NULL,
+      NULL
+    },
+
+    { 
+      "GNUNET_setup_minimum_friends_spinbutton",
+      "value-changed",
+      "topology",
+      "MINIMUM-FRIENDS",
+      gettext_noop ("Minimum number of friendly connections"),
+      "https://gnunet.org/configuration-f2f";,
+      &load_number,
+      &save_number, NULL,
+      NULL
+    },    
+
     {
       "GNUNET_setup_general_services_fs_checkbutton",
       "toggled",
       "arm",
       "DEFAULTSERVICES",
-      gettext_noop ("Should file-sharing be started automatically when GNUnet 
starts?"),
+      gettext_noop ("Should file-sharing be started automatically on 
startup?"),
       "https://gnunet.org/configuration-fs";,
       &load_option_list,
       &save_option_list, "fs",
@@ -241,7 +393,7 @@
       "toggled",
       "arm",
       "DEFAULTSERVICES",
-      gettext_noop ("Should the VPN be started automatically when GNUnet 
starts?"),
+      gettext_noop ("Should the VPN be started automatically on startup?"),
       "https://gnunet.org/configuration-vpn";,
       &load_option_list,
       &save_option_list, "vpn",

Modified: gnunet-setup/src/gnunet-setup.c
===================================================================
--- gnunet-setup/src/gnunet-setup.c     2010-11-02 21:40:05 UTC (rev 13507)
+++ gnunet-setup/src/gnunet-setup.c     2010-11-02 21:47:08 UTC (rev 13508)
@@ -147,12 +147,15 @@
 
 
 static gboolean
-widget_focused_callback (GtkWidget *widget,
-                        gpointer user_data)
+help_click_callback (GtkWidget *widget,
+                    GdkEventButton *event,
+                    gpointer user_data)
 {
   const struct GNUNET_SETUP_OptionSpecification *os = user_data;
   GtkLinkButton *help;
 
+  if (event->type != GDK_BUTTON_PRESS)
+    return FALSE;
   help = GTK_LINK_BUTTON (gtk_builder_get_object (builder, 
                                                  "GNUNET_setup_help_text"));
   gtk_link_button_set_uri (help, 
@@ -206,9 +209,7 @@
          if (0 == regexec (&r, value, 0, NULL, 0))
            gtk_widget_show (widget);
          else
-           {
-             gtk_widget_hide (widget);
-           }
+           gtk_widget_hide (widget);       
          regfree (&r);
        }
       if (NULL != vs->hide_value)
@@ -222,9 +223,9 @@
              continue;
            }
          if (0 == regexec (&r, value, 0, NULL, 0))
+           gtk_widget_hide (widget);
+         else
            gtk_widget_show (widget);
-         else
-           gtk_widget_hide (widget);
          regfree (&r);
        }
       i++;
@@ -365,8 +366,8 @@
       if (os->help_text != NULL)
        {
          g_signal_connect (widget,
-                           "enter",
-                           G_CALLBACK (&widget_focused_callback),
+                           "button-press-event",
+                           G_CALLBACK (&help_click_callback),
                            (void*) os);
        }
       g_signal_connect_swapped (widget,




reply via email to

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