aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filter/ChangeLog6
-rw-r--r--filter/rule-context.c31
-rw-r--r--filter/rule-editor.c35
3 files changed, 41 insertions, 31 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 70d21b1ac1..ad5d72adae 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,9 @@
+2001-07-18 Jeffrey Stedfast <fejj@ximian.com>
+
+ * rule-context.c (rule_context_get_rank_rule): Return -1 if we
+ don't find it? This is what most of the code expected but not what
+ we were returning on fail.
+
2001-07-12 Zbigniew Chyla <cyba@gnome.pl>
* filter-datespec.c (stringify_agoness): Marked string for translation.
diff --git a/filter/rule-context.c b/filter/rule-context.c
index b89a3ffac7..f24e9948be 100644
--- a/filter/rule-context.c
+++ b/filter/rule-context.c
@@ -439,32 +439,35 @@ rule_context_add_rule_gui(RuleContext * f, FilterRule * rule, const char *title,
}
void
-rule_context_remove_rule(RuleContext * f, FilterRule * rule)
+rule_context_remove_rule (RuleContext *f, FilterRule *rule)
{
- f->rules = g_list_remove(f->rules, rule);
+ f->rules = g_list_remove (f->rules, rule);
}
void
-rule_context_rank_rule(RuleContext * f, FilterRule * rule, int rank)
+rule_context_rank_rule (RuleContext *f, FilterRule *rule, int rank)
{
- f->rules = g_list_remove(f->rules, rule);
- f->rules = g_list_insert(f->rules, rule, rank);
+ f->rules = g_list_remove (f->rules, rule);
+ f->rules = g_list_insert (f->rules, rule, rank);
}
int
-rule_context_get_rank_rule(RuleContext * f, FilterRule * rule, const char *source)
+rule_context_get_rank_rule (RuleContext *f, FilterRule *rule, const char *source)
{
- GList *n = f->rules;
+ GList *node = f->rules;
int i = 0;
-
- while (n) {
- FilterRule *r = n->data;
-
+
+ while (node) {
+ FilterRule *r = node->data;
+
if (r == rule)
return i;
- if (source == NULL || (r->source && strcmp(r->source, source) == 0))
+
+ if (source == NULL || (r->source && strcmp (r->source, source) == 0))
i++;
- n = g_list_next(n);
+
+ node = node->next;
}
- return i;
+
+ return -1;
}
diff --git a/filter/rule-editor.c b/filter/rule-editor.c
index 19c49bb16e..395e296ad6 100644
--- a/filter/rule-editor.c
+++ b/filter/rule-editor.c
@@ -377,7 +377,8 @@ rule_down (GtkWidget *widget, RuleEditor *re)
d(printf ("down rule\n"));
pos = rule_context_get_rank_rule (re->context, re->current, re->source);
- rule_move (re, pos, pos + 1);
+ if (pos >= 0)
+ rule_move (re, pos, pos + 1);
}
static struct {
@@ -407,10 +408,10 @@ set_sensitive (RuleEditor *re)
count--;
- gtk_widget_set_sensitive(GTK_WIDGET(re->priv->buttons[BUTTON_EDIT]), index != -1);
- gtk_widget_set_sensitive(GTK_WIDGET(re->priv->buttons[BUTTON_DELETE]), index != -1);
- gtk_widget_set_sensitive(GTK_WIDGET(re->priv->buttons[BUTTON_UP]), index > 0);
- gtk_widget_set_sensitive(GTK_WIDGET(re->priv->buttons[BUTTON_DOWN]), index >= 0 && index < count);
+ gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_EDIT]), index != -1);
+ gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_DELETE]), index != -1);
+ gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_UP]), index > 0);
+ gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_DOWN]), index >= 0 && index < count);
}
@@ -432,7 +433,7 @@ double_click (GtkWidget *widget, GdkEventButton *event, RuleEditor *re)
}
static void
-set_source(RuleEditor *re, const char *source)
+set_source (RuleEditor *re, const char *source)
{
FilterRule *rule = NULL;
GList *newitems = NULL;
@@ -445,23 +446,23 @@ set_source(RuleEditor *re, const char *source)
char *s;
d(printf(" hit %s(%d)\n", rule->name, source));
- s = e_utf8_to_gtk_string(GTK_WIDGET(re->list), rule->name);
- item = gtk_list_item_new_with_label(s);
- g_free(s);
- gtk_object_set_data(GTK_OBJECT(item), "rule", rule);
- gtk_widget_show(GTK_WIDGET(item));
- newitems = g_list_append(newitems, item);
+ s = e_utf8_to_gtk_string (GTK_WIDGET (re->list), rule->name);
+ item = gtk_list_item_new_with_label (s);
+ g_free (s);
+ gtk_object_set_data (GTK_OBJECT (item), "rule", rule);
+ gtk_widget_show (GTK_WIDGET (item));
+ newitems = g_list_append (newitems, item);
}
- gtk_list_append_items(re->list, newitems);
- g_free(re->source);
- re->source = g_strdup(source);
+ gtk_list_append_items (re->list, newitems);
+ g_free (re->source);
+ re->source = g_strdup (source);
re->current = NULL;
- rule_editor_set_sensitive(re);
+ rule_editor_set_sensitive (re);
}
void
-rule_editor_construct(RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source)
+rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source)
{
GtkWidget *w;
int i;