diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-04-03 10:22:17 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-04-03 10:22:17 +0800 |
commit | 0884233afc1e0a1f14b6b882dedc54cbfccfe322 (patch) | |
tree | 44da41f0497742a4395bfcca1b7b0dea19dae83f | |
parent | a98e9bf9eb54132540536cc528adb2c5c34e180f (diff) | |
download | gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.tar gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.tar.gz gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.tar.bz2 gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.tar.lz gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.tar.xz gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.tar.zst gsoc2013-evolution-0884233afc1e0a1f14b6b882dedc54cbfccfe322.zip |
Set the newpart on the container object. (less_parts): Remove the rule tht
2001-04-02 Jeffrey Stedfast <fejj@ximian.com>
* filter-filter.c (option_activate): Set the newpart on the
container object.
(less_parts): Remove the rule tht the user wants to remove.
(attach_rule): Attach a new rule and it's remove button to the end
of the table.
(more_parts): Fix to resize the table and such.
(get_widget): Don't have a remove action button, we are putting
this next to the rule part now.
* filter-rule.c (option_activate): Set the newpart on the
container object.
(less_parts): Remove the rule tht the user wants to remove.
(attach_rule): Attach a new rule and it's remove button to the end
of the table.
(more_parts): Fix to resize the table and such.
(get_widget): Don't have a remove action button, we are putting
this next to the rule part now.
svn path=/trunk/; revision=9115
-rw-r--r-- | filter/ChangeLog | 20 | ||||
-rw-r--r-- | filter/filter-filter.c | 80 | ||||
-rw-r--r-- | filter/filter-rule.c | 79 | ||||
-rw-r--r-- | filter/libfilter-i18n.h | 36 |
4 files changed, 125 insertions, 90 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index 32d7683be3..c6111aadb2 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,23 @@ +2001-04-02 Jeffrey Stedfast <fejj@ximian.com> + + * filter-filter.c (option_activate): Set the newpart on the + container object. + (less_parts): Remove the rule tht the user wants to remove. + (attach_rule): Attach a new rule and it's remove button to the end + of the table. + (more_parts): Fix to resize the table and such. + (get_widget): Don't have a remove action button, we are putting + this next to the rule part now. + + * filter-rule.c (option_activate): Set the newpart on the + container object. + (less_parts): Remove the rule tht the user wants to remove. + (attach_rule): Attach a new rule and it's remove button to the end + of the table. + (more_parts): Fix to resize the table and such. + (get_widget): Don't have a remove action button, we are putting + this next to the rule part now. + 2001-03-30 Kjartan Maraas <kmaraas@gnome.org> * *.*: Fix headers. Remove unneccesary ones and replace diff --git a/filter/filter-filter.c b/filter/filter-filter.c index c939fa9b2c..9625b5cd59 100644 --- a/filter/filter-filter.c +++ b/filter/filter-filter.c @@ -1,8 +1,8 @@ /* - * Copyright (C) 2000 Helix Code Inc. + * Copyright (C) 2000-2001 Ximian Inc. * - * Authors: Not Zed <notzed@lostzed.mmc.com.au> - * Jeffrey Stedfast <fejj@helixcode.com> + * Authors: Not Zed <notzed@ximian.com> + * Jeffrey Stedfast <fejj@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License @@ -298,6 +298,8 @@ option_activate (GtkMenuItem *item, struct _part_data *data) data->partwidget = filter_part_get_widget (newpart); if (data->partwidget) gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); + + gtk_object_set_data (GTK_OBJECT (data->container), "part", newpart); } static GtkWidget * @@ -361,49 +363,64 @@ struct _rule_data { static void less_parts (GtkWidget *button, struct _rule_data *data) { - GList *l; FilterPart *part; - GtkWidget *w; + GtkWidget *rule; + GList *l; l = ((FilterFilter *)data->fr)->actions; if (g_list_length (l) < 2) return; - /* remove the last one from the list */ - l = g_list_last (l); - part = l->data; + rule = gtk_object_get_data (GTK_OBJECT (button), "rule"); + part = gtk_object_get_data (GTK_OBJECT (rule), "part"); + + /* remove the part from the list */ filter_filter_remove_action ((FilterFilter *)data->fr, part); gtk_object_unref (GTK_OBJECT (part)); /* and from the display */ - l = g_list_last (GTK_BOX (data->parts)->children); - w = ((GtkBoxChild *) l->data)->widget; - gtk_container_remove (GTK_CONTAINER (data->parts), w); + gtk_container_remove (GTK_CONTAINER (data->parts), rule); + gtk_container_remove (GTK_CONTAINER (data->parts), button); +} + +static void +attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) +{ + GtkWidget *remove; + GtkWidget *pixmap; - /* if there's only 1 action, we can't remove anymore so set insensitive */ - if (g_list_length (((FilterFilter *)data->fr)->actions) <= 1) - gtk_widget_set_sensitive (button, FALSE); + gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, + GTK_EXPAND | GTK_FILL, 0, 0, 0); + + pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_REMOVE); + remove = gnome_pixmap_button (pixmap, _("Remove")); + gtk_object_set_data (GTK_OBJECT (remove), "rule", rule); + gtk_object_set_data (GTK_OBJECT (rule), "part", part); + /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ + gtk_signal_connect (GTK_OBJECT (remove), "clicked", less_parts, data); + gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, + 0, 0, 0, 0); + gtk_widget_show (remove); } static void more_parts (GtkWidget *button, struct _rule_data *data) { FilterPart *new; - GtkWidget *w; /* create a new rule entry, use the first type of rule */ new = filter_context_next_action ((FilterContext *)data->f, NULL); if (new) { + GtkWidget *w; + guint16 rows; + new = filter_part_clone (new); filter_filter_add_action ((FilterFilter *)data->fr, new); w = get_rule_part_widget (data->f, new, data->fr); - gtk_box_pack_start (GTK_BOX (data->parts), w, FALSE, FALSE, 0); - } - - /* set the "Remove action" button sensitive */ - if (g_list_length (((FilterFilter *)data->fr)->actions) > 1) { - w = gtk_object_get_data (GTK_OBJECT (button), "remove"); - gtk_widget_set_sensitive (w, TRUE); + + rows = GTK_TABLE (data->parts)->nrows; + gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2); + attach_rule (w, data, new, rows); } } @@ -413,7 +430,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f) GtkWidget *widget; GtkWidget *parts, *inframe; GtkWidget *hbox; - GtkWidget *add, *remove, *pixmap; + GtkWidget *add, *pixmap; GtkWidget *w; GtkWidget *frame; GtkWidget *scrolledwindow; @@ -422,6 +439,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f) FilterPart *part; struct _rule_data *data; FilterFilter *ff = (FilterFilter *)fr; + gint rows, i = 0; widget = ((FilterRuleClass *)(parent_class))->get_widget (fr, f); @@ -430,7 +448,8 @@ get_widget (FilterRule *fr, struct _RuleContext *f) inframe = gtk_vbox_new (FALSE, 3); gtk_container_add (GTK_CONTAINER (frame), inframe); - parts = gtk_vbox_new (FALSE, 3); + rows = g_list_length (ff->actions); + parts = gtk_table_new (rows, 2, FALSE); data = g_malloc0 (sizeof (*data)); data->f = (FilterContext *)f; data->fr = fr; @@ -444,17 +463,6 @@ get_widget (FilterRule *fr, struct _RuleContext *f) gtk_signal_connect (GTK_OBJECT (add), "clicked", more_parts, data); gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 3); - pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_REMOVE); - remove = gnome_pixmap_button (pixmap, _("Remove action")); - gtk_object_set_data (GTK_OBJECT (add), "remove", remove); - gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE); - gtk_signal_connect (GTK_OBJECT (remove), "clicked", less_parts, data); - gtk_box_pack_start (GTK_BOX (hbox), remove, FALSE, FALSE, 3); - - /* if we only have 1 action, then we can't remove any more so disable this */ - if (g_list_length (ff->actions) <= 1) - gtk_widget_set_sensitive (remove, FALSE); - gtk_box_pack_start (GTK_BOX (inframe), hbox, FALSE, FALSE, 3); l = ff->actions; @@ -462,7 +470,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f) part = l->data; d(printf ("adding action %s\n", part->title)); w = get_rule_part_widget ((FilterContext *)f, part, fr); - gtk_box_pack_start (GTK_BOX (parts), w, FALSE, FALSE, 3); + attach_rule (w, data, part, i++); l = g_list_next (l); } diff --git a/filter/filter-rule.c b/filter/filter-rule.c index 8ad3262136..71590b1302 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -443,6 +443,8 @@ option_activate (GtkMenuItem *item, struct _part_data *data) data->partwidget = filter_part_get_widget (newpart); if (data->partwidget) gtk_box_pack_start (GTK_BOX (data->container), data->partwidget, FALSE, FALSE, 0); + + gtk_object_set_data (GTK_OBJECT (data->container), "part", newpart); } static GtkWidget * @@ -508,35 +510,48 @@ struct _rule_data { static void less_parts (GtkWidget *button, struct _rule_data *data) { - GList *l; FilterPart *part; - GtkWidget *w; + GtkWidget *rule; - l = data->fr->parts; - if (g_list_length (l) < 2) + if (g_list_length (data->fr->parts) < 2) return; - /* remove the last one from the list */ - l = g_list_last (l); - part = l->data; + rule = gtk_object_get_data (GTK_OBJECT (button), "rule"); + part = gtk_object_get_data (GTK_OBJECT (rule), "part"); + + /* remove the part from the list */ filter_rule_remove_part (data->fr, part); gtk_object_unref (GTK_OBJECT (part)); /* and from the display */ - l = g_list_last (GTK_BOX (data->parts)->children); - w = ((GtkBoxChild *) l->data)->widget; - gtk_container_remove (GTK_CONTAINER (data->parts), w); + gtk_container_remove (GTK_CONTAINER (data->parts), rule); + gtk_container_remove (GTK_CONTAINER (data->parts), button); +} + +static void +attach_rule (GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) +{ + GtkWidget *remove; + GtkWidget *pixmap; - /* if there's only 1 criterion, we can't remove anymore so set insensitive */ - if (g_list_length (data->fr->parts) <= 1) - gtk_widget_set_sensitive (button, FALSE); + gtk_table_attach (GTK_TABLE (data->parts), rule, 0, 1, row, row + 1, + GTK_EXPAND | GTK_FILL, 0, 0, 0); + + pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_REMOVE); + remove = gnome_pixmap_button (pixmap, _("Remove")); + gtk_object_set_data (GTK_OBJECT (remove), "rule", rule); + gtk_object_set_data (GTK_OBJECT (rule), "part", part); + /*gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE);*/ + gtk_signal_connect (GTK_OBJECT (remove), "clicked", less_parts, data); + gtk_table_attach (GTK_TABLE (data->parts), remove, 1, 2, row, row + 1, + 0, 0, 0, 0); + gtk_widget_show (remove); } static void more_parts (GtkWidget *button, struct _rule_data *data) { FilterPart *new; - GtkWidget *w; /* first make sure that the last part is ok */ if (data->fr->parts) { @@ -552,16 +567,16 @@ more_parts (GtkWidget *button, struct _rule_data *data) /* create a new rule entry, use the first type of rule */ new = rule_context_next_part (data->f, NULL); if (new) { + GtkWidget *w; + int rows; + new = filter_part_clone (new); filter_rule_add_part (data->fr, new); w = get_rule_part_widget (data->f, new, data->fr); - gtk_box_pack_start (GTK_BOX (data->parts), w, FALSE, FALSE, 0); - } - - /* set the "Remove criterion" button sensitive */ - if (g_list_length (data->fr->parts) > 1) { - w = gtk_object_get_data (GTK_OBJECT (button), "remove"); - gtk_widget_set_sensitive (w, TRUE); + + rows = GTK_TABLE (data->parts)->nrows; + gtk_table_resize (GTK_TABLE (data->parts), rows + 1, 2); + attach_rule (w, data, new, rows); } } @@ -583,7 +598,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f) { GtkWidget *vbox, *parts, *inframe; GtkWidget *hbox; - GtkWidget *add, *remove, *pixmap; + GtkWidget *add, *pixmap; GtkWidget *w; GtkWidget *menu, *item, *omenu; GtkWidget *frame; @@ -594,6 +609,7 @@ get_widget (FilterRule *fr, struct _RuleContext *f) GList *l; FilterPart *part; struct _rule_data *data; + gint rows, i = 0; /* this stuff should probably be a table, but the rule parts need to be a vbox */ @@ -623,8 +639,9 @@ get_widget (FilterRule *fr, struct _RuleContext *f) inframe = gtk_vbox_new (FALSE, 3); gtk_container_add (GTK_CONTAINER (frame), inframe); - /* this is the parts list, it should probably be inside a scrolling list */ - parts = gtk_vbox_new (FALSE, 3); + /* this is the parts table, it should probably be inside a scrolling list */ + rows = g_list_length (fr->parts); + parts = gtk_table_new (rows, 2, FALSE); /* data for the parts part of the display */ data = g_malloc0 (sizeof (*data)); @@ -661,17 +678,6 @@ get_widget (FilterRule *fr, struct _RuleContext *f) gtk_signal_connect (GTK_OBJECT (add), "clicked", more_parts, data); gtk_box_pack_start (GTK_BOX (hbox), add, FALSE, FALSE, 3); - pixmap = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_REMOVE); - remove = gnome_pixmap_button (pixmap, _("Remove criterion")); - gtk_object_set_data (GTK_OBJECT (add), "remove", remove); - gtk_button_set_relief (GTK_BUTTON (remove), GTK_RELIEF_NONE); - gtk_signal_connect (GTK_OBJECT (remove), "clicked", less_parts, data); - gtk_box_pack_start (GTK_BOX (hbox), remove, FALSE, FALSE, 3); - - /* if we only have 1 criterion, then we can't remove any more so disable this */ - if (g_list_length (fr->parts) <= 1) - gtk_widget_set_sensitive (remove, FALSE); - gtk_box_pack_end (GTK_BOX (hbox), omenu, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); @@ -680,8 +686,9 @@ get_widget (FilterRule *fr, struct _RuleContext *f) l = fr->parts; while (l) { part = l->data; + d(printf ("adding rule %s\n", part->title)); w = get_rule_part_widget (f, part, fr); - gtk_box_pack_start (GTK_BOX (parts), w, FALSE, FALSE, 3); + attach_rule (w, data, part, i++); l = g_list_next (l); } diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h index 3bf6f96f4f..e561ee8071 100644 --- a/filter/libfilter-i18n.h +++ b/filter/libfilter-i18n.h @@ -1,40 +1,24 @@ /* Automatically generated. Do not edit. */ -char *s = N_("after"); char *s = N_("Assign Colour"); char *s = N_("Assign Score"); char *s = N_("Attachments"); -char *s = N_("before"); -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_("Exist"); -char *s = N_("exists"); char *s = N_("Expression"); char *s = N_("Forward to Address"); char *s = N_("Important"); -char *s = N_("is"); -char *s = N_("is greater than"); -char *s = N_("is less than"); -char *s = N_("is not"); char *s = N_("Mailing list"); char *s = N_("Message Body"); char *s = N_("Message Header"); char *s = N_("Message was received"); char *s = N_("Message was sent"); char *s = N_("Move to Folder"); -char *s = N_("on or after"); -char *s = N_("on or before"); char *s = N_("Read"); char *s = N_("Recipients"); char *s = N_("Regex Match"); @@ -42,11 +26,27 @@ char *s = N_("Replied to"); char *s = N_("Score"); char *s = N_("Sender"); char *s = N_("Set Status"); -char *s = N_("sounds like"); 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_("after"); +char *s = N_("before"); +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 greater than"); +char *s = N_("is less than"); +char *s = N_("is not"); +char *s = N_("is"); +char *s = N_("on or after"); +char *s = N_("on or before"); +char *s = N_("sounds like"); +char *s = N_("starts with"); char *s = N_("was after"); char *s = N_("was before"); |