aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-31 12:00:00 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-31 12:00:00 +0000
commit77abd7e4be632270c09fda9ffeae809d01ced4e1 (patch)
tree6009cd934014a58a36d55c9f736a27963eca23d2
parent84a18dee8b6044facfdde00d36f9a27b59f02d45 (diff)
downloadgnunet-gtk-77abd7e4be632270c09fda9ffeae809d01ced4e1.tar.gz
gnunet-gtk-77abd7e4be632270c09fda9ffeae809d01ced4e1.zip
-making progress dialog nice and responsive
-rw-r--r--contrib/gnunet_fs_gtk_progress_dialog.glade59
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_publish.c49
2 files changed, 79 insertions, 29 deletions
diff --git a/contrib/gnunet_fs_gtk_progress_dialog.glade b/contrib/gnunet_fs_gtk_progress_dialog.glade
index 6e63b9ee..f05405fa 100644
--- a/contrib/gnunet_fs_gtk_progress_dialog.glade
+++ b/contrib/gnunet_fs_gtk_progress_dialog.glade
@@ -15,23 +15,42 @@
15 <property name="orientation">vertical</property> 15 <property name="orientation">vertical</property>
16 <property name="spacing">2</property> 16 <property name="spacing">2</property>
17 <child> 17 <child>
18 <object class="GtkScrolledWindow" id="GNUNET_FS_GTK_progress_dialog_scrolled_window"> 18 <object class="GtkFrame" id="GNUNET_FS_GTK_progress_dialog_frame">
19 <property name="visible">True</property> 19 <property name="visible">True</property>
20 <property name="can_focus">True</property> 20 <property name="label_xalign">0</property>
21 <property name="hadjustment">GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment</property> 21 <property name="shadow_type">none</property>
22 <property name="vadjustment">GNUNET_FS_GTK_progress_dialog_textview_vertical_adjustment</property>
23 <property name="hscrollbar_policy">automatic</property>
24 <property name="vscrollbar_policy">automatic</property>
25 <property name="shadow_type">in</property>
26 <child> 22 <child>
27 <object class="GtkTextView" id="GNUNET_FS_GTK_progress_dialog_textview"> 23 <object class="GtkAlignment" id="GNUNET_FS_GTK_progress_dialog_alignment">
28 <property name="visible">True</property> 24 <property name="visible">True</property>
29 <property name="can_focus">True</property> 25 <property name="left_padding">12</property>
30 <property name="editable">False</property> 26 <child>
31 <property name="wrap_mode">word</property> 27 <object class="GtkScrolledWindow" id="GNUNET_FS_GTK_progress_dialog_scrolled_window">
32 <property name="indent">-10</property> 28 <property name="visible">True</property>
33 <property name="buffer">GNUNET_FS_GTK_progress_dialog_textbuffer</property> 29 <property name="can_focus">True</property>
34 <property name="accepts_tab">False</property> 30 <property name="hadjustment">GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment</property>
31 <property name="vadjustment">GNUNET_FS_GTK_progress_dialog_textview_vertical_adjustment</property>
32 <property name="hscrollbar_policy">automatic</property>
33 <property name="vscrollbar_policy">automatic</property>
34 <child>
35 <object class="GtkTextView" id="GNUNET_FS_GTK_progress_dialog_textview">
36 <property name="visible">True</property>
37 <property name="can_focus">True</property>
38 <property name="editable">False</property>
39 <property name="wrap_mode">word</property>
40 <property name="indent">-10</property>
41 <property name="buffer">GNUNET_FS_GTK_progress_dialog_textbuffer</property>
42 <property name="accepts_tab">False</property>
43 </object>
44 </child>
45 </object>
46 </child>
47 </object>
48 </child>
49 <child type="label">
50 <object class="GtkLabel" id="GNUNET_FS_GTK_progress_dialog_label">
51 <property name="visible">True</property>
52 <property name="label" translatable="yes">&lt;b&gt;Messages&lt;/b&gt;</property>
53 <property name="use_markup">True</property>
35 </object> 54 </object>
36 </child> 55 </child>
37 </object> 56 </object>
@@ -43,6 +62,10 @@
43 <object class="GtkProgressBar" id="GNUNET_FS_GTK_progress_dialog_progressbar"> 62 <object class="GtkProgressBar" id="GNUNET_FS_GTK_progress_dialog_progressbar">
44 <property name="visible">True</property> 63 <property name="visible">True</property>
45 <property name="activity_mode">True</property> 64 <property name="activity_mode">True</property>
65 <property name="pulse_step">0.050000002607703209</property>
66 <property name="text" translatable="yes">Preprocessing...</property>
67 <property name="adjustment">GNUNET_FS_GTK_progress_bar_adjustment</property>
68 <property name="discrete_blocks">5</property>
46 </object> 69 </object>
47 <packing> 70 <packing>
48 <property name="expand">False</property> 71 <property name="expand">False</property>
@@ -69,6 +92,7 @@
69 <packing> 92 <packing>
70 <property name="expand">False</property> 93 <property name="expand">False</property>
71 <property name="fill">False</property> 94 <property name="fill">False</property>
95 <property name="pack_type">end</property>
72 <property name="position">1</property> 96 <property name="position">1</property>
73 </packing> 97 </packing>
74 </child> 98 </child>
@@ -82,7 +106,6 @@
82 </object> 106 </object>
83 </child> 107 </child>
84 </object> 108 </object>
85 <object class="GtkSizeGroup" id="GNUNET_FS_GTK_progress_dialog_buttons_sizegroup"/>
86 <object class="GtkTextBuffer" id="GNUNET_FS_GTK_progress_dialog_textbuffer"/> 109 <object class="GtkTextBuffer" id="GNUNET_FS_GTK_progress_dialog_textbuffer"/>
87 <object class="GtkAdjustment" id="GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment"> 110 <object class="GtkAdjustment" id="GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment">
88 <property name="upper">100</property> 111 <property name="upper">100</property>
@@ -94,4 +117,10 @@
94 <property name="step_increment">1</property> 117 <property name="step_increment">1</property>
95 <property name="page_increment">10</property> 118 <property name="page_increment">10</property>
96 </object> 119 </object>
120 <object class="GtkAdjustment" id="GNUNET_FS_GTK_progress_bar_adjustment">
121 <property name="upper">100</property>
122 <property name="step_increment">1</property>
123 <property name="page_increment">10</property>
124 <property name="page_size">10</property>
125 </object>
97</interface> 126</interface>
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);