Re: [evolution-patches] (Mail) Modified patch for 73341
- From: Not Zed <notzed ximian com>
- To: Madan <madanraj gmail com>
- Cc: evolution-patches lists ximian com
- Subject: Re: [evolution-patches] (Mail) Modified patch for 73341
- Date: Tue, 29 Mar 2005 10:18:37 +0800
On Tue, 2005-03-22 at 19:03 -0800, Madan wrote:
Index: em-folder-view.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v
retrieving revision 1.111
diff -u -p -r1.111 em-folder-view.c
--- em-folder-view.c 17 Mar 2005 02:18:01 -0000 1.111
+++ em-folder-view.c 23 Mar 2005 02:58:40 -0000
@@ -135,6 +135,7 @@ struct _EMFolderViewPrivate {
guint selected_id;
int nomarkseen:1;
int destroyed:1;
+ int event_hooked:1;
GtkWidget *invisible;
char *selection_uri;
@@ -158,6 +159,7 @@ static guint signals[LAST_SIGNAL];
static void emfv_selection_get(GtkWidget *widget, GtkSelectionData *data, guint info, guint time_stamp, EMFolderView *emfv);
static void emfv_selection_clear_event(GtkWidget *widget, GdkEventSelection *event, EMFolderView *emfv);
+static void emfv_change_signal_emit_cb (CamelObject *o, void *event_data, void *data);
static void
emfv_init(GObject *o)
@@ -170,6 +172,7 @@ emfv_init(GObject *o)
p = emfv->priv = g_malloc0(sizeof(struct _EMFolderViewPrivate));
+ p->event_hooked = FALSE;
If you're going to this much trouble to track the hook, then you should save the hook id's explictly, and then unhook using them explicitly as well.
camel_object_hook_event() returns an id, and there's another unhook_event call which removes the even by id.
emfv->statusbar_active = TRUE;
emfv->list_active = FALSE;
@@ -242,6 +245,13 @@ emfv_destroy (GtkObject *o)
}
if (emfv->folder) {
+ if (p->event_hooked) {
+ camel_object_unhook_event (emfv->folder->parent_store, "folder_deleted",
+ (CamelObjectEventHookFunc) emfv_change_signal_emit_cb, emfv);
+ camel_object_unhook_event (emfv->folder->parent_store, "folder_renamed",
+ (CamelObjectEventHookFunc) emfv_change_signal_emit_cb, emfv);
+ p->event_hooked = FALSE;
+ }
camel_object_unref(emfv->folder);
g_free(emfv->folder_uri);
emfv->folder = NULL;
@@ -582,6 +592,15 @@ emfv_set_folder(EMFolderView *emfv, Came
emfv->hide_deleted = emfv->list->hidedeleted; /* <- a bit nasty but makes it track the display better */
mail_sync_folder (emfv->folder, NULL, NULL);
camel_object_unref(emfv->folder);
+
+ if (!emfv->priv->event_hooked) {
+ camel_object_hook_event (emfv->folder->parent_store, "folder_deleted",
+ (CamelObjectEventHookFunc) emfv_change_signal_emit_cb, emfv);
+ camel_object_hook_event (emfv->folder->parent_store, "folder_renamed",
+ (CamelObjectEventHookFunc) emfv_change_signal_emit_cb, emfv);
+ emfv->priv->event_hooked = TRUE;
These events should be on the folder, not the store (there are equivelent, if differently-named events).
+ }
+
}
emfv->folder = folder;
@@ -646,6 +665,13 @@ emfv_selection_clear_event(GtkWidget *wi
#endif
}
+static void
+emfv_change_signal_emit_cb (CamelObject *o, void *event_data, void *data)
+{
+ EMFolderView *emfv = data;
+ g_signal_emit (emfv, signals[EMFV_CHANGED], 0);
+}
+
/* ********************************************************************** */
/* Popup menu
Index: mail-component.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.c,v
retrieving revision 1.110
diff -u -p -r1.110 mail-component.c
--- mail-component.c 17 Mar 2005 01:51:12 -0000 1.110
+++ mail-component.c 23 Mar 2005 02:59:55 -0000
@@ -549,8 +549,16 @@ view_changed_cb(EMFolderView *emfv, EInf
&& (!strcmp (name, "Drafts") || !strcmp (name, "Inbox")
|| !strcmp (name, "Outbox") || !strcmp (name, "Sent")))
e_info_label_set_info(el, _(name), tmp->str);
- else
- e_info_label_set_info(el, name, tmp->str);
+ else {
+ if (!camel_store_get_folder_info (emfv->folder->parent_store, emfv->folder->full_name,
+ CAMEL_STORE_FOLDER_INFO_FAST, NULL) && !CAMEL_IS_VTRASH_FOLDER(emfv->folder)) {
+ /* Folder has been deleted */
+ e_info_label_set_info(el, _("Mail"), "");
Ugh, no, don't do this. Any camel calls like this need to be in another thread, and besides, it is a wildly-inefficient and slow call.
Just check the folder->folder_flags bitfield for CAMEL_FOLDER_HAS_BEEN_DELETED (god, who came up with that naff name).
You should also do this before all the code which actually calculates the string. i.e. in the same code which short-cuts when there is no folder at all.
+ } else {
+ e_info_label_set_info(el, name, tmp->str);
+ }
+ }
+
g_string_free(tmp, TRUE);
camel_object_free(emfv->folder, CAMEL_FOLDER_NAME, name);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]