diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-16 18:25:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-16 18:25:53 +0000 |
commit | 68be2f90b7de06c2ec4194d19023dd34ad213de6 (patch) | |
tree | 8864e306c504c58420a3827b7fbc7633d5559840 /src/fs/gnunet-fs-gtk_event-handler.c | |
parent | 8e437c78f7e33900f04e70b60044ab1bb58b148a (diff) | |
download | gnunet-gtk-68be2f90b7de06c2ec4194d19023dd34ad213de6.tar.gz gnunet-gtk-68be2f90b7de06c2ec4194d19023dd34ad213de6.zip |
-starting to get working animation for publish tab
Diffstat (limited to 'src/fs/gnunet-fs-gtk_event-handler.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk_event-handler.c | 95 |
1 files changed, 76 insertions, 19 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c index 003a2ea7..81a23ad1 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.c +++ b/src/fs/gnunet-fs-gtk_event-handler.c | |||
@@ -191,6 +191,11 @@ struct PublishTab | |||
191 | * Associated tree store. | 191 | * Associated tree store. |
192 | */ | 192 | */ |
193 | GtkTreeStore *ts; | 193 | GtkTreeStore *ts; |
194 | |||
195 | /** | ||
196 | * Animation handle associated with the tree store. | ||
197 | */ | ||
198 | struct GNUNET_FS_AnimationTreeViewHandle *atv; | ||
194 | }; | 199 | }; |
195 | 200 | ||
196 | 201 | ||
@@ -250,10 +255,33 @@ static struct SearchTab *uri_tab; | |||
250 | */ | 255 | */ |
251 | static struct PublishTab *publish_tab; | 256 | static struct PublishTab *publish_tab; |
252 | 257 | ||
258 | /** | ||
259 | * Animation to display while publishing. | ||
260 | */ | ||
261 | static struct GNUNET_FS_AnimationContext *animation_publishing; | ||
262 | |||
263 | |||
253 | 264 | ||
254 | /* ***************** Search event handling ****************** */ | 265 | /* ***************** Search event handling ****************** */ |
255 | 266 | ||
256 | 267 | ||
268 | static struct GNUNET_FS_AnimationContext * | ||
269 | load_animation (const char *basename) | ||
270 | { | ||
271 | struct GNUNET_FS_AnimationContext *ac; | ||
272 | const char *dd; | ||
273 | char *fn; | ||
274 | |||
275 | dd = GNUNET_GTK_get_data_dir (); | ||
276 | GNUNET_asprintf (&fn, | ||
277 | "%s%s.gif", | ||
278 | dd, basename); | ||
279 | ac = GNUNET_GTK_animation_context_create (fn); | ||
280 | GNUNET_free (fn); | ||
281 | return ac; | ||
282 | } | ||
283 | |||
284 | |||
257 | /** | 285 | /** |
258 | * Clear the metadata list and the preview widget. | 286 | * Clear the metadata list and the preview widget. |
259 | */ | 287 | */ |
@@ -2617,6 +2645,36 @@ handle_publish_error (struct PublishEntry *pe, | |||
2617 | 2645 | ||
2618 | 2646 | ||
2619 | /** | 2647 | /** |
2648 | * Remove publish tab from notebook | ||
2649 | */ | ||
2650 | static void | ||
2651 | delete_publish_tab () | ||
2652 | { | ||
2653 | GtkNotebook *notebook; | ||
2654 | int index; | ||
2655 | int i; | ||
2656 | |||
2657 | notebook = | ||
2658 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
2659 | ("GNUNET_GTK_main_window_notebook")); | ||
2660 | index = -1; | ||
2661 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) | ||
2662 | if (publish_tab->frame == gtk_notebook_get_nth_page (notebook, i)) | ||
2663 | index = i; | ||
2664 | gtk_notebook_remove_page (notebook, index); | ||
2665 | |||
2666 | /* fully destroy tab */ | ||
2667 | g_object_unref (publish_tab->builder); | ||
2668 | if (NULL != publish_tab->atv) | ||
2669 | GNUNET_GTK_animation_tree_view_unregister (publish_tab->atv); | ||
2670 | GNUNET_free (publish_tab); | ||
2671 | publish_tab = NULL; | ||
2672 | GNUNET_GTK_animation_context_destroy (animation_publishing); | ||
2673 | animation_publishing = NULL; | ||
2674 | } | ||
2675 | |||
2676 | |||
2677 | /** | ||
2620 | * A publishing operation was stopped (in FS API). Free an entry in | 2678 | * A publishing operation was stopped (in FS API). Free an entry in |
2621 | * the publish tab and its associated state. | 2679 | * the publish tab and its associated state. |
2622 | * | 2680 | * |
@@ -2644,6 +2702,8 @@ handle_publish_stop (struct PublishEntry *pe) | |||
2644 | GNUNET_FS_uri_destroy (pe->uri); | 2702 | GNUNET_FS_uri_destroy (pe->uri); |
2645 | pe->uri = NULL; | 2703 | pe->uri = NULL; |
2646 | } | 2704 | } |
2705 | if (! gtk_tree_model_iter_children (GTK_TREE_MODEL (pe->tab->ts), &iter, NULL)) | ||
2706 | delete_publish_tab (); | ||
2647 | GNUNET_free (pe); | 2707 | GNUNET_free (pe); |
2648 | } | 2708 | } |
2649 | 2709 | ||
@@ -2663,9 +2723,6 @@ GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button, | |||
2663 | struct PublishEntry *pe; | 2723 | struct PublishEntry *pe; |
2664 | GtkTreeIter iter; | 2724 | GtkTreeIter iter; |
2665 | GtkTreeModel *tm; | 2725 | GtkTreeModel *tm; |
2666 | GtkNotebook *notebook; | ||
2667 | int index; | ||
2668 | int i; | ||
2669 | 2726 | ||
2670 | GNUNET_assert (tab == publish_tab); | 2727 | GNUNET_assert (tab == publish_tab); |
2671 | /* stop all active operations */ | 2728 | /* stop all active operations */ |
@@ -2676,21 +2733,7 @@ GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button, | |||
2676 | GNUNET_FS_publish_stop (pe->pc); | 2733 | GNUNET_FS_publish_stop (pe->pc); |
2677 | } | 2734 | } |
2678 | clear_metadata_display (); | 2735 | clear_metadata_display (); |
2679 | 2736 | delete_publish_tab (); | |
2680 | /* remove tab from notebook */ | ||
2681 | notebook = | ||
2682 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | ||
2683 | ("GNUNET_GTK_main_window_notebook")); | ||
2684 | index = -1; | ||
2685 | for (i = gtk_notebook_get_n_pages (notebook) - 1; i >= 0; i--) | ||
2686 | if (publish_tab->frame == gtk_notebook_get_nth_page (notebook, i)) | ||
2687 | index = i; | ||
2688 | gtk_notebook_remove_page (notebook, index); | ||
2689 | |||
2690 | /* fully destroy tab */ | ||
2691 | g_object_unref (publish_tab->builder); | ||
2692 | GNUNET_free (publish_tab); | ||
2693 | publish_tab = NULL; | ||
2694 | } | 2737 | } |
2695 | 2738 | ||
2696 | 2739 | ||
@@ -2717,6 +2760,8 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
2717 | GtkWidget *tab_label; | 2760 | GtkWidget *tab_label; |
2718 | GtkNotebook *notebook; | 2761 | GtkNotebook *notebook; |
2719 | char *size_fancy; | 2762 | char *size_fancy; |
2763 | GtkTreeView *tv; | ||
2764 | GtkTreeViewColumn *anim_col; | ||
2720 | 2765 | ||
2721 | if (NULL == publish_tab) | 2766 | if (NULL == publish_tab) |
2722 | { | 2767 | { |
@@ -2739,7 +2784,15 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
2739 | g_object_ref (tab_label); | 2784 | g_object_ref (tab_label); |
2740 | gtk_container_remove (GTK_CONTAINER (df), tab_label); | 2785 | gtk_container_remove (GTK_CONTAINER (df), tab_label); |
2741 | gtk_widget_destroy (GTK_WIDGET (df)); | 2786 | gtk_widget_destroy (GTK_WIDGET (df)); |
2742 | 2787 | ||
2788 | tv = GTK_TREE_VIEW (gtk_builder_get_object | ||
2789 | (publish_tab->builder, "_publish_tree_view")); | ||
2790 | anim_col = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object | ||
2791 | (publish_tab->builder, "_publish_animated_icon")); | ||
2792 | if ( (NULL != tv) && (NULL != anim_col) ) | ||
2793 | publish_tab->atv = GNUNET_GTK_animation_tree_view_register (tv, | ||
2794 | anim_col); | ||
2795 | |||
2743 | /* make visible */ | 2796 | /* make visible */ |
2744 | notebook = | 2797 | notebook = |
2745 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object | 2798 | GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object |
@@ -2770,6 +2823,8 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
2770 | } | 2823 | } |
2771 | pitrptr = &piter; | 2824 | pitrptr = &piter; |
2772 | } | 2825 | } |
2826 | if (NULL == animation_publishing) | ||
2827 | animation_publishing = load_animation ("publishing"); | ||
2773 | 2828 | ||
2774 | /* create entry and perform insertion */ | 2829 | /* create entry and perform insertion */ |
2775 | ent = GNUNET_malloc (sizeof (struct PublishEntry)); | 2830 | ent = GNUNET_malloc (sizeof (struct PublishEntry)); |
@@ -2783,6 +2838,8 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
2783 | PUBLISH_TAB_MC_BGCOLOUR, "white", | 2838 | PUBLISH_TAB_MC_BGCOLOUR, "white", |
2784 | PUBLISH_TAB_MC_PROGRESS, (guint) 0, | 2839 | PUBLISH_TAB_MC_PROGRESS, (guint) 0, |
2785 | PUBLISH_TAB_MC_ENT, ent, | 2840 | PUBLISH_TAB_MC_ENT, ent, |
2841 | PUBLISH_TAB_MC_STATUS_ICON, | ||
2842 | GNUNET_GTK_animation_context_get_pixbuf (animation_publishing), | ||
2786 | -1); | 2843 | -1); |
2787 | GNUNET_free (size_fancy); | 2844 | GNUNET_free (size_fancy); |
2788 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); | 2845 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); |