aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-10-31 07:17:04 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-10-31 07:17:04 +0800
commit4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa (patch)
treed5937eeed6b6098bfd40d737e6d8a3f4759427e8
parentdd76f4c007ae749393c702a3d8b4555ec36711d3 (diff)
downloadgsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.tar
gsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.tar.gz
gsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.tar.bz2
gsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.tar.lz
gsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.tar.xz
gsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.tar.zst
gsoc2013-evolution-4ac107769e4ac89e0b9595a6ed7a9539f4ef64fa.zip
Pure formatting changes, no actual code changes. Since I know I'm going to
2000-10-30 Jeffrey Stedfast <fejj@helixcode.com> * filter-input.c: * filter-option.c: * filter-part.c: Pure formatting changes, no actual code changes. Since I know I'm going to get flamed for this, I'm sorry but I'll probably have to modify code in these files and it's easier if the code is quickly readable by me. * filter-rule.c (get_widget): Set the "remove" button insensitive for <= 1 instead of == 1. svn path=/trunk/; revision=6283
-rw-r--r--filter/ChangeLog12
-rw-r--r--filter/filter-input.c116
-rw-r--r--filter/filter-option.c195
-rw-r--r--filter/filter-part.c243
-rw-r--r--filter/filter-rule.c4
-rw-r--r--filter/filtertypes.xml5
6 files changed, 316 insertions, 259 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 24fbbef29d..a43dce3f0d 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,15 @@
+2000-10-30 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * filter-input.c:
+ * filter-option.c:
+ * filter-part.c: Pure formatting changes, no actual code
+ changes. Since I know I'm going to get flamed for this, I'm sorry
+ but I'll probably have to modify code in these files and it's
+ easier if the code is quickly readable by me.
+
+ * filter-rule.c (get_widget): Set the "remove" button insensitive
+ for <= 1 instead of == 1.
+
2000-10-28 Jeffrey Stedfast <fejj@helixcode.com>
* filter-driver.c (filter_driver_filter_message): Copy the message
diff --git a/filter/filter-input.c b/filter/filter-input.c
index fc82622391..2ef4327c33 100644
--- a/filter/filter-input.c
+++ b/filter/filter-input.c
@@ -122,22 +122,24 @@ filter_input_finalise(GtkObject *obj)
* Return value: A new #FilterInput object.
**/
FilterInput *
-filter_input_new(void)
+filter_input_new (void)
{
FilterInput *o = (FilterInput *)gtk_type_new(filter_input_get_type ());
return o;
}
-FilterInput *filter_input_new_type_name (const char *type)
+FilterInput *
+filter_input_new_type_name (const char *type)
{
FilterInput *o = filter_input_new();
o->type = g_strdup(type);
-
+
d(printf("new type %s = %p\n", type, o));
return o;
}
-void filter_input_set_value(FilterInput *fi, const char *value)
+void
+filter_input_set_value (FilterInput *fi, const char *value)
{
GList *l;
@@ -151,112 +153,124 @@ void filter_input_set_value(FilterInput *fi, const char *value)
fi->values = g_list_append(NULL, g_strdup(value));
}
-static void xml_create(FilterElement *fe, xmlNodePtr node)
+static void
+xml_create (FilterElement *fe, xmlNodePtr node)
{
/* parent implementation */
((FilterElementClass *)(parent_class))->xml_create(fe, node);
}
-static xmlNodePtr xml_encode(FilterElement *fe)
+static xmlNodePtr
+xml_encode (FilterElement *fe)
{
xmlNodePtr value;
GList *l;
FilterInput *fi = (FilterInput *)fe;
char *type;
-
- type = fi->type?fi->type:"string";
-
- d(printf("Encoding %s as xml\n", type));
-
- value = xmlNewNode(NULL, "value");
- xmlSetProp(value, "name", fe->name);
- xmlSetProp(value, "type", type);
+
+ type = fi->type ? fi->type : "string";
+
+ d(printf ("Encoding %s as xml\n", type));
+
+ value = xmlNewNode (NULL, "value");
+ xmlSetProp (value, "name", fe->name);
+ xmlSetProp (value, "type", type);
l = fi->values;
while (l) {
xmlNodePtr cur;
char *str = l->data;
-
- cur = xmlNewChild(value, NULL, type, NULL);
- xmlNodeSetContent(cur, str);
- l = g_list_next(l);
+
+ cur = xmlNewChild (value, NULL, type, NULL);
+ xmlNodeSetContent (cur, str);
+ l = g_list_next (l);
}
+
return value;
}
-static int xml_decode(FilterElement *fe, xmlNodePtr node)
+static int
+xml_decode (FilterElement *fe, xmlNodePtr node)
{
FilterInput *fi = (FilterInput *)fe;
char *name, *str, *type;
xmlNodePtr n;
-
- type = fi->type?fi->type:"string";
-
+
+ type = fi->type ? fi->type : "string";
+
d(printf("Decoding %s from xml %p\n", type, fe));
-
- name = xmlGetProp(node, "name");
- d(printf("Name = %s\n", name));
+
+ name = xmlGetProp (node, "name");
+ d(printf ("Name = %s\n", name));
fe->name = name;
- fi->type = xmlGetProp(node, "type");
+ fi->type = xmlGetProp (node, "type");
n = node->childs;
while (n) {
- if (!strcmp(n->name, type)) {
- str = xmlNodeGetContent(n);
- d(printf(" '%s'\n", str));
- fi->values = g_list_append(fi->values, str);
+ if (!strcmp (n->name, type)) {
+ str = xmlNodeGetContent (n);
+ d(printf (" '%s'\n", str));
+ fi->values = g_list_append (fi->values, str);
} else {
- g_warning("Unknown node type '%s' encountered decoding a %s\n", n->name, type);
+ g_warning ("Unknown node type '%s' encountered decoding a %s\n", n->name, type);
}
n = n->next;
}
+
return 0;
}
-static void entry_changed(GtkEntry *entry, FilterElement *fe)
+static void
+entry_changed (GtkEntry *entry, FilterElement *fe)
{
char *new;
FilterInput *fi = (FilterInput *)fe;
GList *l;
-
+
new = e_utf8_gtk_entry_get_text(entry);
-
+
/* NOTE: entry only supports a single value ... */
l = fi->values;
while (l) {
- g_free(l->data);
- l = g_list_next(l);
+ g_free (l->data);
+ l = g_list_next (l);
}
- g_list_free(fi->values);
-
- fi->values = g_list_append(NULL, new);
+
+ g_list_free (fi->values);
+
+ fi->values = g_list_append (NULL, new);
}
-static GtkWidget *get_widget(FilterElement *fe)
+static GtkWidget *
+get_widget (FilterElement *fe)
{
- GtkEntry *entry;
+ GtkWidget *entry;
FilterInput *fi = (FilterInput *)fe;
-
- entry = (GtkEntry *)gtk_entry_new();
+
+ entry = gtk_entry_new ();
if (fi->values && fi->values->data) {
- e_utf8_gtk_entry_set_text(entry, fi->values->data);
+ e_utf8_gtk_entry_set_text (GTK_ENTRY (entry), fi->values->data);
}
- gtk_signal_connect((GtkObject *)entry, "changed", entry_changed, fe);
- return (GtkWidget *)entry;
+
+ gtk_signal_connect (GTK_OBJECT (entry), "changed", entry_changed, fe);
+
+ return entry;
}
-static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff)
+static void
+build_code (FilterElement *fe, GString *out, struct _FilterPart *ff)
{
return;
}
-static void format_sexp(FilterElement *fe, GString *out)
+static void
+format_sexp (FilterElement *fe, GString *out)
{
GList *l;
FilterInput *fi = (FilterInput *)fe;
-
+
l = fi->values;
while (l) {
- e_sexp_encode_string(out, l->data);
- l = g_list_next(l);
+ e_sexp_encode_string (out, l->data);
+ l = g_list_next (l);
}
}
diff --git a/filter/filter-option.c b/filter/filter-option.c
index 28b7f88850..10ac977a1d 100644
--- a/filter/filter-option.c
+++ b/filter/filter-option.c
@@ -70,7 +70,7 @@ filter_option_get_type (void)
(GtkArgGetFunc)NULL
};
- type = gtk_type_unique(filter_element_get_type (), &type_info);
+ type = gtk_type_unique (filter_element_get_type (), &type_info);
}
return type;
@@ -81,12 +81,12 @@ filter_option_class_init (FilterOptionClass *class)
{
GtkObjectClass *object_class;
FilterElementClass *filter_element = (FilterElementClass *)class;
-
+
object_class = (GtkObjectClass *)class;
parent_class = gtk_type_class(filter_element_get_type ());
object_class->finalize = filter_option_finalise;
-
+
/* override methods */
filter_element->xml_create = xml_create;
filter_element->xml_encode = xml_encode;
@@ -95,25 +95,25 @@ filter_option_class_init (FilterOptionClass *class)
filter_element->get_widget = get_widget;
filter_element->build_code = build_code;
filter_element->format_sexp = format_sexp;
-
+
/* signals */
-
+
gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL);
}
static void
filter_option_init (FilterOption *o)
{
- o->priv = g_malloc0(sizeof(*o->priv));
+ o->priv = g_malloc0 (sizeof (*o->priv));
}
static void
-filter_option_finalise(GtkObject *obj)
+filter_option_finalise (GtkObject *obj)
{
FilterOption *o = (FilterOption *)obj;
-
+
o = o;
-
+
((GtkObjectClass *)(parent_class))->finalize(obj);
}
@@ -125,188 +125,201 @@ filter_option_finalise(GtkObject *obj)
* Return value: A new #FilterOption object.
**/
FilterOption *
-filter_option_new(void)
+filter_option_new (void)
{
- FilterOption *o = (FilterOption *)gtk_type_new(filter_option_get_type ());
+ FilterOption *o = (FilterOption *)gtk_type_new (filter_option_get_type ());
return o;
}
static struct _filter_option *
-find_option(FilterOption *fo, const char *name)
+find_option (FilterOption *fo, const char *name)
{
GList *l = fo->options;
struct _filter_option *op;
-
+
while (l) {
op = l->data;
- if (!strcmp(name, op->value)) {
+ if (!strcmp (name, op->value)) {
return op;
}
- l = g_list_next(l);
+ l = g_list_next (l);
}
+
return NULL;
}
-void filter_option_set_current(FilterOption *option, const char *name)
+void
+filter_option_set_current (FilterOption *option, const char *name)
{
g_assert(IS_FILTER_OPTION(option));
-
- option->current = find_option(option, name);
+
+ option->current = find_option (option, name);
}
-static void xml_create(FilterElement *fe, xmlNodePtr node)
+static void
+xml_create (FilterElement *fe, xmlNodePtr node)
{
FilterOption *fo = (FilterOption *)fe;
xmlNodePtr n, work;
struct _filter_option *op;
-
+
/* parent implementation */
((FilterElementClass *)(parent_class))->xml_create(fe, node);
-
+
n = node->childs;
while (n) {
- if (!strcmp(n->name, "option")) {
- op = g_malloc0(sizeof(*op));
- op->value = xmlGetProp(n, "value");
+ if (!strcmp (n->name, "option")) {
+ op = g_malloc0 (sizeof (*op));
+ op->value = xmlGetProp (n, "value");
work = n->childs;
while (work) {
- if (!strcmp(work->name, "title")) {
+ if (!strcmp (work->name, "title")) {
if (!op->title) {
- op->title = xmlNodeGetContent(work);
+ op->title = xmlNodeGetContent (work);
}
- } else if (!strcmp(work->name, "code")) {
+ } else if (!strcmp (work->name, "code")) {
if (!op->code) {
- op->code = xmlNodeGetContent(work);
+ op->code = xmlNodeGetContent (work);
}
}
work = work->next;
}
- d(printf("creating new option:\n title %s\n value %s\n code %s\n", op->title, op->value, op->code));
- fo->options = g_list_append(fo->options, op);
+ d(printf ("creating new option:\n title %s\n value %s\n code %s\n",
+ op->title, op->value, op->code));
+ fo->options = g_list_append (fo->options, op);
if (fo->current == NULL)
fo->current = op;
} else {
- g_warning("Unknown xml node within optionlist: %s\n", n->name);
+ g_warning ("Unknown xml node within optionlist: %s\n", n->name);
}
n = n->next;
}
}
-static xmlNodePtr xml_encode(FilterElement *fe)
+static xmlNodePtr
+xml_encode (FilterElement *fe)
{
xmlNodePtr value;
FilterOption *fo = (FilterOption *)fe;
-
- d(printf("Encoding option as xml\n"));
- value = xmlNewNode(NULL, "value");
- xmlSetProp(value, "name", fe->name);
- xmlSetProp(value, "type", "option");
+
+ d(printf ("Encoding option as xml\n"));
+ value = xmlNewNode (NULL, "value");
+ xmlSetProp (value, "name", fe->name);
+ xmlSetProp (value, "type", "option");
if (fo->current) {
- xmlSetProp(value, "value", fo->current->value);
+ xmlSetProp (value, "value", fo->current->value);
}
+
return value;
}
-static int xml_decode(FilterElement *fe, xmlNodePtr node)
+static int
+xml_decode (FilterElement *fe, xmlNodePtr node)
{
FilterOption *fo = (FilterOption *)fe;
char *value;
-
- d(printf("Decoding option from xml\n"));
- fe->name = xmlGetProp(node, "name");
- value = xmlGetProp(node, "value");
+
+ d(printf ("Decoding option from xml\n"));
+ fe->name = xmlGetProp (node, "name");
+ value = xmlGetProp (node, "value");
if (value) {
- fo->current = find_option(fo, value);
- xmlFree(value);
+ fo->current = find_option (fo, value);
+ xmlFree (value);
} else {
fo->current = NULL;
}
return 0;
}
-static void option_activate(GtkMenuItem *item, FilterOption *fo)
+static void
+option_activate (GtkMenuItem *item, FilterOption *fo)
{
- fo->current = gtk_object_get_data((GtkObject *)item, "option");
- d(printf("option changed to %s\n", fo->current->title));
+ fo->current = gtk_object_get_data (GTK_OBJECT (item), "option");
+ d(printf ("option changed to %s\n", fo->current->title));
}
-static GtkWidget *get_widget(FilterElement *fe)
+static GtkWidget *
+get_widget (FilterElement *fe)
{
FilterOption *fo = (FilterOption *)fe;
- GtkMenu *menu;
- GtkOptionMenu *omenu;
- GtkMenuItem *item;
+ GtkWidget *menu;
+ GtkWidget *omenu;
+ GtkWidget *item;
GList *l = fo->options;
struct _filter_option *op;
- int index = 0, current=0;
-
- menu = (GtkMenu *)gtk_menu_new();
+ int index = 0, current = 0;
+
+ menu = gtk_menu_new ();
while (l) {
op = l->data;
- item = (GtkMenuItem *)gtk_menu_item_new_with_label(_(op->title));
- gtk_object_set_data((GtkObject *)item, "option", op);
- gtk_signal_connect((GtkObject *)item, "activate", option_activate, fo);
- gtk_menu_append(menu, (GtkWidget *)item);
- gtk_widget_show((GtkWidget *)item);
+ item = gtk_menu_item_new_with_label (_(op->title));
+ gtk_object_set_data (GTK_OBJECT (item), "option", op);
+ gtk_signal_connect (GTK_OBJECT (item), "activate", option_activate, fo);
+ gtk_menu_append (GTK_MENU (menu), item);
+ gtk_widget_show (item);
if (op == fo->current) {
current = index;
}
- l = g_list_next(l);
+
+ l = g_list_next (l);
index++;
}
-
- omenu = (GtkOptionMenu *)gtk_option_menu_new();
- gtk_option_menu_set_menu(omenu, (GtkWidget *)menu);
- gtk_option_menu_set_history(omenu, current);
-
- return (GtkWidget *)omenu;
+
+ omenu = gtk_option_menu_new ();
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current);
+
+ return omenu;
}
-static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff)
+static void
+build_code (FilterElement *fe, GString *out, struct _FilterPart *ff)
{
FilterOption *fo = (FilterOption *)fe;
-
- d(printf("building option code %p, current = %p\n", fo, fo->current));
-
+
+ d(printf ("building option code %p, current = %p\n", fo, fo->current));
+
if (fo->current) {
- filter_part_expand_code(ff, fo->current->code, out);
+ filter_part_expand_code (ff, fo->current->code, out);
}
}
-static void format_sexp(FilterElement *fe, GString *out)
+static void
+format_sexp (FilterElement *fe, GString *out)
{
FilterOption *fo = (FilterOption *)fe;
-
+
if (fo->current) {
- e_sexp_encode_string(out, fo->current->value);
+ e_sexp_encode_string (out, fo->current->value);
}
}
-static FilterElement *clone(FilterElement *fe)
+static FilterElement *
+clone (FilterElement *fe)
{
FilterOption *fo = (FilterOption *)fe, *new;
GList *l;
struct _filter_option *fn, *op;
-
- d(printf("cloning option\n"));
-
- new = FILTER_OPTION(((FilterElementClass *)(parent_class))->clone(fe));
+
+ d(printf ("cloning option\n"));
+
+ new = FILTER_OPTION (((FilterElementClass *)(parent_class))->clone(fe));
l = fo->options;
while (l) {
op = l->data;
- fn = g_malloc(sizeof(*fn));
- d(printf(" option %s\n", op->title));
- fn->title = g_strdup(op->title);
- fn->value = g_strdup(op->value);
- fn->code = g_strdup(op->code);
- new->options = g_list_append(new->options, fn);
- l = g_list_next(l);
-
+ fn = g_malloc (sizeof (*fn));
+ d(printf (" option %s\n", op->title));
+ fn->title = g_strdup (op->title);
+ fn->value = g_strdup (op->value);
+ fn->code = g_strdup (op->code);
+ new->options = g_list_append (new->options, fn);
+ l = g_list_next (l);
+
if (new->current == NULL)
new->current = fn;
}
-
- d(printf("cloning option code %p, current = %p\n", new, new->current));
-
+
+ d(printf ("cloning option code %p, current = %p\n", new, new->current));
+
return (FilterElement *)new;
}
diff --git a/filter/filter-part.c b/filter/filter-part.c
index e5ae231b7c..a467a0c3c0 100644
--- a/filter/filter-part.c
+++ b/filter/filter-part.c
@@ -73,29 +73,29 @@ filter_part_class_init (FilterPartClass *class)
GtkObjectClass *object_class;
object_class = (GtkObjectClass *)class;
- parent_class = gtk_type_class(gtk_object_get_type ());
-
+ parent_class = gtk_type_class (gtk_object_get_type ());
+
object_class->finalize = filter_part_finalise;
/* override methods */
-
+
/* signals */
-
- gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
static void
filter_part_init (FilterPart *o)
{
- o->priv = g_malloc0(sizeof(*o->priv));
+ o->priv = g_malloc0 (sizeof (*o->priv));
}
static void
filter_part_finalise(GtkObject *obj)
{
FilterPart *o = (FilterPart *)obj;
-
+
o = o;
-
+
((GtkObjectClass *)(parent_class))->finalize(obj);
}
@@ -107,153 +107,165 @@ filter_part_finalise(GtkObject *obj)
* Return value: A new #FilterPart object.
**/
FilterPart *
-filter_part_new(void)
+filter_part_new (void)
{
FilterPart *o = (FilterPart *)gtk_type_new(filter_part_get_type ());
return o;
}
-
-int filter_part_xml_create (FilterPart *ff, xmlNodePtr node)
+int
+filter_part_xml_create (FilterPart *ff, xmlNodePtr node)
{
xmlNodePtr n;
char *type;
FilterElement *el;
-
+
ff->name = xmlGetProp(node, "name");
n = node->childs;
while (n) {
- if (!strcmp(n->name, "input")) {
- type = xmlGetProp(n, "type");
- d(printf("creating new element type input '%s'\n", type));
+ if (!strcmp (n->name, "input")) {
+ type = xmlGetProp (n, "type");
+ d(printf ("creating new element type input '%s'\n", type));
if (type != NULL
- && (el = filter_element_new_type_name(type)) != NULL) {
- filter_element_xml_create(el, n);
- xmlFree(type);
- d(printf("adding element part %p %s\n", el, el->name));
- ff->elements = g_list_append(ff->elements, el);
+ && (el = filter_element_new_type_name (type)) != NULL) {
+ filter_element_xml_create (el, n);
+ xmlFree (type);
+ d(printf ("adding element part %p %s\n", el, el->name));
+ ff->elements = g_list_append (ff->elements, el);
} else {
- g_warning("Invalid xml format, missing/unknown input type");
+ g_warning ("Invalid xml format, missing/unknown input type");
}
- } else if (!strcmp(n->name, "title")) {
+ } else if (!strcmp (n->name, "title")) {
if (!ff->title)
- ff->title = xmlNodeGetContent(n);
- } else if (!strcmp(n->name, "code")) {
+ ff->title = xmlNodeGetContent (n);
+ } else if (!strcmp (n->name, "code")) {
if (!ff->code)
- ff->code = xmlNodeGetContent(n);
+ ff->code = xmlNodeGetContent (n);
} else {
- g_warning("Unknwon part element in xml: %s\n", n->name);
+ g_warning ("Unknwon part element in xml: %s\n", n->name);
}
n = n->next;
}
+
return 0;
}
-xmlNodePtr filter_part_xml_encode (FilterPart *fp)
+xmlNodePtr
+filter_part_xml_encode (FilterPart *fp)
{
GList *l;
FilterElement *fe;
xmlNodePtr part, value;
-
- g_return_val_if_fail(fp != NULL, NULL);
-
- part = xmlNewNode(NULL, "part");
- xmlSetProp(part, "name", fp->name);
+
+ g_return_val_if_fail (fp != NULL, NULL);
+
+ part = xmlNewNode (NULL, "part");
+ xmlSetProp (part, "name", fp->name);
l = fp->elements;
while (l) {
fe = l->data;
- value = filter_element_xml_encode(fe);
- xmlAddChild(part, value);
- l = g_list_next(l);
+ value = filter_element_xml_encode (fe);
+ xmlAddChild (part, value);
+ l = g_list_next (l);
}
+
return part;
}
-int filter_part_xml_decode (FilterPart *fp, xmlNodePtr node)
+
+int
+filter_part_xml_decode (FilterPart *fp, xmlNodePtr node)
{
FilterElement *fe;
xmlNodePtr n;
char *name;
-
- g_return_val_if_fail(fp != NULL, -1);
- g_return_val_if_fail(node != NULL, -1);
-
+
+ g_return_val_if_fail (fp != NULL, -1);
+ g_return_val_if_fail (node != NULL, -1);
+
n = node->childs;
while (n) {
- if (!strcmp(n->name, "value")) {
- name = xmlGetProp(n, "name");
- d(printf("finding element part %p %s = %p\n", name, name, fe));
- fe = filter_part_find_element(fp, name);
- d(printf("finding element part %p %s = %p\n", name, name, fe));
- xmlFree(name);
+ if (!strcmp (n->name, "value")) {
+ name = xmlGetProp (n, "name");
+ d(printf ("finding element part %p %s = %p\n", name, name, fe));
+ fe = filter_part_find_element (fp, name);
+ d(printf ("finding element part %p %s = %p\n", name, name, fe));
+ xmlFree (name);
if (fe) {
- filter_element_xml_decode(fe, n);
+ filter_element_xml_decode (fe, n);
}
}
n = n->next;
}
+
return 0;
}
-FilterPart *filter_part_clone (FilterPart *fp)
+FilterPart *
+filter_part_clone (FilterPart *fp)
{
FilterPart *new;
GList *l;
FilterElement *fe, *ne;
-
- new = (FilterPart *)gtk_type_new( ((GtkObject *)fp)->klass->type );
- new->name = g_strdup(fp->name);
- new->title = g_strdup(fp->title);
- new->code = g_strdup(fp->code);
+
+ new = (FilterPart *)gtk_type_new ((GTK_OBJECT (fp))->klass->type);
+ new->name = g_strdup (fp->name);
+ new->title = g_strdup (fp->title);
+ new->code = g_strdup (fp->code);
l = fp->elements;
while (l) {
fe = l->data;
- ne = filter_element_clone(fe);
- new->elements = g_list_append(new->elements, ne);
- l = g_list_next(l);
+ ne = filter_element_clone (fe);
+ new->elements = g_list_append (new->elements, ne);
+ l = g_list_next (l);
}
+
return new;
}
-FilterElement *filter_part_find_element(FilterPart *ff, const char *name)
+FilterElement *
+filter_part_find_element (FilterPart *ff, const char *name)
{
GList *l = ff->elements;
FilterElement *fe;
-
+
if (name == NULL)
return NULL;
-
+
while (l) {
fe = l->data;
- if (fe->name && !strcmp(fe->name, name))
+ if (fe->name && !strcmp (fe->name, name))
return fe;
- l = g_list_next(l);
+ l = g_list_next (l);
}
-
+
return NULL;
}
-GtkWidget *filter_part_get_widget (FilterPart *ff)
+GtkWidget *
+filter_part_get_widget (FilterPart *ff)
{
- GtkHBox *hbox;
+ GtkWidget *hbox;
GList *l = ff->elements;
FilterElement *fe;
GtkWidget *w;
-
- hbox = (GtkHBox *)gtk_hbox_new(FALSE, 3);
-
+
+ hbox = gtk_hbox_new (FALSE, 3);
+
while (l) {
fe = l->data;
- w = filter_element_get_widget(fe);
+ w = filter_element_get_widget (fe);
if (w) {
- gtk_box_pack_start((GtkBox *)hbox, w, FALSE, FALSE, 3);
+ gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 3);
}
- l = g_list_next(l);
+ l = g_list_next (l);
}
- gtk_widget_show_all((GtkWidget *)hbox);
- return (GtkWidget *)hbox;
+
+ gtk_widget_show_all (hbox);
+
+ return hbox;
}
/**
@@ -263,18 +275,19 @@ GtkWidget *filter_part_get_widget (FilterPart *ff)
*
* Outputs the code of a part.
**/
-void filter_part_build_code (FilterPart *ff, GString *out)
+void
+filter_part_build_code (FilterPart *ff, GString *out)
{
GList *l = ff->elements;
FilterElement *fe;
-
+
if (ff->code) {
- filter_part_expand_code(ff, ff->code, out);
+ filter_part_expand_code (ff, ff->code, out);
}
while (l) {
fe = l->data;
- filter_element_build_code(fe, out, ff);
- l = g_list_next(l);
+ filter_element_build_code (fe, out, ff);
+ l = g_list_next (l);
}
}
@@ -287,15 +300,15 @@ void filter_part_build_code (FilterPart *ff, GString *out)
* a single string.
**/
void
-filter_part_build_code_list(GList *l, GString *out)
+filter_part_build_code_list (GList *l, GString *out)
{
FilterPart *fp;
-
+
while (l) {
fp = l->data;
- filter_part_build_code(fp, out);
- g_string_append(out, "\n ");
- l = g_list_next(l);
+ filter_part_build_code (fp, out);
+ g_string_append (out, "\n ");
+ l = g_list_next (l);
}
}
@@ -308,19 +321,22 @@ filter_part_build_code_list(GList *l, GString *out)
*
* Return value:
**/
-FilterPart *filter_part_find_list (GList *l, const char *name)
+FilterPart *
+filter_part_find_list (GList *l, const char *name)
{
FilterPart *part;
- d(printf("Find part named %s\n", name));
-
+
+ d(printf ("Find part named %s\n", name));
+
while (l) {
part = l->data;
- if (!strcmp(part->name, name)) {
- d(printf("Found!\n"));
+ if (!strcmp (part->name, name)) {
+ d(printf ("Found!\n"));
return part;
}
- l = g_list_next(l);
+ l = g_list_next (l);
}
+
return NULL;
}
@@ -335,19 +351,21 @@ FilterPart *filter_part_find_list (GList *l, const char *name)
* Return value: The next value in the list, or NULL if the
* list is expired.
**/
-FilterPart *filter_part_next_list (GList *l, FilterPart *last)
+FilterPart *
+filter_part_next_list (GList *l, FilterPart *last)
{
GList *node = l;
-
+
if (last != NULL) {
- node = g_list_find(node, last);
+ node = g_list_find (node, last);
if (node == NULL)
node = l;
else
- node = g_list_next(node);
+ node = g_list_next (node);
}
if (node)
return node->data;
+
return NULL;
}
@@ -359,39 +377,40 @@ FilterPart *filter_part_next_list (GList *l, FilterPart *last)
*
* Expands the variables in string @str based on the values of the part.
**/
-void filter_part_expand_code (FilterPart *ff, const char *source, GString *out)
+void
+filter_part_expand_code (FilterPart *ff, const char *source, GString *out)
{
const char *newstart, *start, *end;
- char *name=alloca(32);
- int len, namelen=32;
+ char *name = alloca (32);
+ int len, namelen = 32;
FilterElement *fe;
-
+
start = source;
- while ( (newstart = strstr(start, "${"))
- && (end = strstr(newstart+2, "}")) ) {
- len = end-newstart-2;
- if (len+1>namelen) {
- namelen = (len+1)*2;
- name = alloca(namelen);
+ while ( (newstart = strstr (start, "${"))
+ && (end = strstr (newstart+2, "}")) ) {
+ len = end - newstart - 2;
+ if (len + 1 > namelen) {
+ namelen = (len + 1) * 2;
+ name = alloca (namelen);
}
- memcpy(name, newstart+2, len);
+ memcpy (name, newstart+2, len);
name[len] = 0;
- fe = filter_part_find_element(ff, name);
+ fe = filter_part_find_element (ff, name);
d(printf("expand code: looking up variab le '%s' = %p\n", name, fe));
if (fe) {
- g_string_sprintfa(out, "%.*s", newstart-start, start);
- filter_element_format_sexp(fe, out);
+ g_string_sprintfa (out, "%.*s", newstart-start, start);
+ filter_element_format_sexp (fe, out);
#if 0
- } else if ( (val = g_hash_table_lookup(ff->globals, name)) ) {
- g_string_sprintfa(out, "%.*s", newstart-start, start);
- e_sexp_encode_string(out, val);
+ } else if ( (val = g_hash_table_lookup (ff->globals, name)) ) {
+ g_string_sprintfa (out, "%.*s", newstart-start, start);
+ e_sexp_encode_string (out, val);
#endif
} else {
- g_string_sprintfa(out, "%.*s", end-start+1, start);
+ g_string_sprintfa (out, "%.*s", end-start+1, start);
}
- start = end+1;
+ start = end + 1;
}
- g_string_append(out, start);
+ g_string_append (out, start);
}
#if 0
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index 37afe15518..51e474aa72 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -448,7 +448,7 @@ less_parts (GtkWidget *button, struct _rule_data *data)
gtk_container_remove (GTK_CONTAINER (data->parts), w);
/* if there's only 1 criterion, we can't remove anymore so set insensitive */
- if (g_list_length (data->fr->parts) == 1)
+ if (g_list_length (data->fr->parts) <= 1)
gtk_widget_set_sensitive (button, FALSE);
}
@@ -574,7 +574,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f)
gtk_box_pack_start (GTK_BOX (hbox), remove, FALSE, FALSE, 3);
/* if we only have 1 criterion, then we can't remove any more so disable this */
- if (g_list_length (fr->parts) == 1)
+ if (g_list_length (fr->parts) <= 1)
gtk_widget_set_sensitive (remove, FALSE);
gtk_box_pack_end (GTK_BOX (hbox), omenu, FALSE, FALSE, 0);
diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml
index 38723dbf98..925593e402 100644
--- a/filter/filtertypes.xml
+++ b/filter/filtertypes.xml
@@ -28,7 +28,6 @@
(match-all (not (header-matches "From" ${sender})))
</code>
</option>
-
<option value="starts with">
<title>starts with</title>
<code>
@@ -53,13 +52,13 @@
(match-all (not (header-ends-with "From" ${sender})))
</code>
</option>
- <option value="matches regex">
+ <option value="matches regex" type="regex">
<title>matches regex</title>
<code>
(match-all (header-regex "From" ${sender}))
</code>
</option>
- <option value="not match regex">
+ <option value="not match regex" type="regex">
<title>does not match regex</title>
<code>
(match-all (not (header-regex "From" ${sender})))