diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-18 22:11:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-18 22:11:40 +0000 |
commit | 84e88c10dac59016c254f64b37864f74eefe82f8 (patch) | |
tree | 3eb9c7b75c50e8bde62c3f98e1d7e57e62199fe8 | |
parent | 92313d7a362c02930898c66c4c06db9ee1f029b0 (diff) | |
download | gnunet-gtk-84e88c10dac59016c254f64b37864f74eefe82f8.tar.gz gnunet-gtk-84e88c10dac59016c254f64b37864f74eefe82f8.zip |
fixing 1772, also use filename for description if/once available
-rw-r--r-- | src/fs/gnunet-fs-gtk-event_handler.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index 2659b0f2..06b199e4 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -157,10 +157,28 @@ change_publish_colour (struct PublishEntry *pe, const char *colour) | |||
157 | static void | 157 | static void |
158 | stop_download (struct DownloadEntry *de, int is_suspend) | 158 | stop_download (struct DownloadEntry *de, int is_suspend) |
159 | { | 159 | { |
160 | change_download_colour (de, "white"); | 160 | GtkTreeIter iter; |
161 | GtkTreePath *path; | ||
162 | GtkTreeModel *tm; | ||
163 | struct SearchResult *search_result; | ||
164 | |||
165 | path = gtk_tree_row_reference_get_path (de->rr); | ||
166 | tm = gtk_tree_row_reference_get_model (de->rr); | ||
167 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) | ||
168 | GNUNET_break (0); | ||
169 | else | ||
170 | { | ||
171 | gtk_tree_model_get (tm, &iter, | ||
172 | 9, &search_result, -1); | ||
173 | GNUNET_assert (search_result->download == de); | ||
174 | search_result->download = NULL; | ||
175 | if (NULL == search_result->result) | ||
176 | (void) gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); | ||
177 | else | ||
178 | change_download_colour (de, "white"); | ||
179 | } | ||
180 | gtk_tree_path_free (path); | ||
161 | gtk_tree_row_reference_free (de->rr); | 181 | gtk_tree_row_reference_free (de->rr); |
162 | if (is_suspend == GNUNET_NO) | ||
163 | GNUNET_FS_download_stop (de->dc, GNUNET_YES); | ||
164 | GNUNET_FS_uri_destroy (de->uri); | 182 | GNUNET_FS_uri_destroy (de->uri); |
165 | GNUNET_CONTAINER_meta_data_destroy (de->meta); | 183 | GNUNET_CONTAINER_meta_data_destroy (de->meta); |
166 | GNUNET_free (de); | 184 | GNUNET_free (de); |
@@ -415,6 +433,7 @@ move_children (GtkTreeModel * src_model, GtkTreeIter * src_iter, | |||
415 | gtk_tree_row_reference_free (search_result->rr); | 433 | gtk_tree_row_reference_free (search_result->rr); |
416 | path = gtk_tree_model_get_path (dst_model, &dst_child); | 434 | path = gtk_tree_model_get_path (dst_model, &dst_child); |
417 | search_result->rr = gtk_tree_row_reference_new (dst_model, path); | 435 | search_result->rr = gtk_tree_row_reference_new (dst_model, path); |
436 | search_result->result = NULL; | ||
418 | gtk_tree_path_free (path); | 437 | gtk_tree_path_free (path); |
419 | if (search_result->download != NULL) | 438 | if (search_result->download != NULL) |
420 | { | 439 | { |
@@ -464,8 +483,8 @@ download_lost_parent (struct DownloadEntry *de, uint64_t size, | |||
464 | GtkTreeModel * model; | 483 | GtkTreeModel * model; |
465 | 484 | ||
466 | rr_old = de->rr; | 485 | rr_old = de->rr; |
467 | de->sr = NULL; | 486 | tab = GNUNET_GTK_add_to_uri_tab (&iter, &de->sr, de->meta, de->uri); |
468 | tab = GNUNET_GTK_add_to_uri_tab (&iter, NULL, de->meta, de->uri); | 487 | de->sr->download = de; |
469 | de->ts = tab->ts; | 488 | de->ts = tab->ts; |
470 | model = GTK_TREE_MODEL (de->ts); | 489 | model = GTK_TREE_MODEL (de->ts); |
471 | path = gtk_tree_model_get_path (model, &iter); | 490 | path = gtk_tree_model_get_path (model, &iter); |
@@ -511,6 +530,7 @@ static struct DownloadEntry * | |||
511 | setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | 530 | setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, |
512 | struct SearchResult *sr, struct GNUNET_FS_DownloadContext *dc, | 531 | struct SearchResult *sr, struct GNUNET_FS_DownloadContext *dc, |
513 | const struct GNUNET_FS_Uri *uri, | 532 | const struct GNUNET_FS_Uri *uri, |
533 | const char *filename, | ||
514 | const struct GNUNET_CONTAINER_MetaData *meta, uint64_t size, | 534 | const struct GNUNET_CONTAINER_MetaData *meta, uint64_t size, |
515 | uint64_t completed) | 535 | uint64_t completed) |
516 | { | 536 | { |
@@ -520,12 +540,15 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | |||
520 | if (de == NULL) | 540 | if (de == NULL) |
521 | { | 541 | { |
522 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); | 542 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); |
523 | GNUNET_assert (sr->download == NULL); | ||
524 | sr->download = de; | ||
525 | de->sr = sr; | ||
526 | de->dc = dc; | ||
527 | de->uri = GNUNET_FS_uri_dup (uri); | 543 | de->uri = GNUNET_FS_uri_dup (uri); |
528 | } | 544 | } |
545 | de->dc = dc; | ||
546 | de->sr = sr; | ||
547 | if (NULL != sr) | ||
548 | { | ||
549 | GNUNET_assert (sr->download == NULL); | ||
550 | sr->download = de; | ||
551 | } | ||
529 | de->pde = pde; | 552 | de->pde = pde; |
530 | if ((meta != NULL) && (de->meta == NULL)) | 553 | if ((meta != NULL) && (de->meta == NULL)) |
531 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 554 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
@@ -555,6 +578,7 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | |||
555 | (guint) ((size > | 578 | (guint) ((size > |
556 | 0) ? (100 * completed / | 579 | 0) ? (100 * completed / |
557 | size) : 100) /* progress */ , | 580 | size) : 100) /* progress */ , |
581 | 6, filename /* filename/description */ , | ||
558 | 8, "blue" /* status colour: pending */ , | 582 | 8, "blue" /* status colour: pending */ , |
559 | -1); | 583 | -1); |
560 | return de; | 584 | return de; |
@@ -994,7 +1018,7 @@ clear_downloads (GtkButton * button, gpointer user_data) | |||
994 | { | 1018 | { |
995 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); | 1019 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); |
996 | if ((sr->download != NULL) && (sr->download->is_done == GNUNET_YES)) | 1020 | if ((sr->download != NULL) && (sr->download->is_done == GNUNET_YES)) |
997 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); | 1021 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); |
998 | } | 1022 | } |
999 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1023 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1000 | } | 1024 | } |
@@ -1227,7 +1251,8 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, GtkTreeIter * iter, | |||
1227 | } | 1251 | } |
1228 | desc = | 1252 | desc = |
1229 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1253 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
1230 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 1254 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
1255 | EXTRACTOR_METATYPE_PACKAGE_NAME, | ||
1231 | EXTRACTOR_METATYPE_TITLE, | 1256 | EXTRACTOR_METATYPE_TITLE, |
1232 | EXTRACTOR_METATYPE_BOOK_TITLE, | 1257 | EXTRACTOR_METATYPE_BOOK_TITLE, |
1233 | EXTRACTOR_METATYPE_FILENAME, | 1258 | EXTRACTOR_METATYPE_FILENAME, |
@@ -1709,6 +1734,7 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1709 | return setup_download (info->value.download.cctx, info->value.download.pctx, | 1734 | return setup_download (info->value.download.cctx, info->value.download.pctx, |
1710 | info->value.download.sctx, info->value.download.dc, | 1735 | info->value.download.sctx, info->value.download.dc, |
1711 | info->value.download.uri, | 1736 | info->value.download.uri, |
1737 | info->value.download.filename, | ||
1712 | info->value.download.specifics.start.meta, | 1738 | info->value.download.specifics.start.meta, |
1713 | info->value.download.size, | 1739 | info->value.download.size, |
1714 | info->value.download.completed); | 1740 | info->value.download.completed); |
@@ -1717,6 +1743,7 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1717 | setup_download (info->value.download.cctx, info->value.download.pctx, | 1743 | setup_download (info->value.download.cctx, info->value.download.pctx, |
1718 | info->value.download.sctx, info->value.download.dc, | 1744 | info->value.download.sctx, info->value.download.dc, |
1719 | info->value.download.uri, | 1745 | info->value.download.uri, |
1746 | info->value.download.filename, | ||
1720 | info->value.download.specifics.resume.meta, | 1747 | info->value.download.specifics.resume.meta, |
1721 | info->value.download.size, | 1748 | info->value.download.size, |
1722 | info->value.download.completed); | 1749 | info->value.download.completed); |