From 92313d7a362c02930898c66c4c06db9ee1f029b0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 18 Sep 2011 21:34:08 +0000 Subject: fixing #1781 --- src/include/gnunet_gtk.h | 11 +++++++++++ src/lib/eventloop.c | 26 +++++++++++++++++++++++--- src/setup/gnunet-setup.c | 19 +++---------------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h index f5e61bb7..c567efb0 100644 --- a/src/include/gnunet_gtk.h +++ b/src/include/gnunet_gtk.h @@ -146,6 +146,7 @@ GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help, const char *main_window_file, GNUNET_SCHEDULER_Task main_task); + /** * Get an object from the main window. * @@ -159,6 +160,16 @@ GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml, +/** + * Obtain the name of the configuration file that is being used. + * + * @param ml handle to the main loop + * @return name of configuration file + */ +const char * +GNUNET_GTK_main_loop_get_configuration_file (struct GNUNET_GTK_MainLoop *ml); + + /** * Get the configuration. * diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c index cc0ab120..2ba01101 100644 --- a/src/lib/eventloop.c +++ b/src/lib/eventloop.c @@ -86,6 +86,11 @@ struct GNUNET_GTK_MainLoop */ GPollFD *cached_poll_array; + /** + * Name of the configuration file. + */ + char *cfgfile; + /** * Size of the 'cached_poll_array'. */ @@ -187,6 +192,19 @@ GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml) } +/** + * Obtain the name of the configuration file that is being used. + * + * @param ml handle to the main loop + * @return name of configuration file + */ +const char * +GNUNET_GTK_main_loop_get_configuration_file (struct GNUNET_GTK_MainLoop *ml) +{ + return ml->cfgfile; +} + + /** * Get an object from the main window. * @@ -816,7 +834,7 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds, */ static void run_main_loop (void *cls, char *const *args, const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_GTK_MainLoop *ml = cls; int argc; @@ -836,6 +854,7 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile, ml->gml = g_main_loop_new (NULL, TRUE); ml->gmc = g_main_loop_get_context (ml->gml); ml->cfg = cfg; + ml->cfgfile = GNUNET_strdup (cfgfile); #if WINDOWS ml->hEventRead = CreateEvent (NULL, TRUE, FALSE, NULL); ml->hEventReadReady = CreateEvent (NULL, TRUE, TRUE, NULL); @@ -891,8 +910,8 @@ GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help, ml.main_window_file = main_window_file; ml.main_task = main_task; ret = - GNUNET_PROGRAM_run (argc, argv, binary_name, "GTK GUI for GNUnet", - options, &run_main_loop, &ml); + GNUNET_PROGRAM_run (argc, argv, binary_name, binary_help, + options, &run_main_loop, &ml); if (NULL != ml.cached_poll_array) g_free (ml.cached_poll_array); if (NULL != ml.rs) @@ -903,6 +922,7 @@ GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help, g_object_unref (G_OBJECT (ml.builder)); if (NULL != ml.gml) g_main_loop_unref (ml.gml); + GNUNET_free_non_null (ml.cfgfile); return ret; } diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c index 92f72589..120949d9 100644 --- a/src/setup/gnunet-setup.c +++ b/src/setup/gnunet-setup.c @@ -38,12 +38,7 @@ static struct GNUNET_GTK_MainLoop *ml; /** * Name of the configuration file. */ -static char *cfgName; - -/** - * Our log level (FIXME: needed!?) - */ -static char *loglev; +static const char *cfgName; /** * Our configuration. @@ -319,6 +314,7 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GtkWidget *main_window; ml = cls; + cfgName = GNUNET_GTK_main_loop_get_configuration_file (ml); cfg = GNUNET_CONFIGURATION_create (); (void) GNUNET_CONFIGURATION_load (cfg, cfgName); main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); @@ -342,26 +338,17 @@ int main (int argc, char *const *argv) { struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_CFG_FILE (&cfgName), - GNUNET_GETOPT_OPTION_HELP (gettext_noop ("Setup tool for GNUnet")), - GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), - GNUNET_GETOPT_OPTION_VERSION (PACKAGE_VERSION), GNUNET_GETOPT_OPTION_END }; int ret; - cfgName = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE); - loglev = GNUNET_strdup ("WARNING"); - if (GNUNET_OK == - GNUNET_GTK_main_loop_start ("gnunet-setup", "guunet-setup", argc, argv, + GNUNET_GTK_main_loop_start ("gnunet-setup", "gnunet-setup", argc, argv, options, "gnunet_setup_gtk_main_window.glade", &run)) ret = gret; else ret = 1; - GNUNET_free (cfgName); - GNUNET_free (loglev); return ret; } -- cgit v1.2.3