aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-18 21:34:08 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-18 21:34:08 +0000
commit92313d7a362c02930898c66c4c06db9ee1f029b0 (patch)
tree4a86fd84b7a408b5d75667e4166efa20f92e95fc
parent77b4b6331f34791817084ed0e1b8c97815a1e1e7 (diff)
downloadgnunet-gtk-92313d7a362c02930898c66c4c06db9ee1f029b0.tar.gz
gnunet-gtk-92313d7a362c02930898c66c4c06db9ee1f029b0.zip
fixing #1781
-rw-r--r--src/include/gnunet_gtk.h11
-rw-r--r--src/lib/eventloop.c26
-rw-r--r--src/setup/gnunet-setup.c19
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,
146 const char *main_window_file, 146 const char *main_window_file,
147 GNUNET_SCHEDULER_Task main_task); 147 GNUNET_SCHEDULER_Task main_task);
148 148
149
149/** 150/**
150 * Get an object from the main window. 151 * Get an object from the main window.
151 * 152 *
@@ -160,6 +161,16 @@ GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml,
160 161
161 162
162/** 163/**
164 * Obtain the name of the configuration file that is being used.
165 *
166 * @param ml handle to the main loop
167 * @return name of configuration file
168 */
169const char *
170GNUNET_GTK_main_loop_get_configuration_file (struct GNUNET_GTK_MainLoop *ml);
171
172
173/**
163 * Get the configuration. 174 * Get the configuration.
164 * 175 *
165 * @param ml handle to the main loop 176 * @param ml handle to the main loop
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
@@ -87,6 +87,11 @@ struct GNUNET_GTK_MainLoop
87 GPollFD *cached_poll_array; 87 GPollFD *cached_poll_array;
88 88
89 /** 89 /**
90 * Name of the configuration file.
91 */
92 char *cfgfile;
93
94 /**
90 * Size of the 'cached_poll_array'. 95 * Size of the 'cached_poll_array'.
91 */ 96 */
92 guint cached_poll_array_size; 97 guint cached_poll_array_size;
@@ -188,6 +193,19 @@ GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml)
188 193
189 194
190/** 195/**
196 * Obtain the name of the configuration file that is being used.
197 *
198 * @param ml handle to the main loop
199 * @return name of configuration file
200 */
201const char *
202GNUNET_GTK_main_loop_get_configuration_file (struct GNUNET_GTK_MainLoop *ml)
203{
204 return ml->cfgfile;
205}
206
207
208/**
191 * Get an object from the main window. 209 * Get an object from the main window.
192 * 210 *
193 * @param ml handle to the main loop 211 * @param ml handle to the main loop
@@ -816,7 +834,7 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds,
816 */ 834 */
817static void 835static void
818run_main_loop (void *cls, char *const *args, const char *cfgfile, 836run_main_loop (void *cls, char *const *args, const char *cfgfile,
819 const struct GNUNET_CONFIGURATION_Handle *cfg) 837 const struct GNUNET_CONFIGURATION_Handle *cfg)
820{ 838{
821 struct GNUNET_GTK_MainLoop *ml = cls; 839 struct GNUNET_GTK_MainLoop *ml = cls;
822 int argc; 840 int argc;
@@ -836,6 +854,7 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile,
836 ml->gml = g_main_loop_new (NULL, TRUE); 854 ml->gml = g_main_loop_new (NULL, TRUE);
837 ml->gmc = g_main_loop_get_context (ml->gml); 855 ml->gmc = g_main_loop_get_context (ml->gml);
838 ml->cfg = cfg; 856 ml->cfg = cfg;
857 ml->cfgfile = GNUNET_strdup (cfgfile);
839#if WINDOWS 858#if WINDOWS
840 ml->hEventRead = CreateEvent (NULL, TRUE, FALSE, NULL); 859 ml->hEventRead = CreateEvent (NULL, TRUE, FALSE, NULL);
841 ml->hEventReadReady = CreateEvent (NULL, TRUE, TRUE, NULL); 860 ml->hEventReadReady = CreateEvent (NULL, TRUE, TRUE, NULL);
@@ -891,8 +910,8 @@ GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help,
891 ml.main_window_file = main_window_file; 910 ml.main_window_file = main_window_file;
892 ml.main_task = main_task; 911 ml.main_task = main_task;
893 ret = 912 ret =
894 GNUNET_PROGRAM_run (argc, argv, binary_name, "GTK GUI for GNUnet", 913 GNUNET_PROGRAM_run (argc, argv, binary_name, binary_help,
895 options, &run_main_loop, &ml); 914 options, &run_main_loop, &ml);
896 if (NULL != ml.cached_poll_array) 915 if (NULL != ml.cached_poll_array)
897 g_free (ml.cached_poll_array); 916 g_free (ml.cached_poll_array);
898 if (NULL != ml.rs) 917 if (NULL != ml.rs)
@@ -903,6 +922,7 @@ GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help,
903 g_object_unref (G_OBJECT (ml.builder)); 922 g_object_unref (G_OBJECT (ml.builder));
904 if (NULL != ml.gml) 923 if (NULL != ml.gml)
905 g_main_loop_unref (ml.gml); 924 g_main_loop_unref (ml.gml);
925 GNUNET_free_non_null (ml.cfgfile);
906 return ret; 926 return ret;
907} 927}
908 928
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;
38/** 38/**
39 * Name of the configuration file. 39 * Name of the configuration file.
40 */ 40 */
41static char *cfgName; 41static const char *cfgName;
42
43/**
44 * Our log level (FIXME: needed!?)
45 */
46static char *loglev;
47 42
48/** 43/**
49 * Our configuration. 44 * Our configuration.
@@ -319,6 +314,7 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
319 GtkWidget *main_window; 314 GtkWidget *main_window;
320 315
321 ml = cls; 316 ml = cls;
317 cfgName = GNUNET_GTK_main_loop_get_configuration_file (ml);
322 cfg = GNUNET_CONFIGURATION_create (); 318 cfg = GNUNET_CONFIGURATION_create ();
323 (void) GNUNET_CONFIGURATION_load (cfg, cfgName); 319 (void) GNUNET_CONFIGURATION_load (cfg, cfgName);
324 main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); 320 main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog"));
@@ -342,26 +338,17 @@ int
342main (int argc, char *const *argv) 338main (int argc, char *const *argv)
343{ 339{
344 struct GNUNET_GETOPT_CommandLineOption options[] = { 340 struct GNUNET_GETOPT_CommandLineOption options[] = {
345 GNUNET_GETOPT_OPTION_CFG_FILE (&cfgName),
346 GNUNET_GETOPT_OPTION_HELP (gettext_noop ("Setup tool for GNUnet")),
347 GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
348 GNUNET_GETOPT_OPTION_VERSION (PACKAGE_VERSION),
349 GNUNET_GETOPT_OPTION_END 341 GNUNET_GETOPT_OPTION_END
350 }; 342 };
351 int ret; 343 int ret;
352 344
353 cfgName = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE);
354 loglev = GNUNET_strdup ("WARNING");
355
356 if (GNUNET_OK == 345 if (GNUNET_OK ==
357 GNUNET_GTK_main_loop_start ("gnunet-setup", "guunet-setup", argc, argv, 346 GNUNET_GTK_main_loop_start ("gnunet-setup", "gnunet-setup", argc, argv,
358 options, "gnunet_setup_gtk_main_window.glade", 347 options, "gnunet_setup_gtk_main_window.glade",
359 &run)) 348 &run))
360 ret = gret; 349 ret = gret;
361 else 350 else
362 ret = 1; 351 ret = 1;
363 GNUNET_free (cfgName);
364 GNUNET_free (loglev);
365 return ret; 352 return ret;
366} 353}
367 354