aboutsummaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorMichael Zucci <zucchi@src.gnome.org>2000-08-09 14:48:39 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-08-09 14:48:39 +0800
commit2f6003c9ed5291b6feb4694bbf5f88084adeded6 (patch)
tree7126cbeb9d60b6549cbe83bf86a4c107266b2496 /filter
parent970050a51ce8ba8acbe23577b45c154cbdb0adf0 (diff)
downloadgsoc2013-evolution-2f6003c9ed5291b6feb4694bbf5f88084adeded6.tar.gz
gsoc2013-evolution-2f6003c9ed5291b6feb4694bbf5f88084adeded6.tar.zst
gsoc2013-evolution-2f6003c9ed5291b6feb4694bbf5f88084adeded6.zip
(rule_context_add_rule_gui): Keep track of context so it isn't freed under us.
svn path=/trunk/; revision=4645
Diffstat (limited to 'filter')
-rw-r--r--filter/ChangeLog10
-rw-r--r--filter/filter-context.c12
-rw-r--r--filter/filter-context.h4
-rw-r--r--filter/rule-context.c40
-rw-r--r--filter/rule-context.h1
5 files changed, 63 insertions, 4 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index f99e3199d4..af6da0e2de 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,13 @@
+2000-08-09 Not Zed <NotZed@HelixCode.com>
+
+ * rule-context.c (rule_context_add_rule_gui): Helper function to
+ add a rule, but present a gui first, asking for confirmation/allow
+ editing.
+ (rule_context_add_rule_gui): Keep track of context so it isn't freed under us.
+
+ * filter-context.c (filter_context_create_action): Implement,
+ helper to aid filter generation.
+
2000-08-03 Ettore Perazzoli <ettore@helixcode.com>
* filter-folder.c (button_clicked): Use the base name of the
diff --git a/filter/filter-context.c b/filter/filter-context.c
index 701010fde9..c31eba205a 100644
--- a/filter/filter-context.c
+++ b/filter/filter-context.c
@@ -126,12 +126,22 @@ void filter_context_add_action(FilterContext *f, FilterPart *action)
f->actions = g_list_append(f->actions, action);
}
-FilterPart *filter_context_find_action(FilterContext *f, char *name)
+FilterPart *filter_context_find_action(FilterContext *f, const char *name)
{
d(printf("find action : "));
return filter_part_find_list(f->actions, name);
}
+FilterPart *filter_context_create_action(FilterContext *f, const char *name)
+{
+ FilterPart *part;
+
+ part = filter_context_find_action(f, name);
+ if (part)
+ part = filter_part_clone(part);
+ return part;
+}
+
FilterPart *filter_context_next_action(FilterContext *f, FilterPart *last)
{
return filter_part_next_list(f->actions, last);
diff --git a/filter/filter-context.h b/filter/filter-context.h
index 57ce961aaf..1fa0b80af7 100644
--- a/filter/filter-context.h
+++ b/filter/filter-context.h
@@ -51,8 +51,8 @@ FilterContext *filter_context_new (void);
/* methods */
void filter_context_add_action(FilterContext *f, FilterPart *action);
-FilterPart *filter_context_find_action(FilterContext *f, char *name);
-/*FilterPart *filter_context_create_action(FilterContext *f, char *name);*/
+FilterPart *filter_context_find_action(FilterContext *f, const char *name);
+FilterPart *filter_context_create_action(FilterContext *f, const char *name);
FilterPart *filter_context_next_action(FilterContext *f, FilterPart *last);
#endif /* ! _FILTER_CONTEXT_H */
diff --git a/filter/rule-context.c b/filter/rule-context.c
index 6d43a99f8c..9621599b0f 100644
--- a/filter/rule-context.c
+++ b/filter/rule-context.c
@@ -155,7 +155,7 @@ void rule_context_add_rule_set(RuleContext *f, const char *setname, int rule_ty
*
* Set the text error for the context, or NULL to clear it.
**/
-void
+static void
rule_context_set_error(RuleContext *f, char *error)
{
g_free(f->error);
@@ -343,6 +343,44 @@ void rule_context_add_rule(RuleContext *f, FilterRule *new)
f->rules = g_list_append(f->rules, new);
}
+static void
+new_rule_clicked(GtkWidget *w, int button, RuleContext *context)
+{
+#warning "Need a changed signal for this to work best"
+ if (button == 0) {
+ FilterRule *rule = gtk_object_get_data((GtkObject *)w, "rule");
+ char *user = gtk_object_get_data((GtkObject *)w, "path");
+
+ gtk_object_ref((GtkObject *)rule);
+ rule_context_add_rule(context, rule);
+ if (user) {
+ rule_context_save((RuleContext *)context, user);
+ }
+ }
+ if (button != -1) {
+ gnome_dialog_close((GnomeDialog *)w);
+ }
+}
+
+/* add a rule, with a gui, asking for confirmation first ... optionally save to path */
+void rule_context_add_rule_gui(RuleContext *f, FilterRule *rule, const char *title, const char *path)
+{
+ GtkWidget *w;
+ GnomeDialog *gd;
+
+ w = filter_rule_get_widget(rule, f);
+ gd = (GnomeDialog *)gnome_dialog_new(title, "Ok", "Cancel", NULL);
+ gtk_box_pack_start((GtkBox *)gd->vbox, w, FALSE, TRUE, 0);
+ gtk_widget_show((GtkWidget *)gd);
+ gtk_object_set_data_full((GtkObject *)gd, "rule", rule, (GtkDestroyNotify)gtk_object_unref);
+ if (path)
+ gtk_object_set_data_full((GtkObject *)gd, "path", g_strdup(path), (GtkDestroyNotify)g_free);
+ gtk_signal_connect((GtkObject *)gd, "clicked", new_rule_clicked, f);
+ gtk_object_ref((GtkObject *)f);
+ gtk_object_set_data_full((GtkObject *)gd, "context", f, (GtkDestroyNotify)gtk_object_unref);
+ gtk_widget_show((GtkWidget *)gd);
+}
+
void rule_context_remove_rule(RuleContext *f, FilterRule *rule)
{
f->rules = g_list_remove(f->rules, rule);
diff --git a/filter/rule-context.h b/filter/rule-context.h
index 6a442d504b..06d32e0be3 100644
--- a/filter/rule-context.h
+++ b/filter/rule-context.h
@@ -96,6 +96,7 @@ FilterPart *rule_context_next_part(RuleContext *f, FilterPart *last);
FilterRule *rule_context_next_rule(RuleContext *f, FilterRule *last);
FilterRule *rule_context_find_rule(RuleContext *f, const char *name);
void rule_context_add_rule(RuleContext *f, FilterRule *new);
+void rule_context_add_rule_gui(RuleContext *f, FilterRule *rule, const char *title, const char *path);
void rule_context_remove_rule(RuleContext *f, FilterRule *rule);
/* get/set the rank (position) of a rule */