aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--filter/ChangeLog14
-rw-r--r--filter/filter-datespec.c1
-rw-r--r--filter/filter-element.c59
-rw-r--r--filter/filter-element.h1
-rw-r--r--filter/filter-filter.c1
-rw-r--r--filter/filter-part.c30
-rw-r--r--filter/filter-part.h1
-rw-r--r--filter/filter-rule.c1
-rw-r--r--filter/libfilter-i18n.h36
9 files changed, 126 insertions, 18 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 1e449c566b..789fac2f7b 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,17 @@
+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.
+
2002-02-12 Jeffrey Stedfast <fejj@ximian.com>
* vfoldertypes.xml:
diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c
index c01ea56f94..fe4e5e3b32 100644
--- a/filter/filter-datespec.c
+++ b/filter/filter-datespec.c
@@ -761,3 +761,4 @@ cal_day_selected_double_click (GtkCalendar *cal, gpointer user_data)
PRIV (fds)->double_click = TRUE;
gnome_dialog_close (PRIV (fds)->gd);
}
+
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);
+ }
+ }
+}
+
diff --git a/filter/filter-element.h b/filter/filter-element.h
index 3147fb12b4..d5ff5177ce 100644
--- a/filter/filter-element.h
+++ b/filter/filter-element.h
@@ -77,6 +77,7 @@ void filter_element_xml_create (FilterElement *fe, xmlNodePtr node);
xmlNodePtr filter_element_xml_encode (FilterElement *fe);
int filter_element_xml_decode (FilterElement *fe, xmlNodePtr node);
FilterElement *filter_element_clone (FilterElement *fe);
+void filter_element_copy_value (FilterElement *de, FilterElement *se);
GtkWidget *filter_element_get_widget (FilterElement *fe);
void filter_element_build_code (FilterElement *fe, GString *out, struct _FilterPart *ff);
diff --git a/filter/filter-filter.c b/filter/filter-filter.c
index ad3ba7ac6b..199018da6c 100644
--- a/filter/filter-filter.c
+++ b/filter/filter-filter.c
@@ -332,6 +332,7 @@ option_activate (GtkMenuItem *item, struct _part_data *data)
gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget);
newpart = filter_part_clone (part);
+ filter_part_copy_values(newpart, data->part);
filter_filter_replace_action ((FilterFilter *)data->fr, data->part, newpart);
gtk_object_unref (GTK_OBJECT (data->part));
data->part = newpart;
diff --git a/filter/filter-part.c b/filter/filter-part.c
index 15e78b77b8..e92c42aafb 100644
--- a/filter/filter-part.c
+++ b/filter/filter-part.c
@@ -273,6 +273,36 @@ filter_part_clone (FilterPart *fp)
return new;
}
+/* only copies values of matching parts in the right order */
+void
+filter_part_copy_values (FilterPart *dst, FilterPart *src)
+{
+ GList *dstl, *srcl, *dstt;
+ FilterElement *de, *se;
+
+ /* NOTE: we go backwards, it just works better that way */
+
+ /* for each source type, search the dest type for
+ a matching type in the same order */
+ srcl = g_list_last(src->elements);
+ dstl = g_list_last(dst->elements);
+ while (srcl && dstl) {
+ se = srcl->data;
+ dstt = dstl;
+ while (dstt) {
+ de = dstt->data;
+ if (((GtkObject *)de)->klass == ((GtkObject *)se)->klass) {
+ filter_element_copy_value(de, se);
+ dstl = dstt->prev;
+ break;
+ }
+ dstt = dstt->prev;
+ }
+
+ srcl = srcl->prev;
+ }
+}
+
FilterElement *
filter_part_find_element (FilterPart *ff, const char *name)
{
diff --git a/filter/filter-part.h b/filter/filter-part.h
index 1a29cee981..904be6b191 100644
--- a/filter/filter-part.h
+++ b/filter/filter-part.h
@@ -61,6 +61,7 @@ xmlNodePtr filter_part_xml_encode (FilterPart *fe);
int filter_part_xml_decode (FilterPart *fe, xmlNodePtr node);
FilterPart *filter_part_clone (FilterPart *fp);
+void filter_part_copy_values (FilterPart *dfp, FilterPart *sfp);
FilterElement *filter_part_find_element(FilterPart *ff, const char *name);
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index 2f8fd76047..89e0d76726 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -533,6 +533,7 @@ option_activate (GtkMenuItem *item, struct _part_data *data)
gtk_container_remove (GTK_CONTAINER (data->container), data->partwidget);
newpart = filter_part_clone (part);
+ filter_part_copy_values(newpart, data->part);
filter_rule_replace_part (data->fr, data->part, newpart);
gtk_object_unref (GTK_OBJECT (data->part));
data->part = newpart;
diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h
index 9d272d478d..611ea38ceb 100644
--- a/filter/libfilter-i18n.h
+++ b/filter/libfilter-i18n.h
@@ -2,34 +2,18 @@
char *s = N_("Assign Color");
char *s = N_("Assign Score");
char *s = N_("Attachments");
-char *s = N_("contains");
char *s = N_("Copy to Folder");
char *s = N_("Date received");
char *s = N_("Date sent");
char *s = N_("Delete");
char *s = N_("Deleted");
-char *s = N_("does not contain");
-char *s = N_("does not end with");
-char *s = N_("does not exist");
-char *s = N_("does not sound like");
-char *s = N_("does not start with");
char *s = N_("Do Not Exist");
char *s = N_("Draft");
-char *s = N_("ends with");
char *s = N_("Execute Shell Command");
char *s = N_("Exist");
-char *s = N_("exists");
char *s = N_("Expression");
char *s = N_("Follow Up");
char *s = N_("Important");
-char *s = N_("is");
-char *s = N_("is after");
-char *s = N_("is before");
-char *s = N_("is Flagged");
-char *s = N_("is greater than");
-char *s = N_("is less than");
-char *s = N_("is not");
-char *s = N_("is not Flagged");
char *s = N_("Mailing list");
char *s = N_("Message Body");
char *s = N_("Message Header");
@@ -42,10 +26,26 @@ char *s = N_("Score");
char *s = N_("Sender");
char *s = N_("Set Status");
char *s = N_("Size (kB)");
-char *s = N_("sounds like");
char *s = N_("Source Account");
char *s = N_("Specific header");
-char *s = N_("starts with");
char *s = N_("Status");
char *s = N_("Stop Processing");
char *s = N_("Subject");
+char *s = N_("contains");
+char *s = N_("does not contain");
+char *s = N_("does not end with");
+char *s = N_("does not exist");
+char *s = N_("does not sound like");
+char *s = N_("does not start with");
+char *s = N_("ends with");
+char *s = N_("exists");
+char *s = N_("is Flagged");
+char *s = N_("is after");
+char *s = N_("is before");
+char *s = N_("is greater than");
+char *s = N_("is less than");
+char *s = N_("is not Flagged");
+char *s = N_("is not");
+char *s = N_("is");
+char *s = N_("sounds like");
+char *s = N_("starts with");