aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-31 11:02:18 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-31 11:02:18 +0000
commit84a18dee8b6044facfdde00d36f9a27b59f02d45 (patch)
tree41e6ae3275573137af19829fb7abbe6286c4e110
parent33b63f8c4ccc242fac0b134d6d6bc3045596718b (diff)
downloadgnunet-gtk-84a18dee8b6044facfdde00d36f9a27b59f02d45.tar.gz
gnunet-gtk-84a18dee8b6044facfdde00d36f9a27b59f02d45.zip
-misc bugfixes to progress dialog for publishing
-rw-r--r--contrib/gnunet_fs_gtk_progress_dialog.glade41
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_publish.c69
2 files changed, 53 insertions, 57 deletions
diff --git a/contrib/gnunet_fs_gtk_progress_dialog.glade b/contrib/gnunet_fs_gtk_progress_dialog.glade
index 8f2b1743..6e63b9ee 100644
--- a/contrib/gnunet_fs_gtk_progress_dialog.glade
+++ b/contrib/gnunet_fs_gtk_progress_dialog.glade
@@ -1,19 +1,18 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0"?>
2<interface> 2<interface>
3 <requires lib="gtk+" version="2.20"/> 3 <requires lib="gtk+" version="2.20"/>
4 <!-- interface-naming-policy project-wide --> 4 <!-- interface-naming-policy project-wide -->
5 <object class="GtkWindow" id="GNUNET_FS_GTK_progress_dialog"> 5 <object class="GtkWindow" id="GNUNET_FS_GTK_progress_dialog">
6 <property name="can_focus">False</property>
7 <property name="border_width">2</property> 6 <property name="border_width">2</property>
8 <property name="window_position">center-on-parent</property> 7 <property name="window_position">center-on-parent</property>
9 <property name="default_width">800</property> 8 <property name="default_width">800</property>
10 <property name="default_height">600</property> 9 <property name="default_height">600</property>
11 <property name="destroy_with_parent">True</property> 10 <property name="destroy_with_parent">True</property>
12 <signal name="delete-event" handler="GNUNET_FS_GTK_progress_dialog_delete_event_cb" swapped="no"/> 11 <signal name="delete_event" handler="GNUNET_FS_GTK_progress_dialog_delete_event_cb"/>
13 <child> 12 <child>
14 <object class="GtkVBox" id="GNUNET_FS_GTK_progress_dialog_main_vbox"> 13 <object class="GtkVBox" id="GNUNET_FS_GTK_progress_dialog_main_vbox">
15 <property name="visible">True</property> 14 <property name="visible">True</property>
16 <property name="can_focus">False</property> 15 <property name="orientation">vertical</property>
17 <property name="spacing">2</property> 16 <property name="spacing">2</property>
18 <child> 17 <child>
19 <object class="GtkScrolledWindow" id="GNUNET_FS_GTK_progress_dialog_scrolled_window"> 18 <object class="GtkScrolledWindow" id="GNUNET_FS_GTK_progress_dialog_scrolled_window">
@@ -37,15 +36,12 @@
37 </child> 36 </child>
38 </object> 37 </object>
39 <packing> 38 <packing>
40 <property name="expand">True</property>
41 <property name="fill">True</property>
42 <property name="position">0</property> 39 <property name="position">0</property>
43 </packing> 40 </packing>
44 </child> 41 </child>
45 <child> 42 <child>
46 <object class="GtkProgressBar" id="GNUNET_FS_GTK_progress_dialog_progressbar"> 43 <object class="GtkProgressBar" id="GNUNET_FS_GTK_progress_dialog_progressbar">
47 <property name="visible">True</property> 44 <property name="visible">True</property>
48 <property name="can_focus">False</property>
49 <property name="activity_mode">True</property> 45 <property name="activity_mode">True</property>
50 </object> 46 </object>
51 <packing> 47 <packing>
@@ -57,43 +53,23 @@
57 <child> 53 <child>
58 <object class="GtkHBox" id="GNUNET_FS_GTK_progress_dialog_buttons_hbox"> 54 <object class="GtkHBox" id="GNUNET_FS_GTK_progress_dialog_buttons_hbox">
59 <property name="visible">True</property> 55 <property name="visible">True</property>
60 <property name="can_focus">False</property>
61 <property name="spacing">2</property> 56 <property name="spacing">2</property>
62 <child> 57 <child>
63 <placeholder/> 58 <placeholder/>
64 </child> 59 </child>
65 <child> 60 <child>
66 <object class="GtkButton" id="GNUNET_FS_GTK_progress_dialog_ok_button">
67 <property name="label">gtk-ok</property>
68 <property name="use_action_appearance">False</property>
69 <property name="visible">True</property>
70 <property name="can_focus">True</property>
71 <property name="receives_default">True</property>
72 <property name="use_stock">True</property>
73 <signal name="clicked" handler="GNUNET_FS_GTK_progress_dialog_ok_button_clicked_cb" swapped="no"/>
74 </object>
75 <packing>
76 <property name="expand">False</property>
77 <property name="fill">False</property>
78 <property name="pack_type">end</property>
79 <property name="position">1</property>
80 </packing>
81 </child>
82 <child>
83 <object class="GtkButton" id="GNUNET_FS_GTK_progress_dialog_cancel_button"> 61 <object class="GtkButton" id="GNUNET_FS_GTK_progress_dialog_cancel_button">
84 <property name="label">gtk-cancel</property> 62 <property name="label">gtk-cancel</property>
85 <property name="use_action_appearance">False</property>
86 <property name="visible">True</property> 63 <property name="visible">True</property>
87 <property name="can_focus">True</property> 64 <property name="can_focus">True</property>
88 <property name="receives_default">True</property> 65 <property name="receives_default">True</property>
89 <property name="use_stock">True</property> 66 <property name="use_stock">True</property>
90 <signal name="clicked" handler="GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb" swapped="no"/> 67 <signal name="clicked" handler="GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb"/>
91 </object> 68 </object>
92 <packing> 69 <packing>
93 <property name="expand">False</property> 70 <property name="expand">False</property>
94 <property name="fill">False</property> 71 <property name="fill">False</property>
95 <property name="pack_type">end</property> 72 <property name="position">1</property>
96 <property name="position">2</property>
97 </packing> 73 </packing>
98 </child> 74 </child>
99 </object> 75 </object>
@@ -106,12 +82,7 @@
106 </object> 82 </object>
107 </child> 83 </child>
108 </object> 84 </object>
109 <object class="GtkSizeGroup" id="GNUNET_FS_GTK_progress_dialog_buttons_sizegroup"> 85 <object class="GtkSizeGroup" id="GNUNET_FS_GTK_progress_dialog_buttons_sizegroup"/>
110 <widgets>
111 <widget name="GNUNET_FS_GTK_progress_dialog_ok_button"/>
112 <widget name="GNUNET_FS_GTK_progress_dialog_cancel_button"/>
113 </widgets>
114 </object>
115 <object class="GtkTextBuffer" id="GNUNET_FS_GTK_progress_dialog_textbuffer"/> 86 <object class="GtkTextBuffer" id="GNUNET_FS_GTK_progress_dialog_textbuffer"/>
116 <object class="GtkAdjustment" id="GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment"> 87 <object class="GtkAdjustment" id="GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment">
117 <property name="upper">100</property> 88 <property name="upper">100</property>
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 6aa622c5..948078a1 100644
--- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c
+++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
@@ -86,6 +86,9 @@ struct AddDirClientContext
86 GtkTextView *progress_dialog_textview; 86 GtkTextView *progress_dialog_textview;
87 GtkTextBuffer *progress_dialog_textbuffer; 87 GtkTextBuffer *progress_dialog_textbuffer;
88 GtkTextMark *progress_dialog_textmark; 88 GtkTextMark *progress_dialog_textmark;
89
90 unsigned int done;
91 unsigned int total;
89}; 92};
90 93
91void 94void
@@ -821,8 +824,11 @@ add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
821 GNUNET_CONTAINER_meta_data_delete (item->meta, 824 GNUNET_CONTAINER_meta_data_delete (item->meta,
822 EXTRACTOR_METATYPE_MIMETYPE, NULL, 0); 825 EXTRACTOR_METATYPE_MIMETYPE, NULL, 0);
823 GNUNET_FS_meta_data_make_directory (item->meta); 826 GNUNET_FS_meta_data_make_directory (item->meta);
824 GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME, 827 if (NULL == item->ksk_uri)
825 GNUNET_NO); 828 item->ksk_uri = GNUNET_FS_uri_ksk_create (GNUNET_FS_DIRECTORY_MIME, NULL);
829 else
830 GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
831 GNUNET_NO);
826 fi = GNUNET_FS_file_information_create_empty_directory ( 832 fi = GNUNET_FS_file_information_create_empty_directory (
827 GNUNET_FS_GTK_get_fs_handle (), row_reference, item->ksk_uri, 833 GNUNET_FS_GTK_get_fs_handle (), row_reference, item->ksk_uri,
828 item->meta, &adcc->directory_scan_bo, item->filename); 834 item->meta, &adcc->directory_scan_bo, item->filename);
@@ -834,8 +840,6 @@ add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
834 item->ksk_uri, item->meta, adcc->directory_scan_do_index, 840 item->ksk_uri, item->meta, adcc->directory_scan_do_index,
835 &adcc->directory_scan_bo); 841 &adcc->directory_scan_bo);
836 } 842 }
837 GNUNET_CONTAINER_meta_data_destroy (item->meta);
838 GNUNET_FS_uri_destroy (item->ksk_uri);
839 if (item->is_directory) 843 if (item->is_directory)
840 file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE); 844 file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE);
841 else 845 else
@@ -850,8 +854,6 @@ add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
850 6, (guint64) adcc->directory_scan_bo.expiration_time.abs_value, 854 6, (guint64) adcc->directory_scan_bo.expiration_time.abs_value,
851 7, (guint) adcc->directory_scan_bo.replication_level, -1); 855 7, (guint) adcc->directory_scan_bo.replication_level, -1);
852 GNUNET_free (file_size_fancy); 856 GNUNET_free (file_size_fancy);
853 GNUNET_free (item->short_filename);
854 GNUNET_free (item->filename);
855} 857}
856 858
857 859
@@ -877,7 +879,7 @@ add_share_items_to_treestore (struct AddDirClientContext *adcc,
877 sibling_iter = &last_added; 879 sibling_iter = &last_added;
878 if (item->is_directory) 880 if (item->is_directory)
879 add_share_items_to_treestore (adcc, 881 add_share_items_to_treestore (adcc,
880 item, 882 item->children_head,
881 sibling_iter); 883 sibling_iter);
882 } 884 }
883} 885}
@@ -929,36 +931,58 @@ directory_scan_cb (void *cls,
929{ 931{
930 struct AddDirClientContext *adcc = cls; 932 struct AddDirClientContext *adcc = cls;
931 char *s; 933 char *s;
934 gdouble fraction;
932 935
933 gtk_progress_bar_pulse (adcc->progress_dialog_bar); 936 gtk_progress_bar_pulse (adcc->progress_dialog_bar);
934 switch (reason) 937 switch (reason)
935 { 938 {
936 case GNUNET_FS_DIRSCANNER_FILE_START: 939 case GNUNET_FS_DIRSCANNER_FILE_START:
937 if (filename != NULL) 940 GNUNET_assert (filename != NULL);
941 if (is_directory)
938 { 942 {
939 if (is_directory) 943 GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
940 GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
941 else
942 GNUNET_asprintf (&s, _("Scanning file `%s'.\n"), filename);
943 insert_progress_dialog_text (adcc, s); 944 insert_progress_dialog_text (adcc, s);
944 GNUNET_free (s); 945 GNUNET_free (s);
945 } 946 }
947 else
948 adcc->total++;
946 break; 949 break;
947 case GNUNET_FS_DIRSCANNER_FILE_IGNORED: 950 case GNUNET_FS_DIRSCANNER_FILE_IGNORED:
948 if (filename != NULL) 951 GNUNET_assert (filename != NULL);
949 { 952 GNUNET_asprintf (&s,
950 GNUNET_asprintf (&s, 953 _("Failed to scan `%s' (access error). Skipping.\n"),
951 _("Failed to scan `%s', because it does not exist.\n"), 954 filename);
952 filename); 955 insert_progress_dialog_text (adcc, s);
953 insert_progress_dialog_text (adcc, s); 956 GNUNET_free (s);
954 GNUNET_free (s);
955 }
956 break; 957 break;
957 case GNUNET_FS_DIRSCANNER_ALL_COUNTED: 958 case GNUNET_FS_DIRSCANNER_ALL_COUNTED:
958 // FIXME... 959 fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
960 GNUNET_asprintf (&s, "%u/%u (%3f%%)",
961 adcc->done,
962 adcc->total,
963 100.0 * fraction);
964 gtk_progress_bar_set_text (adcc->progress_dialog_bar,
965 s);
966 GNUNET_free (s);
967 gtk_progress_bar_set_fraction (adcc->progress_dialog_bar,
968 fraction);
959 break; 969 break;
960 case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: 970 case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED:
961 // FIXME... 971 GNUNET_asprintf (&s, _("Processed file `%s'.\n"), filename);
972 insert_progress_dialog_text (adcc, s);
973 GNUNET_free (s);
974 adcc->done++;
975 GNUNET_assert (adcc->done <= adcc->total);
976 fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
977 GNUNET_asprintf (&s, "%u/%u (%3f%%)",
978 adcc->done,
979 adcc->total,
980 100.0 * fraction);
981 gtk_progress_bar_set_text (adcc->progress_dialog_bar,
982 s);
983 GNUNET_free (s);
984 gtk_progress_bar_set_fraction (adcc->progress_dialog_bar,
985 fraction);
962 break; 986 break;
963 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: 987 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
964 insert_progress_dialog_text (adcc, _("Operation failed (press cancel)\n")); 988 insert_progress_dialog_text (adcc, _("Operation failed (press cancel)\n"));
@@ -1026,6 +1050,7 @@ scan_file_or_directory (struct MainPublishingDialogContext *ctx,
1026 &iter, FALSE); 1050 &iter, FALSE);
1027 1051
1028 gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), adcc->ctx->master_pubdialog); 1052 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);
1029 gtk_window_present (GTK_WINDOW (adcc->progress_dialog)); 1054 gtk_window_present (GTK_WINDOW (adcc->progress_dialog));
1030 1055
1031 update_selectivity (ctx); 1056 update_selectivity (ctx);