diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-20 11:47:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-20 11:47:54 +0000 |
commit | 25f46f6a23a52d8e60e5de3f8d83def688257908 (patch) | |
tree | ea503443444eff68d6a94a8ac624b6b63c8255f3 | |
parent | 5016c5037afc9e9aef98fb5ff2894af2bf5155cd (diff) | |
download | gnunet-gtk-25f46f6a23a52d8e60e5de3f8d83def688257908.tar.gz gnunet-gtk-25f46f6a23a52d8e60e5de3f8d83def688257908.zip |
publish stop, suspend handling
-rw-r--r-- | src/fs_event_handler.c | 82 |
1 files changed, 66 insertions, 16 deletions
diff --git a/src/fs_event_handler.c b/src/fs_event_handler.c index 27da359c..98f9989d 100644 --- a/src/fs_event_handler.c +++ b/src/fs_event_handler.c | |||
@@ -56,6 +56,7 @@ struct PublishTab | |||
56 | { | 56 | { |
57 | struct PublishTab *next; | 57 | struct PublishTab *next; |
58 | struct PublishTab *prev; | 58 | struct PublishTab *prev; |
59 | GtkWidget *frame; | ||
59 | GtkBuilder *builder; | 60 | GtkBuilder *builder; |
60 | struct GNUNET_FS_PublishContext *pc; | 61 | struct GNUNET_FS_PublishContext *pc; |
61 | GtkTreeStore *ts; | 62 | GtkTreeStore *ts; |
@@ -67,6 +68,7 @@ struct PublishEntry | |||
67 | struct GNUNET_FS_PublishContext *pc; | 68 | struct GNUNET_FS_PublishContext *pc; |
68 | struct PublishTab *tab; | 69 | struct PublishTab *tab; |
69 | GtkTreeRowReference *rr; | 70 | GtkTreeRowReference *rr; |
71 | int is_top; | ||
70 | }; | 72 | }; |
71 | 73 | ||
72 | static struct PublishTab *publish_tab_head; | 74 | static struct PublishTab *publish_tab_head; |
@@ -516,6 +518,40 @@ close_search_tab (struct SearchTab *tab) | |||
516 | } | 518 | } |
517 | 519 | ||
518 | 520 | ||
521 | |||
522 | /** | ||
523 | * Close a publish tab and free associated state. | ||
524 | */ | ||
525 | static void | ||
526 | close_publish_tab (struct PublishEntry *ent) | ||
527 | { | ||
528 | struct PublishTab *tab; | ||
529 | GtkNotebook *notebook; | ||
530 | int index; | ||
531 | int i; | ||
532 | |||
533 | gtk_tree_row_reference_free (ent->rr); | ||
534 | if (GNUNET_YES != ent->is_top) | ||
535 | { | ||
536 | GNUNET_free (ent); | ||
537 | return; | ||
538 | } | ||
539 | tab = ent->tab; | ||
540 | GNUNET_free (ent); | ||
541 | notebook = GTK_NOTEBOOK (GNUNET_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | ||
542 | index = -1; | ||
543 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) | ||
544 | if (tab->frame == gtk_notebook_get_nth_page (notebook, i)) | ||
545 | index = i; | ||
546 | gtk_notebook_remove_page (notebook, index); | ||
547 | g_object_unref (tab->builder); | ||
548 | GNUNET_CONTAINER_DLL_remove (publish_tab_head, | ||
549 | publish_tab_tail, | ||
550 | tab); | ||
551 | GNUNET_free (tab); | ||
552 | } | ||
553 | |||
554 | |||
519 | /** | 555 | /** |
520 | * Tell FS to stop a search. | 556 | * Tell FS to stop a search. |
521 | */ | 557 | */ |
@@ -891,7 +927,6 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, | |||
891 | GtkWidget *tab_label; | 927 | GtkWidget *tab_label; |
892 | GtkLabel *fn_label; | 928 | GtkLabel *fn_label; |
893 | GtkWidget *close_button; | 929 | GtkWidget *close_button; |
894 | GtkWidget *frame; | ||
895 | GtkNotebook *notebook; | 930 | GtkNotebook *notebook; |
896 | gint pages; | 931 | gint pages; |
897 | char *size_fancy; | 932 | char *size_fancy; |
@@ -907,9 +942,9 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, | |||
907 | tab->builder = GNUNET_GTK_get_new_builder ("publish_tab.glade"); | 942 | tab->builder = GNUNET_GTK_get_new_builder ("publish_tab.glade"); |
908 | df = GTK_WINDOW (gtk_builder_get_object (tab->builder, | 943 | df = GTK_WINDOW (gtk_builder_get_object (tab->builder, |
909 | "_search_result_frame_window")); | 944 | "_search_result_frame_window")); |
910 | frame = gtk_bin_get_child (GTK_BIN (df)); | 945 | tab->frame = gtk_bin_get_child (GTK_BIN (df)); |
911 | gtk_widget_ref (frame); | 946 | gtk_widget_ref (tab->frame); |
912 | gtk_container_remove (GTK_CONTAINER (df), frame); | 947 | gtk_container_remove (GTK_CONTAINER (df), tab->frame); |
913 | gtk_widget_destroy (GTK_WIDGET (df)); | 948 | gtk_widget_destroy (GTK_WIDGET (df)); |
914 | 949 | ||
915 | /* load tab_label */ | 950 | /* load tab_label */ |
@@ -932,7 +967,7 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, | |||
932 | notebook = GTK_NOTEBOOK (GNUNET_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 967 | notebook = GTK_NOTEBOOK (GNUNET_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); |
933 | pages = gtk_notebook_get_n_pages (notebook); | 968 | pages = gtk_notebook_get_n_pages (notebook); |
934 | gtk_notebook_insert_page (notebook, | 969 | gtk_notebook_insert_page (notebook, |
935 | frame, | 970 | tab->frame, |
936 | tab_label, | 971 | tab_label, |
937 | pages - 1); | 972 | pages - 1); |
938 | gtk_widget_show (GTK_WIDGET (notebook)); | 973 | gtk_widget_show (GTK_WIDGET (notebook)); |
@@ -965,6 +1000,7 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, | |||
965 | -1); | 1000 | -1); |
966 | GNUNET_free (size_fancy); | 1001 | GNUNET_free (size_fancy); |
967 | ent = GNUNET_malloc (sizeof (struct PublishEntry)); | 1002 | ent = GNUNET_malloc (sizeof (struct PublishEntry)); |
1003 | ent->is_top = (parent == NULL) ? GNUNET_YES : GNUNET_NO; | ||
968 | ent->tab = tab; | 1004 | ent->tab = tab; |
969 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (tab->ts), &iter); | 1005 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (tab->ts), &iter); |
970 | ent->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (tab->ts), | 1006 | ent->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (tab->ts), |
@@ -1006,8 +1042,8 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1006 | GNUNET_break (0); | 1042 | GNUNET_break (0); |
1007 | break; | 1043 | break; |
1008 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: | 1044 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: |
1009 | GNUNET_break (0); | 1045 | close_publish_tab (info->value.publish.cctx); |
1010 | break; | 1046 | return NULL; |
1011 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 1047 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
1012 | return mark_publish_progress (info->value.publish.cctx, | 1048 | return mark_publish_progress (info->value.publish.cctx, |
1013 | info->value.publish.size, | 1049 | info->value.publish.size, |
@@ -1019,8 +1055,8 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1019 | return change_publish_colour (info->value.publish.cctx, | 1055 | return change_publish_colour (info->value.publish.cctx, |
1020 | "green"); | 1056 | "green"); |
1021 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | 1057 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: |
1022 | GNUNET_break (0); | 1058 | close_publish_tab (info->value.publish.cctx); |
1023 | break; | 1059 | return NULL; |
1024 | case GNUNET_FS_STATUS_DOWNLOAD_START: | 1060 | case GNUNET_FS_STATUS_DOWNLOAD_START: |
1025 | return setup_download (info->value.download.pctx, | 1061 | return setup_download (info->value.download.pctx, |
1026 | info->value.download.sctx, | 1062 | info->value.download.sctx, |
@@ -1107,13 +1143,27 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1107 | case GNUNET_FS_STATUS_SEARCH_STOPPED: | 1143 | case GNUNET_FS_STATUS_SEARCH_STOPPED: |
1108 | close_search_tab (info->value.search.cctx); | 1144 | close_search_tab (info->value.search.cctx); |
1109 | return NULL; | 1145 | return NULL; |
1110 | case GNUNET_FS_STATUS_UNINDEX_START: GNUNET_break (0); break; | 1146 | case GNUNET_FS_STATUS_UNINDEX_START: |
1111 | case GNUNET_FS_STATUS_UNINDEX_RESUME: GNUNET_break (0); break; | 1147 | GNUNET_break (0); |
1112 | case GNUNET_FS_STATUS_UNINDEX_SUSPEND: GNUNET_break (0); break; | 1148 | break; |
1113 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: GNUNET_break (0); break; | 1149 | case GNUNET_FS_STATUS_UNINDEX_RESUME: |
1114 | case GNUNET_FS_STATUS_UNINDEX_ERROR: GNUNET_break (0); break; | 1150 | GNUNET_break (0); |
1115 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: GNUNET_break (0); break; | 1151 | break; |
1116 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_break (0); break; | 1152 | case GNUNET_FS_STATUS_UNINDEX_SUSPEND: |
1153 | GNUNET_break (0); | ||
1154 | break; | ||
1155 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | ||
1156 | GNUNET_break (0); | ||
1157 | break; | ||
1158 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | ||
1159 | GNUNET_break (0); | ||
1160 | break; | ||
1161 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | ||
1162 | GNUNET_break (0); | ||
1163 | break; | ||
1164 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | ||
1165 | GNUNET_break (0); | ||
1166 | break; | ||
1117 | default: | 1167 | default: |
1118 | GNUNET_break (0); | 1168 | GNUNET_break (0); |
1119 | break; | 1169 | break; |