diff options
author | 3 <NotZed@Ximian.com> | 2001-09-15 16:13:19 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-09-15 16:13:19 +0800 |
commit | 07a40707a39c663f06893a5cba36d49ed63ba5b6 (patch) | |
tree | 8e650e3f5508d50a8d10bd3a4b6804cd5cf61385 /filter/rule-context.c | |
parent | 466e05c024510d8019989f8bf8f04541c3ca792d (diff) | |
download | gsoc2013-evolution-07a40707a39c663f06893a5cba36d49ed63ba5b6.tar.gz gsoc2013-evolution-07a40707a39c663f06893a5cba36d49ed63ba5b6.tar.zst gsoc2013-evolution-07a40707a39c663f06893a5cba36d49ed63ba5b6.zip |
Emit changed events.
2001-09-13 <NotZed@Ximian.com>
* filter-filter.c (filter_filter_add_action):
(filter_filter_remove_action):
(filter_filter_replace_action): Emit changed events.
* filter-rule.c (filter_rule_xml_decode): Emiot a rule changed event.
(filter_rule_copy): Emit a changed event.
(filter_rule_replace_part): "
(filter_rule_add_part): "
(filter_rule_remove_part): "
(filter_rule_xml_decode): Freeze around decoding, so we only emit changed when done.
(filter_rule_emit_changed): New function to emit changed events if not frozen.
2001-09-13 <NotZed@Ximian.com>
* rule-context.c (rule_context_class_init): Added a 'rule_added'
and 'rule_removed' signal.
(rule_context_load): Set a (private) frozen flag while we're loading.
(rule_context_add_rule): Emit a rule_added signal if we're not
frozen.
(rule_context_remove_rule): Emit a rule_removed signal if we're
not frozen.
svn path=/trunk/; revision=12855
Diffstat (limited to 'filter/rule-context.c')
-rw-r--r-- | filter/rule-context.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/filter/rule-context.c b/filter/rule-context.c index 61e422eeb1..389ef7296a 100644 --- a/filter/rule-context.c +++ b/filter/rule-context.c @@ -42,11 +42,14 @@ static void rule_context_finalise(GtkObject * obj); #define _PRIVATE(x) (((RuleContext *)(x))->priv) struct _RuleContextPrivate { + int frozen; }; static GtkObjectClass *parent_class; enum { + RULE_ADDED, + RULE_REMOVED, LAST_SIGNAL }; @@ -89,6 +92,21 @@ rule_context_class_init (RuleContextClass * class) class->save = save; /* signals */ + signals[RULE_ADDED] = + gtk_signal_new("rule_added", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (RuleContextClass, rule_added), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + + signals[RULE_REMOVED] = + gtk_signal_new("rule_removed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (RuleContextClass, rule_removed), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); } @@ -222,9 +240,15 @@ rule_context_set_error (RuleContext * f, char *error) int rule_context_load (RuleContext *f, const char *system, const char *user) { + int res; + d(printf("rule_context: loading %s %s\n", system, user)); - - return ((RuleContextClass *) ((GtkObject *) f)->klass)->load (f, system, user); + + f->priv->frozen++; + res= ((RuleContextClass *) ((GtkObject *) f)->klass)->load (f, system, user); + f->priv->frozen--; + + return res; } static int @@ -240,8 +264,8 @@ load (RuleContext *f, const char *system, const char *user) f->system = xmlParseFile (system); if (f->system == NULL) { - rule_context_set_error (f, g_strdup_printf ("Unable to load system rules '%s': %s", - system, g_strerror (errno))); + rule_context_set_error(f, g_strdup_printf ("Unable to load system rules '%s': %s", + system, strerror(errno))); return -1; } if (strcmp (f->system->root->name, "filterdescription")) { @@ -400,6 +424,9 @@ void rule_context_add_rule (RuleContext *f, FilterRule *new) { f->rules = g_list_append (f->rules, new); + + if (f->priv->frozen == 0) + gtk_signal_emit((GtkObject *)f, signals[RULE_ADDED], new); } static void @@ -455,6 +482,9 @@ void rule_context_remove_rule (RuleContext *f, FilterRule *rule) { f->rules = g_list_remove (f->rules, rule); + + if (f->priv->frozen == 0) + gtk_signal_emit((GtkObject *)f, signals[RULE_REMOVED], rule); } void |