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.c224
1 files changed, 166 insertions, 58 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 5015e6ca..ff481140 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -1580,13 +1580,18 @@ static void
1580close_search_tab (struct SearchTab *tab) 1580close_search_tab (struct SearchTab *tab)
1581{ 1581{
1582 struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); 1582 struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context ();
1583 GtkTreeIter iter;
1583 int index; 1584 int index;
1584 int i; 1585 int i;
1585 1586
1586 if (tab->parent != NULL) 1587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1588 "Closing search tab `%s'\n",
1589 tab->query_txt);
1590 if (NULL != tab->parent)
1587 { 1591 {
1588 /* not a top-level search (namespace update search), do not close 1592 /* not a top-level search (namespace update search), do not close
1589 tab here! */ 1593 tab here! */
1594 tab->parent->tab = NULL;
1590 GNUNET_free (tab); 1595 GNUNET_free (tab);
1591 return; 1596 return;
1592 } 1597 }
@@ -1595,10 +1600,31 @@ close_search_tab (struct SearchTab *tab)
1595 for (i = gtk_notebook_get_n_pages (mctx->notebook) - 1; i >= 0; i--) 1600 for (i = gtk_notebook_get_n_pages (mctx->notebook) - 1; i >= 0; i--)
1596 if (tab->frame == gtk_notebook_get_nth_page (mctx->notebook, i)) 1601 if (tab->frame == gtk_notebook_get_nth_page (mctx->notebook, i))
1597 index = i; 1602 index = i;
1598 gtk_notebook_remove_page (mctx->notebook, index); 1603 if (gtk_tree_model_iter_children (GTK_TREE_MODEL (tab->ts),
1604 &iter,
1605 NULL))
1606 {
1607 do
1608 {
1609 struct SearchResult *sr;
1610
1611 gtk_tree_model_get (GTK_TREE_MODEL (tab->ts),
1612 &iter,
1613 SEARCH_TAB_MC_SEARCH_RESULT, &sr,
1614 -1);
1615 if (NULL != sr)
1616 sr->tab = NULL;
1617 }
1618 while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tab->ts),
1619 &iter));
1620 }
1621 gtk_notebook_remove_page (mctx->notebook,
1622 index);
1599 g_object_unref (tab->builder); 1623 g_object_unref (tab->builder);
1600 GNUNET_free (tab->query_txt); 1624 GNUNET_free (tab->query_txt);
1601 GNUNET_CONTAINER_DLL_remove (search_tab_head, search_tab_tail, tab); 1625 GNUNET_CONTAINER_DLL_remove (search_tab_head,
1626 search_tab_tail,
1627 tab);
1602 if (tab == uri_tab) 1628 if (tab == uri_tab)
1603 uri_tab = NULL; 1629 uri_tab = NULL;
1604 if (NULL != tab->atv) 1630 if (NULL != tab->atv)
@@ -1648,12 +1674,16 @@ GNUNET_FS_GTK_close_uri_tab_ ()
1648static void 1674static void
1649download_lost_parent (struct DownloadEntry *de) 1675download_lost_parent (struct DownloadEntry *de)
1650{ 1676{
1651 de->sr->tab = NULL; 1677 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1678 "Download %p lost search parent; removing from search result %p list.\n",
1679 de,
1680 de->sr);
1652 if (NULL != de->sr->rr) 1681 if (NULL != de->sr->rr)
1653 { 1682 {
1654 gtk_tree_row_reference_free (de->sr->rr); 1683 gtk_tree_row_reference_free (de->sr->rr);
1655 de->sr->rr = NULL; 1684 de->sr->rr = NULL;
1656 } 1685 }
1686 de->sr = NULL;
1657} 1687}
1658 1688
1659 1689
@@ -1755,7 +1785,8 @@ free_search_result (struct SearchResult *sr)
1755 return; 1785 return;
1756 } 1786 }
1757 /* get ready for later removal of the tree */ 1787 /* get ready for later removal of the tree */
1758 gtk_tree_store_set (GTK_TREE_STORE (tm), &iter, 1788 gtk_tree_store_set (GTK_TREE_STORE (tm),
1789 &iter,
1759 SEARCH_TAB_MC_METADATA, NULL, 1790 SEARCH_TAB_MC_METADATA, NULL,
1760 SEARCH_TAB_MC_URI, NULL, 1791 SEARCH_TAB_MC_URI, NULL,
1761 SEARCH_TAB_MC_SEARCH_RESULT, NULL, 1792 SEARCH_TAB_MC_SEARCH_RESULT, NULL,
@@ -1940,14 +1971,18 @@ GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy,
1940 * User clicked on the 'close' button for a search tab. Tell FS to stop the search. 1971 * User clicked on the 'close' button for a search tab. Tell FS to stop the search.
1941 * 1972 *
1942 * @param button the 'close' button 1973 * @param button the 'close' button
1943 * @param user_data the 'struct SearchTab' of the tab to close 1974 * @param user_data the `struct SearchTab` of the tab to close
1944 */ 1975 */
1945void 1976void
1946GNUNET_FS_GTK_search_result_close_button_clicked (GtkButton *button, gpointer user_data) 1977GNUNET_FS_GTK_search_result_close_button_clicked (GtkButton *button,
1978 gpointer user_data)
1947{ 1979{
1948 struct SearchTab *tab = user_data; 1980 struct SearchTab *tab = user_data;
1949 struct GNUNET_FS_SearchContext *sc; 1981 struct GNUNET_FS_SearchContext *sc;
1950 1982
1983 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1984 "Stopping search `%s'\n",
1985 tab->query_txt);
1951 sc = tab->sc; 1986 sc = tab->sc;
1952 if (NULL == sc) 1987 if (NULL == sc)
1953 { 1988 {
@@ -2082,13 +2117,16 @@ GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton * button,
2082 (GNUNET_YES == sr->download->is_done) ) 2117 (GNUNET_YES == sr->download->is_done) )
2083 { 2118 {
2084 /* got a finished download, stop it */ 2119 /* got a finished download, stop it */
2085 GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); 2120 GNUNET_FS_download_stop (sr->download->dc,
2086 if (! gtk_tree_model_get_iter_first (tm, &iter)) 2121 GNUNET_YES);
2122 if (! gtk_tree_model_get_iter_first (tm,
2123 &iter))
2087 return; 2124 return;
2088 } 2125 }
2089 if ( (NULL == sr->download) && 2126 if ( (NULL == sr->download) &&
2090 (NULL == sr->result) && 2127 (NULL == sr->result) &&
2091 (GNUNET_YES == stop_downloads_in_subtree (tm, &iter)) ) 2128 (GNUNET_YES == stop_downloads_in_subtree (tm,
2129 &iter)) )
2092 { 2130 {
2093 /* no active download and no associated FS-API search result; 2131 /* no active download and no associated FS-API search result;
2094 so this must be some left-over entry from an opened 2132 so this must be some left-over entry from an opened
@@ -2747,23 +2785,35 @@ change_download_color (struct DownloadEntry *de,
2747{ 2785{
2748 GtkTreeIter iter; 2786 GtkTreeIter iter;
2749 GtkTreePath *path; 2787 GtkTreePath *path;
2788 struct DownloadEntry *deep;
2789 struct SearchTab *tab;
2750 2790
2751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2791 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2752 "Changing download DE=%p color to %s\n", 2792 "Changing download DE=%p color to %s\n",
2753 de, color); 2793 de,
2754 if (NULL != de->sr->tab) 2794 color);
2795 deep = de;
2796 while (NULL != deep->pde)
2797 deep = deep->pde;
2798 tab = NULL;
2799 if ( (NULL != deep->sr) &&
2800 (NULL != (tab = deep->sr->tab)) )
2755 { 2801 {
2756 path = gtk_tree_row_reference_get_path (de->sr->rr); 2802 path = gtk_tree_row_reference_get_path (de->sr->rr);
2757 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), 2803 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts),
2758 &iter, path)); 2804 &iter,
2805 path));
2759 gtk_tree_path_free (path); 2806 gtk_tree_path_free (path);
2760 gtk_tree_store_set (de->sr->tab->ts, &iter, 2807 gtk_tree_store_set (tab->ts,
2808 &iter,
2761 SEARCH_TAB_MC_STATUS_COLOUR, color, 2809 SEARCH_TAB_MC_STATUS_COLOUR, color,
2762 -1); 2810 -1);
2763 } 2811 }
2764 /* do the same update to the downloads tree store */ 2812 /* do the same update to the downloads tree store */
2765 get_download_list_entry (de, &iter); 2813 get_download_list_entry (de,
2766 gtk_tree_store_set (downloads_treestore, &iter, 2814 &iter);
2815 gtk_tree_store_set (downloads_treestore,
2816 &iter,
2767 SEARCH_TAB_MC_STATUS_COLOUR, color, 2817 SEARCH_TAB_MC_STATUS_COLOUR, color,
2768 -1); 2818 -1);
2769 2819
@@ -2782,19 +2832,30 @@ change_download_status_icon (struct DownloadEntry *de,
2782{ 2832{
2783 GtkTreeIter iter; 2833 GtkTreeIter iter;
2784 GtkTreePath *path; 2834 GtkTreePath *path;
2835 struct DownloadEntry *deep;
2836 struct SearchTab *tab;
2785 2837
2786 if (NULL != de->sr->tab) 2838 deep = de;
2839 while (NULL != deep->pde)
2840 deep = deep->pde;
2841 tab = NULL;
2842 if ( (NULL != deep->sr) &&
2843 (NULL != (tab = deep->sr->tab)) )
2787 { 2844 {
2788 path = gtk_tree_row_reference_get_path (de->sr->rr); 2845 path = gtk_tree_row_reference_get_path (de->sr->rr);
2789 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), &iter, path)); 2846 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts),
2847 &iter,
2848 path));
2790 gtk_tree_path_free (path); 2849 gtk_tree_path_free (path);
2791 gtk_tree_store_set (de->sr->tab->ts, &iter, 2850 gtk_tree_store_set (tab->ts,
2851 &iter,
2792 SEARCH_TAB_MC_STATUS_ICON, icon, 2852 SEARCH_TAB_MC_STATUS_ICON, icon,
2793 -1); 2853 -1);
2794 } 2854 }
2795 /* do the same update to the downloads tree store */ 2855 /* do the same update to the downloads tree store */
2796 get_download_list_entry (de, &iter); 2856 get_download_list_entry (de, &iter);
2797 gtk_tree_store_set (downloads_treestore, &iter, 2857 gtk_tree_store_set (downloads_treestore,
2858 &iter,
2798 SEARCH_TAB_MC_STATUS_ICON, icon, 2859 SEARCH_TAB_MC_STATUS_ICON, icon,
2799 -1); 2860 -1);
2800} 2861}
@@ -2876,7 +2937,8 @@ static void
2876add_directory_entry (void *cls, const char *filename, 2937add_directory_entry (void *cls, const char *filename,
2877 const struct GNUNET_FS_Uri *uri, 2938 const struct GNUNET_FS_Uri *uri,
2878 const struct GNUNET_CONTAINER_MetaData *meta, 2939 const struct GNUNET_CONTAINER_MetaData *meta,
2879 size_t length, const void *data) 2940 size_t length,
2941 const void *data)
2880{ 2942{
2881 struct AddDirectoryEntryContext *ade = cls; 2943 struct AddDirectoryEntryContext *ade = cls;
2882 GtkTreeIter iter; 2944 GtkTreeIter iter;
@@ -2895,7 +2957,7 @@ add_directory_entry (void *cls, const char *filename,
2895 the original search result... */ 2957 the original search result... */
2896 return; 2958 return;
2897 } 2959 }
2898 if (ade->check_duplicates == GNUNET_YES) 2960 if (GNUNET_YES == ade->check_duplicates)
2899 { 2961 {
2900 tm = gtk_tree_row_reference_get_model (ade->prr); 2962 tm = gtk_tree_row_reference_get_model (ade->prr);
2901 path = gtk_tree_row_reference_get_path (ade->prr); 2963 path = gtk_tree_row_reference_get_path (ade->prr);
@@ -2906,7 +2968,7 @@ add_directory_entry (void *cls, const char *filename,
2906 return; 2968 return;
2907 } 2969 }
2908 gtk_tree_path_free (path); 2970 gtk_tree_path_free (path);
2909 if (TRUE == gtk_tree_model_iter_children (tm, &iter, &piter)) 2971 if (gtk_tree_model_iter_children (tm, &iter, &piter))
2910 { 2972 {
2911 do 2973 do
2912 { 2974 {
@@ -2916,13 +2978,15 @@ add_directory_entry (void *cls, const char *filename,
2916 if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri)) 2978 if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri))
2917 return; /* already present */ 2979 return; /* already present */
2918 } 2980 }
2919 while (TRUE == gtk_tree_model_iter_next (tm, &iter)); 2981 while (gtk_tree_model_iter_next (tm,
2982 &iter));
2920 } 2983 }
2921 } 2984 }
2922 GNUNET_GTK_add_search_result (ade->tab, 2985 GNUNET_GTK_add_search_result (ade->tab,
2923 ade->anonymity, 2986 ade->anonymity,
2924 ade->prr, 2987 ade->prr,
2925 uri, meta, NULL, 2988 uri,
2989 meta, NULL,
2926 0); 2990 0);
2927} 2991}
2928 2992
@@ -2954,6 +3018,8 @@ mark_download_progress (struct DownloadEntry *de,
2954 GtkTreeIter iter; 3018 GtkTreeIter iter;
2955 GtkTreeIter diter; 3019 GtkTreeIter diter;
2956 GtkTreePath *path; 3020 GtkTreePath *path;
3021 struct DownloadEntry *deep;
3022 struct SearchTab *tab;
2957 3023
2958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3024 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2959 "Marking download progress for DE=%p, %llu/%llu, %llu@%llu depth=%u\n", 3025 "Marking download progress for DE=%p, %llu/%llu, %llu@%llu depth=%u\n",
@@ -2963,28 +3029,34 @@ mark_download_progress (struct DownloadEntry *de,
2963 (unsigned long long) block_size, 3029 (unsigned long long) block_size,
2964 (unsigned long long) offset, 3030 (unsigned long long) offset,
2965 depth); 3031 depth);
2966 3032 deep = de;
2967 if (NULL != de->sr->tab) 3033 while (NULL != deep->pde)
3034 deep = deep->pde;
3035 tab = NULL;
3036 if ( (NULL != deep->sr) &&
3037 (NULL != (tab = deep->sr->tab)) )
2968 { 3038 {
2969 path = gtk_tree_row_reference_get_path (de->sr->rr); 3039 path = gtk_tree_row_reference_get_path (de->sr->rr);
2970 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), 3040 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts),
2971 &iter, path)); 3041 &iter,
3042 path));
2972 gtk_tree_path_free (path); 3043 gtk_tree_path_free (path);
2973 /* FIXME-DESIGN: should we replace the 'availability' with 3044 /* FIXME-DESIGN: should we replace the 'availability' with
2974 'progress' once the download has started and re-use the 3045 'progress' once the download has started and re-use the
2975 space in the display? Probably yes, at least once we have 3046 space in the display? Probably yes, at least once we have
2976 a custom CellRenderer... */ 3047 a custom CellRenderer... */
2977 gtk_tree_store_set (de->sr->tab->ts, &iter, 3048 gtk_tree_store_set (tab->ts,
3049 &iter,
2978 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), 3050 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100),
2979 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) ((size > 0) ? (100 * completed / size) : 100),
2980 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (completed ? -1 : 0), 3051 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (completed ? -1 : 0),
2981 SEARCH_TAB_MC_COMPLETED, completed, 3052 SEARCH_TAB_MC_COMPLETED, completed,
2982 -1); 3053 -1);
2983 } 3054 }
2984 get_download_list_entry (de, &diter); 3055 get_download_list_entry (de,
2985 gtk_tree_store_set (downloads_treestore, &diter, 3056 &diter);
3057 gtk_tree_store_set (downloads_treestore,
3058 &diter,
2986 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), 3059 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100),
2987 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) ((size > 0) ? (100 * completed / size) : 100),
2988 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (completed ? -1 : 0), 3060 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (completed ? -1 : 0),
2989 SEARCH_TAB_MC_COMPLETED, completed, 3061 SEARCH_TAB_MC_COMPLETED, completed,
2990 -1); 3062 -1);
@@ -2998,21 +3070,26 @@ mark_download_progress (struct DownloadEntry *de,
2998 /* got a data block of a directory, list its contents */ 3070 /* got a data block of a directory, list its contents */
2999 struct AddDirectoryEntryContext ade; 3071 struct AddDirectoryEntryContext ade;
3000 3072
3001 ade.tab = de->sr->tab; 3073 ade.tab = tab;
3002 ade.prr = de->sr->rr; 3074 ade.prr = de->sr->rr;
3003 ade.check_duplicates = GNUNET_NO; 3075 ade.check_duplicates = GNUNET_NO;
3004 ade.anonymity = de->anonymity; 3076 ade.anonymity = de->anonymity;
3005 if (GNUNET_SYSERR == 3077 if (GNUNET_SYSERR ==
3006 GNUNET_FS_directory_list_contents ((size_t) block_size, block_data, 3078 GNUNET_FS_directory_list_contents ((size_t) block_size,
3007 offset, &add_directory_entry, &ade)) 3079 block_data,
3080 offset,
3081 &add_directory_entry,
3082 &ade))
3008 { 3083 {
3009 /* Mime type was wrong, this is not a directory, update model! */ 3084 /* Mime type was wrong, this is not a directory, update model! */
3010 de->is_directory = GNUNET_SYSERR; 3085 de->is_directory = GNUNET_SYSERR;
3011 if (NULL != de->sr->tab) 3086 if (NULL != tab)
3012 gtk_tree_store_set (de->sr->tab->ts, &iter, 3087 gtk_tree_store_set (tab->ts,
3088 &iter,
3013 SEARCH_TAB_MC_MIMETYPE, "", 3089 SEARCH_TAB_MC_MIMETYPE, "",
3014 -1); 3090 -1);
3015 gtk_tree_store_set (downloads_treestore, &diter, 3091 gtk_tree_store_set (downloads_treestore,
3092 &diter,
3016 SEARCH_TAB_MC_MIMETYPE, "", 3093 SEARCH_TAB_MC_MIMETYPE, "",
3017 -1); 3094 -1);
3018 } 3095 }
@@ -3028,11 +3105,13 @@ mark_download_progress (struct DownloadEntry *de,
3028 3105
3029 /* download was for a directory (and we have a temp file for scanning); 3106 /* download was for a directory (and we have a temp file for scanning);
3030 add contents of the directory to the view */ 3107 add contents of the directory to the view */
3031 ade.tab = de->sr->tab; 3108 ade.tab = tab;
3032 ade.prr = de->sr->rr; 3109 ade.prr = de->sr->rr;
3033 ade.check_duplicates = GNUNET_YES; 3110 ade.check_duplicates = GNUNET_YES;
3034 if (GNUNET_OK != 3111 if (GNUNET_OK !=
3035 GNUNET_FS_GTK_mmap_and_scan (filename, &add_directory_entry, &ade)) 3112 GNUNET_FS_GTK_mmap_and_scan (filename,
3113 &add_directory_entry,
3114 &ade))
3036 de->is_directory = GNUNET_NO; 3115 de->is_directory = GNUNET_NO;
3037 } 3116 }
3038 } 3117 }
@@ -3052,17 +3131,27 @@ mark_download_error (struct DownloadEntry *de,
3052{ 3131{
3053 GtkTreeIter iter; 3132 GtkTreeIter iter;
3054 GtkTreePath *path; 3133 GtkTreePath *path;
3134 struct DownloadEntry *deep;
3135 struct SearchTab *tab;
3055 3136
3056 change_download_color (de, "red"); 3137 change_download_color (de, "red");
3057 de->is_done = GNUNET_YES; 3138 de->is_done = GNUNET_YES;
3058 if (NULL == animation_error) 3139 if (NULL == animation_error)
3059 animation_error = load_animation ("error"); 3140 animation_error = load_animation ("error");
3060 if (NULL != de->sr->tab) 3141 deep = de;
3142 while (NULL != deep->pde)
3143 deep = deep->pde;
3144 tab = NULL;
3145 if ( (NULL != deep->sr) &&
3146 (NULL != (tab = deep->sr->tab)) )
3061 { 3147 {
3062 path = gtk_tree_row_reference_get_path (de->sr->rr); 3148 path = gtk_tree_row_reference_get_path (de->sr->rr);
3063 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), &iter, path)); 3149 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts),
3150 &iter,
3151 path));
3064 gtk_tree_path_free (path); 3152 gtk_tree_path_free (path);
3065 gtk_tree_store_set (de->sr->tab->ts, &iter, 3153 gtk_tree_store_set (tab->ts,
3154 &iter,
3066 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 0, 3155 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 0,
3067 SEARCH_TAB_MC_URI_AS_STRING, emsg, 3156 SEARCH_TAB_MC_URI_AS_STRING, emsg,
3068 SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_error), 3157 SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_error),
@@ -3085,28 +3174,41 @@ mark_download_error (struct DownloadEntry *de,
3085 * @param size overall size of the file 3174 * @param size overall size of the file
3086 */ 3175 */
3087static void 3176static void
3088mark_download_completed (struct DownloadEntry *de, uint64_t size) 3177mark_download_completed (struct DownloadEntry *de,
3178 uint64_t size)
3089{ 3179{
3090 GtkTreeIter iter; 3180 GtkTreeIter iter;
3091 GtkTreePath *path; 3181 GtkTreePath *path;
3182 struct DownloadEntry *deep;
3183 struct SearchTab *tab;
3092 3184
3093 de->is_done = GNUNET_YES; 3185 de->is_done = GNUNET_YES;
3094 change_download_color (de, "green"); 3186 change_download_color (de, "green");
3095 if (NULL != de->sr->tab) 3187
3188 deep = de;
3189 while (NULL != deep->pde)
3190 deep = deep->pde;
3191 tab = NULL;
3192 if ( (NULL != deep->sr) &&
3193 (NULL != (tab = deep->sr->tab)) )
3096 { 3194 {
3097 path = gtk_tree_row_reference_get_path (de->sr->rr); 3195 path = gtk_tree_row_reference_get_path (de->sr->rr);
3098 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), 3196 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts),
3099 &iter, path)); 3197 &iter,
3198 path));
3100 gtk_tree_path_free (path); 3199 gtk_tree_path_free (path);
3101 gtk_tree_store_set (de->sr->tab->ts, &iter, 3200 gtk_tree_store_set (tab->ts,
3201 &iter,
3102 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100, 3202 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100,
3103 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100, 3203 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100,
3104 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, 3204 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1,
3105 SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_downloaded), 3205 SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_downloaded),
3106 -1); 3206 -1);
3107 } 3207 }
3108 get_download_list_entry (de, &iter); 3208 get_download_list_entry (de,
3109 gtk_tree_store_set (downloads_treestore, &iter, 3209 &iter);
3210 gtk_tree_store_set (downloads_treestore,
3211 &iter,
3110 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100, 3212 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100,
3111 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100, 3213 SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100,
3112 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, 3214 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1,
@@ -3145,6 +3247,7 @@ setup_download (struct DownloadEntry *de,
3145 GtkTreeIter iter; 3247 GtkTreeIter iter;
3146 GtkTreePath *path; 3248 GtkTreePath *path;
3147 GtkTreeModel *tm; 3249 GtkTreeModel *tm;
3250 struct DownloadEntry *deep;
3148 3251
3149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3150 "Setting up download, initially DE=%p, PDE=%p for %p & %p into %llu/%llu `%s'\n", 3253 "Setting up download, initially DE=%p, PDE=%p for %p & %p into %llu/%llu `%s'\n",
@@ -3182,9 +3285,12 @@ setup_download (struct DownloadEntry *de,
3182 GNUNET_assert (sr == de->sr); 3285 GNUNET_assert (sr == de->sr);
3183 } 3286 }
3184 } 3287 }
3288 deep = de;
3289 while (NULL != deep->pde)
3290 deep = deep->pde;
3185 if ( (NULL == de->sr) && 3291 if ( (NULL == de->sr) &&
3186 (NULL != pde) && 3292 (NULL != pde) &&
3187 (NULL != pde->sr->tab) ) 3293 (NULL != deep->sr->tab) )
3188 { 3294 {
3189 /* child download, find appropriate search result from parent! */ 3295 /* child download, find appropriate search result from parent! */
3190 GtkTreePath *path; 3296 GtkTreePath *path;
@@ -3193,7 +3299,7 @@ setup_download (struct DownloadEntry *de,
3193 GtkTreeIter child; 3299 GtkTreeIter child;
3194 struct GNUNET_FS_Uri *uri; 3300 struct GNUNET_FS_Uri *uri;
3195 3301
3196 tm = GTK_TREE_MODEL (pde->sr->tab->ts); 3302 tm = GTK_TREE_MODEL (deep->sr->tab->ts);
3197 path = gtk_tree_row_reference_get_path (pde->sr->rr); 3303 path = gtk_tree_row_reference_get_path (pde->sr->rr);
3198 if ( (! gtk_tree_model_get_iter (tm, &iter, path)) || 3304 if ( (! gtk_tree_model_get_iter (tm, &iter, path)) ||
3199 (! gtk_tree_model_iter_children (tm, &child, &iter)) ) 3305 (! gtk_tree_model_iter_children (tm, &child, &iter)) )
@@ -3278,7 +3384,6 @@ setup_download (struct DownloadEntry *de,
3278 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), 3384 SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100),
3279 SEARCH_TAB_MC_FILENAME, filename, 3385 SEARCH_TAB_MC_FILENAME, filename,
3280 SEARCH_TAB_MC_STATUS_COLOUR, "blue", 3386 SEARCH_TAB_MC_STATUS_COLOUR, "blue",
3281 SEARCH_TAB_MC_PERCENT_AVAILABILITY, 0,
3282 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, 3387 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1,
3283 SEARCH_TAB_MC_SEARCH_RESULT, de->sr, 3388 SEARCH_TAB_MC_SEARCH_RESULT, de->sr,
3284 SEARCH_TAB_MC_COMPLETED, (guint64) completed, 3389 SEARCH_TAB_MC_COMPLETED, (guint64) completed,
@@ -3293,7 +3398,6 @@ setup_download (struct DownloadEntry *de,
3293 SEARCH_TAB_MC_FILENAME, filename, 3398 SEARCH_TAB_MC_FILENAME, filename,
3294 SEARCH_TAB_MC_STATUS_COLOUR, "blue", 3399 SEARCH_TAB_MC_STATUS_COLOUR, "blue",
3295 SEARCH_TAB_MC_SEARCH_RESULT, de->sr, 3400 SEARCH_TAB_MC_SEARCH_RESULT, de->sr,
3296 SEARCH_TAB_MC_PERCENT_AVAILABILITY, 0,
3297 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, 3401 SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1,
3298 SEARCH_TAB_MC_COMPLETED, (guint64) completed, 3402 SEARCH_TAB_MC_COMPLETED, (guint64) completed,
3299 SEARCH_TAB_MC_DOWNLOADED_FILENAME, de->filename, 3403 SEARCH_TAB_MC_DOWNLOADED_FILENAME, de->filename,
@@ -3490,7 +3594,8 @@ handle_publish_stop (struct PublishEntry *pe)
3490 GNUNET_break (0); 3594 GNUNET_break (0);
3491 return; 3595 return;
3492 } 3596 }
3493 (void) gtk_tree_store_remove (pe->tab->ts, &iter); 3597 (void) gtk_tree_store_remove (pe->tab->ts,
3598 &iter);
3494 gtk_tree_path_free (path); 3599 gtk_tree_path_free (path);
3495 gtk_tree_row_reference_free (pe->rr); 3600 gtk_tree_row_reference_free (pe->rr);
3496 if (NULL != pe->uri) 3601 if (NULL != pe->uri)
@@ -3904,6 +4009,9 @@ GNUNET_GTK_fs_event_handler (void *cls,
3904{ 4009{
3905 void *ret; 4010 void *ret;
3906 4011
4012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4013 "Got FS event %d\n",
4014 info->status);
3907 GNUNET_FS_GTK_set_fs_handle (info->fsh); 4015 GNUNET_FS_GTK_set_fs_handle (info->fsh);
3908 switch (info->status) 4016 switch (info->status)
3909 { 4017 {