aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-vfolder.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-07-15 10:06:46 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-07-15 10:06:46 +0800
commit393fa3c3e84b73dc591fa4481bcf2731dc640157 (patch)
tree3dab076406b9611fd5fa3eb7b77289c99f6136a5 /mail/mail-vfolder.c
parent68ec840bca073bc8e8ea2f58ad36078df9c619c1 (diff)
downloadgsoc2013-evolution-393fa3c3e84b73dc591fa4481bcf2731dc640157.tar.gz
gsoc2013-evolution-393fa3c3e84b73dc591fa4481bcf2731dc640157.tar.zst
gsoc2013-evolution-393fa3c3e84b73dc591fa4481bcf2731dc640157.zip
** fixes for #10781
2002-07-10 Not Zed <NotZed@Ximian.com> ** fixes for #10781 * mail-callbacks.c (filter_edit): Add back a cancel button. We dont need to do anything special to 'undo' here, as the rules are loaded every time they're used. * mail-vfolder.c (vfolder_editor_clicked): If ok wans't clicked, revert the ruleset. (vfolder_editor_destroy): Fake a button of -1 if we get destroyed with no click. (context_rule_removed): Unref the folder after we delete it. If we're the last ref to the folder, unrefing it means it no longer exist,s which means no delte processing occurs ... svn path=/trunk/; revision=17449
Diffstat (limited to 'mail/mail-vfolder.c')
-rw-r--r--mail/mail-vfolder.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 79e7721b61..4e969c3a6c 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -42,7 +42,7 @@
#include "filter/vfolder-context.h"
#include "filter/vfolder-editor.h"
-#define d(x)
+#define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
static VfolderContext *context; /* context remains open all time */
static CamelStore *vfolder_store; /* the 1 static vfolder store */
@@ -340,7 +340,7 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
int found = FALSE;
if (!rule->name) {
- d(printf ("invalid rule (%p): rule->name is set to NULL\n"));
+ d(printf("invalid rule (%p): rule->name is set to NULL\n", rule));
continue;
}
@@ -592,7 +592,7 @@ static void context_rule_added(RuleContext *ctx, FilterRule *rule)
static void context_rule_removed(RuleContext *ctx, FilterRule *rule)
{
char *key, *path;
- CamelFolder *folder;
+ CamelFolder *folder = NULL;
d(printf("rule removed; %s\n", rule->name));
@@ -606,12 +606,13 @@ static void context_rule_removed(RuleContext *ctx, FilterRule *rule)
if (g_hash_table_lookup_extended(vfolder_hash, rule->name, (void **)&key, (void **)&folder)) {
g_hash_table_remove(vfolder_hash, key);
g_free(key);
- UNLOCK();
- camel_object_unref((CamelObject *)folder);
- } else
- UNLOCK();
+ }
+ UNLOCK();
camel_store_delete_folder(vfolder_store, rule->name, NULL);
+ /* this must be unref'd after its deleted */
+ if (folder)
+ camel_object_unref(folder);
}
static void
@@ -743,7 +744,7 @@ vfolder_load_storage(GNOME_Evolution_Shell shell)
if (rule->name)
context_rule_added((RuleContext *)context, rule);
else
- d(printf ("invalid rule (%p) encountered: rule->name is NULL\n"));
+ d(printf("invalid rule (%p) encountered: rule->name is NULL\n", rule));
}
g_free(storeuri);
@@ -752,24 +753,29 @@ vfolder_load_storage(GNOME_Evolution_Shell shell)
static GtkWidget *vfolder_editor = NULL;
static void
-vfolder_editor_destroy (GtkWidget *widget, gpointer user_data)
+vfolder_editor_clicked (GtkWidget *dialog, int button, void *data)
{
+ char *user;
+
+ user = alloca(strlen(evolution_dir)+16);
+ sprintf(user, "%s/vfolders.xml", evolution_dir);
+
+ if (button == 0)
+ rule_context_save ((RuleContext *)context, user);
+ else
+ rule_context_revert ((RuleContext *)context, user);
+
+ if (button != -1)
+ gnome_dialog_close (GNOME_DIALOG (dialog));
+
vfolder_editor = NULL;
}
static void
-vfolder_editor_clicked (GtkWidget *dialog, int button, void *data)
+vfolder_editor_destroy (GtkWidget *widget, gpointer user_data)
{
- if (button == 0) {
- char *user;
-
- user = g_strdup_printf ("%s/vfolders.xml", evolution_dir);
- rule_context_save ((RuleContext *)context, user);
- g_free (user);
- }
- if (button != -1) {
- gnome_dialog_close (GNOME_DIALOG (dialog));
- }
+ if (vfolder_editor)
+ vfolder_editor_clicked(vfolder_editor, -1, user_data);
}
void
@@ -784,6 +790,8 @@ vfolder_edit (void)
gtk_window_set_title (GTK_WINDOW (vfolder_editor), _("vFolders"));
gtk_signal_connect (GTK_OBJECT (vfolder_editor), "clicked", vfolder_editor_clicked, NULL);
gtk_signal_connect (GTK_OBJECT (vfolder_editor), "destroy", vfolder_editor_destroy, NULL);
+ gnome_dialog_append_buttons (GNOME_DIALOG (vfolder_editor), GNOME_STOCK_BUTTON_CANCEL, NULL);
+
gtk_widget_show (vfolder_editor);
}