static void rule_match_recipients (ERuleContext *context, EFilterRule *rule, CamelInternetAddress *iaddr) { EFilterPart *part; EFilterElement *element; gint i; const gchar *real, *addr; gchar *namestr; /* address types etc should handle multiple values */ for (i = 0; camel_internet_address_get (iaddr, i, &real, &addr); i++) { part = e_rule_context_create_part (context, "to"); e_filter_rule_add_part ((EFilterRule *) rule, part); element = e_filter_part_find_element (part, "recipient-type"); e_filter_option_set_current ((EFilterOption *)element, "contains"); element = e_filter_part_find_element (part, "recipient"); e_filter_input_set_value ((EFilterInput *) element, addr); namestr = g_strdup_printf (_("Mail to %s"), real && real[0] ? real : addr); e_filter_rule_set_name (rule, namestr); g_free (namestr); } }
static void rule_add_sender (ERuleContext *context, EFilterRule *rule, const gchar *text) { EFilterPart *part; EFilterElement *element; /* dont match on empty strings ever */ if (*text == 0) return; part = e_rule_context_create_part (context, "sender"); e_filter_rule_add_part ((EFilterRule *) rule, part); element = e_filter_part_find_element (part, "sender-type"); e_filter_option_set_current ((EFilterOption *)element, "contains"); element = e_filter_part_find_element (part, "sender"); e_filter_input_set_value ((EFilterInput *) element, text); }
static void rule_match_mlist (ERuleContext *context, EFilterRule *rule, const gchar *mlist) { EFilterPart *part; EFilterElement *element; if (mlist[0] == 0) return; part = e_rule_context_create_part(context, "mlist"); e_filter_rule_add_part (rule, part); element = e_filter_part_find_element(part, "mlist-type"); e_filter_option_set_current((EFilterOption *)element, "is"); element = e_filter_part_find_element (part, "mlist"); e_filter_input_set_value ((EFilterInput *) element, mlist); }
static GtkWidget * filter_option_get_widget (EFilterElement *element) { EFilterOption *option = E_FILTER_OPTION (element); GtkWidget *combobox; GList *l; struct _filter_option *op; gint index = 0, current = 0; if (option->dynamic_func) { /* it is dynamically filled, thus remove all dynamics * and put there the fresh ones */ GSList *items, *i; GList *old_ops; struct _filter_option *old_cur; old_ops = option->options; old_cur = option->current; /* start with an empty list */ option->current = NULL; option->options = NULL; for (l = option->options; l; l = l->next) { op = l->data; if (op->is_dynamic) { break; } else { e_filter_option_add ( option, op->value, op->title, op->code, op->code_gen_func, FALSE); } } items = filter_option_get_dynamic_options (option); for (i = items; i; i = i->next) { op = i->data; if (op) { e_filter_option_add ( option, op->value, op->title, op->code, op->code_gen_func, TRUE); free_option (op); } } g_slist_free (items); /* maybe some static left after those dynamic, add them too */ for (; l; l = l->next) { op = l->data; if (!op->is_dynamic) e_filter_option_add ( option, op->value, op->title, op->code, op->code_gen_func, FALSE); } if (old_cur) e_filter_option_set_current (option, old_cur->value); /* free old list */ g_list_foreach (old_ops, (GFunc) free_option, NULL); g_list_free (old_ops); } combobox = gtk_combo_box_text_new (); l = option->options; while (l) { op = l->data; gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT (combobox), _(op->title)); if (op == option->current) current = index; l = g_list_next (l); index++; } g_signal_connect ( combobox, "changed", G_CALLBACK (filter_option_combobox_changed), element); gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), current); return combobox; }