aboutsummaryrefslogtreecommitdiffstats
path: root/filter/rule-editor.c
diff options
context:
space:
mode:
authorMatthew Hall <matt@castleinthesky.org>2005-12-21 02:21:51 +0800
committerAndre Klapper <aklapper@src.gnome.org>2005-12-21 02:21:51 +0800
commit0a197d13a3f7a9da34db502b0447a39d30fe48a4 (patch)
treed4258645f76439e5ae475473717a939451970c31 /filter/rule-editor.c
parent2e5070b5672eb705f83ccee85d8e95ea19240bdd (diff)
downloadgsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.tar
gsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.tar.gz
gsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.tar.bz2
gsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.tar.lz
gsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.tar.xz
gsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.tar.zst
gsoc2013-evolution-0a197d13a3f7a9da34db502b0447a39d30fe48a4.zip
adding top/bottom buttons for filter manager dialog (#205616) (committing
2005-12-20 Matthew Hall <matt@castleinthesky.org> * filter.glade; rule-editor.c: adding top/bottom buttons for filter manager dialog (#205616) (committing this on behalf of Matthew and as discussed with srag) svn path=/trunk/; revision=30908
Diffstat (limited to 'filter/rule-editor.c')
-rw-r--r--filter/rule-editor.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/filter/rule-editor.c b/filter/rule-editor.c
index ad45ab8672..bc356b1024 100644
--- a/filter/rule-editor.c
+++ b/filter/rule-editor.c
@@ -59,8 +59,10 @@ enum {
BUTTON_ADD,
BUTTON_EDIT,
BUTTON_DELETE,
+ BUTTON_TOP,
BUTTON_UP,
BUTTON_DOWN,
+ BUTTON_BOTTOM,
BUTTON_LAST
};
@@ -476,6 +478,17 @@ rule_move (RuleEditor *re, int from, int to)
}
static void
+rule_top (GtkWidget *widget, RuleEditor *re)
+{
+ int pos;
+
+ d(printf ("top rule\n"));
+ pos = rule_context_get_rank_rule (re->context, re->current, re->source);
+ if (pos > 0)
+ rule_move (re, pos, 0);
+}
+
+static void
rule_up (GtkWidget *widget, RuleEditor *re)
{
int pos;
@@ -497,6 +510,26 @@ rule_down (GtkWidget *widget, RuleEditor *re)
rule_move (re, pos, pos + 1);
}
+static void
+rule_bottom (GtkWidget *widget, RuleEditor *re)
+{
+ int pos;
+ int index = -1, count = 0;
+ FilterRule *rule = NULL;
+
+ d(printf ("bottom rule\n"));
+ pos = rule_context_get_rank_rule (re->context, re->current, re->source);
+ /* There's probably a better/faster way to get the count of the list here */
+ while ((rule = rule_context_next_rule (re->context, rule, re->source))) {
+ if (rule == re->current)
+ index = count;
+ count++;
+ }
+ count--;
+ if (pos >= 0)
+ rule_move (re, pos, count);
+}
+
static struct {
char *name;
GtkSignalFunc func;
@@ -504,8 +537,10 @@ static struct {
{ "rule_add", G_CALLBACK (rule_add) },
{ "rule_edit", G_CALLBACK (rule_edit) },
{ "rule_delete", G_CALLBACK (rule_delete) },
+ { "rule_top", G_CALLBACK (rule_top) },
{ "rule_up", G_CALLBACK (rule_up) },
{ "rule_down", G_CALLBACK (rule_down) },
+ { "rule_bottom", G_CALLBACK (rule_bottom) },
};
static void
@@ -526,8 +561,10 @@ set_sensitive (RuleEditor *re)
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_TOP]), index > 0);
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_BOTTOM]), index >= 0 && index < count);
}