Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2313
diff -u -r1.2313 ChangeLog
--- ChangeLog	1 Aug 2002 21:28:52 -0000	1.2313
+++ ChangeLog	2 Aug 2002 19:40:44 -0000
@@ -1,3 +1,29 @@
+2002-08-02  Peter Williams  <peterw@ximian.com>
+
+	* subscribe-dialog.c (struct _FolderETree): Add members for
+	keeping track of activity state.
+	(get_short_folderinfo_got): Notify with the new activity level.
+	(subscribe_get_short_folderinfo): Here too.
+	(folder_etree_init): Initialize activity_level to 0;
+	(folder_etree_construct): Take the callback and its closure as
+	arguments.
+	(folder_etree_new): Here too.
+	(store_data_get_widget): Here too, and pass them on.
+	(struct _SubscribeDialogPrivate): Save the id of our activity
+	timeout.
+	(sc_activity_timeout): New function, called when we're getting
+	folderinfo to get the progress bar to update.
+	(sc_activity_cb): New function, called when the activity level
+	changes.  Either enter or exit activity mode.
+	(menu_item_selected): Pass sc_activity_cb as the callback to
+	store_data_get_widget.
+	(subscribe_dialog_destroy): Remove the activity timeout if
+	necessary.
+	(subscribe_dialog_construct): Setup some parameters on the
+	progress bar.
+
+	* subscribe-dialog.glade: Add the progress bar at the bottom.
+	
 2002-08-01  Ettore Perazzoli  <ettore@ximian.com>
 
 	* component-factory.c (create_component): Use
Index: subscribe-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/subscribe-dialog.c,v
retrieving revision 1.73
diff -u -r1.73 subscribe-dialog.c
--- subscribe-dialog.c	1 Aug 2002 15:52:38 -0000	1.73
+++ subscribe-dialog.c	2 Aug 2002 19:40:44 -0000
@@ -124,6 +124,8 @@
 typedef struct _FolderETree              FolderETree;
 typedef struct _FolderETreeClass         FolderETreeClass;
 
+typedef void (*FolderETreeActivityCallback) (int level, gpointer user_data);
+
 struct _FolderETree {
 	ETreeMemory parent;
 	ETreePath root;
@@ -135,6 +137,10 @@
 	EvolutionStorage *e_storage;
 	char *service_name;
 	char *search;
+
+	FolderETreeActivityCallback activity_cb;
+	gpointer activity_data;
+	int activity_level;
 };
 
 struct _FolderETreeClass {
@@ -242,6 +248,9 @@
 			   camel_service_get_url (CAMEL_SERVICE (m->ftree->store)),
 			   camel_exception_get_description (&mm->ex));
 
+	m->ftree->activity_level--;
+	(m->ftree->activity_cb) (m->ftree->activity_level, m->ftree->activity_data);
+
 	/* 'done' is probably guaranteed to fail, but... */
 
 	if (m->func)
@@ -288,6 +297,9 @@
 	m->func = func;
 	m->user_data = user_data;
 
+	ftree->activity_level++;
+	(ftree->activity_cb) (ftree->activity_level, ftree->activity_data);
+
 	id = m->msg.seq;
 	e_thread_put (mail_thread_queued, (EMsg *)m);
 	return id;
@@ -935,11 +947,15 @@
 	ftree->subscribe_ops = g_hash_table_new (g_direct_hash, g_direct_equal);
 
 	ftree->search = g_strdup ("");
+
+	ftree->activity_level = 0;
 }
 
 static FolderETree *
 folder_etree_construct (FolderETree *ftree,
-			CamelStore  *store)
+			CamelStore  *store,
+			FolderETreeActivityCallback activity_cb,
+			gpointer                    activity_data)
 {
 	e_tree_memory_construct (E_TREE_MEMORY (ftree));
 	
@@ -950,6 +966,9 @@
 	
 	ftree->e_storage = mail_lookup_storage (store); /* this gives us a ref */
 
+	ftree->activity_cb = activity_cb;
+	ftree->activity_data = activity_data;
+
 	fe_create_root_node (ftree);
 
 	return ftree;
@@ -961,12 +980,14 @@
 /* public */
 
 static FolderETree *
-folder_etree_new (CamelStore *store)
+folder_etree_new (CamelStore *store,
+		  FolderETreeActivityCallback activity_cb,
+		  gpointer                    activity_data)
 {
 	FolderETree *ftree;
 
 	ftree = gtk_type_new (folder_etree_get_type());
-	ftree = folder_etree_construct (ftree, store);
+	ftree = folder_etree_construct (ftree, store, activity_cb, activity_data);
 	return ftree;
 }
 
@@ -1169,7 +1190,9 @@
 }
 
 static GtkWidget *
-store_data_get_widget (StoreData *sd)
+store_data_get_widget (StoreData *sd, 
+		       FolderETreeActivityCallback activity_cb,
+		       gpointer                    activity_data)
 {
 	GtkWidget *tree;
 
@@ -1181,7 +1204,7 @@
 	if (sd->widget)
 		return sd->widget;
 
-	sd->ftree = folder_etree_new (sd->store);
+	sd->ftree = folder_etree_new (sd->store, activity_cb, activity_data);
 
 	/* You annoy me, etree! */
 	tree = gtk_widget_new (E_TREE_SCROLLED_TYPE,
@@ -1293,6 +1316,9 @@
 	GtkWidget *hbox;
 	GtkWidget *filter_radio, *all_radio;
 	GtkWidget *sub_button, *unsub_button, *refresh_button;
+	GtkWidget *progress;
+
+	guint activity_timeout_id;
 };
 
 static GtkObjectClass *subscribe_dialog_parent_class;
@@ -1416,6 +1442,40 @@
 	gtk_widget_set_sensitive (sc->priv->unsub_button, sensitive);
 }
 
