aboutsummaryrefslogtreecommitdiffstats
path: root/filter/filter-element.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-02-26 10:27:22 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-02-26 10:27:22 +0800
commit1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820 (patch)
tree774eb5e2210876050674433cdaa18aad875060d4 /filter/filter-element.c
parent43a998d8cba35528f094d206b23084e114353e12 (diff)
downloadgsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.tar
gsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.tar.gz
gsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.tar.bz2
gsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.tar.lz
gsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.tar.xz
gsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.tar.zst
gsoc2013-evolution-1b00ce5ca9b8a7c3a0cf0d96579aa04aad5e0820.zip
Copy values across to new part.
2002-02-26 Not Zed <NotZed@Ximian.com> * filter-filter.c (option_activate): Copy values across to new part. * filter-rule.c (option_activate): copy values across to new part, if they are compatible. * filter-element.c (filter_element_copy_value): New function to copy values (where they can be) from one filter element to another. * filter-part.c (filter_part_copy_values): New function to copy values of a filter part. #1359. svn path=/trunk/; revision=15841
Diffstat (limited to 'filter/filter-element.c')
-rw-r--r--filter/filter-element.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/filter/filter-element.c b/filter/filter-element.c
index 4343720e87..3ff4bee533 100644
--- a/filter/filter-element.c
+++ b/filter/filter-element.c
@@ -23,6 +23,7 @@
#endif
#include <string.h>
+#include <stdlib.h>
#include <gtk/gtktypeutils.h>
#include "filter-element.h"
@@ -310,3 +311,61 @@ clone (FilterElement *fe)
return new;
}
+
+/* only copies the value, not the name/type */
+void
+filter_element_copy_value(FilterElement *de, FilterElement *se)
+{
+ /* bit of a hack, but saves having to do the same in each type ? */
+
+ if (IS_FILTER_INPUT(se)) {
+ if (IS_FILTER_INPUT(de)) {
+ if (((FilterInput *)se)->values)
+ filter_input_set_value((FilterInput*)de, ((FilterInput *)se)->values->data);
+ } else if (IS_FILTER_INT(de)) {
+ ((FilterInt *)de)->val = atoi((char *) ((FilterInput *)se)->values->data);
+ }
+ } else if (IS_FILTER_FOLDER(se)) {
+ if (IS_FILTER_FOLDER(de)) {
+ filter_folder_set_value((FilterFolder *)de, ((FilterFolder *)se)->uri, ((FilterFolder *)se)->name);
+ }
+ } else if (IS_FILTER_COLOUR(se)) {
+ if (IS_FILTER_COLOUR(de)) {
+ FilterColour *s = (FilterColour *)se, *d = (FilterColour *)de;
+
+ d->r = s->r;
+ d->g = s->g;
+ d->b = s->b;
+ d->a = s->a;
+ }
+ } else if (IS_FILTER_DATESPEC(se)) {
+ if (IS_FILTER_DATESPEC(de)) {
+ FilterDatespec *s = (FilterDatespec *)se, *d = (FilterDatespec *)de;
+
+ d->type = s->type;
+ d->value = s->value;
+ }
+ } else if (IS_FILTER_INT(se)) {
+ if (IS_FILTER_INT(de)) {
+ FilterInt *s = (FilterInt *)se, *d = (FilterInt *)de;
+
+ d->val = s->val;
+ } else if (IS_FILTER_INPUT(de)) {
+ FilterInt *s = (FilterInt *)se;
+ FilterInput *d = (FilterInput *)de;
+ char *v;
+
+ v = g_strdup_printf("%d", s->val);
+ filter_input_set_value(d, v);
+ g_free(v);
+ }
+ } else if (IS_FILTER_OPTION(se)) {
+ if (IS_FILTER_OPTION(de)) {
+ FilterOption *s = (FilterOption *)se, *d = (FilterOption *)de;
+
+ if (s->current)
+ filter_option_set_current(d, s->current->value);
+ }
+ }
+}
+