diff options
author | Peter Williams <peterw@ximian.com> | 2002-08-17 03:28:54 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2002-08-17 03:28:54 +0800 |
commit | 1cb3f6986b706aef6f508f547f70de1691e5b3bd (patch) | |
tree | c96a638cae70a7e1a7c0c1493e0f1a56f47fe02f /mail/subscribe-dialog.c | |
parent | 6c2e746a7d99f1f1859b07c07eecf476fb5d0831 (diff) | |
download | gsoc2013-evolution-1cb3f6986b706aef6f508f547f70de1691e5b3bd.tar.gz gsoc2013-evolution-1cb3f6986b706aef6f508f547f70de1691e5b3bd.tar.zst gsoc2013-evolution-1cb3f6986b706aef6f508f547f70de1691e5b3bd.zip |
Change this into a GnomeApp so we get a statusbar and the dialog is a
2002-08-09 Peter Williams <peterw@ximian.com>
* subscribe-dialog.c: Change this into a GnomeApp so we get a
statusbar and the dialog is a little more comprehensible.
* subscribe-dialog.c: (struct _FolderETree): Add members for
tracking activity callback information.
(get_short_folderinfo_got): Notify the activity callback.
(subscribe_get_short_folderinfo): Here too.
(folder_etree_init): Initialize the activity level to 0.
(folder_etree_construct): Take new parameters of our activity
callback and user_data.
(folder_etree_new): Here too.
(store_data_get_widget): Take the parameters here and pass them
on.
(sc_close_pressed): New callback for when close button is pressed.
(sc_activity_timeout): New timeout to move the activity bar when
folders are being scanned.
(sc_activity_cb): If activity_level > 0, start the progressbar
moving and set the status.
(menu_item_selected): Pass the callback to store_data_get_widget.
(subscribe_dialog_construct): Load some more widgets and adapt to
some changes in the XML. Also connect the close button signal and
initialize the progress bar's settings.
* mail-callbacks.c (manage_subscriptions): Don't call
gnome_dialog_set_close on it anymore since it's no longer a gnome
dialog.
svn path=/trunk/; revision=17793
Diffstat (limited to 'mail/subscribe-dialog.c')
-rw-r--r-- | mail/subscribe-dialog.c | 112 |
1 files changed, 100 insertions, 12 deletions
diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c index e9c42855c0..7669833e7f 100644 --- a/mail/subscribe-dialog.c +++ b/mail/subscribe-dialog.c @@ -26,6 +26,9 @@ #include <config.h> #endif +#include <libgnomeui/gnome-app.h> +#include <libgnomeui/gnome-appbar.h> + #include <gal/util/e-util.h> #include <gal/widgets/e-unicode.h> @@ -124,6 +127,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 +140,10 @@ struct _FolderETree { EvolutionStorage *e_storage; char *service_name; char *search; + + FolderETreeActivityCallback activity_cb; + gpointer activity_data; + int activity_level; }; struct _FolderETreeClass { @@ -242,6 +251,9 @@ get_short_folderinfo_got (struct _mail_msg *mm) 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 +300,9 @@ subscribe_get_short_folderinfo (FolderETree *ftree, 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 +950,15 @@ folder_etree_init (GtkObject *object) 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 +969,9 @@ folder_etree_construct (FolderETree *ftree, 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 +983,14 @@ E_MAKE_TYPE (folder_etree, "FolderETree", FolderETree, folder_etree_class_init, /* 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 +1193,9 @@ sd_toggle_cb (ETree *tree, int row, ETreePath path, int col, GdkEvent *event, gp } static GtkWidget * -store_data_get_widget (StoreData *sd) +store_data_get_widget (StoreData *sd, + FolderETreeActivityCallback activity_cb, + gpointer activity_data) { GtkWidget *tree; @@ -1181,7 +1207,7 @@ store_data_get_widget (StoreData *sd) 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, @@ -1292,7 +1318,11 @@ struct _SubscribeDialogPrivate { GtkWidget *search_entry; GtkWidget *hbox; GtkWidget *filter_radio, *all_radio; - GtkWidget *sub_button, *unsub_button, *refresh_button; + GtkWidget *sub_button, *unsub_button, *refresh_button, *close_button; + GtkWidget *progress; + GtkWidget *appbar; + + guint activity_timeout_id; }; static GtkObjectClass *subscribe_dialog_parent_class; @@ -1321,6 +1351,14 @@ sc_search_activated (GtkWidget *widget, gpointer user_data) } static void +sc_close_pressed (GtkWidget *widget, gpointer user_data) +{ + SubscribeDialog *sc = SUBSCRIBE_DIALOG (user_data); + + gtk_widget_destroy (GTK_WIDGET (sc->app)); +} + +static void sc_subscribe_pressed (GtkWidget *widget, gpointer user_data) { SubscribeDialog *sc = SUBSCRIBE_DIALOG (user_data); @@ -1416,6 +1454,43 @@ sc_selection_changed (GtkObject *obj, gpointer user_data) 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); + gnome_appbar_set_status (GNOME_APPBAR (sc->priv->appbar), _("Scanning folders...")); + } else { + if (sc->priv->activity_timeout_id) { + gtk_timeout_remove (sc->priv->activity_timeout_id); + sc->priv->activity_timeout_id = 0; + } + + gnome_appbar_set_status (GNOME_APPBAR (sc->priv->appbar), ""); + } +} + static void menu_item_selected (GtkMenuItem *item, gpointer user_data) { @@ -1429,7 +1504,7 @@ menu_item_selected (GtkMenuItem *item, gpointer user_data) 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 +1605,10 @@ subscribe_dialog_destroy (GtkObject *object) 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; @@ -1589,17 +1667,21 @@ subscribe_dialog_construct (GtkObject *object) SubscribeDialog *sc = SUBSCRIBE_DIALOG (object); /* Load the XML */ - sc->priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/subscribe-dialog.glade", NULL); + /* "app2" */ + sc->priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/subscribe-dialog.glade", "app"); - sc->app = glade_xml_get_widget (sc->priv->xml, "Manage Subscriptions"); + sc->app = glade_xml_get_widget (sc->priv->xml, "app"); sc->priv->hbox = glade_xml_get_widget (sc->priv->xml, "tree_box"); sc->priv->search_entry = glade_xml_get_widget (sc->priv->xml, "search_entry"); sc->priv->filter_radio = glade_xml_get_widget (sc->priv->xml, "filter_radio"); sc->priv->all_radio = glade_xml_get_widget (sc->priv->xml, "all_radio"); + sc->priv->close_button = glade_xml_get_widget (sc->priv->xml, "close_button"); 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->appbar = GNOME_APP (sc->app)->statusbar; + sc->priv->progress = GTK_WIDGET (gnome_appbar_get_progress (GNOME_APPBAR (sc->priv->appbar))); + /* create default view */ sc->priv->default_widget = sc_create_default_widget(); sc->priv->current_widget = sc->priv->default_widget; @@ -1615,12 +1697,18 @@ subscribe_dialog_construct (GtkObject *object) /* hook up some signals */ gtk_signal_connect (GTK_OBJECT (sc->priv->search_entry), "activate", sc_search_activated, sc); + gtk_signal_connect (GTK_OBJECT (sc->priv->close_button), "clicked", sc_close_pressed, sc); gtk_signal_connect (GTK_OBJECT (sc->priv->sub_button), "clicked", sc_subscribe_pressed, sc); gtk_signal_connect (GTK_OBJECT (sc->priv->unsub_button), "clicked", sc_unsubscribe_pressed, sc); 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), 10); + /* Get the list of stores */ populate_store_list (sc); } |