diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-event_handler.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-event_handler.c | 196 |
1 files changed, 102 insertions, 94 deletions
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index 631c3426..ac734af5 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -161,24 +161,23 @@ stop_download (struct DownloadEntry *de, int is_suspend) | |||
161 | GtkTreePath *path; | 161 | GtkTreePath *path; |
162 | GtkTreeModel *tm; | 162 | GtkTreeModel *tm; |
163 | struct SearchResult *search_result; | 163 | struct SearchResult *search_result; |
164 | 164 | ||
165 | path = gtk_tree_row_reference_get_path (de->rr); | 165 | path = gtk_tree_row_reference_get_path (de->rr); |
166 | tm = gtk_tree_row_reference_get_model (de->rr); | 166 | tm = gtk_tree_row_reference_get_model (de->rr); |
167 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) | 167 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) |
168 | GNUNET_break (0); | 168 | GNUNET_break (0); |
169 | else | 169 | else |
170 | { | 170 | { |
171 | gtk_tree_model_get (tm, &iter, | 171 | gtk_tree_model_get (tm, &iter, 9, &search_result, -1); |
172 | 9, &search_result, -1); | 172 | /*Always fails on downloads started by Download URI */ |
173 | /*Always fails on downloads started by Download URI*/ | 173 | /*GNUNET_assert (search_result->download == de); */ |
174 | /*GNUNET_assert (search_result->download == de);*/ | 174 | search_result->download = NULL; |
175 | search_result->download = NULL; | 175 | if (NULL == search_result->result) |
176 | if (NULL == search_result->result) | 176 | (void) gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); |
177 | (void) gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); | 177 | else |
178 | else | 178 | change_download_colour (de, "white"); |
179 | change_download_colour (de, "white"); | 179 | } |
180 | } | 180 | gtk_tree_path_free (path); |
181 | gtk_tree_path_free (path); | ||
182 | gtk_tree_row_reference_free (de->rr); | 181 | gtk_tree_row_reference_free (de->rr); |
183 | GNUNET_FS_uri_destroy (de->uri); | 182 | GNUNET_FS_uri_destroy (de->uri); |
184 | GNUNET_CONTAINER_meta_data_destroy (de->meta); | 183 | GNUNET_CONTAINER_meta_data_destroy (de->meta); |
@@ -332,7 +331,7 @@ mark_download_completed (struct DownloadEntry *de, uint64_t size, | |||
332 | const char *filename) | 331 | const char *filename) |
333 | { | 332 | { |
334 | struct AddDirectoryEntryContext ade; | 333 | struct AddDirectoryEntryContext ade; |
335 | 334 | ||
336 | de->is_done = GNUNET_YES; | 335 | de->is_done = GNUNET_YES; |
337 | (void) mark_download_progress (de, size, size, NULL, 0, 0, 0); | 336 | (void) mark_download_progress (de, size, size, NULL, 0, 0, 0); |
338 | if ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta)) && | 337 | if ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta)) && |
@@ -481,7 +480,7 @@ download_lost_parent (struct DownloadEntry *de, uint64_t size, | |||
481 | GtkTreeModel *tm_old; | 480 | GtkTreeModel *tm_old; |
482 | GtkTreeIter iter_old; | 481 | GtkTreeIter iter_old; |
483 | GtkTreeIter child; | 482 | GtkTreeIter child; |
484 | GtkTreeModel * model; | 483 | GtkTreeModel *model; |
485 | 484 | ||
486 | rr_old = de->rr; | 485 | rr_old = de->rr; |
487 | tab = GNUNET_GTK_add_to_uri_tab (&iter, &de->sr, de->meta, de->uri); | 486 | tab = GNUNET_GTK_add_to_uri_tab (&iter, &de->sr, de->meta, de->uri); |
@@ -498,19 +497,19 @@ download_lost_parent (struct DownloadEntry *de, uint64_t size, | |||
498 | if (NULL == path) | 497 | if (NULL == path) |
499 | { | 498 | { |
500 | GNUNET_break (0); | 499 | GNUNET_break (0); |
501 | return NULL; | 500 | return NULL; |
502 | } | 501 | } |
503 | if (TRUE != gtk_tree_model_get_iter (tm_old, &iter_old, path)) | 502 | if (TRUE != gtk_tree_model_get_iter (tm_old, &iter_old, path)) |
504 | { | 503 | { |
505 | GNUNET_break (0); | 504 | GNUNET_break (0); |
506 | gtk_tree_path_free (path); | 505 | gtk_tree_path_free (path); |
507 | return NULL; | 506 | return NULL; |
508 | } | 507 | } |
509 | gtk_tree_path_free (path); | 508 | gtk_tree_path_free (path); |
510 | move_children (tm_old, &iter_old, model, &iter); | 509 | move_children (tm_old, &iter_old, model, &iter); |
511 | while (TRUE == gtk_tree_model_iter_children (model, &child, &iter)) | 510 | while (TRUE == gtk_tree_model_iter_children (model, &child, &iter)) |
512 | delete_stale_subtree (model, &child); | 511 | delete_stale_subtree (model, &child); |
513 | if (size > completed) | 512 | if (size > completed) |
514 | { | 513 | { |
515 | if (is_active) | 514 | if (is_active) |
516 | change_download_colour (de, "yellow"); | 515 | change_download_colour (de, "yellow"); |
@@ -540,8 +539,7 @@ download_lost_parent (struct DownloadEntry *de, uint64_t size, | |||
540 | static struct DownloadEntry * | 539 | static struct DownloadEntry * |
541 | setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | 540 | setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, |
542 | struct SearchResult *sr, struct GNUNET_FS_DownloadContext *dc, | 541 | struct SearchResult *sr, struct GNUNET_FS_DownloadContext *dc, |
543 | const struct GNUNET_FS_Uri *uri, | 542 | const struct GNUNET_FS_Uri *uri, const char *filename, |
544 | const char *filename, | ||
545 | const struct GNUNET_CONTAINER_MetaData *meta, uint64_t size, | 543 | const struct GNUNET_CONTAINER_MetaData *meta, uint64_t size, |
546 | uint64_t completed) | 544 | uint64_t completed) |
547 | { | 545 | { |
@@ -556,12 +554,12 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | |||
556 | de->uri = GNUNET_FS_uri_dup (uri); | 554 | de->uri = GNUNET_FS_uri_dup (uri); |
557 | } | 555 | } |
558 | de->dc = dc; | 556 | de->dc = dc; |
559 | de->sr = sr; | 557 | de->sr = sr; |
560 | if (NULL != sr) | 558 | if (NULL != sr) |
561 | { | 559 | { |
562 | GNUNET_assert (sr->download == NULL); | 560 | GNUNET_assert (sr->download == NULL); |
563 | sr->download = de; | 561 | sr->download = de; |
564 | } | 562 | } |
565 | de->pde = pde; | 563 | de->pde = pde; |
566 | if ((meta != NULL) && (de->meta == NULL)) | 564 | if ((meta != NULL) && (de->meta == NULL)) |
567 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 565 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
@@ -593,7 +591,7 @@ setup_download (struct DownloadEntry *de, struct DownloadEntry *pde, | |||
593 | (guint) ((size > | 591 | (guint) ((size > |
594 | 0) ? (100 * completed / | 592 | 0) ? (100 * completed / |
595 | size) : 100) /* progress */ , | 593 | size) : 100) /* progress */ , |
596 | 6, filename_utf8 /* filename/description */ , | 594 | 6, filename_utf8 /* filename/description */ , |
597 | 8, "blue" /* status colour: pending */ , | 595 | 8, "blue" /* status colour: pending */ , |
598 | -1); | 596 | -1); |
599 | GNUNET_free_non_null (filename_utf8); | 597 | GNUNET_free_non_null (filename_utf8); |
@@ -626,8 +624,7 @@ start_download (GtkTreeView * tree_view, GtkTreePath * path, | |||
626 | return; | 624 | return; |
627 | } | 625 | } |
628 | gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, 9, &sr, 10, &mime, -1); | 626 | gtk_tree_model_get (tm, &iter, 0, &meta, 1, &uri, 9, &sr, 10, &mime, -1); |
629 | if (! (GNUNET_FS_uri_test_chk (uri) || | 627 | if (!(GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))) |
630 | GNUNET_FS_uri_test_loc (uri)) ) | ||
631 | { | 628 | { |
632 | /* can only download chk/loc URIs, ignore */ | 629 | /* can only download chk/loc URIs, ignore */ |
633 | g_free (mime); | 630 | g_free (mime); |
@@ -787,9 +784,9 @@ search_list_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
787 | tm = gtk_tree_view_get_model (tv); | 784 | tm = gtk_tree_view_get_model (tv); |
788 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) | 785 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) |
789 | { | 786 | { |
790 | /* model empty? */ | 787 | /* model empty? */ |
791 | current_context_search_tab = NULL; | 788 | current_context_search_tab = NULL; |
792 | return FALSE; | 789 | return FALSE; |
793 | } | 790 | } |
794 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); | 791 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); |
795 | current_context_row_reference = gtk_tree_row_reference_new (tm, path); | 792 | current_context_row_reference = gtk_tree_row_reference_new (tm, path); |
@@ -989,7 +986,7 @@ handle_publish_stop (struct PublishEntry *ent) | |||
989 | } | 986 | } |
990 | if (NULL != ent->pc) | 987 | if (NULL != ent->pc) |
991 | { | 988 | { |
992 | /* get piter from parent */ | 989 | /* get piter from parent */ |
993 | path = gtk_tree_row_reference_get_path (ent->rr); | 990 | path = gtk_tree_row_reference_get_path (ent->rr); |
994 | tm = gtk_tree_row_reference_get_model (ent->rr); | 991 | tm = gtk_tree_row_reference_get_model (ent->rr); |
995 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) | 992 | if (TRUE != gtk_tree_model_get_iter (tm, &iter, path)) |
@@ -1046,8 +1043,8 @@ clear_downloads (GtkButton * button, gpointer user_data) | |||
1046 | do | 1043 | do |
1047 | { | 1044 | { |
1048 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); | 1045 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); |
1049 | if ((sr->download != NULL) && (sr->download->is_done == GNUNET_YES)) | 1046 | if ((sr->download != NULL) && (sr->download->is_done == GNUNET_YES)) |
1050 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); | 1047 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); |
1051 | } | 1048 | } |
1052 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1049 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1053 | } | 1050 | } |
@@ -1281,8 +1278,8 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, GtkTreeIter * iter, | |||
1281 | } | 1278 | } |
1282 | desc = | 1279 | desc = |
1283 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1280 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
1284 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 1281 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
1285 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 1282 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
1286 | EXTRACTOR_METATYPE_TITLE, | 1283 | EXTRACTOR_METATYPE_TITLE, |
1287 | EXTRACTOR_METATYPE_BOOK_TITLE, | 1284 | EXTRACTOR_METATYPE_BOOK_TITLE, |
1288 | EXTRACTOR_METATYPE_FILENAME, | 1285 | EXTRACTOR_METATYPE_FILENAME, |
@@ -1298,7 +1295,10 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, GtkTreeIter * iter, | |||
1298 | else | 1295 | else |
1299 | { | 1296 | { |
1300 | char *utf8_desc = NULL; | 1297 | char *utf8_desc = NULL; |
1301 | utf8_desc = GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, strlen (desc) + 1); | 1298 | |
1299 | utf8_desc = | ||
1300 | GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, | ||
1301 | strlen (desc) + 1); | ||
1302 | GNUNET_free (desc); | 1302 | GNUNET_free (desc); |
1303 | if (utf8_desc != NULL) | 1303 | if (utf8_desc != NULL) |
1304 | desc = utf8_desc; | 1304 | desc = utf8_desc; |
@@ -1485,7 +1485,10 @@ update_search_result (struct SearchResult *sr, | |||
1485 | else | 1485 | else |
1486 | { | 1486 | { |
1487 | char *utf8_desc = NULL; | 1487 | char *utf8_desc = NULL; |
1488 | utf8_desc = GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, strlen (desc) + 1); | 1488 | |
1489 | utf8_desc = | ||
1490 | GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, | ||
1491 | strlen (desc) + 1); | ||
1489 | GNUNET_free (desc); | 1492 | GNUNET_free (desc); |
1490 | if (utf8_desc != NULL) | 1493 | if (utf8_desc != NULL) |
1491 | desc = utf8_desc; | 1494 | desc = utf8_desc; |
@@ -1590,7 +1593,7 @@ stop_publishing (GtkButton * button, gpointer user_data) | |||
1590 | GtkNotebook *notebook; | 1593 | GtkNotebook *notebook; |
1591 | int index; | 1594 | int index; |
1592 | int i; | 1595 | int i; |
1593 | 1596 | ||
1594 | GNUNET_assert (tab == publish_tab); | 1597 | GNUNET_assert (tab == publish_tab); |
1595 | tm = GTK_TREE_MODEL (publish_tab->ts); | 1598 | tm = GTK_TREE_MODEL (publish_tab->ts); |
1596 | if (TRUE == gtk_tree_model_iter_children (tm, &iter, NULL)) | 1599 | if (TRUE == gtk_tree_model_iter_children (tm, &iter, NULL)) |
@@ -1599,16 +1602,16 @@ stop_publishing (GtkButton * button, gpointer user_data) | |||
1599 | { | 1602 | { |
1600 | gtk_tree_model_get (tm, &iter, 4, &ent, -1); | 1603 | gtk_tree_model_get (tm, &iter, 4, &ent, -1); |
1601 | if (NULL != (pc = ent->pc)) | 1604 | if (NULL != (pc = ent->pc)) |
1602 | { | 1605 | { |
1603 | ent->pc = NULL; | 1606 | ent->pc = NULL; |
1604 | GNUNET_FS_publish_stop (pc); | 1607 | GNUNET_FS_publish_stop (pc); |
1605 | } | 1608 | } |
1606 | } | 1609 | } |
1607 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1610 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1608 | } | 1611 | } |
1609 | notebook = | 1612 | notebook = |
1610 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | 1613 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object |
1611 | ("GNUNET_GTK_main_window_notebook")); | 1614 | ("GNUNET_GTK_main_window_notebook")); |
1612 | index = -1; | 1615 | index = -1; |
1613 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) | 1616 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) |
1614 | if (publish_tab->frame == gtk_notebook_get_nth_page (notebook, i)) | 1617 | if (publish_tab->frame == gtk_notebook_get_nth_page (notebook, i)) |
@@ -1643,40 +1646,40 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
1643 | /* create new tab */ | 1646 | /* create new tab */ |
1644 | publish_tab = GNUNET_malloc (sizeof (struct PublishTab)); | 1647 | publish_tab = GNUNET_malloc (sizeof (struct PublishTab)); |
1645 | publish_tab->builder = | 1648 | publish_tab->builder = |
1646 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade"); | 1649 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade"); |
1647 | df = GTK_WINDOW (gtk_builder_get_object | 1650 | df = GTK_WINDOW (gtk_builder_get_object |
1648 | (publish_tab->builder, "_publish_frame_window")); | 1651 | (publish_tab->builder, "_publish_frame_window")); |
1649 | publish_tab->frame = gtk_bin_get_child (GTK_BIN (df)); | 1652 | publish_tab->frame = gtk_bin_get_child (GTK_BIN (df)); |
1650 | g_object_ref (publish_tab->frame); | 1653 | g_object_ref (publish_tab->frame); |
1651 | gtk_container_remove (GTK_CONTAINER (df), publish_tab->frame); | 1654 | gtk_container_remove (GTK_CONTAINER (df), publish_tab->frame); |
1652 | gtk_widget_destroy (GTK_WIDGET (df)); | 1655 | gtk_widget_destroy (GTK_WIDGET (df)); |
1653 | 1656 | ||
1654 | /* load tab_label */ | 1657 | /* load tab_label */ |
1655 | df = GTK_WINDOW (gtk_builder_get_object | 1658 | df = GTK_WINDOW (gtk_builder_get_object |
1656 | (publish_tab->builder, "_publish_label_window")); | 1659 | (publish_tab->builder, "_publish_label_window")); |
1657 | tab_label = gtk_bin_get_child (GTK_BIN (df)); | 1660 | tab_label = gtk_bin_get_child (GTK_BIN (df)); |
1658 | g_object_ref (tab_label); | 1661 | g_object_ref (tab_label); |
1659 | gtk_container_remove (GTK_CONTAINER (df), tab_label); | 1662 | gtk_container_remove (GTK_CONTAINER (df), tab_label); |
1660 | gtk_widget_destroy (GTK_WIDGET (df)); | 1663 | gtk_widget_destroy (GTK_WIDGET (df)); |
1661 | 1664 | ||
1662 | /* get refs to widgets */ | 1665 | /* get refs to widgets */ |
1663 | close_button = | 1666 | close_button = |
1664 | GTK_WIDGET (gtk_builder_get_object | 1667 | GTK_WIDGET (gtk_builder_get_object |
1665 | (publish_tab->builder, "_publish_label_close_button")); | 1668 | (publish_tab->builder, "_publish_label_close_button")); |
1666 | g_signal_connect (G_OBJECT (close_button), "clicked", | 1669 | g_signal_connect (G_OBJECT (close_button), "clicked", |
1667 | G_CALLBACK (stop_publishing), publish_tab); | 1670 | G_CALLBACK (stop_publishing), publish_tab); |
1668 | /* FIXME: we don't actually need the closure anymore, | 1671 | /* FIXME: we don't actually need the closure anymore, |
1669 | so we could have glade connect the above signal... */ | 1672 | * so we could have glade connect the above signal... */ |
1670 | /* make visible */ | 1673 | /* make visible */ |
1671 | notebook = | 1674 | notebook = |
1672 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | 1675 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object |
1673 | ("GNUNET_GTK_main_window_notebook")); | 1676 | ("GNUNET_GTK_main_window_notebook")); |
1674 | gtk_notebook_insert_page (notebook, publish_tab->frame, tab_label, 0); | 1677 | gtk_notebook_insert_page (notebook, publish_tab->frame, tab_label, 0); |
1675 | gtk_widget_show (GTK_WIDGET (notebook)); | 1678 | gtk_widget_show (GTK_WIDGET (notebook)); |
1676 | gtk_notebook_set_current_page (notebook, 0); | 1679 | gtk_notebook_set_current_page (notebook, 0); |
1677 | publish_tab->ts = | 1680 | publish_tab->ts = |
1678 | GTK_TREE_STORE (gtk_builder_get_object | 1681 | GTK_TREE_STORE (gtk_builder_get_object |
1679 | (publish_tab->builder, "_publish_frame_tree_store")); | 1682 | (publish_tab->builder, "_publish_frame_tree_store")); |
1680 | pitrptr = NULL; | 1683 | pitrptr = NULL; |
1681 | } | 1684 | } |
1682 | else | 1685 | else |
@@ -1690,7 +1693,8 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
1690 | /* create new iter from parent */ | 1693 | /* create new iter from parent */ |
1691 | path = gtk_tree_row_reference_get_path (parent->rr); | 1694 | path = gtk_tree_row_reference_get_path (parent->rr); |
1692 | if (TRUE != | 1695 | if (TRUE != |
1693 | gtk_tree_model_get_iter (GTK_TREE_MODEL (publish_tab->ts), &piter, path)) | 1696 | gtk_tree_model_get_iter (GTK_TREE_MODEL (publish_tab->ts), &piter, |
1697 | path)) | ||
1694 | { | 1698 | { |
1695 | GNUNET_break (0); | 1699 | GNUNET_break (0); |
1696 | return NULL; | 1700 | return NULL; |
@@ -1703,11 +1707,9 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
1703 | ent->tab = publish_tab; | 1707 | ent->tab = publish_tab; |
1704 | fn_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) fn); | 1708 | fn_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) fn); |
1705 | gtk_tree_store_insert_with_values (publish_tab->ts, &iter, pitrptr, G_MAXINT, | 1709 | gtk_tree_store_insert_with_values (publish_tab->ts, &iter, pitrptr, G_MAXINT, |
1706 | 0, fn_utf8, | 1710 | 0, fn_utf8, 1, size_fancy, 2, "white", 3, |
1707 | 1, size_fancy, 2, "white", 3, | ||
1708 | (guint) 0 /* progress */ , | 1711 | (guint) 0 /* progress */ , |
1709 | 4, ent, | 1712 | 4, ent, -1); |
1710 | -1); | ||
1711 | GNUNET_free_non_null (fn_utf8); | 1713 | GNUNET_free_non_null (fn_utf8); |
1712 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); | 1714 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); |
1713 | GNUNET_assert (NULL != path); | 1715 | GNUNET_assert (NULL != path); |
@@ -1786,7 +1788,7 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1786 | return setup_download (info->value.download.cctx, info->value.download.pctx, | 1788 | return setup_download (info->value.download.cctx, info->value.download.pctx, |
1787 | info->value.download.sctx, info->value.download.dc, | 1789 | info->value.download.sctx, info->value.download.dc, |
1788 | info->value.download.uri, | 1790 | info->value.download.uri, |
1789 | info->value.download.filename, | 1791 | info->value.download.filename, |
1790 | info->value.download.specifics.start.meta, | 1792 | info->value.download.specifics.start.meta, |
1791 | info->value.download.size, | 1793 | info->value.download.size, |
1792 | info->value.download.completed); | 1794 | info->value.download.completed); |
@@ -1794,8 +1796,7 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1794 | ret = | 1796 | ret = |
1795 | setup_download (info->value.download.cctx, info->value.download.pctx, | 1797 | setup_download (info->value.download.cctx, info->value.download.pctx, |
1796 | info->value.download.sctx, info->value.download.dc, | 1798 | info->value.download.sctx, info->value.download.dc, |
1797 | info->value.download.uri, | 1799 | info->value.download.uri, info->value.download.filename, |
1798 | info->value.download.filename, | ||
1799 | info->value.download.specifics.resume.meta, | 1800 | info->value.download.specifics.resume.meta, |
1800 | info->value.download.size, | 1801 | info->value.download.size, |
1801 | info->value.download.completed); | 1802 | info->value.download.completed); |
@@ -1980,8 +1981,8 @@ GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy, | |||
1980 | } | 1981 | } |
1981 | 1982 | ||
1982 | static void | 1983 | static void |
1983 | copy_metadata_to_clipboard (GtkTreeModel *model, GtkTreePath *path, | 1984 | copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path, |
1984 | GtkTreeIter *iter, gpointer user_data) | 1985 | GtkTreeIter * iter, gpointer user_data) |
1985 | { | 1986 | { |
1986 | gchar *type, *value; | 1987 | gchar *type, *value; |
1987 | GList **l = (GList **) user_data; | 1988 | GList **l = (GList **) user_data; |
@@ -1993,7 +1994,7 @@ copy_metadata_to_clipboard (GtkTreeModel *model, GtkTreePath *path, | |||
1993 | } | 1994 | } |
1994 | 1995 | ||
1995 | void | 1996 | void |
1996 | metadata_copy_selection_activated (GtkMenuItem *menuitem, gpointer user_data) | 1997 | metadata_copy_selection_activated (GtkMenuItem * menuitem, gpointer user_data) |
1997 | { | 1998 | { |
1998 | GtkBuilder *builder; | 1999 | GtkBuilder *builder; |
1999 | GtkTreeView *tree; | 2000 | GtkTreeView *tree; |
@@ -2003,11 +2004,12 @@ metadata_copy_selection_activated (GtkMenuItem *menuitem, gpointer user_data) | |||
2003 | gchar *s, *p; | 2004 | gchar *s, *p; |
2004 | 2005 | ||
2005 | builder = GTK_BUILDER (user_data); | 2006 | builder = GTK_BUILDER (user_data); |
2006 | tree = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 2007 | tree = |
2007 | "GNUNET_GTK_main_window_metadata_treeview")); | 2008 | GTK_TREE_VIEW (gtk_builder_get_object |
2009 | (builder, "GNUNET_GTK_main_window_metadata_treeview")); | ||
2008 | 2010 | ||
2009 | gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), | 2011 | gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), |
2010 | copy_metadata_to_clipboard, &pairs); | 2012 | copy_metadata_to_clipboard, &pairs); |
2011 | 2013 | ||
2012 | total_len = 0; | 2014 | total_len = 0; |
2013 | pairs = g_list_reverse (pairs); | 2015 | pairs = g_list_reverse (pairs); |
@@ -2018,12 +2020,13 @@ metadata_copy_selection_activated (GtkMenuItem *menuitem, gpointer user_data) | |||
2018 | if (!value) | 2020 | if (!value) |
2019 | break; | 2021 | break; |
2020 | next = value->next; | 2022 | next = value->next; |
2021 | total_len += strlen ((gchar *) type->data) | 2023 | total_len += |
2022 | + strlen ((gchar *) value->data) + 2 /* ": " */ + (next ? 1 : 0) /* "\n" */; | 2024 | strlen ((gchar *) type->data) + strlen ((gchar *) value->data) + |
2025 | 2 /* ": " */ + (next ? 1 : 0) /* "\n" */ ; | ||
2023 | } | 2026 | } |
2024 | if (total_len > 0) | 2027 | if (total_len > 0) |
2025 | { | 2028 | { |
2026 | total_len += 1; /* "\0" */ | 2029 | total_len += 1; /* "\0" */ |
2027 | s = g_new0 (gchar, total_len); | 2030 | s = g_new0 (gchar, total_len); |
2028 | p = s; | 2031 | p = s; |
2029 | for (l = pairs; l; l = next) | 2032 | for (l = pairs; l; l = next) |
@@ -2057,8 +2060,8 @@ metadata_copy_selection_activated (GtkMenuItem *menuitem, gpointer user_data) | |||
2057 | } | 2060 | } |
2058 | 2061 | ||
2059 | void | 2062 | void |
2060 | metadata_menu_popup_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, | 2063 | metadata_menu_popup_position (GtkMenu * menu, gint * x, gint * y, |
2061 | gpointer user_data) | 2064 | gboolean * push_in, gpointer user_data) |
2062 | { | 2065 | { |
2063 | GtkBuilder *builder; | 2066 | GtkBuilder *builder; |
2064 | GtkTreeView *tree; | 2067 | GtkTreeView *tree; |
@@ -2071,8 +2074,9 @@ metadata_menu_popup_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in | |||
2071 | 2074 | ||
2072 | builder = GTK_BUILDER (user_data); | 2075 | builder = GTK_BUILDER (user_data); |
2073 | 2076 | ||
2074 | tree = GTK_TREE_VIEW (gtk_builder_get_object (builder, | 2077 | tree = |
2075 | "GNUNET_GTK_main_window_metadata_treeview")); | 2078 | GTK_TREE_VIEW (gtk_builder_get_object |
2079 | (builder, "GNUNET_GTK_main_window_metadata_treeview")); | ||
2076 | 2080 | ||
2077 | gtk_widget_get_allocation (GTK_WIDGET (tree), &tree_allocation); | 2081 | gtk_widget_get_allocation (GTK_WIDGET (tree), &tree_allocation); |
2078 | 2082 | ||
@@ -2092,6 +2096,7 @@ metadata_menu_popup_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in | |||
2092 | if (rows->data) | 2096 | if (rows->data) |
2093 | { | 2097 | { |
2094 | GdkRectangle r; | 2098 | GdkRectangle r; |
2099 | |||
2095 | p = (GtkTreePath *) rows->data; | 2100 | p = (GtkTreePath *) rows->data; |
2096 | gtk_tree_view_get_cell_area (tree, p, NULL, &r); | 2101 | gtk_tree_view_get_cell_area (tree, p, NULL, &r); |
2097 | popup_x += r.x; | 2102 | popup_x += r.x; |
@@ -2106,8 +2111,8 @@ metadata_menu_popup_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in | |||
2106 | } | 2111 | } |
2107 | 2112 | ||
2108 | static void | 2113 | static void |
2109 | do_metadata_popup_menu (GtkWidget *widget, GdkEventButton *event, | 2114 | do_metadata_popup_menu (GtkWidget * widget, GdkEventButton * event, |
2110 | gpointer user_data) | 2115 | gpointer user_data) |
2111 | { | 2116 | { |
2112 | GtkMenu *menu; | 2117 | GtkMenu *menu; |
2113 | GtkBuilder *builder; | 2118 | GtkBuilder *builder; |
@@ -2119,25 +2124,28 @@ do_metadata_popup_menu (GtkWidget *widget, GdkEventButton *event, | |||
2119 | menu = GTK_MENU (gtk_builder_get_object (builder, "metadata_popup_menu")); | 2124 | menu = GTK_MENU (gtk_builder_get_object (builder, "metadata_popup_menu")); |
2120 | 2125 | ||
2121 | if (event) | 2126 | if (event) |
2122 | { | 2127 | { |
2123 | button = event->button; | 2128 | button = event->button; |
2124 | event_time = event->time; | 2129 | event_time = event->time; |
2125 | } | 2130 | } |
2126 | else | 2131 | else |
2127 | { | 2132 | { |
2128 | button = 0; | 2133 | button = 0; |
2129 | event_time = gtk_get_current_event_time (); | 2134 | event_time = gtk_get_current_event_time (); |
2130 | } | 2135 | } |
2131 | 2136 | ||
2132 | gtk_menu_popup (menu, NULL, NULL, mpf, user_data, | 2137 | gtk_menu_popup (menu, NULL, NULL, mpf, user_data, button, event_time); |
2133 | button, event_time); | ||
2134 | } | 2138 | } |
2135 | 2139 | ||
2136 | gboolean | 2140 | gboolean |
2137 | GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget *widget, | 2141 | GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * |
2138 | GdkEventButton *event, gpointer user_data) | 2142 | widget, |
2143 | GdkEventButton * | ||
2144 | event, | ||
2145 | gpointer | ||
2146 | user_data) | ||
2139 | { | 2147 | { |
2140 | /* Ignore double-clicks and triple-clicks */ | 2148 | /* Ignore double-clicks and triple-clicks */ |
2141 | if (event->button == 3 && event->type == GDK_BUTTON_PRESS) | 2149 | if (event->button == 3 && event->type == GDK_BUTTON_PRESS) |
2142 | { | 2150 | { |
2143 | do_metadata_popup_menu (widget, event, user_data); | 2151 | do_metadata_popup_menu (widget, event, user_data); |
@@ -2148,8 +2156,8 @@ GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget *widge | |||
2148 | } | 2156 | } |
2149 | 2157 | ||
2150 | gboolean | 2158 | gboolean |
2151 | GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget *widget, | 2159 | GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget, |
2152 | gpointer user_data) | 2160 | gpointer user_data) |
2153 | { | 2161 | { |
2154 | do_metadata_popup_menu (widget, NULL, user_data); | 2162 | do_metadata_popup_menu (widget, NULL, user_data); |
2155 | return TRUE; | 2163 | return TRUE; |