diff options
author | Christian Grothoff <christian@grothoff.org> | 2006-10-29 23:57:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2006-10-29 23:57:48 +0000 |
commit | 10d8b6fb428da9bb3cb2140e9f460d992cd525a9 (patch) | |
tree | 345dd0c6af1ae23f026ec5db1b34dddcf7413cf8 | |
parent | 2376fb6108dac617e0b517544fb663bc0dba3924 (diff) | |
download | gnunet-gtk-10d8b6fb428da9bb3cb2140e9f460d992cd525a9.tar.gz gnunet-gtk-10d8b6fb428da9bb3cb2140e9f460d992cd525a9.zip |
more event handlers and proper save calling
-rw-r--r-- | gnunet-gtk.glade | 4 | ||||
-rw-r--r-- | src/plugins/fs/download.c | 55 | ||||
-rw-r--r-- | src/plugins/fs/search.c | 40 | ||||
-rw-r--r-- | src/plugins/fs/upload.c | 101 |
4 files changed, 179 insertions, 21 deletions
diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade index 40c192ac..6117e3c1 100644 --- a/gnunet-gtk.glade +++ b/gnunet-gtk.glade | |||
@@ -1236,7 +1236,7 @@ This release fixes downloads of files from directories. The previous version ha | |||
1236 | <property name="use_stock">True</property> | 1236 | <property name="use_stock">True</property> |
1237 | <property name="relief">GTK_RELIEF_NORMAL</property> | 1237 | <property name="relief">GTK_RELIEF_NORMAL</property> |
1238 | <property name="focus_on_click">True</property> | 1238 | <property name="focus_on_click">True</property> |
1239 | <signal name="clicked" handler="on_abortDownloadButton_clicked" last_modification_time="Wed, 01 Jun 2005 19:54:07 GMT"/> | 1239 | <signal name="clicked" handler="on_abortDownloadButton_clicked_" last_modification_time="Wed, 01 Jun 2005 19:54:07 GMT"/> |
1240 | </widget> | 1240 | </widget> |
1241 | <packing> | 1241 | <packing> |
1242 | <property name="padding">0</property> | 1242 | <property name="padding">0</property> |
@@ -1414,7 +1414,7 @@ This release fixes downloads of files from directories. The previous version ha | |||
1414 | <property name="use_stock">True</property> | 1414 | <property name="use_stock">True</property> |
1415 | <property name="relief">GTK_RELIEF_NORMAL</property> | 1415 | <property name="relief">GTK_RELIEF_NORMAL</property> |
1416 | <property name="focus_on_click">True</property> | 1416 | <property name="focus_on_click">True</property> |
1417 | <signal name="clicked" handler="on_clearCompletedDownloadsButton_clicked_" last_modification_time="Wed, 01 Jun 2005 19:53:58 GMT"/> | 1417 | <signal name="clicked" handler="on_clearCompletedUploadsButton_clicked_" last_modification_time="Mon, 30 Oct 2006 00:26:29 GMT"/> |
1418 | </widget> | 1418 | </widget> |
1419 | <packing> | 1419 | <packing> |
1420 | <property name="padding">0</property> | 1420 | <property name="padding">0</property> |
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index b58bb5ef..b77615d6 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -639,6 +639,18 @@ void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry, | |||
639 | FREE(urid); | 639 | FREE(urid); |
640 | } | 640 | } |
641 | 641 | ||
642 | struct FCBC { | ||
643 | int (*method)(struct FSUI_Context * ctx, | ||
644 | struct FSUI_DownloadList * list); | ||
645 | struct FSUI_DownloadList * argument; | ||
646 | }; | ||
647 | |||
648 | static void * fsui_callback(void * cls) { | ||
649 | struct FCBC * fcbc = cls; | ||
650 | fcbc->method(ctx, | ||
651 | fcbc->argument); | ||
652 | return NULL; | ||
653 | } | ||
642 | 654 | ||
643 | static void | 655 | static void |
644 | clearCompletedDownloadCallback(GtkTreeModel * model, | 656 | clearCompletedDownloadCallback(GtkTreeModel * model, |
@@ -646,6 +658,7 @@ clearCompletedDownloadCallback(GtkTreeModel * model, | |||
646 | GtkTreeIter * iter, | 658 | GtkTreeIter * iter, |
647 | gpointer unused) { | 659 | gpointer unused) { |
648 | DownloadList * dl; | 660 | DownloadList * dl; |
661 | struct FCBC fcbc; | ||
649 | 662 | ||
650 | GE_ASSERT(ectx, | 663 | GE_ASSERT(ectx, |
651 | model == GTK_TREE_MODEL(download_summary)); | 664 | model == GTK_TREE_MODEL(download_summary)); |
@@ -653,9 +666,12 @@ clearCompletedDownloadCallback(GtkTreeModel * model, | |||
653 | iter, | 666 | iter, |
654 | DOWNLOAD_INTERNAL, &dl, | 667 | DOWNLOAD_INTERNAL, &dl, |
655 | -1); | 668 | -1); |
656 | if (dl->has_terminated) | 669 | if (dl->has_terminated) { |
657 | FSUI_stopDownload(ctx, | 670 | fcbc.method = &FSUI_stopDownload; |
658 | dl->fsui_list); | 671 | fcbc.argument = dl->fsui_list; |
672 | run_with_save_calls(&fsui_callback, | ||
673 | &fcbc); | ||
674 | } | ||
659 | } | 675 | } |
660 | 676 | ||
661 | void on_clearCompletedDownloadsButton_clicked_fs(void * unused, | 677 | void on_clearCompletedDownloadsButton_clicked_fs(void * unused, |
@@ -673,11 +689,12 @@ void on_clearCompletedDownloadsButton_clicked_fs(void * unused, | |||
673 | } | 689 | } |
674 | 690 | ||
675 | static void | 691 | static void |
676 | abortDownloadCallback(GtkTreeModel * model, | 692 | fsuiCallDownloadCallback(GtkTreeModel * model, |
677 | GtkTreePath * path, | 693 | GtkTreePath * path, |
678 | GtkTreeIter * iter, | 694 | GtkTreeIter * iter, |
679 | gpointer unused) { | 695 | gpointer fsui_call) { |
680 | DownloadList * dl; | 696 | DownloadList * dl; |
697 | struct FCBC fcbc; | ||
681 | 698 | ||
682 | GE_ASSERT(ectx, | 699 | GE_ASSERT(ectx, |
683 | model == GTK_TREE_MODEL(download_summary)); | 700 | model == GTK_TREE_MODEL(download_summary)); |
@@ -685,8 +702,10 @@ abortDownloadCallback(GtkTreeModel * model, | |||
685 | iter, | 702 | iter, |
686 | DOWNLOAD_INTERNAL, &dl, | 703 | DOWNLOAD_INTERNAL, &dl, |
687 | -1); | 704 | -1); |
688 | FSUI_abortDownload(ctx, | 705 | fcbc.method = fsui_call; |
689 | dl->fsui_list); | 706 | fcbc.argument = dl->fsui_list; |
707 | run_with_save_calls(&fsui_callback, | ||
708 | &fcbc); | ||
690 | } | 709 | } |
691 | 710 | ||
692 | void on_abortDownloadButton_clicked_fs(void * unused, | 711 | void on_abortDownloadButton_clicked_fs(void * unused, |
@@ -699,8 +718,22 @@ void on_abortDownloadButton_clicked_fs(void * unused, | |||
699 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(downloadList)); | 718 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(downloadList)); |
700 | gtk_tree_selection_selected_foreach | 719 | gtk_tree_selection_selected_foreach |
701 | (selection, | 720 | (selection, |
702 | &abortDownloadCallback, | 721 | &fsuiCallDownloadCallback, |
703 | NULL); | 722 | &FSUI_abortDownload); |
723 | } | ||
724 | |||
725 | void on_stopDownloadButton_clicked_fs(void * unused, | ||
726 | GtkWidget * clearButton) { | ||
727 | GtkTreeSelection * selection; | ||
728 | GtkWidget * downloadList; | ||
729 | |||
730 | downloadList = glade_xml_get_widget(getMainXML(), | ||
731 | "activeDownloadsList"); | ||
732 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(downloadList)); | ||
733 | gtk_tree_selection_selected_foreach | ||
734 | (selection, | ||
735 | &fsuiCallDownloadCallback, | ||
736 | &FSUI_stopDownload); | ||
704 | } | 737 | } |
705 | 738 | ||
706 | /* end of download.c */ | 739 | /* end of download.c */ |
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index acb046c6..71744feb 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -588,6 +588,19 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
588 | uri); | 588 | uri); |
589 | } | 589 | } |
590 | 590 | ||
591 | struct FCBC { | ||
592 | int (*method)(struct FSUI_Context * ctx, | ||
593 | struct FSUI_SearchList * list); | ||
594 | struct FSUI_SearchList * argument; | ||
595 | }; | ||
596 | |||
597 | static void * fsui_callback(void * cls) { | ||
598 | struct FCBC * fcbc = cls; | ||
599 | fcbc->method(ctx, | ||
600 | fcbc->argument); | ||
601 | return NULL; | ||
602 | } | ||
603 | |||
591 | /** | 604 | /** |
592 | * This method is called when the user clicks on either | 605 | * This method is called when the user clicks on either |
593 | * the "CLOSE" button (at the bottom of the search page) | 606 | * the "CLOSE" button (at the bottom of the search page) |
@@ -599,6 +612,7 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
599 | void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, | 612 | void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, |
600 | GtkWidget * closeButton) { | 613 | GtkWidget * closeButton) { |
601 | SearchList * list; | 614 | SearchList * list; |
615 | struct FCBC fcbc; | ||
602 | 616 | ||
603 | list = search_head; | 617 | list = search_head; |
604 | while (list != NULL) { | 618 | while (list != NULL) { |
@@ -608,8 +622,10 @@ void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, | |||
608 | list = list->next; | 622 | list = list->next; |
609 | } | 623 | } |
610 | GE_ASSERT(ectx, list != NULL); | 624 | GE_ASSERT(ectx, list != NULL); |
611 | FSUI_stopSearch(ctx, | 625 | fcbc.method = &FSUI_stopSearch; |
612 | list->fsui_list); | 626 | fcbc.argument = list->fsui_list; |
627 | run_with_save_calls(&fsui_callback, | ||
628 | &fcbc); | ||
613 | } | 629 | } |
614 | 630 | ||
615 | /** | 631 | /** |
@@ -635,15 +651,19 @@ static void stopSearch(GtkTreeModel * model, | |||
635 | GtkTreeIter * iter, | 651 | GtkTreeIter * iter, |
636 | gpointer unused) { | 652 | gpointer unused) { |
637 | SearchList * s; | 653 | SearchList * s; |
654 | struct FCBC fcbc; | ||
638 | 655 | ||
639 | s = NULL; | 656 | s = NULL; |
640 | gtk_tree_model_get(model, | 657 | gtk_tree_model_get(model, |
641 | iter, | 658 | iter, |
642 | SEARCH_SUMMARY_INTERNAL, &s, | 659 | SEARCH_SUMMARY_INTERNAL, &s, |
643 | -1); | 660 | -1); |
644 | if (s != NULL) | 661 | if (s != NULL) { |
645 | FSUI_stopSearch(ctx, | 662 | fcbc.method = &FSUI_stopSearch; |
646 | s->fsui_list); | 663 | fcbc.argument = s->fsui_list; |
664 | run_with_save_calls(&fsui_callback, | ||
665 | &fcbc); | ||
666 | } | ||
647 | } | 667 | } |
648 | 668 | ||
649 | /** | 669 | /** |
@@ -665,15 +685,19 @@ static void abortSearch(GtkTreeModel * model, | |||
665 | GtkTreeIter * iter, | 685 | GtkTreeIter * iter, |
666 | gpointer unused) { | 686 | gpointer unused) { |
667 | SearchList * s; | 687 | SearchList * s; |
688 | struct FCBC fcbc; | ||
668 | 689 | ||
669 | s = NULL; | 690 | s = NULL; |
670 | gtk_tree_model_get(model, | 691 | gtk_tree_model_get(model, |
671 | iter, | 692 | iter, |
672 | SEARCH_SUMMARY_INTERNAL, &s, | 693 | SEARCH_SUMMARY_INTERNAL, &s, |
673 | -1); | 694 | -1); |
674 | if (s != NULL) | 695 | if (s != NULL) { |
675 | FSUI_abortSearch(ctx, | 696 | fcbc.method = &FSUI_abortSearch; |
676 | s->fsui_list); | 697 | fcbc.argument = s->fsui_list; |
698 | run_with_save_calls(&fsui_callback, | ||
699 | &fcbc); | ||
700 | } | ||
677 | } | 701 | } |
678 | 702 | ||
679 | /** | 703 | /** |
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c index 500830ba..103cdce9 100644 --- a/src/plugins/fs/upload.c +++ b/src/plugins/fs/upload.c | |||
@@ -390,4 +390,105 @@ void on_mainFileSharingInsertBrowseButton_clicked_fs(GtkWidget * browseButton, | |||
390 | free(filename); | 390 | free(filename); |
391 | } | 391 | } |
392 | 392 | ||
393 | /* FIXME: handlers for clear and stop! */ | ||
394 | |||
395 | struct FCBC { | ||
396 | int (*method)(struct FSUI_Context * ctx, | ||
397 | struct FSUI_UploadList * list); | ||
398 | struct FSUI_UploadList * argument; | ||
399 | }; | ||
400 | |||
401 | static void * fsui_callback(void * cls) { | ||
402 | struct FCBC * fcbc = cls; | ||
403 | fcbc->method(ctx, | ||
404 | fcbc->argument); | ||
405 | return NULL; | ||
406 | } | ||
407 | |||
408 | static void | ||
409 | clearCompletedUploadCallback(GtkTreeModel * model, | ||
410 | GtkTreePath * path, | ||
411 | GtkTreeIter * iter, | ||
412 | gpointer unused) { | ||
413 | UploadList * ul; | ||
414 | struct FCBC fcbc; | ||
415 | |||
416 | GE_ASSERT(ectx, | ||
417 | model == GTK_TREE_MODEL(upload_summary)); | ||
418 | gtk_tree_model_get(model, | ||
419 | iter, | ||
420 | UPLOAD_INTERNAL, &ul, | ||
421 | -1); | ||
422 | if (ul->has_terminated) { | ||
423 | fcbc.method = &FSUI_stopUpload; | ||
424 | fcbc.argument = ul->fsui_list; | ||
425 | run_with_save_calls(&fsui_callback, | ||
426 | &fcbc); | ||
427 | } | ||
428 | } | ||
429 | |||
430 | void on_clearCompletedUploadsButton_clicked_fs(void * unused, | ||
431 | GtkWidget * clearButton) { | ||
432 | GtkTreeSelection * selection; | ||
433 | GtkWidget * uploadList; | ||
434 | |||
435 | uploadList = glade_xml_get_widget(getMainXML(), | ||
436 | "activeUploadsList"); | ||
437 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(uploadList)); | ||
438 | gtk_tree_selection_selected_foreach | ||
439 | (selection, | ||
440 | &clearCompletedUploadCallback, | ||
441 | NULL); | ||
442 | } | ||
443 | |||
444 | static void | ||
445 | fsuiCallUploadCallback(GtkTreeModel * model, | ||
446 | GtkTreePath * path, | ||
447 | GtkTreeIter * iter, | ||
448 | gpointer fsui_call) { | ||
449 | UploadList * ul; | ||
450 | struct FCBC fcbc; | ||
451 | |||
452 | GE_ASSERT(ectx, | ||
453 | model == GTK_TREE_MODEL(upload_summary)); | ||
454 | gtk_tree_model_get(model, | ||
455 | iter, | ||
456 | UPLOAD_INTERNAL, &ul, | ||
457 | -1); | ||
458 | fcbc.method = fsui_call; | ||
459 | fcbc.argument = ul->fsui_list; | ||
460 | run_with_save_calls(&fsui_callback, | ||
461 | &fcbc); | ||
462 | } | ||
463 | |||
464 | void on_abortUploadButton_clicked_fs(void * unused, | ||
465 | GtkWidget * clearButton) { | ||
466 | GtkTreeSelection * selection; | ||
467 | GtkWidget * uploadList; | ||
468 | |||
469 | uploadList = glade_xml_get_widget(getMainXML(), | ||
470 | "activeUploadsList"); | ||
471 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(uploadList)); | ||
472 | gtk_tree_selection_selected_foreach | ||
473 | (selection, | ||
474 | &fsuiCallUploadCallback, | ||
475 | &FSUI_abortUpload); | ||
476 | } | ||
477 | |||
478 | void on_stopUploadButton_clicked_fs(void * unused, | ||
479 | GtkWidget * clearButton) { | ||
480 | GtkTreeSelection * selection; | ||
481 | GtkWidget * uploadList; | ||
482 | |||
483 | uploadList = glade_xml_get_widget(getMainXML(), | ||
484 | "activeUploadsList"); | ||
485 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(uploadList)); | ||
486 | gtk_tree_selection_selected_foreach | ||
487 | (selection, | ||
488 | &fsuiCallUploadCallback, | ||
489 | &FSUI_stopUpload); | ||
490 | } | ||
491 | |||
492 | |||
493 | |||
393 | /* end of upload.c */ | 494 | /* end of upload.c */ |