[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r13510 - gnunet-setup/src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r13510 - gnunet-setup/src |
Date: |
Tue, 2 Nov 2010 23:20:53 +0100 |
Author: grothoff
Date: 2010-11-02 23:20:53 +0100 (Tue, 02 Nov 2010)
New Revision: 13510
Modified:
gnunet-setup/src/gnunet-setup-options.c
gnunet-setup/src/gnunet-setup-options.h
gnunet-setup/src/gnunet-setup.c
Log:
more
Modified: gnunet-setup/src/gnunet-setup-options.c
===================================================================
--- gnunet-setup/src/gnunet-setup-options.c 2010-11-02 22:06:58 UTC (rev
13509)
+++ gnunet-setup/src/gnunet-setup-options.c 2010-11-02 22:20:53 UTC (rev
13510)
@@ -53,7 +53,7 @@
const char *section,
const char *option,
const char *value,
- GtkWidget *widget,
+ GObject *widget,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GtkToggleButton *button;
@@ -81,7 +81,7 @@
save_yes_no (const void *cls,
const char *section,
const char *option,
- GtkWidget *widget,
+ GObject *widget,
struct GNUNET_CONFIGURATION_Handle *cfg)
{
GtkToggleButton *button;
@@ -114,7 +114,7 @@
const char *section,
const char *option,
const char *value,
- GtkWidget *widget,
+ GObject *widget,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GtkFileChooser *chooser;
@@ -142,7 +142,7 @@
save_filename (const void *cls,
const char *section,
const char *option,
- GtkWidget *widget,
+ GObject *widget,
struct GNUNET_CONFIGURATION_Handle *cfg)
{
GtkFileChooser *chooser;
@@ -179,7 +179,7 @@
const char *section,
const char *option,
const char *value,
- GtkWidget *widget,
+ GObject *widget,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GtkSpinButton *spin;
@@ -210,7 +210,7 @@
save_number (const void *cls,
const char *section,
const char *option,
- GtkWidget *widget,
+ GObject *widget,
struct GNUNET_CONFIGURATION_Handle *cfg)
{
GtkSpinButton *spin;
@@ -225,7 +225,6 @@
}
-
/**
* Initialize a toggle button based on the existence of a word
* in an option value.
@@ -243,7 +242,7 @@
const char *section,
const char *option,
const char *value,
- GtkWidget *widget,
+ GObject *widget,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
const char *word = cls;
@@ -288,7 +287,7 @@
save_option_list (const void *cls,
const char *section,
const char *option,
- GtkWidget *widget,
+ GObject *widget,
struct GNUNET_CONFIGURATION_Handle *cfg)
{
const char *word = cls;
@@ -314,6 +313,71 @@
/**
+ * Initialize a GtkListStore by tokenizing the value into strings.
+ *
+ * @param cls closure (unused)
+ * @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_string_list_store (const void *cls,
+ const char *section,
+ const char *option,
+ const char *value,
+ GObject *widget,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *t;
+ char *w;
+ GtkListStore *ls;
+ GtkTreeIter iter;
+
+ ls = GTK_LIST_STORE (widget);
+ if (ls == NULL)
+ return GNUNET_SYSERR;
+ t = GNUNET_strdup (value);
+ w = strtok (t, " ");
+ while (w != NULL)
+ {
+ gtk_list_store_insert_with_values (ls,
+ &iter,
+ G_MAXINT,
+ 0, w,
+ -1);
+ w = strtok (NULL, " ");
+ }
+ GNUNET_free (t);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Create an option string by merging strings from
+ * a GtkListStore.
+ *
+ * @param cls closure (unused)
+ * @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_string_list_store (const void *cls,
+ const char *section,
+ const char *option,
+ GObject *widget,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ return GNUNET_OK;
+}
+
+
+/**
* Hide "min connected friends" option if in F2F-only mode.
*/
static struct GNUNET_SETUP_VisibilitySpecification
hide_min_connected_friends[] =
@@ -364,6 +428,9 @@
*/
const struct GNUNET_SETUP_OptionSpecification option_specifications[] =
{
+
+ /* GENERAL TAB */
+
{
"GNUNET_setup_friends_only_checkbutton",
"toggled",
@@ -509,25 +576,31 @@
NULL
},
-#if 0
{
"GNUNET_setup_hostlist_url_liststore",
"row-changed",
"hostlist",
"SERVERS",
- gettext_noop ("Known hostlist URLs"),
- "https://gnunet.org/configuration-hostlist",
+ NULL, NULL,
&load_string_list_store,
&save_string_list_store, NULL,
NULL
},
-#endif
-
+
{
- "GNUNET_setup_bandwidth_in_spinbutton",
+ "GNUNET_setup_hostlist_url_treeview",
+ NULL, NULL, NULL,
+ gettext_noop ("Known hostlist URLs"),
+ "https://gnunet.org/configuration-hostlist",
+ NULL, NULL, NULL,
+ NULL
+ },
+
+ {
+ "GNUNET_setup_bandwidth_out_spinbutton",
"value-changed",
"core",
- "TOTAL_QUOTA_IN",
+ "TOTAL_QUOTA_OUT",
gettext_noop ("How many bytes per second are we allowed to transmit?"),
"https://gnunet.org/configuration-bandwidth",
&load_number,
@@ -536,10 +609,10 @@
},
{
- "GNUNET_setup_bandwidth_out_spinbutton",
+ "GNUNET_setup_bandwidth_in_spinbutton",
"value-changed",
"core",
- "TOTAL_QUOTA_OUT",
+ "TOTAL_QUOTA_IN",
gettext_noop ("How many bytes per second are we allowed to receive?"),
"https://gnunet.org/configuration-bandwidth",
&load_number,
@@ -547,7 +620,12 @@
NULL
},
+ /* Transport TAB */
+ /* FS TAB */
+
+ /* END of list */
+
{ NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL }
};
Modified: gnunet-setup/src/gnunet-setup-options.h
===================================================================
--- gnunet-setup/src/gnunet-setup-options.h 2010-11-02 22:06:58 UTC (rev
13509)
+++ gnunet-setup/src/gnunet-setup-options.h 2010-11-02 22:20:53 UTC (rev
13510)
@@ -53,7 +53,7 @@
const char *section,
const char *option,
const char *value,
- GtkWidget *widget,
+ GObject *widget,
const struct
GNUNET_CONFIGURATION_Handle *cfg);
@@ -71,7 +71,7 @@
typedef int (*GNUNET_SETUP_SaveFunction)(const void *cls,
const char *section,
const char *option,
- GtkWidget *widget,
+ GObject *widget,
struct GNUNET_CONFIGURATION_Handle
*cfg);
Modified: gnunet-setup/src/gnunet-setup.c
===================================================================
--- gnunet-setup/src/gnunet-setup.c 2010-11-02 22:06:58 UTC (rev 13509)
+++ gnunet-setup/src/gnunet-setup.c 2010-11-02 22:20:53 UTC (rev 13510)
@@ -239,11 +239,12 @@
static void
widget_state_change_callback (const struct GNUNET_SETUP_OptionSpecification
*os)
{
- GtkWidget *widget;
+ GObject *widget;
char *value;
- widget = GTK_WIDGET (gtk_builder_get_object (builder,
- os->widget_name));
+ widget = gtk_builder_get_object (builder,
+ os->widget_name);
+ GNUNET_assert (NULL != os->save_function);
if (GNUNET_OK !=
os->save_function (os->load_save_cls,
os->section,
@@ -282,7 +283,7 @@
gint ret;
GtkWidget *main_window;
GtkWidget *dialog;
- GtkWidget *widget;
+ GObject *widget;
int arg_off;
int iret;
char *const *argp;
@@ -325,8 +326,8 @@
while (option_specifications[i].widget_name != NULL)
{
os = &option_specifications[i];
- widget = GTK_WIDGET (gtk_builder_get_object (builder,
- os->widget_name));
+ widget = gtk_builder_get_object (builder,
+ os->widget_name);
if (NULL == widget)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -335,33 +336,38 @@
i++;
continue;
}
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- os->section,
- os->option,
- &value))
+ if (os->load_function != NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No default value known for option `%s' in section
`%s'\n",
- os->option,
- os->section);
- i++;
- continue;
- }
- 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);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ os->section,
+ os->option,
+ &value))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "No default value known for option `%s' in section
`%s'\n",
+ os->option,
+ os->section);
+ i++;
+ continue;
+ }
+ 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);
+ GNUNET_free (value);
+ i++;
+ continue;
+ }
+ update_visibility (os, value);
GNUNET_free (value);
- i++;
- continue;
}
if (os->help_text != NULL)
{
@@ -370,12 +376,14 @@
G_CALLBACK (&help_click_callback),
(void*) os);
}
- g_signal_connect_swapped (widget,
- os->change_signal,
- G_CALLBACK (&widget_state_change_callback),
- (void*) os);
- update_visibility (os, value);
- GNUNET_free (value);
+ if (os->change_signal != NULL)
+ {
+ GNUNET_assert (NULL != os->save_function);
+ g_signal_connect_swapped (widget,
+ os->change_signal,
+ G_CALLBACK (&widget_state_change_callback),
+ (void*) os);
+ }
i++;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r13510 - gnunet-setup/src,
gnunet <=