aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-filter-rule.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/em-filter-rule.c')
-rw-r--r--mail/em-filter-rule.c242
1 files changed, 121 insertions, 121 deletions
diff --git a/mail/em-filter-rule.c b/mail/em-filter-rule.c
index b8ae4d66d7..47faf57c91 100644
--- a/mail/em-filter-rule.c
+++ b/mail/em-filter-rule.c
@@ -35,34 +35,34 @@
#define d(x)
-static gint validate(EFilterRule *fr, EAlert **alert);
-static gint filter_eq(EFilterRule *fr, EFilterRule *cm);
-static xmlNodePtr xml_encode(EFilterRule *fr);
-static gint xml_decode(EFilterRule *fr, xmlNodePtr, ERuleContext *rc);
-static void rule_copy(EFilterRule *dest, EFilterRule *src);
+static gint validate (EFilterRule *fr, EAlert **alert);
+static gint filter_eq (EFilterRule *fr, EFilterRule *cm);
+static xmlNodePtr xml_encode (EFilterRule *fr);
+static gint xml_decode (EFilterRule *fr, xmlNodePtr, ERuleContext *rc);
+static void rule_copy (EFilterRule *dest, EFilterRule *src);
/*static void build_code(EFilterRule *, GString *out);*/
-static GtkWidget *get_widget(EFilterRule *fr, ERuleContext *rc);
+static GtkWidget *get_widget (EFilterRule *fr, ERuleContext *rc);
-static void em_filter_rule_class_init(EMFilterRuleClass *klass);
-static void em_filter_rule_init(EMFilterRule *ff);
-static void em_filter_rule_finalise(GObject *obj);
+static void em_filter_rule_class_init (EMFilterRuleClass *klass);
+static void em_filter_rule_init (EMFilterRule *ff);
+static void em_filter_rule_finalise (GObject *obj);
static EFilterRuleClass *parent_class = NULL;
GType
-em_filter_rule_get_type(void)
+em_filter_rule_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo info = {
- sizeof(EMFilterRuleClass),
+ sizeof (EMFilterRuleClass),
NULL, /* base_class_init */
NULL, /* base_class_finalize */
(GClassInitFunc) em_filter_rule_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof(EMFilterRule),
+ sizeof (EMFilterRule),
0, /* n_preallocs */
(GInstanceInitFunc)em_filter_rule_init,
};
@@ -74,12 +74,12 @@ em_filter_rule_get_type(void)
}
static void
-em_filter_rule_class_init(EMFilterRuleClass *klass)
+em_filter_rule_class_init (EMFilterRuleClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
EFilterRuleClass *fr_class =(EFilterRuleClass *)klass;
- parent_class = g_type_class_ref(E_TYPE_FILTER_RULE);
+ parent_class = g_type_class_ref (E_TYPE_FILTER_RULE);
object_class->finalize = em_filter_rule_finalise;
@@ -94,29 +94,29 @@ em_filter_rule_class_init(EMFilterRuleClass *klass)
}
static void
-em_filter_rule_init(EMFilterRule *ff)
+em_filter_rule_init (EMFilterRule *ff)
{
;
}
static void
-unref_list(GList *l)
+unref_list (GList *l)
{
while (l) {
- g_object_unref(l->data);
+ g_object_unref (l->data);
l = l->next;
}
}
static void
-em_filter_rule_finalise(GObject *obj)
+em_filter_rule_finalise (GObject *obj)
{
EMFilterRule *ff =(EMFilterRule *) obj;
- unref_list(ff->actions);
- g_list_free(ff->actions);
+ unref_list (ff->actions);
+ g_list_free (ff->actions);
- G_OBJECT_CLASS(parent_class)->finalize(obj);
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
/**
@@ -127,58 +127,58 @@ em_filter_rule_finalise(GObject *obj)
* Return value: A new #EMFilterRule object.
**/
EMFilterRule *
-em_filter_rule_new(void)
+em_filter_rule_new (void)
{
- return (EMFilterRule *)g_object_new(em_filter_rule_get_type(), NULL, NULL);
+ return (EMFilterRule *)g_object_new (em_filter_rule_get_type (), NULL, NULL);
}
void
-em_filter_rule_add_action(EMFilterRule *fr, EFilterPart *fp)
+em_filter_rule_add_action (EMFilterRule *fr, EFilterPart *fp)
{
- fr->actions = g_list_append(fr->actions, fp);
+ fr->actions = g_list_append (fr->actions, fp);
- e_filter_rule_emit_changed((EFilterRule *)fr);
+ e_filter_rule_emit_changed ((EFilterRule *)fr);
}
void
-em_filter_rule_remove_action(EMFilterRule *fr, EFilterPart *fp)
+em_filter_rule_remove_action (EMFilterRule *fr, EFilterPart *fp)
{
- fr->actions = g_list_remove(fr->actions, fp);
+ fr->actions = g_list_remove (fr->actions, fp);
- e_filter_rule_emit_changed((EFilterRule *)fr);
+ e_filter_rule_emit_changed ((EFilterRule *)fr);
}
void
-em_filter_rule_replace_action(EMFilterRule *fr, EFilterPart *fp, EFilterPart *new)
+em_filter_rule_replace_action (EMFilterRule *fr, EFilterPart *fp, EFilterPart *new)
{
GList *l;
- l = g_list_find(fr->actions, fp);
+ l = g_list_find (fr->actions, fp);
if (l) {
l->data = new;
} else {
- fr->actions = g_list_append(fr->actions, new);
+ fr->actions = g_list_append (fr->actions, new);
}
- e_filter_rule_emit_changed((EFilterRule *)fr);
+ e_filter_rule_emit_changed ((EFilterRule *)fr);
}
void
-em_filter_rule_build_action(EMFilterRule *fr, GString *out)
+em_filter_rule_build_action (EMFilterRule *fr, GString *out)
{
g_string_append(out, "(begin\n");
- e_filter_part_build_code_list(fr->actions, out);
+ e_filter_part_build_code_list (fr->actions, out);
g_string_append(out, ")\n");
}
static gint
-validate(EFilterRule *fr, EAlert **alert)
+validate (EFilterRule *fr, EAlert **alert)
{
EMFilterRule *ff =(EMFilterRule *)fr;
GList *parts;
gint valid;
- valid = E_FILTER_RULE_CLASS(parent_class)->validate (fr, alert);
+ valid = E_FILTER_RULE_CLASS (parent_class)->validate (fr, alert);
/* validate rule actions */
parts = ff->actions;
@@ -191,14 +191,14 @@ validate(EFilterRule *fr, EAlert **alert)
}
static gint
-list_eq(GList *al, GList *bl)
+list_eq (GList *al, GList *bl)
{
gint truth = TRUE;
while (truth && al && bl) {
EFilterPart *a = al->data, *b = bl->data;
- truth = e_filter_part_eq(a, b);
+ truth = e_filter_part_eq (a, b);
al = al->next;
bl = bl->next;
}
@@ -207,27 +207,27 @@ list_eq(GList *al, GList *bl)
}
static gint
-filter_eq(EFilterRule *fr, EFilterRule *cm)
+filter_eq (EFilterRule *fr, EFilterRule *cm)
{
- return E_FILTER_RULE_CLASS(parent_class)->eq(fr, cm)
- && list_eq(((EMFilterRule *)fr)->actions,((EMFilterRule *)cm)->actions);
+ return E_FILTER_RULE_CLASS (parent_class)->eq (fr, cm)
+ && list_eq (((EMFilterRule *)fr)->actions,((EMFilterRule *)cm)->actions);
}
static xmlNodePtr
-xml_encode(EFilterRule *fr)
+xml_encode (EFilterRule *fr)
{
EMFilterRule *ff =(EMFilterRule *)fr;
xmlNodePtr node, set, work;
GList *l;
- node = E_FILTER_RULE_CLASS(parent_class)->xml_encode(fr);
+ node = E_FILTER_RULE_CLASS (parent_class)->xml_encode (fr);
g_return_val_if_fail (node != NULL, NULL);
set = xmlNewNode(NULL, (const guchar *)"actionset");
- xmlAddChild(node, set);
+ xmlAddChild (node, set);
l = ff->actions;
while (l) {
- work = e_filter_part_xml_encode((EFilterPart *)l->data);
- xmlAddChild(set, work);
+ work = e_filter_part_xml_encode ((EFilterPart *)l->data);
+ xmlAddChild (set, work);
l = l->next;
}
@@ -236,7 +236,7 @@ xml_encode(EFilterRule *fr)
}
static void
-load_set(xmlNodePtr node, EMFilterRule *ff, ERuleContext *rc)
+load_set (xmlNodePtr node, EMFilterRule *ff, ERuleContext *rc)
{
xmlNodePtr work;
gchar *rulename;
@@ -246,15 +246,15 @@ load_set(xmlNodePtr node, EMFilterRule *ff, ERuleContext *rc)
while (work) {
if (!strcmp((gchar *)work->name, "part")) {
rulename = (gchar *)xmlGetProp(work, (const guchar *)"name");
- part = em_filter_context_find_action((EMFilterContext *)rc, rulename);
+ part = em_filter_context_find_action ((EMFilterContext *)rc, rulename);
if (part) {
- part = e_filter_part_clone(part);
- e_filter_part_xml_decode(part, work);
- em_filter_rule_add_action(ff, part);
+ part = e_filter_part_clone (part);
+ e_filter_part_xml_decode (part, work);
+ em_filter_rule_add_action (ff, part);
} else {
g_warning("cannot find rule part '%s'\n", rulename);
}
- xmlFree(rulename);
+ xmlFree (rulename);
} else if (work->type == XML_ELEMENT_NODE) {
g_warning("Unknown xml node in part: %s", work->name);
}
@@ -263,20 +263,20 @@ load_set(xmlNodePtr node, EMFilterRule *ff, ERuleContext *rc)
}
static gint
-xml_decode(EFilterRule *fr, xmlNodePtr node, ERuleContext *rc)
+xml_decode (EFilterRule *fr, xmlNodePtr node, ERuleContext *rc)
{
EMFilterRule *ff =(EMFilterRule *)fr;
xmlNodePtr work;
gint result;
- result = E_FILTER_RULE_CLASS(parent_class)->xml_decode(fr, node, rc);
+ result = E_FILTER_RULE_CLASS (parent_class)->xml_decode (fr, node, rc);
if (result != 0)
return result;
work = node->children;
while (work) {
if (!strcmp((gchar *)work->name, "actionset")) {
- load_set(work, ff, rc);
+ load_set (work, ff, rc);
}
work = work->next;
}
@@ -285,7 +285,7 @@ xml_decode(EFilterRule *fr, xmlNodePtr node, ERuleContext *rc)
}
static void
-rule_copy(EFilterRule *dest, EFilterRule *src)
+rule_copy (EFilterRule *dest, EFilterRule *src)
{
EMFilterRule *fdest, *fsrc;
GList *node;
@@ -294,8 +294,8 @@ rule_copy(EFilterRule *dest, EFilterRule *src)
fsrc =(EMFilterRule *)src;
if (fdest->actions) {
- g_list_foreach(fdest->actions, (GFunc)g_object_unref, NULL);
- g_list_free(fdest->actions);
+ g_list_foreach (fdest->actions, (GFunc)g_object_unref, NULL);
+ g_list_free (fdest->actions);
fdest->actions = NULL;
}
@@ -303,17 +303,17 @@ rule_copy(EFilterRule *dest, EFilterRule *src)
while (node) {
EFilterPart *part = node->data;
- g_object_ref(part);
- fdest->actions = g_list_append(fdest->actions, part);
+ g_object_ref (part);
+ fdest->actions = g_list_append (fdest->actions, part);
node = node->next;
}
- E_FILTER_RULE_CLASS(parent_class)->copy(dest, src);
+ E_FILTER_RULE_CLASS (parent_class)->copy (dest, src);
}
/*static void build_code(EFilterRule *fr, GString *out)
{
- return FILTER_RULE_CLASS(parent_class)->build_code(fr, out);
+ return FILTER_RULE_CLASS (parent_class)->build_code (fr, out);
}*/
struct _part_data {
@@ -360,7 +360,7 @@ part_combobox_changed (GtkComboBox *combobox, struct _part_data *data)
}
static GtkWidget *
-get_rule_part_widget(EMFilterContext *f, EFilterPart *newpart, EFilterRule *fr)
+get_rule_part_widget (EMFilterContext *f, EFilterPart *newpart, EFilterRule *fr)
{
EFilterPart *part = NULL;
GtkWidget *combobox;
@@ -369,25 +369,25 @@ get_rule_part_widget(EMFilterContext *f, EFilterPart *newpart, EFilterRule *fr)
gint index = 0, current = 0;
struct _part_data *data;
- data = g_malloc0(sizeof(*data));
+ data = g_malloc0 (sizeof (*data));
data->fr = fr;
data->f = f;
data->part = newpart;
- hbox = gtk_hbox_new(FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
/* only set to automatically clean up the memory and for less_parts */
g_object_set_data_full ((GObject *) hbox, "data", data, g_free);
- p = e_filter_part_get_widget(newpart);
+ p = e_filter_part_get_widget (newpart);
data->partwidget = p;
data->container = hbox;
combobox = gtk_combo_box_new_text ();
- while ((part = em_filter_context_next_action(f, part))) {
+ while ((part = em_filter_context_next_action (f, part))) {
gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _(part->title));
- if (!strcmp(newpart->title, part->title))
+ if (!strcmp (newpart->title, part->title))
current = index;
index++;
@@ -397,11 +397,11 @@ get_rule_part_widget(EMFilterContext *f, EFilterPart *newpart, EFilterRule *fr)
g_signal_connect (combobox, "changed", G_CALLBACK (part_combobox_changed), data);
gtk_widget_show (combobox);
- gtk_box_pack_start(GTK_BOX(hbox), combobox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, FALSE, 0);
if (p)
- gtk_box_pack_start(GTK_BOX(hbox), p, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), p, TRUE, TRUE, 0);
- gtk_widget_show_all(hbox);
+ gtk_widget_show_all (hbox);
return hbox;
}
@@ -413,7 +413,7 @@ struct _rule_data {
};
static void
-less_parts(GtkWidget *button, struct _rule_data *data)
+less_parts (GtkWidget *button, struct _rule_data *data)
{
EFilterPart *part;
GtkWidget *rule;
@@ -421,7 +421,7 @@ less_parts(GtkWidget *button, struct _rule_data *data)
GList *l;
l =((EMFilterRule *)data->fr)->actions;
- if (g_list_length(l) < 2)
+ if (g_list_length (l) < 2)
return;
rule = g_object_get_data((GObject *)button, "rule");
@@ -432,29 +432,29 @@ less_parts(GtkWidget *button, struct _rule_data *data)
part = part_data->part;
/* remove the part from the list */
- em_filter_rule_remove_action((EMFilterRule *)data->fr, part);
- g_object_unref(part);
+ em_filter_rule_remove_action ((EMFilterRule *)data->fr, part);
+ g_object_unref (part);
/* and from the display */
- gtk_container_remove(GTK_CONTAINER(data->parts), rule);
- gtk_container_remove(GTK_CONTAINER(data->parts), button);
+ gtk_container_remove (GTK_CONTAINER (data->parts), rule);
+ gtk_container_remove (GTK_CONTAINER (data->parts), button);
}
static void
-attach_rule(GtkWidget *rule, struct _rule_data *data, EFilterPart *part, gint row)
+attach_rule (GtkWidget *rule, struct _rule_data *data, EFilterPart *part, gint row)
{
GtkWidget *remove;
- gtk_table_attach(GTK_TABLE(data->parts), rule, 0, 1, row, row + 1,
+ gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1,
GTK_EXPAND | GTK_FILL, 0, 0, 0);
- remove = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
+ remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
g_object_set_data((GObject *)remove, "rule", rule);
/*gtk_button_set_relief(GTK_BUTTON(remove), GTK_RELIEF_NONE);*/
g_signal_connect(remove, "clicked", G_CALLBACK(less_parts), data);
- gtk_table_attach(GTK_TABLE(data->parts), remove, 1, 2, row, row + 1,
+ gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1,
0, 0, 0, 0);
- gtk_widget_show(remove);
+ gtk_widget_show (remove);
}
static void
@@ -472,23 +472,23 @@ do_grab_focus_cb (GtkWidget *widget, gpointer data)
}
static void
-more_parts(GtkWidget *button, struct _rule_data *data)
+more_parts (GtkWidget *button, struct _rule_data *data)
{
EFilterPart *new;
/* create a new rule entry, use the first type of rule */
- new = em_filter_context_next_action((EMFilterContext *)data->f, NULL);
+ new = em_filter_context_next_action ((EMFilterContext *)data->f, NULL);
if (new) {
GtkWidget *w;
guint rows;
- new = e_filter_part_clone(new);
- em_filter_rule_add_action((EMFilterRule *)data->fr, new);
- w = get_rule_part_widget(data->f, new, data->fr);
+ new = e_filter_part_clone (new);
+ em_filter_rule_add_action ((EMFilterRule *)data->fr, new);
+ w = get_rule_part_widget (data->f, new, data->fr);
g_object_get (data->parts, "n-rows", &rows, NULL);
- gtk_table_resize(GTK_TABLE(data->parts), rows + 1, 2);
- attach_rule(w, data, new, rows);
+ gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2);
+ attach_rule (w, data, new, rows);
if (GTK_IS_CONTAINER (w)) {
gboolean done = FALSE;
@@ -514,7 +514,7 @@ more_parts(GtkWidget *button, struct _rule_data *data)
}
static GtkWidget *
-get_widget(EFilterRule *fr, ERuleContext *rc)
+get_widget (EFilterRule *fr, ERuleContext *rc)
{
GtkWidget *widget, *hbox, *add, *label;
GtkWidget *parts, *inframe, *w;
@@ -527,31 +527,31 @@ get_widget(EFilterRule *fr, ERuleContext *rc)
gint rows, i = 0;
gchar *msg;
- widget = E_FILTER_RULE_CLASS(parent_class)->get_widget(fr, rc);
+ widget = E_FILTER_RULE_CLASS (parent_class)->get_widget (fr, rc);
/* and now for the action area */
msg = g_strdup_printf("<b>%s</b>", _("Then"));
- label = gtk_label_new(msg);
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_box_pack_start(GTK_BOX(widget), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
- g_free(msg);
+ label = gtk_label_new (msg);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (widget), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+ g_free (msg);
- hbox = gtk_hbox_new(FALSE, 12);
- gtk_box_pack_start(GTK_BOX(widget), hbox, TRUE, TRUE, 0);
- gtk_widget_show(hbox);
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (widget), hbox, TRUE, TRUE, 0);
+ gtk_widget_show (hbox);
label = gtk_label_new("");
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
- inframe = gtk_vbox_new(FALSE, 6);
- gtk_box_pack_start(GTK_BOX(hbox), inframe, TRUE, TRUE, 0);
+ inframe = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), inframe, TRUE, TRUE, 0);
- rows = g_list_length(ff->actions);
- parts = gtk_table_new(rows, 2, FALSE);
- data = g_malloc0(sizeof(*data));
+ rows = g_list_length (ff->actions);
+ parts = gtk_table_new (rows, 2, FALSE);
+ data = g_malloc0 (sizeof (*data));
data->f =(EMFilterContext *)rc;
data->fr = fr;
data->parts = parts;
@@ -559,41 +559,41 @@ get_widget(EFilterRule *fr, ERuleContext *rc)
/* only set to automatically clean up the memory */
g_object_set_data_full ((GObject *) hbox, "data", data, g_free);
- hbox = gtk_hbox_new(FALSE, 3);
+ hbox = gtk_hbox_new (FALSE, 3);
add = gtk_button_new_with_mnemonic (_("Add Ac_tion"));
gtk_button_set_image (
GTK_BUTTON (add), gtk_image_new_from_stock (
GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON));
g_signal_connect(add, "clicked", G_CALLBACK(more_parts), data);
- gtk_box_pack_start(GTK_BOX(hbox), add, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(inframe), hbox, FALSE, FALSE, 3);
+ gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 3);
l = ff->actions;
while (l) {
part = l->data;
d(printf("adding action %s\n", part->title));
- w = get_rule_part_widget((EMFilterContext *)rc, part, fr);
- attach_rule(w, data, part, i++);
+ w = get_rule_part_widget ((EMFilterContext *)rc, part, fr);
+ attach_rule (w, data, part, i++);
l = l->next;
}
- hadj = gtk_adjustment_new(0.0, 0.0, 1.0, 1.0 ,1.0, 1.0);
- vadj = gtk_adjustment_new(0.0, 0.0, 1.0, 1.0 ,1.0, 1.0);
- scrolledwindow = gtk_scrolled_window_new(GTK_ADJUSTMENT(hadj), GTK_ADJUSTMENT(vadj));
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
+ hadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0);
+ vadj = gtk_adjustment_new (0.0, 0.0, 1.0, 1.0 ,1.0, 1.0);
+ scrolledwindow = gtk_scrolled_window_new (GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj));
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), parts);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow), parts);
- gtk_box_pack_start(GTK_BOX(inframe), scrolledwindow, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (inframe), scrolledwindow, TRUE, TRUE, 0);
/*gtk_box_pack_start(GTK_BOX(inframe), parts, FALSE, FALSE, 3);*/
g_object_set_data (G_OBJECT (add), "scrolled-window", scrolledwindow);
- gtk_widget_show_all(widget);
+ gtk_widget_show_all (widget);
return widget;
}