aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_event-handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_event-handler.c')
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c486
1 files changed, 335 insertions, 151 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index fb1fdb97..be5c3ba7 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -29,6 +29,136 @@
29#include "gnunet-fs-gtk_event-handler.h" 29#include "gnunet-fs-gtk_event-handler.h"
30#include "gnunet-fs-gtk_unindex.h" 30#include "gnunet-fs-gtk_unindex.h"
31 31
32
33/**
34 * Columns in the file sharing result model.
35 */
36enum SEARCH_TAB_ModelColumns
37 {
38 /**
39 * A gpointer.
40 */
41 SEARCH_TAB_MC_METADATA = 0,
42
43 /**
44 * A gpointer.
45 */
46 SEARCH_TAB_MC_URI = 1,
47
48 /**
49 * A guint64.
50 */
51 SEARCH_TAB_MC_FILESIZE = 2,
52
53 /**
54 * A GdkPixbuf.
55 */
56 SEARCH_TAB_MC_PREVIEW = 3,
57
58 /**
59 * A guint.
60 */
61 SEARCH_TAB_MC_PERCENT_PROGRESS = 4,
62
63 /**
64 * A guint.
65 */
66 SEARCH_TAB_MC_PERCENT_AVAILABILITY = 5,
67
68 /**
69 * A gchararray.
70 */
71 SEARCH_TAB_MC_FILENAME = 6,
72
73 /**
74 * A gchararray.
75 */
76 SEARCH_TAB_MC_URI_AS_STRING = 7,
77
78 /**
79 * A gchararray.
80 */
81 SEARCH_TAB_MC_STATUS_COLOUR = 8,
82
83 /**
84 * A gpointer.
85 */
86 SEARCH_TAB_MC_SEARCH_RESULT = 9,
87
88 /**
89 * A gchararray.
90 */
91 SEARCH_TAB_MC_MIMETYPE = 10,
92
93 /**
94 * A guint.
95 */
96 SEARCH_TAB_MC_APPLICABILITY_RANK = 11,
97
98 /**
99 * A guint.
100 */
101 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY = 12,
102
103 /**
104 * A gint.
105 */
106 SEARCH_TAB_MC_AVAILABILITY_RANK = 13,
107
108 /**
109 * A guint64.
110 */
111 SEARCH_TAB_MC_COMPLETED = 14,
112
113 /**
114 * A gchararray.
115 */
116 SEARCH_TAB_MC_DOWNLOADED_FILENAME = 15,
117
118 /**
119 * A gint.
120 */
121 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY = 16,
122 };
123
124
125/**
126 * Columns in the publish frame model.
127 */
128enum PUBLISH_TAB_ModelColumns
129 {
130 /**
131 * A gchararray.
132 */
133 PUBLISH_TAB_MC_FILENAME = 0,
134
135 /**
136 * A gchararray.
137 */
138 PUBLISH_TAB_MC_FILESIZE = 1,
139
140 /**
141 * A gchararray.
142 */
143 PUBLISH_TAB_MC_BGCOLOUR = 2,
144
145 /**
146 * A guint.
147 */
148 PUBLISH_TAB_MC_PROGRESS = 3,
149
150 /**
151 * A gpointer.
152 */
153 PUBLISH_TAB_MC_ENT = 4,
154
155 /**
156 * A gchararray.
157 */
158 PUBLISH_TAB_MC_RESULT_STRING = 5,
159 };
160
161
32/** 162/**
33 * We have a single tab where we display publishing operations. 163 * We have a single tab where we display publishing operations.
34 * So there is only one instance of this struct. 164 * So there is only one instance of this struct.
@@ -190,10 +320,12 @@ get_suggested_filename_anonymity (GtkTreeModel *tm,
190 320
191 /* FIXME-BUG-MAYBE: this function is likely responsible for not always 321 /* FIXME-BUG-MAYBE: this function is likely responsible for not always
192 suggesting the best filename... To be investigated some more... */ 322 suggesting the best filename... To be investigated some more... */
193 gtk_tree_model_get (tm, iter, 0, &meta, 323 gtk_tree_model_get (tm, iter,
194 15, &local_filename, 324 SEARCH_TAB_MC_METADATA, &meta,
195 16, &downloaded_anonymity, 325 SEARCH_TAB_MC_DOWNLOADED_FILENAME, &local_filename,
196 -1); 326 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY,
327 &downloaded_anonymity,
328 -1);
197 if (GNUNET_NO == top) 329 if (GNUNET_NO == top)
198 { 330 {
199 if (NULL != local_filename) 331 if (NULL != local_filename)
@@ -305,7 +437,11 @@ start_download (GtkTreeView *tree_view,
305 GNUNET_break (0); 437 GNUNET_break (0);
306 return; 438 return;
307 } 439 }
308 gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, 9, &sr, -1); 440 gtk_tree_model_get (tm, &iter,
441 SEARCH_TAB_MC_METADATA, &meta,
442 SEARCH_TAB_MC_URI, &uri,
443 SEARCH_TAB_MC_SEARCH_RESULT, &sr,
444 -1);
309 if (NULL == uri) 445 if (NULL == uri)
310 { 446 {
311 /* user clicked on directory that was opened (not downloaded!), so we 447 /* user clicked on directory that was opened (not downloaded!), so we
@@ -463,7 +599,8 @@ GNUNET_FS_GTK_search_treeview_row_activated (GtkTreeView * tree_view,
463 GNUNET_break (0); 599 GNUNET_break (0);
464 return; 600 return;
465 } 601 }
466 gtk_tree_model_get (tm, &iter, 1, &uri, -1); 602 gtk_tree_model_get (tm, &iter,
603 SEARCH_TAB_MC_URI, &uri, -1);
467 if (NULL == uri) 604 if (NULL == uri)
468 { 605 {
469 /* user clicked on directory that was opened (not downloaded!), so we 606 /* user clicked on directory that was opened (not downloaded!), so we
@@ -598,7 +735,8 @@ copy_search_uri_to_clipboard_ctx_menu (GtkMenuItem *item, gpointer user_data)
598 gtk_tree_path_free (path); 735 gtk_tree_path_free (path);
599 return; 736 return;
600 } 737 }
601 gtk_tree_model_get (tm, &iter, 1, &uri, -1); 738 gtk_tree_model_get (tm, &iter,
739 SEARCH_TAB_MC_URI, &uri, -1);
602 gtk_tree_path_free (path); 740 gtk_tree_path_free (path);
603 if (uri == NULL) 741 if (uri == NULL)
604 { 742 {
@@ -643,7 +781,10 @@ search_list_popup (GtkTreeModel *tm,
643 path = gtk_tree_model_get_path (tm, iter); 781 path = gtk_tree_model_get_path (tm, iter);
644 spc->rr = gtk_tree_row_reference_new (tm, path); 782 spc->rr = gtk_tree_row_reference_new (tm, path);
645 gtk_tree_path_free (path); 783 gtk_tree_path_free (path);
646 gtk_tree_model_get (tm, iter, 1, &uri, 9, &sr, -1); 784 gtk_tree_model_get (tm, iter,
785 SEARCH_TAB_MC_URI, &uri,
786 SEARCH_TAB_MC_SEARCH_RESULT, &sr,
787 -1);
647 spc->sr = sr; 788 spc->sr = sr;
648 menu = GTK_MENU (gtk_menu_new ()); 789 menu = GTK_MENU (gtk_menu_new ());
649 if ( (NULL == sr->download) && 790 if ( (NULL == sr->download) &&
@@ -882,25 +1023,28 @@ copy_children (GtkTreeModel * src_model, GtkTreeIter * src_iter,
882 return; 1023 return;
883 do 1024 do
884 { 1025 {
885 gtk_tree_model_get (src_model, &src_child, 1026 gtk_tree_model_get (src_model, &src_child,
886 0, &meta, 1027 SEARCH_TAB_MC_METADATA, &meta,
887 1, &uri, 1028 SEARCH_TAB_MC_URI, &uri,
888 2, &filesize, 1029 SEARCH_TAB_MC_FILESIZE, &filesize,
889 3, &preview, 1030 SEARCH_TAB_MC_PREVIEW, &preview,
890 4, &percent_progress, 1031 SEARCH_TAB_MC_PERCENT_PROGRESS, &percent_progress,
891 5, &percent_availability, 1032 SEARCH_TAB_MC_PERCENT_AVAILABILITY,
892 6, &filename, 1033 &percent_availability,
893 7, &uri_as_string, 1034 SEARCH_TAB_MC_FILENAME, &filename,
894 8, &status_colour, 1035 SEARCH_TAB_MC_URI_AS_STRING, &uri_as_string,
895 9, &search_result_old, 1036 SEARCH_TAB_MC_STATUS_COLOUR, &status_colour,
896 10, &mimetype, 1037 SEARCH_TAB_MC_SEARCH_RESULT, &search_result_old,
897 11, &applicability_rank, 1038 SEARCH_TAB_MC_MIMETYPE, &mimetype,
898 12, &availability_certainty, 1039 SEARCH_TAB_MC_APPLICABILITY_RANK, &applicability_rank,
899 13, &availability_rank, 1040 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY,
900 14, &completed, 1041 &availability_certainty,
901 15, &downloaded_filename, 1042 SEARCH_TAB_MC_AVAILABILITY_RANK, &availability_rank,
902 16, &downloaded_anonymity, 1043 SEARCH_TAB_MC_COMPLETED, &completed,
903 -1); 1044 SEARCH_TAB_MC_DOWNLOADED_FILENAME, &downloaded_filename,
1045 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY,
1046 &downloaded_anonymity,
1047 -1);
904 search_result_new = GNUNET_malloc (sizeof (struct SearchResult)); 1048 search_result_new = GNUNET_malloc (sizeof (struct SearchResult));
905 search_result_new->tab = dst_tab; 1049 search_result_new->tab = dst_tab;
906 search_result_new->download = search_result_old->download; 1050 search_result_new->download = search_result_old->download;
@@ -910,25 +1054,37 @@ copy_children (GtkTreeModel * src_model, GtkTreeIter * src_iter,
910 search_result_new->download->sr = search_result_new; 1054 search_result_new->download->sr = search_result_new;
911 } 1055 }
912 gtk_tree_store_insert_with_values (dst_tab->ts, &dst_child, 1056 gtk_tree_store_insert_with_values (dst_tab->ts, &dst_child,
913 dst_iter, G_MAXINT, 1057 dst_iter, G_MAXINT,
914 0, GNUNET_CONTAINER_meta_data_duplicate (meta), 1058 SEARCH_TAB_MC_METADATA,
915 1, GNUNET_FS_uri_dup (uri), 1059 GNUNET_CONTAINER_meta_data_duplicate (meta),
916 2, filesize, 1060 SEARCH_TAB_MC_URI,
917 3, preview, 1061 GNUNET_FS_uri_dup (uri),
918 4, percent_progress, 1062 SEARCH_TAB_MC_SEARCH_RESULT, filesize,
919 5, percent_availability, 1063 SEARCH_TAB_MC_PREVIEW, preview,
920 6, filename, 1064 SEARCH_TAB_MC_PERCENT_PROGRESS,
921 7, uri_as_string, 1065 percent_progress,
922 8, status_colour, 1066 SEARCH_TAB_MC_PERCENT_AVAILABILITY,
923 9, search_result_new, 1067 percent_availability,
924 10, mimetype, 1068 SEARCH_TAB_MC_FILENAME, filename,
925 11, applicability_rank, 1069 SEARCH_TAB_MC_URI_AS_STRING,
926 12, availability_certainty, 1070 uri_as_string,
927 13, availability_rank, 1071 SEARCH_TAB_MC_STATUS_COLOUR,
928 14, completed, 1072 status_colour,
929 15, downloaded_filename, 1073 SEARCH_TAB_MC_SEARCH_RESULT,
930 16, downloaded_anonymity, 1074 search_result_new,
931 -1); 1075 SEARCH_TAB_MC_MIMETYPE, mimetype,
1076 SEARCH_TAB_MC_APPLICABILITY_RANK,
1077 applicability_rank,
1078 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY,
1079 availability_certainty,
1080 SEARCH_TAB_MC_AVAILABILITY_RANK,
1081 availability_rank,
1082 SEARCH_TAB_MC_COMPLETED, completed,
1083 SEARCH_TAB_MC_DOWNLOADED_FILENAME,
1084 downloaded_filename,
1085 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY,
1086 downloaded_anonymity,
1087 -1);
932 g_free (filename); 1088 g_free (filename);
933 g_free (downloaded_filename); 1089 g_free (downloaded_filename);
934 g_free (uri_as_string); 1090 g_free (uri_as_string);
@@ -985,19 +1141,20 @@ download_lost_parent (struct DownloadEntry *de)
985 } 1141 }
986 gtk_tree_path_free (path); 1142 gtk_tree_path_free (path);
987 gtk_tree_model_get (tm_old, &iter_old, 1143 gtk_tree_model_get (tm_old, &iter_old,
988 0, &meta, 1144 SEARCH_TAB_MC_METADATA, &meta,
989 1, &uri, 1145 SEARCH_TAB_MC_URI, &uri,
990 4, &percent_progress, 1146 SEARCH_TAB_MC_PERCENT_PROGRESS, &percent_progress,
991 5, &percent_availability, 1147 SEARCH_TAB_MC_PERCENT_AVAILABILITY, &percent_availability,
992 6, &filename, 1148 SEARCH_TAB_MC_FILENAME, &filename,
993 8, &status_colour, 1149 SEARCH_TAB_MC_STATUS_COLOUR, &status_colour,
994 11, &applicability_rank, 1150 SEARCH_TAB_MC_APPLICABILITY_RANK, &applicability_rank,
995 12, &availability_certainty, 1151 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY,
996 13, &availability_rank, 1152 &availability_certainty,
997 14, &completed, 1153 SEARCH_TAB_MC_AVAILABILITY_RANK, &availability_rank,
998 15, &downloaded_filename, 1154 SEARCH_TAB_MC_COMPLETED, &completed,
999 16, &downloaded_anonymity, 1155 SEARCH_TAB_MC_DOWNLOADED_FILENAME, &downloaded_filename,
1000 -1); 1156 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, &downloaded_anonymity,
1157 -1);
1001 GNUNET_assert (GNUNET_YES == GNUNET_FS_uri_test_equal (uri, de->uri)); 1158 GNUNET_assert (GNUNET_YES == GNUNET_FS_uri_test_equal (uri, de->uri));
1002 GNUNET_assert (de->sr->download == de); 1159 GNUNET_assert (de->sr->download == de);
1003 de->sr->download = NULL; 1160 de->sr->download = NULL;
@@ -1018,17 +1175,18 @@ download_lost_parent (struct DownloadEntry *de)
1018 gtk_tree_path_free (path); 1175 gtk_tree_path_free (path);
1019 1176
1020 gtk_tree_store_set (de->sr->tab->ts, &iter, 1177 gtk_tree_store_set (de->sr->tab->ts, &iter,
1021 4, percent_progress, 1178 SEARCH_TAB_MC_PERCENT_PROGRESS, percent_progress,
1022 5, percent_availability, 1179 SEARCH_TAB_MC_PERCENT_AVAILABILITY, percent_availability,
1023 6, filename, 1180 SEARCH_TAB_MC_FILENAME, filename,
1024 8, status_colour, 1181 SEARCH_TAB_MC_STATUS_COLOUR, status_colour,
1025 11, applicability_rank, 1182 SEARCH_TAB_MC_APPLICABILITY_RANK, applicability_rank,
1026 12, availability_certainty, 1183 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY,
1027 13, availability_rank, 1184 availability_certainty,
1028 14, completed, 1185 SEARCH_TAB_MC_AVAILABILITY_RANK, availability_rank,
1029 15, downloaded_filename, 1186 SEARCH_TAB_MC_COMPLETED, completed,
1030 16, downloaded_anonymity, 1187 SEARCH_TAB_MC_DOWNLOADED_FILENAME, downloaded_filename,
1031 -1); 1188 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, downloaded_anonymity,
1189 -1);
1032 g_free (filename); 1190 g_free (filename);
1033 g_free (downloaded_filename); 1191 g_free (downloaded_filename);
1034 g_free (status_colour); 1192 g_free (status_colour);
@@ -1062,10 +1220,10 @@ move_downloads_in_subtree (GtkTreeModel *tm,
1062 do 1220 do
1063 { 1221 {
1064 gtk_tree_model_get (tm, &child, 1222 gtk_tree_model_get (tm, &child,
1065 0, &meta, 1223 SEARCH_TAB_MC_METADATA, &meta,
1066 1, &uri, 1224 SEARCH_TAB_MC_URI, &uri,
1067 9, &sr, 1225 SEARCH_TAB_MC_SEARCH_RESULT, &sr,
1068 -1); 1226 -1);
1069 if (NULL != sr->download) 1227 if (NULL != sr->download)
1070 { 1228 {
1071 if (sr->download->is_done == GNUNET_YES) 1229 if (sr->download->is_done == GNUNET_YES)
@@ -1088,10 +1246,10 @@ move_downloads_in_subtree (GtkTreeModel *tm,
1088 GNUNET_free (sr); 1246 GNUNET_free (sr);
1089 /* get ready for removal of the tree */ 1247 /* get ready for removal of the tree */
1090 gtk_tree_store_set (GTK_TREE_STORE (tm), &child, 1248 gtk_tree_store_set (GTK_TREE_STORE (tm), &child,
1091 0, NULL, 1249 SEARCH_TAB_MC_METADATA, NULL,
1092 1, NULL, 1250 SEARCH_TAB_MC_URI, NULL,
1093 9, NULL, 1251 SEARCH_TAB_MC_SEARCH_RESULT, NULL,
1094 -1); 1252 -1);
1095 } 1253 }
1096 while (TRUE == gtk_tree_model_iter_next (tm, &child)); 1254 while (TRUE == gtk_tree_model_iter_next (tm, &child));
1097 } 1255 }
@@ -1133,7 +1291,10 @@ free_search_result (struct SearchResult *sr)
1133 return; 1291 return;
1134 } 1292 }
1135 gtk_tree_path_free (tp); 1293 gtk_tree_path_free (tp);
1136 gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, -1); 1294 gtk_tree_model_get (tm, &iter,
1295 SEARCH_TAB_MC_METADATA, &meta,
1296 SEARCH_TAB_MC_URI, &uri,
1297 -1);
1137 if (uri != NULL) 1298 if (uri != NULL)
1138 GNUNET_FS_uri_destroy (uri); 1299 GNUNET_FS_uri_destroy (uri);
1139 if (meta != NULL) 1300 if (meta != NULL)
@@ -1181,7 +1342,10 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv,
1181 } 1342 }
1182 meta = NULL; 1343 meta = NULL;
1183 pixbuf = NULL; 1344 pixbuf = NULL;
1184 gtk_tree_model_get (model, &iter, 0, &meta, 3, &pixbuf, -1); 1345 gtk_tree_model_get (model, &iter,
1346 SEARCH_TAB_MC_METADATA, &meta,
1347 SEARCH_TAB_MC_PREVIEW, &pixbuf,
1348 -1);
1185 if (NULL != pixbuf) 1349 if (NULL != pixbuf)
1186 { 1350 {
1187 gtk_image_set_from_pixbuf (image, pixbuf); 1351 gtk_image_set_from_pixbuf (image, pixbuf);
@@ -1328,7 +1492,9 @@ stop_downloads_in_subtree (GtkTreeModel *tm,
1328 { 1492 {
1329 do 1493 do
1330 { 1494 {
1331 gtk_tree_model_get (tm, &child, 9, &sr, -1); 1495 gtk_tree_model_get (tm, &child,
1496 SEARCH_TAB_MC_SEARCH_RESULT, &sr,
1497 -1);
1332 if ( (NULL != sr->download) && 1498 if ( (NULL != sr->download) &&
1333 (sr->download->is_done == GNUNET_YES) ) 1499 (sr->download->is_done == GNUNET_YES) )
1334 { 1500 {
@@ -1371,7 +1537,9 @@ GNUNET_FS_GTK_search_result_clear_button_clicked (GtkButton * button, gpointer u
1371 return; 1537 return;
1372 do 1538 do
1373 { 1539 {
1374 gtk_tree_model_get (tm, &iter, 9, &sr, -1); 1540 gtk_tree_model_get (tm, &iter,
1541 SEARCH_TAB_MC_SEARCH_RESULT, &sr,
1542 -1);
1375 if ( (sr->download != NULL) && 1543 if ( (sr->download != NULL) &&
1376 (sr->download->is_done == GNUNET_YES) ) 1544 (sr->download->is_done == GNUNET_YES) )
1377 { 1545 {
@@ -1480,7 +1648,9 @@ update_search_result (struct SearchResult *sr,
1480 desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup); 1648 desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup);
1481 mime = get_mimetype_from_metadata (meta); 1649 mime = get_mimetype_from_metadata (meta);
1482 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); 1650 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta);
1483 gtk_tree_model_get (tm, &iter, 0, &ometa, -1); 1651 gtk_tree_model_get (tm, &iter,
1652 SEARCH_TAB_MC_METADATA, &ometa,
1653 -1);
1484 if (NULL != ometa) 1654 if (NULL != ometa)
1485 GNUNET_CONTAINER_meta_data_destroy (ometa); 1655 GNUNET_CONTAINER_meta_data_destroy (ometa);
1486 if (availability_certainty > 0) 1656 if (availability_certainty > 0)
@@ -1488,13 +1658,18 @@ update_search_result (struct SearchResult *sr,
1488 else 1658 else
1489 percent_avail = 50; 1659 percent_avail = 50;
1490 gtk_tree_store_set (ts, &iter, 1660 gtk_tree_store_set (ts, &iter,
1491 0, GNUNET_CONTAINER_meta_data_duplicate (meta), 1661 SEARCH_TAB_MC_METADATA,
1492 3, pixbuf /* preview */ , 1662 GNUNET_CONTAINER_meta_data_duplicate (meta),
1493 5, (guint) percent_avail /* percent availability */ , 1663 SEARCH_TAB_MC_PREVIEW, pixbuf,
1494 6, desc /* filename/description */ , 1664 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail,
1495 10, mime, 11, (guint) applicability_rank, 12, 1665 SEARCH_TAB_MC_FILENAME, desc,
1496 (guint) availability_certainty, 13, 1666 SEARCH_TAB_MC_MIMETYPE, mime,
1497 (gint) availability_rank, -1); 1667 SEARCH_TAB_MC_APPLICABILITY_RANK,
1668 (guint) applicability_rank,
1669 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY,
1670 (guint) availability_certainty,
1671 SEARCH_TAB_MC_AVAILABILITY_RANK, (gint) availability_rank,
1672 -1);
1498 if (pixbuf != NULL) 1673 if (pixbuf != NULL)
1499 g_object_unref (pixbuf); 1674 g_object_unref (pixbuf);
1500 GNUNET_free (desc); 1675 GNUNET_free (desc);
@@ -1615,24 +1790,28 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab,
1615 pitr = NULL; 1790 pitr = NULL;
1616 ts = tab->ts; 1791 ts = tab->ts;
1617 } 1792 }
1618 gtk_tree_store_insert_with_values (ts, &iter, pitr, G_MAXINT, 1793 gtk_tree_store_insert_with_values (ts, &iter, pitr, G_MAXINT,
1619 0, GNUNET_CONTAINER_meta_data_duplicate (meta), 1794 SEARCH_TAB_MC_METADATA,
1620 1, (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri), 1795 GNUNET_CONTAINER_meta_data_duplicate (meta),
1621 2, fsize, 1796 SEARCH_TAB_MC_URI,
1622 3, pixbuf /* preview */ , 1797 (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri),
1623 4, 0 /* percent progress */ , 1798 SEARCH_TAB_MC_FILESIZE, fsize,
1624 5, (fsize == 0) ? 100 : 0 /* percent availability */ , 1799 SEARCH_TAB_MC_PREVIEW, pixbuf,
1625 6, desc /* filename/description */ , 1800 SEARCH_TAB_MC_PERCENT_PROGRESS, 0,
1626 7, uris, 1801 SEARCH_TAB_MC_PERCENT_AVAILABILITY,
1627 8, status_colour, 1802 (fsize == 0) ? 100 : 0,
1628 9, sr, 1803 SEARCH_TAB_MC_FILENAME, desc,
1629 10, mime, 1804 SEARCH_TAB_MC_URI_AS_STRING, uris,
1630 11, applicability_rank, 1805 SEARCH_TAB_MC_STATUS_COLOUR, status_colour,
1631 12, 0 /* avail-cert */ , 1806 SEARCH_TAB_MC_SEARCH_RESULT, sr,
1632 13, 0, /* avail-rank */ 1807 SEARCH_TAB_MC_MIMETYPE, mime,
1633 14, (guint64) 0, /* completed */ 1808 SEARCH_TAB_MC_APPLICABILITY_RANK,
1634 15, NULL, /* downloaded_filename */ 1809 applicability_rank,
1635 16, -1, /* downloaded_anonymity */ 1810 SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, 0,
1811 SEARCH_TAB_MC_AVAILABILITY_RANK, 0,
1812 SEARCH_TAB_MC_COMPLETED, (guint64) 0,
1813 SEARCH_TAB_MC_DOWNLOADED_FILENAME, NULL,
1814 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, -1,
1636 -1); 1815 -1);
1637 if (pixbuf != NULL) 1816 if (pixbuf != NULL)
1638 g_object_unref (pixbuf); 1817 g_object_unref (pixbuf);
@@ -1881,7 +2060,9 @@ change_download_color (struct DownloadEntry *de,
1881 return; 2060 return;
1882 } 2061 }
1883 gtk_tree_path_free (path); 2062 gtk_tree_path_free (path);
1884 gtk_tree_store_set (de->sr->tab->ts, &iter, 8, color, -1); 2063 gtk_tree_store_set (de->sr->tab->ts, &iter,
2064 SEARCH_TAB_MC_STATUS_COLOUR, color,
2065 -1);
1885} 2066}
1886 2067
1887 2068
@@ -1989,7 +2170,7 @@ add_directory_entry (void *cls, const char *filename,
1989 { 2170 {
1990 do 2171 do
1991 { 2172 {
1992 gtk_tree_model_get (tm, &iter, 1, &xuri, -1); 2173 gtk_tree_model_get (tm, &iter, SEARCH_TAB_MC_URI, &xuri, -1);
1993 if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri)) 2174 if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri))
1994 return; /* already present */ 2175 return; /* already present */
1995 } 2176 }
@@ -2042,15 +2223,13 @@ mark_download_progress (struct DownloadEntry *de,
2042 'progress' once the download has started and re-use the 2223 'progress' once the download has started and re-use the
2043 space in the display? Probably yes, at least once we have 2224 space in the display? Probably yes, at least once we have
2044 a custom CellRenderer... */ 2225 a custom CellRenderer... */
2045 gtk_tree_store_set (de->sr->tab->ts, &iter, 2226 gtk_tree_store_set (de->sr->tab->ts, &iter,
2046 4, (guint) ((size > 2227 SEARCH_TAB_MC_PERCENT_PROGRESS,
2047 0) ? (100 * completed / 2228 (guint) ((size > 0) ? (100 * completed / size) : 100),
2048 size) : 100) /* progress */, 2229 SEARCH_TAB_MC_PERCENT_AVAILABILITY,
2049 5, (guint) ((size > 2230 (guint) ((size > 0) ? (100 * completed / size) : 100),
2050 0) ? (100 * completed / 2231 SEARCH_TAB_MC_COMPLETED, completed,
2051 size) : 100) /* availability == progress */, 2232 -1);
2052 14, completed,
2053 -1);
2054 if (completed < size) 2233 if (completed < size)
2055 { 2234 {
2056 /* partial completion, consider looking at the block */ 2235 /* partial completion, consider looking at the block */
@@ -2070,8 +2249,8 @@ mark_download_progress (struct DownloadEntry *de,
2070 { 2249 {
2071 /* Mime type was wrong, this is not a directory, update model! */ 2250 /* Mime type was wrong, this is not a directory, update model! */
2072 de->is_directory = GNUNET_SYSERR; 2251 de->is_directory = GNUNET_SYSERR;
2073 gtk_tree_store_set (de->sr->tab->ts, &iter, 2252 gtk_tree_store_set (de->sr->tab->ts, &iter,
2074 10, "" /* unknown mime type */, -1); 2253 SEARCH_TAB_MC_MIMETYPE, "", -1);
2075 } 2254 }
2076 } 2255 }
2077 } 2256 }
@@ -2120,7 +2299,10 @@ mark_download_error (struct DownloadEntry *de,
2120 return; 2299 return;
2121 } 2300 }
2122 gtk_tree_path_free (path); 2301 gtk_tree_path_free (path);
2123 gtk_tree_store_set (de->sr->tab->ts, &iter, 4, 0, 7, emsg, -1); 2302 gtk_tree_store_set (de->sr->tab->ts, &iter,
2303 SEARCH_TAB_MC_PERCENT_PROGRESS, 0,
2304 SEARCH_TAB_MC_URI_AS_STRING, emsg
2305 -1);
2124} 2306}
2125 2307
2126 2308
@@ -2148,9 +2330,9 @@ mark_download_completed (struct DownloadEntry *de, uint64_t size)
2148 } 2330 }
2149 gtk_tree_path_free (path); 2331 gtk_tree_path_free (path);
2150 gtk_tree_store_set (de->sr->tab->ts, &iter, 2332 gtk_tree_store_set (de->sr->tab->ts, &iter,
2151 4, (guint) 100, 2333 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100,
2152 5, (guint) 100, 2334 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100,
2153 -1); 2335 -1);
2154} 2336}
2155 2337
2156 2338
@@ -2229,9 +2411,10 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde,
2229 { 2411 {
2230 do 2412 do
2231 { 2413 {
2232 gtk_tree_model_get (tm, &child, 1, &uri, 2414 gtk_tree_model_get (tm, &child,
2233 9, &de->sr, 2415 SEARCH_TAB_MC_URI, &uri,
2234 -1); 2416 SEARCH_TAB_MC_SEARCH_RESULT, &de->sr,
2417 -1);
2235 if (GNUNET_YES == GNUNET_FS_uri_test_equal (de->uri, 2418 if (GNUNET_YES == GNUNET_FS_uri_test_equal (de->uri,
2236 uri)) 2419 uri))
2237 break; 2420 break;
@@ -2278,21 +2461,20 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde,
2278 return de; 2461 return de;
2279 } 2462 }
2280 gtk_tree_model_get (GTK_TREE_MODEL (de->sr->tab->ts), &iter, 2463 gtk_tree_model_get (GTK_TREE_MODEL (de->sr->tab->ts), &iter,
2281 0, &meta, 2464 SEARCH_TAB_MC_METADATA, &meta,
2282 -1); 2465 -1);
2283 de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta); 2466 de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta);
2284 } 2467 }
2285 gtk_tree_path_free (path); 2468 gtk_tree_path_free (path);
2286 gtk_tree_store_set (de->sr->tab->ts, &iter, 2469 gtk_tree_store_set (de->sr->tab->ts, &iter,
2287 4, (guint) ((size > 2470 SEARCH_TAB_MC_PERCENT_PROGRESS,
2288 0) ? (100 * completed / 2471 (guint) ((size > 0) ? (100 * completed / size) : 100),
2289 size) : 100) /* progress */ , 2472 SEARCH_TAB_MC_FILENAME, filename,
2290 6, filename /* filename/description */ , 2473 SEARCH_TAB_MC_STATUS_COLOUR, "blue",
2291 8, "blue" /* status colour: pending */ , 2474 SEARCH_TAB_MC_SEARCH_RESULT, de->sr,
2292 9, de->sr, 2475 SEARCH_TAB_MC_COMPLETED, completed,
2293 14, completed, 2476 SEARCH_TAB_MC_FILENAME, de->filename,
2294 15, de->filename, 2477 SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, de->anonymity,
2295 16, de->anonymity,
2296 -1); 2478 -1);
2297 return de; 2479 return de;
2298} 2480}
@@ -2327,7 +2509,7 @@ change_publish_color (struct PublishEntry *pe,
2327 return; 2509 return;
2328 } 2510 }
2329 gtk_tree_path_free (path); 2511 gtk_tree_path_free (path);
2330 gtk_tree_store_set (pe->tab->ts, &iter, 2, color, -1); 2512 gtk_tree_store_set (pe->tab->ts, &iter, PUBLISH_TAB_MC_BGCOLOUR, color, -1);
2331} 2513}
2332 2514
2333 2515
@@ -2354,10 +2536,9 @@ mark_publish_progress (struct PublishEntry *pe, uint64_t size,
2354 return; 2536 return;
2355 } 2537 }
2356 gtk_tree_path_free (path); 2538 gtk_tree_path_free (path);
2357 gtk_tree_store_set (pe->tab->ts, &iter, 3, 2539 gtk_tree_store_set (pe->tab->ts, &iter,
2358 (guint) ((size > 2540 PUBLISH_TAB_MC_PROGRESS,
2359 0) ? (100 * completed / 2541 (guint) ((size > 0) ? (100 * completed / size) : 100),
2360 size) : 100) /* progress */ ,
2361 -1); 2542 -1);
2362} 2543}
2363 2544
@@ -2388,7 +2569,7 @@ handle_publish_completed (struct PublishEntry *pe,
2388 pe->uri = GNUNET_FS_uri_dup (uri); 2569 pe->uri = GNUNET_FS_uri_dup (uri);
2389 uris = GNUNET_FS_uri_to_string (uri); 2570 uris = GNUNET_FS_uri_to_string (uri);
2390 gtk_tree_store_set (pe->tab->ts, &iter, 2571 gtk_tree_store_set (pe->tab->ts, &iter,
2391 5, uris, 2572 PUBLISH_TAB_MC_RESULT_STRING, uris,
2392 -1); 2573 -1);
2393 GNUNET_free (uris); 2574 GNUNET_free (uris);
2394 change_publish_color (pe, "green"); 2575 change_publish_color (pe, "green");
@@ -2418,7 +2599,7 @@ handle_publish_error (struct PublishEntry *pe,
2418 } 2599 }
2419 gtk_tree_path_free (path); 2600 gtk_tree_path_free (path);
2420 gtk_tree_store_set (pe->tab->ts, &iter, 2601 gtk_tree_store_set (pe->tab->ts, &iter,
2421 5, emsg, 2602 PUBLISH_TAB_MC_RESULT_STRING, emsg,
2422 -1); 2603 -1);
2423 change_publish_color (pe, "red"); 2604 change_publish_color (pe, "red");
2424} 2605}
@@ -2480,7 +2661,7 @@ GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button,
2480 tm = GTK_TREE_MODEL (publish_tab->ts); 2661 tm = GTK_TREE_MODEL (publish_tab->ts);
2481 while (gtk_tree_model_iter_children (tm, &iter, NULL)) 2662 while (gtk_tree_model_iter_children (tm, &iter, NULL))
2482 { 2663 {
2483 gtk_tree_model_get (tm, &iter, 4, &pe, -1); 2664 gtk_tree_model_get (tm, &iter, PUBLISH_TAB_MC_ENT, &pe, -1);
2484 GNUNET_FS_publish_stop (pe->pc); 2665 GNUNET_FS_publish_stop (pe->pc);
2485 } 2666 }
2486 clear_metadata_display (); 2667 clear_metadata_display ();
@@ -2586,9 +2767,12 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn,
2586 ent->pc = pc; 2767 ent->pc = pc;
2587 size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize); 2768 size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize);
2588 gtk_tree_store_insert_with_values (publish_tab->ts, &iter, pitrptr, G_MAXINT, 2769 gtk_tree_store_insert_with_values (publish_tab->ts, &iter, pitrptr, G_MAXINT,
2589 0, fn, 1, size_fancy, 2, "white", 3, 2770 PUBLISH_TAB_MC_FILENAME, fn,
2590 (guint) 0 /* progress */ , 2771 PUBLISH_TAB_MC_FILESIZE, size_fancy,
2591 4, ent, -1); 2772 PUBLISH_TAB_MC_BGCOLOUR, "white",
2773 PUBLISH_TAB_MC_PROGRESS, (guint) 0,
2774 PUBLISH_TAB_MC_ENT, ent,
2775 -1);
2592 GNUNET_free (size_fancy); 2776 GNUNET_free (size_fancy);
2593 path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); 2777 path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter);
2594 ent->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (publish_tab->ts), path); 2778 ent->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (publish_tab->ts), path);
@@ -2709,7 +2893,7 @@ publish_list_popup (GtkTreeModel *tm,
2709 struct PublishEntry *pe; 2893 struct PublishEntry *pe;
2710 struct PublishListPopupContext *ppc; 2894 struct PublishListPopupContext *ppc;
2711 2895
2712 gtk_tree_model_get (tm, iter, 4, &pe, -1); 2896 gtk_tree_model_get (tm, iter, PUBLISH_TAB_MC_ENT, &pe, -1);
2713 if ( (NULL == pe->uri) && 2897 if ( (NULL == pe->uri) &&
2714 ( (NULL == pe->pc) || 2898 ( (NULL == pe->pc) ||
2715 (GNUNET_NO == pe->is_top) ) ) 2899 (GNUNET_NO == pe->is_top) ) )