diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-10 22:09:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-10 22:09:08 +0000 |
commit | 8d6d25bf19eaf612b11053f56d3de5db986c733c (patch) | |
tree | 1113431c120b9123b73724629c52aa42f5a752e8 | |
parent | c1a691dbaab0f6895bc9064a86b0ce5146d81123 (diff) | |
download | gnunet-gtk-8d6d25bf19eaf612b11053f56d3de5db986c733c.tar.gz gnunet-gtk-8d6d25bf19eaf612b11053f56d3de5db986c733c.zip |
-fix loading of flags
-rw-r--r-- | src/peerinfo/gnunet-peerinfo-gtk-flags.c | 2 | ||||
-rw-r--r-- | src/peerinfo/gnunet-peerinfo-gtk.c | 72 |
2 files changed, 46 insertions, 28 deletions
diff --git a/src/peerinfo/gnunet-peerinfo-gtk-flags.c b/src/peerinfo/gnunet-peerinfo-gtk-flags.c index 4970a098..36197ef8 100644 --- a/src/peerinfo/gnunet-peerinfo-gtk-flags.c +++ b/src/peerinfo/gnunet-peerinfo-gtk-flags.c | |||
@@ -100,7 +100,7 @@ GNUNET_PEERINFO_GTK_get_flag (const char *cc) | |||
100 | for (i = 0; i < strlen (mcc); i++) | 100 | for (i = 0; i < strlen (mcc); i++) |
101 | mcc[i] = tolower (mcc[i]); | 101 | mcc[i] = tolower (mcc[i]); |
102 | dir = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR); | 102 | dir = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR); |
103 | GNUNET_asprintf (&fn, "%sgnunet-gtk%sflags%s%s.png", dir, DIR_SEPARATOR_STR, | 103 | GNUNET_asprintf (&fn, "%sflags%s%s.png", dir, |
104 | DIR_SEPARATOR_STR, mcc); | 104 | DIR_SEPARATOR_STR, mcc); |
105 | GNUNET_free (dir); | 105 | GNUNET_free (dir); |
106 | flagBuf = gdk_pixbuf_new_from_file (fn, NULL); | 106 | flagBuf = gdk_pixbuf_new_from_file (fn, NULL); |
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c index 13b820eb..6d8569e8 100644 --- a/src/peerinfo/gnunet-peerinfo-gtk.c +++ b/src/peerinfo/gnunet-peerinfo-gtk.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010 Christian Grothoff (and other contributing authors) | 3 | (C) 2010, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -92,6 +92,10 @@ struct PeerInfo | |||
92 | */ | 92 | */ |
93 | struct GNUNET_TRANSPORT_AddressToStringContext *tos; | 93 | struct GNUNET_TRANSPORT_AddressToStringContext *tos; |
94 | 94 | ||
95 | /** | ||
96 | * Did we get any address? | ||
97 | */ | ||
98 | int got_address; | ||
95 | }; | 99 | }; |
96 | 100 | ||
97 | 101 | ||
@@ -216,7 +220,6 @@ peer_address_string_cb (void *cls, const char *address) | |||
216 | const char *colon; | 220 | const char *colon; |
217 | const char *dot; | 221 | const char *dot; |
218 | 222 | ||
219 | info->tos = NULL; | ||
220 | ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store")); | 223 | ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store")); |
221 | tm = GTK_TREE_MODEL (ls); | 224 | tm = GTK_TREE_MODEL (ls); |
222 | path = gtk_tree_row_reference_get_path (info->rr); | 225 | path = gtk_tree_row_reference_get_path (info->rr); |
@@ -226,34 +229,35 @@ peer_address_string_cb (void *cls, const char *address) | |||
226 | if (NULL == address) | 229 | if (NULL == address) |
227 | { | 230 | { |
228 | /* error */ | 231 | /* error */ |
229 | gtk_list_store_set (ls, &iter, | 232 | if (GNUNET_NO == info->got_address) |
230 | PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 1, | 233 | gtk_list_store_set (ls, &iter, |
231 | PEERINFO_MC_COUNTRY_NAME, NULL, | 234 | PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 1, |
232 | PEERINFO_MC_COUNTRY_FLAG, NULL, | 235 | PEERINFO_MC_COUNTRY_NAME, NULL, |
233 | PEERINFO_MC_ADDRESS_AS_STRING, "<error>", | 236 | PEERINFO_MC_COUNTRY_FLAG, NULL, |
234 | -1); | 237 | PEERINFO_MC_ADDRESS_AS_STRING, "<no address>", |
238 | -1); | ||
239 | info->tos = NULL; | ||
240 | return; | ||
235 | } | 241 | } |
236 | else | 242 | /* last address, store information in model */ |
243 | country = NULL; | ||
244 | colon = strstr (address, ":"); | ||
245 | if (NULL != colon) | ||
237 | { | 246 | { |
238 | /* last address, store information in model */ | 247 | for (dot = colon - 1; dot != address; dot--) |
239 | country = NULL; | ||
240 | colon = strstr (address, ":"); | ||
241 | if (NULL != colon) | ||
242 | { | ||
243 | for (dot = colon - 1; dot != address; dot--) | ||
244 | if ('.' == *dot) | ||
245 | break; | ||
246 | if ('.' == *dot) | 248 | if ('.' == *dot) |
247 | country = GNUNET_strndup (&dot[1], (colon - dot) - 1); | 249 | break; |
248 | } | 250 | if ('.' == *dot) |
249 | gtk_list_store_set (ls, &iter, | 251 | country = GNUNET_strndup (&dot[1], (colon - dot) - 1); |
250 | PEERINFO_MC_NUMBER_OF_ADDRESSES, 1, | ||
251 | PEERINFO_MC_COUNTRY_NAME, country, | ||
252 | PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag (country), | ||
253 | PEERINFO_MC_ADDRESS_AS_STRING, address, | ||
254 | -1); | ||
255 | GNUNET_free (country); | ||
256 | } | 252 | } |
253 | gtk_list_store_set (ls, &iter, | ||
254 | PEERINFO_MC_NUMBER_OF_ADDRESSES, 1, | ||
255 | PEERINFO_MC_COUNTRY_NAME, country, | ||
256 | PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag (country), | ||
257 | PEERINFO_MC_ADDRESS_AS_STRING, address, | ||
258 | -1); | ||
259 | GNUNET_free (country); | ||
260 | info->got_address = GNUNET_YES; | ||
257 | } | 261 | } |
258 | 262 | ||
259 | 263 | ||
@@ -293,6 +297,7 @@ peer_address_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
293 | } | 297 | } |
294 | if (NULL != info->tos) | 298 | if (NULL != info->tos) |
295 | GNUNET_TRANSPORT_address_to_string_cancel (info->tos); | 299 | GNUNET_TRANSPORT_address_to_string_cancel (info->tos); |
300 | info->got_address = GNUNET_NO; | ||
296 | info->tos = | 301 | info->tos = |
297 | GNUNET_TRANSPORT_address_to_string (get_configuration (), address, | 302 | GNUNET_TRANSPORT_address_to_string (get_configuration (), address, |
298 | GNUNET_NO, | 303 | GNUNET_NO, |
@@ -343,7 +348,7 @@ peerinfo_processor (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
343 | PEERINFO_MC_COUNTRY_FLAG, NULL, | 348 | PEERINFO_MC_COUNTRY_FLAG, NULL, |
344 | PEERINFO_MC_BANDWIDTH_IN, (guint64) 0, | 349 | PEERINFO_MC_BANDWIDTH_IN, (guint64) 0, |
345 | PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0, | 350 | PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0, |
346 | PEERINFO_MC_ADDRESS_AS_STRING, "", | 351 | PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>", |
347 | -1); | 352 | -1); |
348 | path = gtk_tree_model_get_path (tm, &iter); | 353 | path = gtk_tree_model_get_path (tm, &iter); |
349 | info = GNUNET_malloc (sizeof (struct PeerInfo)); | 354 | info = GNUNET_malloc (sizeof (struct PeerInfo)); |
@@ -406,6 +411,9 @@ status_cb (void *cls, | |||
406 | 411 | ||
407 | /** | 412 | /** |
408 | * Callback invoked if the application is supposed to exit. | 413 | * Callback invoked if the application is supposed to exit. |
414 | * | ||
415 | * @param object | ||
416 | * @param user_data unused | ||
409 | */ | 417 | */ |
410 | void | 418 | void |
411 | GNUNET_PEERINFO_GTK_quit_cb (GObject * object, gpointer user_data) | 419 | GNUNET_PEERINFO_GTK_quit_cb (GObject * object, gpointer user_data) |
@@ -419,6 +427,9 @@ GNUNET_PEERINFO_GTK_quit_cb (GObject * object, gpointer user_data) | |||
419 | /** | 427 | /** |
420 | * Actual main function run right after GNUnet's scheduler | 428 | * Actual main function run right after GNUnet's scheduler |
421 | * is initialized. Initializes up GTK and Glade. | 429 | * is initialized. Initializes up GTK and Glade. |
430 | * | ||
431 | * @param cls NULL | ||
432 | * @param tc schedule context | ||
422 | */ | 433 | */ |
423 | static void | 434 | static void |
424 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 435 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -460,6 +471,13 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
460 | } | 471 | } |
461 | 472 | ||
462 | 473 | ||
474 | /** | ||
475 | * Main function of gnunet-peerinfo-gtk. | ||
476 | * | ||
477 | * @param argc number of arguments | ||
478 | * @param argv arguments | ||
479 | * @return 0 on success | ||
480 | */ | ||
463 | int | 481 | int |
464 | main (int argc, char *const *argv) | 482 | main (int argc, char *const *argv) |
465 | { | 483 | { |