[anjal] Safely handle MailViewChild's uri, when a folder is renamed. Update URI,
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Safely handle MailViewChild's uri, when a folder is renamed. Update URI,
- Date: Fri, 26 Jun 2009 03:47:32 +0000 (UTC)
commit ab8061239b757a430a477567c5e0004c9de17d69
Author: Srinivasa Ragavan <sragavan novell com>
Date: Fri Jun 26 08:36:21 2009 +0530
Safely handle MailViewChild's uri, when a folder is renamed. Update URI,
so that it is selected and update label.
src/mail-folder-view.c | 37 ++++++++++++++++++++++++++++++++++---
1 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 0a6a79f..c5c6f2f 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -72,6 +72,8 @@ struct _MailFolderViewPrivate {
GtkWidget *info_spinner;
CamelOperation *cancel;
GtkCellRenderer *from_to;
+
+ char *folder_name;
};
enum {
@@ -88,6 +90,9 @@ static void mfv_message_activated (GtkTreeView *tree_view, GtkTreePath
static void mfv_delete (MailFolderView *mfv, gboolean del);
static void mfv_read (MailFolderView *mfv, gboolean del);
static void mfv_junk (MailFolderView *mfv, gboolean junk);
+static void mfv_folder_renamed (CamelStore *store, void *event, void *data);
+
+
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (MailFolderView, mail_folder_view, GTK_TYPE_VBOX)
@@ -264,6 +269,9 @@ mail_folder_view_finalize (GObject *object)
{
MailFolderView *mfv = (MailFolderView *)object;
+ if (mfv->priv->folder_name)
+ g_free (mfv->priv->folder_name);
+
if (mfv->priv->cancel) {
camel_operation_cancel(mfv->priv->cancel);
}
@@ -274,7 +282,11 @@ mail_folder_view_finalize (GObject *object)
if (mfv->search_str) {
g_free(mfv->search_str);
mfv->search_str = NULL;
- }
+ }
+
+ if (mfv->priv->folder->parent_store)
+ camel_object_unhook_event (mfv->priv->folder->parent_store, "folder_renamed", (CamelObjectEventHookFunc)mfv_folder_renamed, mfv);
+
if (mfv->priv->folder) {
camel_object_unref (mfv->priv->folder);
}
@@ -423,6 +435,21 @@ mail_folder_view_set_folder_uri (MailFolderView *mfv, const char *uri)
}
}
+static void
+mfv_folder_renamed (CamelStore *store, void *event, void *data)
+{
+ MailFolderView *mfv = (MailFolderView *)data;
+ CamelRenameInfo *info = (CamelRenameInfo *)event;
+ if (g_strcmp0(info->old_base, mfv->priv->folder_name) == 0){
+ /* Folder renamed. Revamp the uri.*/
+ g_free(mfv->uri);
+ g_free(mfv->priv->folder_name);
+ mfv->uri = g_strdup(info->new->uri);
+ mfv->priv->folder_name = g_strdup (info->new->full_name);
+ gtk_label_set_text ((GtkLabel *)mfv->priv->tab_str, info->new->full_name);
+ }
+}
+
void
mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const char *uri)
{
@@ -445,12 +472,16 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
double pos = 0;
GtkTreeIter iter;
gboolean outgoing = FALSE;
-
+
if (em_utils_folder_is_drafts(folder, uri)
|| em_utils_folder_is_sent(folder, uri)
|| em_utils_folder_is_outbox(folder, uri))
outgoing = TRUE;
-
+ if (mfv->priv->folder_name)
+ g_free (mfv->priv->folder_name);
+ mfv->priv->folder_name = g_strdup(folder->full_name);
+ if (folder->parent_store)
+ camel_object_hook_event (folder->parent_store, "folder_renamed", (CamelObjectEventHookFunc)mfv_folder_renamed, mfv);
if (outgoing) {
if (mfv->priv->light)
g_object_set_data ((GObject *)mfv->priv->from_to, "data", GINT_TO_POINTER (COL_FROM)); /* Implement TO */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]