+static gint
+sc_activity_timeout (SubscribeDialog *sc)
+{
+	GtkAdjustment *adj;
+	gfloat next;
+
+	adj = GTK_PROGRESS (sc->priv->progress)->adjustment;
+	next = adj->value + 1;
+	if (next > adj->upper)
+		next = adj->lower;
+
+	gtk_progress_set_value (GTK_PROGRESS (sc->priv->progress), next);
+	return TRUE;
+}
+
+static void
+sc_activity_cb (int level, SubscribeDialog *sc)
+{
+	g_assert (pthread_self() == mail_gui_thread);
+
+	if (level) {
+		if (sc->priv->activity_timeout_id)
+			return;
+
+		sc->priv->activity_timeout_id = gtk_timeout_add (50, (GtkFunction) 
+								 sc_activity_timeout, sc);
+		gtk_progress_bar_set_activity_blocks (GTK_PROGRESS_BAR (sc->priv->progress), 10);
+	} else if (sc->priv->activity_timeout_id) {
+		gtk_timeout_remove (sc->priv->activity_timeout_id);
+		sc->priv->activity_timeout_id = 0;
+		gtk_progress_bar_set_activity_blocks (GTK_PROGRESS_BAR (sc->priv->progress), 0);
+	}
+}
+
 static void
 menu_item_selected (GtkMenuItem *item, gpointer user_data)
 {
@@ -1429,7 +1489,7 @@
 		ESelectionModel *esm;
 		ETree *tree;
 
-		widget = store_data_get_widget (sd);
+		widget = store_data_get_widget (sd, (FolderETreeActivityCallback) sc_activity_cb, sc);
 		gtk_box_pack_start (GTK_BOX (sc->priv->hbox), widget, TRUE, TRUE, 0);
 
 		tree = e_tree_scrolled_get_tree (E_TREE_SCROLLED (widget));
@@ -1530,7 +1590,10 @@
 	GList *iter;
 	
 	sc = SUBSCRIBE_DIALOG (object);
-	
+
+	if (sc->priv->activity_timeout_id)
+		gtk_timeout_remove (sc->priv->activity_timeout_id);
+
 	for (iter = sc->priv->store_list; iter; iter = iter->next) {
 		StoreData *data = iter->data;
 		
@@ -1599,7 +1662,8 @@
 	sc->priv->sub_button     = glade_xml_get_widget (sc->priv->xml, "subscribe_button");
 	sc->priv->unsub_button   = glade_xml_get_widget (sc->priv->xml, "unsubscribe_button");
 	sc->priv->refresh_button = glade_xml_get_widget (sc->priv->xml, "refresh_button");
-	
+	sc->priv->progress       = glade_xml_get_widget (sc->priv->xml, "progress");
+
 	/* create default view */
 	sc->priv->default_widget = sc_create_default_widget();
 	sc->priv->current_widget = sc->priv->default_widget;
@@ -1620,7 +1684,12 @@
 	gtk_signal_connect (GTK_OBJECT (sc->priv->refresh_button), "clicked", sc_refresh_pressed, sc);
 	gtk_signal_connect (GTK_OBJECT (sc->priv->all_radio), "toggled", sc_all_toggled, sc);
 	gtk_signal_connect (GTK_OBJECT (sc->priv->filter_radio), "toggled", sc_filter_toggled, sc);
-	
+
+	/* progress */
+	gtk_progress_set_activity_mode (GTK_PROGRESS (sc->priv->progress), 1);
+	gtk_progress_bar_set_activity_step (GTK_PROGRESS_BAR (sc->priv->progress), 5);
+	gtk_progress_bar_set_activity_blocks (GTK_PROGRESS_BAR (sc->priv->progress), 0);
+
 	/* Get the list of stores */
 	populate_store_list (sc);
 }
Index: subscribe-dialog.glade
===================================================================
RCS file: /cvs/gnome/evolution/mail/subscribe-dialog.glade,v
retrieving revision 1.4
diff -u -r1.4 subscribe-dialog.glade
--- subscribe-dialog.glade	6 Aug 2001 19:02:00 -0000	1.4
+++ subscribe-dialog.glade	2 Aug 2002 19:40:44 -0000
@@ -320,6 +320,26 @@
 	</widget>
       </widget>
     </widget>
+
+    <widget>
+      <class>GtkProgressBar</class>
+      <name>progress</name>
+      <value>0</value>
+      <lower>0</lower>
+      <upper>100</upper>
+      <bar_style>GTK_PROGRESS_CONTINUOUS</bar_style>
+      <orientation>GTK_PROGRESS_LEFT_TO_RIGHT</orientation>
+      <activity_mode>False</activity_mode>
+      <show_text>False</show_text>
+      <format>%P %%</format>
+      <text_xalign>0.5</text_xalign>
+      <text_yalign>0.5</text_yalign>
+      <child>
+	<padding>0</padding>
+	<expand>False</expand>
+	<fill>False</fill>
+      </child>
+    </widget>
   </widget>
 </widget>
 
