aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-08 07:32:07 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-08 07:32:07 +0000
commit17eabae92ed6b34f8d2ff252be806c0995f02acd (patch)
tree818a99494211a1384d8ed457278d032b2056ec9b
parent0c04264a4aaabe0705c91f732b67062c9c8a5c0d (diff)
downloadgnunet-gtk-17eabae92ed6b34f8d2ff252be806c0995f02acd.tar.gz
gnunet-gtk-17eabae92ed6b34f8d2ff252be806c0995f02acd.zip
-minor code cleanup
-rw-r--r--contrib/gnunet_fs_gtk_main_window.glade156
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c80
2 files changed, 110 insertions, 126 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade
index 4065685d..5033406a 100644
--- a/contrib/gnunet_fs_gtk_main_window.glade
+++ b/contrib/gnunet_fs_gtk_main_window.glade
@@ -971,31 +971,6 @@
971 <property name="can_focus">False</property> 971 <property name="can_focus">False</property>
972 <property name="stock">gtk-index</property> 972 <property name="stock">gtk-index</property>
973 </object> 973 </object>
974 <object class="GtkTreeStore" id="main_window_search_namespace_treestore">
975 <columns>
976 <!-- column-name Name -->
977 <column type="gchararray"/>
978 <!-- column-name Key -->
979 <column type="gpointer"/>
980 <!-- column-name Root -->
981 <column type="gchararray"/>
982 <!-- column-name Tooltip -->
983 <column type="gchararray"/>
984 </columns>
985 </object>
986 <object class="GtkMenu" id="metadata_popup_menu">
987 <property name="visible">True</property>
988 <property name="can_focus">False</property>
989 <child>
990 <object class="GtkMenuItem" id="Copy selection">
991 <property name="visible">True</property>
992 <property name="can_focus">False</property>
993 <property name="label" translatable="yes">Copy selection</property>
994 <property name="use_underline">True</property>
995 <signal name="activate" handler="GNUNET_GTK_FS_metadata_copy_selection_activated" swapped="no"/>
996 </object>
997 </child>
998 </object>
999 <object class="GtkSizeGroup" id="GNUNET_FS_GTK_download_frame_vsize_group"> 974 <object class="GtkSizeGroup" id="GNUNET_FS_GTK_download_frame_vsize_group">
1000 <property name="mode">vertical</property> 975 <property name="mode">vertical</property>
1001 <property name="ignore_hidden">True</property> 976 <property name="ignore_hidden">True</property>
@@ -1017,57 +992,30 @@
1017 <widget name="GNUNET_GTK_search_frame_download_filename_label"/> 992 <widget name="GNUNET_GTK_search_frame_download_filename_label"/>
1018 </widgets> 993 </widgets>
1019 </object> 994 </object>
1020 <object class="GtkSizeGroup" id="enties_and_comboboxes_sizegroup"> 995 <object class="GtkTreeStore" id="main_window_search_namespace_treestore">
1021 <property name="mode">vertical</property>
1022 <widgets>
1023 <widget name="main_window_search_entry"/>
1024 <widget name="main_window_search_anonymity_combobox"/>
1025 <widget name="main_window_search_mime_combobox"/>
1026 </widgets>
1027 </object>
1028 <object class="GtkListStore" id="main_window_search_mime_liststore">
1029 <columns> 996 <columns>
1030 <!-- column-name MIME --> 997 <!-- column-name Name -->
1031 <column type="gchararray"/>
1032 <!-- column-name Type -->
1033 <column type="gchararray"/>
1034 <!-- column-name Extension -->
1035 <column type="gchararray"/> 998 <column type="gchararray"/>
1036 <!-- column-name Lossyness --> 999 <!-- column-name Key -->
1000 <column type="gpointer"/>
1001 <!-- column-name Root -->
1037 <column type="gchararray"/> 1002 <column type="gchararray"/>
1038 <!-- column-name Freedom --> 1003 <!-- column-name Tooltip -->
1039 <column type="gchararray"/> 1004 <column type="gchararray"/>
1040 </columns> 1005 </columns>
1041 <data> 1006 </object>
1042 <row> 1007 <object class="GtkMenu" id="metadata_popup_menu">
1043 <col id="0"> </col> 1008 <property name="visible">True</property>
1044 <col id="1" translatable="yes">Any</col> 1009 <property name="can_focus">False</property>
1045 <col id="2" translatable="yes"> </col> 1010 <child>
1046 <col id="3" translatable="yes"> </col> 1011 <object class="GtkMenuItem" id="Copy selection">
1047 <col id="4" translatable="yes"> </col> 1012 <property name="visible">True</property>
1048 </row> 1013 <property name="can_focus">False</property>
1049 <row> 1014 <property name="label" translatable="yes">Copy selection</property>
1050 <col id="0">plain/text</col> 1015 <property name="use_underline">True</property>
1051 <col id="1" translatable="yes">Text</col> 1016 <signal name="activate" handler="GNUNET_GTK_FS_metadata_copy_selection_activated" swapped="no"/>
1052 <col id="2">txt</col> 1017 </object>
1053 <col id="3" translatable="yes">N/A</col> 1018 </child>
1054 <col id="4" translatable="yes">N/A</col>
1055 </row>
1056 <row>
1057 <col id="0">application/zip</col>
1058 <col id="1" translatable="yes">Zip</col>
1059 <col id="2">zip</col>
1060 <col id="3" translatable="yes">lossless</col>
1061 <col id="4" translatable="yes">free</col>
1062 </row>
1063 <row>
1064 <col id="0">audio/mpeg</col>
1065 <col id="1" translatable="yes">MPEG audio</col>
1066 <col id="2">mp3, mp2, mpeg</col>
1067 <col id="3" translatable="yes">lossy</col>
1068 <col id="4" translatable="yes">non-free</col>
1069 </row>
1070 </data>
1071 </object> 1019 </object>
1072 <object class="GtkWindow" id="namespace_selector_window"> 1020 <object class="GtkWindow" id="namespace_selector_window">
1073 <property name="can_focus">False</property> 1021 <property name="can_focus">False</property>
@@ -1131,20 +1079,6 @@
1131 <property name="position">0</property> 1079 <property name="position">0</property>
1132 </packing> 1080 </packing>
1133 </child> 1081 </child>
1134 <child>
1135 <object class="GtkButton" id="namespace_selector_manage_namespaces_button">
1136 <property name="label" translatable="yes">_Manage namespaces</property>
1137 <property name="can_focus">True</property>
1138 <property name="receives_default">False</property>
1139 <property name="use_underline">True</property>
1140 <signal name="clicked" handler="namespace_selector_manage_namespaces_button_clicked_cb" swapped="no"/>
1141 </object>
1142 <packing>
1143 <property name="expand">False</property>
1144 <property name="fill">False</property>
1145 <property name="position">1</property>
1146 </packing>
1147 </child>
1148 </object> 1082 </object>
1149 </child> 1083 </child>
1150 </object> 1084 </object>
@@ -1158,6 +1092,58 @@
1158 <property name="can_focus">False</property> 1092 <property name="can_focus">False</property>
1159 <property name="stock">gtk-open</property> 1093 <property name="stock">gtk-open</property>
1160 </object> 1094 </object>
1095 <object class="GtkSizeGroup" id="enties_and_comboboxes_sizegroup">
1096 <property name="mode">vertical</property>
1097 <widgets>
1098 <widget name="main_window_search_entry"/>
1099 <widget name="main_window_search_anonymity_combobox"/>
1100 <widget name="main_window_search_mime_combobox"/>
1101 </widgets>
1102 </object>
1103 <object class="GtkListStore" id="main_window_search_mime_liststore">
1104 <columns>
1105 <!-- column-name MIME -->
1106 <column type="gchararray"/>
1107 <!-- column-name Type -->
1108 <column type="gchararray"/>
1109 <!-- column-name Extension -->
1110 <column type="gchararray"/>
1111 <!-- column-name Lossyness -->
1112 <column type="gchararray"/>
1113 <!-- column-name Freedom -->
1114 <column type="gchararray"/>
1115 </columns>
1116 <data>
1117 <row>
1118 <col id="0"> </col>
1119 <col id="1" translatable="yes">Any</col>
1120 <col id="2" translatable="yes"> </col>
1121 <col id="3" translatable="yes"> </col>
1122 <col id="4" translatable="yes"> </col>
1123 </row>
1124 <row>
1125 <col id="0">plain/text</col>
1126 <col id="1" translatable="yes">Text</col>
1127 <col id="2">txt</col>
1128 <col id="3" translatable="yes">N/A</col>
1129 <col id="4" translatable="yes">N/A</col>
1130 </row>
1131 <row>
1132 <col id="0">application/zip</col>
1133 <col id="1" translatable="yes">Zip</col>
1134 <col id="2">zip</col>
1135 <col id="3" translatable="yes">lossless</col>
1136 <col id="4" translatable="yes">free</col>
1137 </row>
1138 <row>
1139 <col id="0">audio/mpeg</col>
1140 <col id="1" translatable="yes">MPEG audio</col>
1141 <col id="2">mp3, mp2, mpeg</col>
1142 <col id="3" translatable="yes">lossy</col>
1143 <col id="4" translatable="yes">non-free</col>
1144 </row>
1145 </data>
1146 </object>
1161 <object class="GtkAdjustment" id="priority_adjustment"> 1147 <object class="GtkAdjustment" id="priority_adjustment">
1162 <property name="upper">10000000</property> 1148 <property name="upper">10000000</property>
1163 <property name="value">1000</property> 1149 <property name="value">1000</property>
diff --git a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
index 7e2df958..666f58bf 100644
--- a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
+++ b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2011, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2011-2013 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
@@ -301,7 +301,8 @@ add_namespace_to_ts (void *cls,
301{ 301{
302 GtkTreeStore *ts = cls; 302 GtkTreeStore *ts = cls;
303 char *root; 303 char *root;
304 char *ns_name, *unique_ns_name; 304 char *ns_name;
305 char *unique_ns_name;
305 struct GNUNET_CRYPTO_EccPublicKey *nsid; 306 struct GNUNET_CRYPTO_EccPublicKey *nsid;
306 char *description; 307 char *description;
307 int desc_is_a_dup; 308 int desc_is_a_dup;
@@ -316,8 +317,8 @@ add_namespace_to_ts (void *cls,
316 GNUNET_FS_pseudonym_get_info (GNUNET_FS_GTK_get_configuration (), 317 GNUNET_FS_pseudonym_get_info (GNUNET_FS_GTK_get_configuration (),
317 pseudonym, NULL, NULL, 318 pseudonym, NULL, NULL,
318 &ns_name, NULL); 319 &ns_name, NULL);
319 unique_ns_name = GNUNET_FS_pseudonym_name_uniquify ( 320 unique_ns_name = GNUNET_FS_pseudonym_name_uniquify (GNUNET_FS_GTK_get_configuration (),
320 GNUNET_FS_GTK_get_configuration (), pseudonym, ns_name, NULL); 321 pseudonym, ns_name, NULL);
321 GNUNET_free (ns_name); 322 GNUNET_free (ns_name);
322 nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey); 323 nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey);
323 *nsid = *pseudonym; 324 *nsid = *pseudonym;
@@ -355,27 +356,22 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai
355{ 356{
356 GtkTreeIter iter; 357 GtkTreeIter iter;
357 GtkTreePath *treepath; 358 GtkTreePath *treepath;
358 struct GNUNET_CRYPTO_EccPublicKey *key = NULL; 359 GtkTreeModel *model;
360 struct GNUNET_CRYPTO_EccPublicKey *key;
359 struct GNUNET_CRYPTO_EccPublicKey *selected_ns_id; 361 struct GNUNET_CRYPTO_EccPublicKey *selected_ns_id;
360 362 gboolean found;
361 gboolean found = FALSE; 363 gchar *value;
362 gchar *value = NULL;
363 364
365 key = NULL;
364 if (NULL != main_ctx->selected_ns_row) 366 if (NULL != main_ctx->selected_ns_row)
365 { 367 {
366 GtkTreeModel *model;
367 treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row); 368 treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row);
368 model = gtk_tree_view_get_model (main_ctx->ns_selector_treeview); 369 model = gtk_tree_view_get_model (main_ctx->ns_selector_treeview);
369 if (model) 370 if (gtk_tree_model_get_iter (model, &iter, treepath))
370 { 371 gtk_tree_model_get (model, &iter,
371 if (gtk_tree_model_get_iter (model, &iter, treepath)) 372 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
372 { 373 &key,
373 gtk_tree_model_get (model, &iter, 374 -1);
374 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
375 &key,
376 -1);
377 }
378 }
379 gtk_tree_path_free (treepath); 375 gtk_tree_path_free (treepath);
380 gtk_tree_row_reference_free (main_ctx->selected_ns_row); 376 gtk_tree_row_reference_free (main_ctx->selected_ns_row);
381 main_ctx->selected_ns_row = NULL; 377 main_ctx->selected_ns_row = NULL;
@@ -387,23 +383,20 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai
387 *selected_ns_id = *key; 383 *selected_ns_id = *key;
388 } 384 }
389 385
390 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( 386 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (main_ctx->search_ns_treestore),
391 main_ctx->search_ns_treestore), &iter)) 387 &iter))
392 { 388 {
393 while (TRUE) 389 do
394 { 390 {
395 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter, 391 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter,
396 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, 392 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
397 &key, 393 &key,
398 -1); 394 -1);
399 GNUNET_free_non_null (key); 395 GNUNET_free_non_null (key);
400 if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL ( 396 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (main_ctx->search_ns_treestore),
401 main_ctx->search_ns_treestore), &iter)) 397 &iter));
402 break;
403 }
404 } 398 }
405 gtk_tree_store_clear (main_ctx->search_ns_treestore); 399 gtk_tree_store_clear (main_ctx->search_ns_treestore);
406
407 gtk_tree_store_insert_with_values (main_ctx->search_ns_treestore, &iter, NULL, G_MAXINT, 400 gtk_tree_store_insert_with_values (main_ctx->search_ns_treestore, &iter, NULL, G_MAXINT,
408 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME, 401 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
409 "Any", 402 "Any",
@@ -417,11 +410,15 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai
417 410
418 if (NULL != main_ctx->ns_discovery_handle) 411 if (NULL != main_ctx->ns_discovery_handle)
419 GNUNET_FS_pseudonym_discovery_callback_unregister (main_ctx->ns_discovery_handle); 412 GNUNET_FS_pseudonym_discovery_callback_unregister (main_ctx->ns_discovery_handle);
420 main_ctx->ns_discovery_handle = GNUNET_FS_pseudonym_discovery_callback_register (main_ctx->cfg, 413 main_ctx->ns_discovery_handle
421 add_namespace_to_ts, main_ctx->search_ns_treestore); 414 = GNUNET_FS_pseudonym_discovery_callback_register (main_ctx->cfg,
422 415 &add_namespace_to_ts,
423 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( 416 main_ctx->search_ns_treestore);
424 main_ctx->search_ns_treestore), &iter)) 417
418 found = FALSE;
419 value = NULL;
420 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (main_ctx->search_ns_treestore),
421 &iter))
425 { 422 {
426 while (TRUE) 423 while (TRUE)
427 { 424 {
@@ -431,20 +428,21 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai
431 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, 428 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
432 &key, 429 &key,
433 -1); 430 -1);
434 if (selected_ns_id == NULL) 431 if (NULL == selected_ns_id)
435 found = TRUE; 432 found = TRUE;
436 else if (key != NULL && memcmp (key, selected_ns_id, sizeof (struct GNUNET_CRYPTO_EccPublicKey)) == 0) 433 if ( (key != NULL) &&
434 (0 == memcmp (key, selected_ns_id, sizeof (struct GNUNET_CRYPTO_EccPublicKey))) )
437 found = TRUE; 435 found = TRUE;
438 if (found || (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL ( 436 if (found ||
439 main_ctx->search_ns_treestore), &iter))) 437 (! gtk_tree_model_iter_next (GTK_TREE_MODEL (main_ctx->search_ns_treestore),
438 &iter)))
440 break; 439 break;
441 else 440 g_free (value);
442 g_free (value);
443 } 441 }
444 } 442 }
445 if ( (!found) && 443 if ( (!found) &&
446 gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( 444 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (main_ctx->search_ns_treestore),
447 main_ctx->search_ns_treestore), &iter)) 445 &iter))
448 { 446 {
449 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter, 447 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter,
450 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME, 448 GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
@@ -460,7 +458,7 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai
460 if (value != NULL) 458 if (value != NULL)
461 { 459 {
462 gtk_label_set_text (main_ctx->search_ns_label, value); 460 gtk_label_set_text (main_ctx->search_ns_label, value);
463 g_free(value); 461 g_free (value);
464 } 462 }
465 GNUNET_free_non_null (selected_ns_id); 463 GNUNET_free_non_null (selected_ns_id);
466} 464}