diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-01 22:37:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-01 22:37:47 +0000 |
commit | 9ae95b89b208c1663345b6cf63013c1500afed19 (patch) | |
tree | 9fe649abf55e1543906af777b57c523130e2fb86 | |
parent | f48cc02d8b7f49729bab01e63b3549aa41012936 (diff) | |
download | gnunet-gtk-9ae95b89b208c1663345b6cf63013c1500afed19.tar.gz gnunet-gtk-9ae95b89b208c1663345b6cf63013c1500afed19.zip |
fixing #2053 and undoing parts of 18880 (diagnostic assertions no longer needed / potentially harmful) -- if URI is NULL, do not display download context menu and ignore double-clicks
-rw-r--r-- | src/fs/gnunet-fs-gtk-event_handler.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index 301e01e7..f083f69b 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -618,7 +618,6 @@ download_lost_parent (struct DownloadEntry *de, uint64_t size, | |||
618 | GtkTreeIter child; | 618 | GtkTreeIter child; |
619 | GtkTreeModel *model; | 619 | GtkTreeModel *model; |
620 | 620 | ||
621 | GNUNET_assert (NULL != de->uri); | ||
622 | rr_old = de->rr; | 621 | rr_old = de->rr; |
623 | tab = GNUNET_GTK_add_to_uri_tab (&iter, &de->sr, de->meta, de->uri); | 622 | tab = GNUNET_GTK_add_to_uri_tab (&iter, &de->sr, de->meta, de->uri); |
624 | de->sr->download = de; | 623 | de->sr->download = de; |
@@ -786,11 +785,18 @@ start_download (GtkTreeView * tree_view, GtkTreePath * path, | |||
786 | return; | 785 | return; |
787 | } | 786 | } |
788 | gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, 9, &sr, 10, &mime, -1); | 787 | gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, 9, &sr, 10, &mime, -1); |
788 | if (NULL == uri) | ||
789 | { | ||
790 | /* user clicked on directory that was opened (not downloaded!), so we | ||
791 | have no URI and downloading makes no sense. Ignore! */ | ||
792 | if (NULL != mime) | ||
793 | g_free (mime); | ||
794 | return; | ||
795 | } | ||
789 | if (!(GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))) | 796 | if (!(GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))) |
790 | { | 797 | { |
791 | /* can only download chk/loc URIs, ignore */ | 798 | /* can only download chk/loc URIs, ignore */ |
792 | g_free (mime); | 799 | g_free (mime); |
793 | GNUNET_free (sdc); | ||
794 | return; | 800 | return; |
795 | } | 801 | } |
796 | 802 | ||
@@ -998,6 +1004,7 @@ search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
998 | GtkTreeModel *tm; | 1004 | GtkTreeModel *tm; |
999 | GtkTreeIter iter; | 1005 | GtkTreeIter iter; |
1000 | struct SearchResult *sr; | 1006 | struct SearchResult *sr; |
1007 | struct GNUNET_FS_Uri *uri; | ||
1001 | 1008 | ||
1002 | tv = GTK_TREE_VIEW (widget); | 1009 | tv = GTK_TREE_VIEW (widget); |
1003 | if (event->type == GDK_BUTTON_PRESS) | 1010 | if (event->type == GDK_BUTTON_PRESS) |
@@ -1027,7 +1034,7 @@ search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
1027 | current_context_search_tab = NULL; | 1034 | current_context_search_tab = NULL; |
1028 | return FALSE; | 1035 | return FALSE; |
1029 | } | 1036 | } |
1030 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); | 1037 | gtk_tree_model_get (tm, &iter, 1, &uri, 9, &sr, -1); |
1031 | current_context_row_reference = gtk_tree_row_reference_new (tm, path); | 1038 | current_context_row_reference = gtk_tree_row_reference_new (tm, path); |
1032 | gtk_tree_path_free (path); | 1039 | gtk_tree_path_free (path); |
1033 | 1040 | ||
@@ -1044,23 +1051,27 @@ search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
1044 | "Creating a menu for SR=%p, DE=%p\n", sr, sr->download); | 1051 | "Creating a menu for SR=%p, DE=%p\n", sr, sr->download); |
1045 | if (sr->download == NULL) | 1052 | if (sr->download == NULL) |
1046 | { | 1053 | { |
1047 | child = gtk_menu_item_new_with_label (_("_Download")); | 1054 | if (NULL != uri) |
1048 | g_signal_connect (child, "activate", | 1055 | { |
1049 | G_CALLBACK (start_download_ctx_menu), NULL); | 1056 | /* only display download menus if there is a URI */ |
1050 | gtk_label_set_use_underline (GTK_LABEL | 1057 | child = gtk_menu_item_new_with_label (_("_Download")); |
1051 | (gtk_bin_get_child (GTK_BIN (child))), | 1058 | g_signal_connect (child, "activate", |
1052 | TRUE); | 1059 | G_CALLBACK (start_download_ctx_menu), NULL); |
1053 | gtk_widget_show (child); | 1060 | gtk_label_set_use_underline (GTK_LABEL |
1054 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1061 | (gtk_bin_get_child (GTK_BIN (child))), |
1055 | 1062 | TRUE); | |
1056 | child = gtk_menu_item_new_with_label (_("Download _recursively")); | 1063 | gtk_widget_show (child); |
1057 | g_signal_connect (child, "activate", | 1064 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1058 | G_CALLBACK (start_download_recursively_ctx_menu), NULL); | 1065 | |
1059 | gtk_label_set_use_underline (GTK_LABEL | 1066 | child = gtk_menu_item_new_with_label (_("Download _recursively")); |
1060 | (gtk_bin_get_child (GTK_BIN (child))), | 1067 | g_signal_connect (child, "activate", |
1061 | TRUE); | 1068 | G_CALLBACK (start_download_recursively_ctx_menu), NULL); |
1062 | gtk_widget_show (child); | 1069 | gtk_label_set_use_underline (GTK_LABEL |
1063 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1070 | (gtk_bin_get_child (GTK_BIN (child))), |
1071 | TRUE); | ||
1072 | gtk_widget_show (child); | ||
1073 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | ||
1074 | } | ||
1064 | } | 1075 | } |
1065 | else | 1076 | else |
1066 | { | 1077 | { |
@@ -1515,8 +1526,7 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, GtkTreeIter * iter, | |||
1515 | GtkTreeStore *ts; | 1526 | GtkTreeStore *ts; |
1516 | uint64_t fsize; | 1527 | uint64_t fsize; |
1517 | 1528 | ||
1518 | GNUNET_assert (NULL != uri); | 1529 | if ((uri != NULL) && (!GNUNET_FS_uri_test_loc (uri)) && |
1519 | if ((!GNUNET_FS_uri_test_loc (uri)) && | ||
1520 | (!GNUNET_FS_uri_test_chk (uri))) | 1530 | (!GNUNET_FS_uri_test_chk (uri))) |
1521 | { | 1531 | { |
1522 | fsize = 0; | 1532 | fsize = 0; |
@@ -1648,7 +1658,6 @@ process_search_result (void *cls, struct SearchResult *parent, | |||
1648 | struct SearchResult *sr; | 1658 | struct SearchResult *sr; |
1649 | GtkTreeIter iter; | 1659 | GtkTreeIter iter; |
1650 | 1660 | ||
1651 | GNUNET_assert (NULL != uri); | ||
1652 | sr = GNUNET_GTK_add_search_result (tab, &iter, | 1661 | sr = GNUNET_GTK_add_search_result (tab, &iter, |
1653 | (parent != NULL) ? parent->rr : NULL, uri, | 1662 | (parent != NULL) ? parent->rr : NULL, uri, |
1654 | meta, result, applicability_rank); | 1663 | meta, result, applicability_rank); |
@@ -1676,7 +1685,6 @@ GNUNET_GTK_add_to_uri_tab (GtkTreeIter * iter, struct SearchResult **srp, | |||
1676 | GtkNotebook *notebook; | 1685 | GtkNotebook *notebook; |
1677 | gint page; | 1686 | gint page; |
1678 | 1687 | ||
1679 | GNUNET_assert (NULL != uri); | ||
1680 | if (uri_tab == NULL) | 1688 | if (uri_tab == NULL) |
1681 | { | 1689 | { |
1682 | uri_tab = setup_search (NULL, NULL); | 1690 | uri_tab = setup_search (NULL, NULL); |
@@ -2129,7 +2137,6 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
2129 | info->value.search.specifics.resume.message); | 2137 | info->value.search.specifics.resume.message); |
2130 | return ret; | 2138 | return ret; |
2131 | case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT: | 2139 | case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT: |
2132 | GNUNET_assert (NULL != info->value.search.specifics.resume_result.uri); | ||
2133 | ret = | 2140 | ret = |
2134 | process_search_result (info->value.search.cctx, info->value.search.pctx, | 2141 | process_search_result (info->value.search.cctx, info->value.search.pctx, |
2135 | info->value.search.specifics.resume_result.uri, | 2142 | info->value.search.specifics.resume_result.uri, |
@@ -2151,7 +2158,6 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
2151 | close_search_tab (info->value.search.cctx); | 2158 | close_search_tab (info->value.search.cctx); |
2152 | return NULL; | 2159 | return NULL; |
2153 | case GNUNET_FS_STATUS_SEARCH_RESULT: | 2160 | case GNUNET_FS_STATUS_SEARCH_RESULT: |
2154 | GNUNET_assert (NULL != info->value.search.specifics.result.uri); | ||
2155 | return process_search_result (info->value.search.cctx, | 2161 | return process_search_result (info->value.search.cctx, |
2156 | info->value.search.pctx, | 2162 | info->value.search.pctx, |
2157 | info->value.search.specifics.result.uri, | 2163 | info->value.search.specifics.result.uri, |