aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-main_window_file_publish.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_file_publish.c')
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_publish.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
index 948078a1..7706da30 100644
--- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c
+++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
@@ -30,6 +30,8 @@
30 30
31#define MARKER_DIR_FILE_SIZE "-" 31#define MARKER_DIR_FILE_SIZE "-"
32 32
33#define VERBOSE_PROGRESS GNUNET_NO
34
33struct AddDirClientContext; 35struct AddDirClientContext;
34 36
35struct MainPublishingDialogContext 37struct MainPublishingDialogContext
@@ -49,7 +51,7 @@ struct MainPublishingDialogContext
49 GtkWidget *cancel_button; 51 GtkWidget *cancel_button;
50 GtkTreeView *file_info_treeview; 52 GtkTreeView *file_info_treeview;
51 GtkTreeSelection *file_info_selection; 53 GtkTreeSelection *file_info_selection;
52 GtkTreeModel *file_info_treemodel; 54 GtkTreeModel *file_info_treemodel;
53 GtkWindow *master_pubdialog; 55 GtkWindow *master_pubdialog;
54 56
55 gulong open_directory_handler_id; 57 gulong open_directory_handler_id;
@@ -86,6 +88,7 @@ struct AddDirClientContext
86 GtkTextView *progress_dialog_textview; 88 GtkTextView *progress_dialog_textview;
87 GtkTextBuffer *progress_dialog_textbuffer; 89 GtkTextBuffer *progress_dialog_textbuffer;
88 GtkTextMark *progress_dialog_textmark; 90 GtkTextMark *progress_dialog_textmark;
91 GtkAdjustment *textview_vertial_adjustment;
89 92
90 unsigned int done; 93 unsigned int done;
91 unsigned int total; 94 unsigned int total;
@@ -779,18 +782,13 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy,
779 782
780static void 783static void
781insert_progress_dialog_text (struct AddDirClientContext *adcc, 784insert_progress_dialog_text (struct AddDirClientContext *adcc,
782 char *text) 785 const char *text)
783{ 786{
784 GtkTextIter iter; 787 gtk_text_buffer_insert_at_cursor (adcc->progress_dialog_textbuffer,
785 788 text, -1);
786 gtk_text_buffer_get_iter_at_mark (adcc->progress_dialog_textbuffer, 789 gtk_text_view_place_cursor_onscreen (adcc->progress_dialog_textview);
787 &iter, adcc->progress_dialog_textmark); 790 gtk_adjustment_set_value (adcc->textview_vertial_adjustment,
788 gtk_text_buffer_insert (adcc->progress_dialog_textbuffer, 791 gtk_adjustment_get_upper (adcc->textview_vertial_adjustment));
789 &iter, text, -1);
790 gtk_text_view_scroll_to_mark (adcc->progress_dialog_textview,
791 adcc->progress_dialog_textmark,
792 0.0, FALSE, 1.0, 1.0);
793
794} 792}
795 793
796 794
@@ -929,15 +927,21 @@ directory_scan_cb (void *cls,
929 const char *filename, int is_directory, 927 const char *filename, int is_directory,
930 enum GNUNET_FS_DirScannerProgressUpdateReason reason) 928 enum GNUNET_FS_DirScannerProgressUpdateReason reason)
931{ 929{
930 static struct GNUNET_TIME_Absolute last_pulse;
932 struct AddDirClientContext *adcc = cls; 931 struct AddDirClientContext *adcc = cls;
933 char *s; 932 char *s;
934 gdouble fraction; 933 gdouble fraction;
935 934
936 gtk_progress_bar_pulse (adcc->progress_dialog_bar);
937 switch (reason) 935 switch (reason)
938 { 936 {
939 case GNUNET_FS_DIRSCANNER_FILE_START: 937 case GNUNET_FS_DIRSCANNER_FILE_START:
940 GNUNET_assert (filename != NULL); 938 GNUNET_assert (filename != NULL);
939 if (GNUNET_TIME_absolute_get_duration (last_pulse).rel_value > 100)
940 {
941 gtk_progress_bar_pulse (adcc->progress_dialog_bar);
942 last_pulse = GNUNET_TIME_absolute_get ();
943 }
944#if VERBOSE_PROGRESS
941 if (is_directory) 945 if (is_directory)
942 { 946 {
943 GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename); 947 GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
@@ -945,13 +949,21 @@ directory_scan_cb (void *cls,
945 GNUNET_free (s); 949 GNUNET_free (s);
946 } 950 }
947 else 951 else
948 adcc->total++; 952 adcc->total++;
953#else
954 if (! is_directory)
955 adcc->total++;
956#endif
949 break; 957 break;
950 case GNUNET_FS_DIRSCANNER_FILE_IGNORED: 958 case GNUNET_FS_DIRSCANNER_FILE_IGNORED:
951 GNUNET_assert (filename != NULL); 959 GNUNET_assert (filename != NULL);
952 GNUNET_asprintf (&s, 960 GNUNET_asprintf (&s,
953 _("Failed to scan `%s' (access error). Skipping.\n"), 961 _("Failed to scan `%s' (access error). Skipping.\n"),
954 filename); 962 filename);
963#if ! VERBOSE_PROGRESS
964 gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (adcc->progress_dialog_builder,
965 "GNUNET_FS_GTK_progress_dialog_scrolled_window")));
966#endif
955 insert_progress_dialog_text (adcc, s); 967 insert_progress_dialog_text (adcc, s);
956 GNUNET_free (s); 968 GNUNET_free (s);
957 break; 969 break;
@@ -968,9 +980,11 @@ directory_scan_cb (void *cls,
968 fraction); 980 fraction);
969 break; 981 break;
970 case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: 982 case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED:
983#if VERBOSE_PROGRESS
971 GNUNET_asprintf (&s, _("Processed file `%s'.\n"), filename); 984 GNUNET_asprintf (&s, _("Processed file `%s'.\n"), filename);
972 insert_progress_dialog_text (adcc, s); 985 insert_progress_dialog_text (adcc, s);
973 GNUNET_free (s); 986 GNUNET_free (s);
987#endif
974 adcc->done++; 988 adcc->done++;
975 GNUNET_assert (adcc->done <= adcc->total); 989 GNUNET_assert (adcc->done <= adcc->total);
976 fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total; 990 fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
@@ -1040,6 +1054,9 @@ scan_file_or_directory (struct MainPublishingDialogContext *ctx,
1040 adcc->progress_dialog_textview = GTK_TEXT_VIEW ( 1054 adcc->progress_dialog_textview = GTK_TEXT_VIEW (
1041 gtk_builder_get_object (adcc->progress_dialog_builder, 1055 gtk_builder_get_object (adcc->progress_dialog_builder,
1042 "GNUNET_FS_GTK_progress_dialog_textview")); 1056 "GNUNET_FS_GTK_progress_dialog_textview"));
1057 adcc->textview_vertial_adjustment = GTK_ADJUSTMENT (
1058 gtk_builder_get_object (adcc->progress_dialog_builder,
1059 "GNUNET_FS_GTK_progress_dialog_textview_vertical_adjustment"));
1043 adcc->progress_dialog_textbuffer = GTK_TEXT_BUFFER ( 1060 adcc->progress_dialog_textbuffer = GTK_TEXT_BUFFER (
1044 gtk_builder_get_object (adcc->progress_dialog_builder, 1061 gtk_builder_get_object (adcc->progress_dialog_builder,
1045 "GNUNET_FS_GTK_progress_dialog_textbuffer")); 1062 "GNUNET_FS_GTK_progress_dialog_textbuffer"));
@@ -1048,6 +1065,10 @@ scan_file_or_directory (struct MainPublishingDialogContext *ctx,
1048 adcc->progress_dialog_textmark = gtk_text_buffer_create_mark ( 1065 adcc->progress_dialog_textmark = gtk_text_buffer_create_mark (
1049 adcc->progress_dialog_textbuffer, "scroll", 1066 adcc->progress_dialog_textbuffer, "scroll",
1050 &iter, FALSE); 1067 &iter, FALSE);
1068#if VERBOSE_PROGRESS
1069 gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (adcc->progress_dialog_builder,
1070 "GNUNET_FS_GTK_progress_dialog_scrolled_window")));
1071#endif
1051 1072
1052 gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), adcc->ctx->master_pubdialog); 1073 gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), adcc->ctx->master_pubdialog);
1053 gtk_window_set_title (GTK_WINDOW (adcc->progress_dialog), filename); 1074 gtk_window_set_title (GTK_WINDOW (adcc->progress_dialog), filename);