From 7c3a6662fe5da0353f31c4385e97f6b19c35e511 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Fri, 2 Mar 2001 23:38:12 +0000 Subject: Added option menu to vfolder editor. 2001-03-03 Not Zed * filter.glade: Added option menu to vfolder editor. 2001-03-02 Not Zed * vfolder-rule.c (get_widget): Setup the data on the base source opiton menu, and make hte option menu reflect the source. (select_source_with): Set the source type for this rule. e.g. these folders, "with ..." * filter-editor.c: Removed the N_() stuff from the source_names array, they must not be internationalised!!! svn path=/trunk/; revision=8533 --- filter/ChangeLog | 14 +++ filter/filter-editor.c | 5 +- filter/filter-rule.c | 39 ++++++-- filter/filter.glade | 267 +++++++++++++------------------------------------ filter/vfolder-rule.c | 43 +++++++- 5 files changed, 160 insertions(+), 208 deletions(-) diff --git a/filter/ChangeLog b/filter/ChangeLog index 382b815c4c..3cecbeb156 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,17 @@ +2001-03-03 Not Zed + + * filter.glade: Added option menu to vfolder editor. + +2001-03-02 Not Zed + + * vfolder-rule.c (get_widget): Setup the data on the base source + opiton menu, and make hte option menu reflect the source. + (select_source_with): Set the source type for this + rule. e.g. these folders, "with ..." + + * filter-editor.c: Removed the N_() stuff from the source_names + array, they must not be internationalised!!! + 2001-02-28 Not Zed * filter-rule.c (filter_rule_clone): New function to clone rules. diff --git a/filter/filter-editor.c b/filter/filter-editor.c index 5e06870fe4..5fa1796e3f 100644 --- a/filter/filter-editor.c +++ b/filter/filter-editor.c @@ -429,10 +429,11 @@ select_source (GtkMenuItem *mi, struct _editor_data *data) set_sensitive (data); } +/* these strings must not be internationalised!!!! */ static char *source_names[] = { - N_("incoming"), + "incoming", /*"demand",*/ - N_("outgoing") + "outgoing" }; GtkWidget * diff --git a/filter/filter-rule.c b/filter/filter-rule.c index c5d36d3496..f99c79e89b 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -144,6 +144,9 @@ filter_rule_clone(FilterRule *base, RuleContext *f) xmlNodePtr xml; FilterRule *rule; + g_assert(IS_FILTER_RULE(base)); + g_assert(IS_RULE_CONTEXT(f)); + /* TODO: do this more directly/efficiently */ xml = filter_rule_xml_encode(base); rule = gtk_type_new(((GtkObject *)base)->klass->type); @@ -156,6 +159,8 @@ filter_rule_clone(FilterRule *base, RuleContext *f) void filter_rule_set_name (FilterRule *fr, const char *name) { + g_assert(IS_FILTER_RULE(fr)); + g_free (fr->name); fr->name = g_strdup (name); } @@ -163,6 +168,8 @@ filter_rule_set_name (FilterRule *fr, const char *name) void filter_rule_set_source (FilterRule *fr, const char *source) { + g_assert(IS_FILTER_RULE(fr)); + g_free (fr->source); fr->source = g_strdup (source); } @@ -170,6 +177,8 @@ filter_rule_set_source (FilterRule *fr, const char *source) xmlNodePtr filter_rule_xml_encode (FilterRule *fr) { + g_assert(IS_FILTER_RULE(fr)); + return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->xml_encode(fr); } @@ -188,7 +197,7 @@ xml_encode (FilterRule *fr) xmlSetProp (node, "grouping", "any"); break; } - + if (fr->source) { xmlSetProp (node, "source", fr->source); } else { @@ -197,12 +206,13 @@ xml_encode (FilterRule *fr) } if (fr->name) { - gchar *encstr; + char *encstr; + work = xmlNewNode (NULL, "title"); - encstr = e_utf8_xml1_encode (fr->name); - xmlNodeSetContent (work, encstr); - g_free (encstr); - xmlAddChild (node, work); + encstr = e_utf8_xml1_encode(fr->name); + xmlNodeSetContent(work, encstr); + g_free(encstr); + xmlAddChild(node, work); } set = xmlNewNode (NULL, "partset"); @@ -247,6 +257,10 @@ load_set (xmlNodePtr node, FilterRule *fr, RuleContext *f) int filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f) { + g_assert(IS_FILTER_RULE(fr)); + g_assert(IS_RULE_CONTEXT(f)); + g_assert(node != NULL); + return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->xml_decode(fr, node, f); } @@ -299,12 +313,18 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f) void filter_rule_add_part (FilterRule *fr, FilterPart *fp) { + g_assert(IS_FILTER_RULE(fr)); + g_assert(IS_FILTER_PART(fp)); + fr->parts = g_list_append (fr->parts, fp); } void filter_rule_remove_part (FilterRule *fr, FilterPart *fp) { + g_assert(IS_FILTER_RULE(fr)); + g_assert(IS_FILTER_PART(fp)); + fr->parts = g_list_remove (fr->parts, fp); } @@ -312,6 +332,10 @@ void filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new) { GList *l; + + g_assert(IS_FILTER_RULE(fr)); + g_assert(IS_FILTER_PART(fp)); + g_assert(IS_FILTER_PART(new)); l = g_list_find (fr->parts, fp); if (l) { @@ -324,6 +348,9 @@ filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new) void filter_rule_build_code (FilterRule *fr, GString *out) { + g_assert(IS_FILTER_RULE(fr)); + g_assert(out != NULL); + return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->build_code(fr, out); } diff --git a/filter/filter.glade b/filter/filter.glade index 96eeb3dc63..259234acbe 100644 --- a/filter/filter.glade +++ b/filter/filter.glade @@ -459,219 +459,72 @@ Outgoing - GtkHBox - hbox3 + GtkVBox + vbox3 False 0 - GtkScrolledWindow - scrolledwindow3 - 256 - 125 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS + GtkOptionMenu + source_option + True + specific folders only +with all local folders +with all active remote folders +with all local and active remote folders + + 0 0 - True - True + False + False - - - GtkViewport - viewport3 - GTK_SHADOW_IN - - - GtkList - source_list - GTK_SELECTION_SINGLE - - - GtkVBox - vbox3 + GtkHBox + hbox3 False 0 0 - False - False + True + True - GtkVButtonBox - vbuttonbox3 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 6 - 0 + GtkScrolledWindow + scrolledwindow3 + 256 + 125 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS 0 - False - False + True + True - GtkButton - source_add - True - True - - - - - GtkButton - source_remove - True - True - - - - - - - - - - - GnomeDialog - vfolder_source - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox3 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area3 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button16 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button17 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button18 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkFrame - vfolder_source_frame - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox3 - False - 0 - - - GtkScrolledWindow - scrolledwindow3 - 256 - 125 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkViewport - viewport3 - GTK_SHADOW_IN - - - GtkList - source_list - GTK_SELECTION_SINGLE + GtkViewport + viewport3 + GTK_SHADOW_IN + + + GtkList + source_list + GTK_SELECTION_SINGLE + - - - - GtkVBox - vbox3 - False - 0 - - 0 - False - False - - GtkVButtonBox - vbuttonbox3 - GTK_BUTTONBOX_DEFAULT_STYLE + GtkVBox + vbox3 + False 0 - 85 - 27 - 6 - 0 0 False @@ -679,19 +532,35 @@ Outgoing - GtkButton - source_add - True - True - - - - - GtkButton - source_remove - True - True - + GtkVButtonBox + vbuttonbox3 + GTK_BUTTONBOX_DEFAULT_STYLE + 0 + 85 + 27 + 6 + 0 + + 0 + False + False + + + + GtkButton + source_add + True + True + + + + + GtkButton + source_remove + True + True + + diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c index 322e3eabb7..8c58d0ba5e 100644 --- a/filter/vfolder-rule.c +++ b/filter/vfolder-rule.c @@ -258,6 +258,14 @@ select_source(GtkWidget *w, GtkWidget *child, struct _source_data *data) set_sensitive(data); } +static void +select_source_with(GtkWidget *w, struct _source_data *data) +{ + char *source = gtk_object_get_data((GtkObject *)w, "source"); + + filter_rule_set_source((FilterRule *)data->vr, source); +} + static void source_add(GtkWidget *widget, struct _source_data *data) { const char *allowed_types[] = { "mail", NULL }; @@ -313,6 +321,14 @@ static void source_remove(GtkWidget *widget, struct _source_data *data) set_sensitive(data); } +/* DO NOT internationalise these strings */ +const char *source_names[] = { + "specific", + "local", + "remote_active", + "local_remote_active" +}; + static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) { GtkWidget *widget, *frame, *w; @@ -320,7 +336,7 @@ static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) const char *source; VfolderRule *vr = (VfolderRule *)fr; struct _source_data *data; - int i; + int i, row; GList *l; widget = ((FilterRuleClass *)(parent_class))->get_widget(fr, f); @@ -354,6 +370,31 @@ static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) } gtk_list_append_items(data->list, l); gtk_signal_connect((GtkObject *)w, "select_child", select_source, data); + + w = glade_xml_get_widget (gui, "source_option"); + l = GTK_MENU_SHELL (GTK_OPTION_MENU (w)->menu)->children; + i = 0; + row = 0; + while (l) { + GtkWidget *b = GTK_WIDGET (l->data); + + /* make sure that the glade is in sync with the source list! */ + if (i < sizeof (source_names) / sizeof (source_names[0])) { + gtk_object_set_data (GTK_OBJECT (b), "source", (char *)source_names[i]); + if (fr->source && strcmp(source_names[i], fr->source) == 0) { + row = i; + } + } else { + g_warning("Glade file " FILTER_GLADEDIR "/filter.glade out of sync with editor code"); + } + gtk_signal_connect (GTK_OBJECT (b), "activate", select_source_with, data); + + i++; + l = l->next; + } + + gtk_option_menu_set_history(GTK_OPTION_MENU(w), row); + set_sensitive(data); gtk_box_pack_start(GTK_BOX(widget), frame, TRUE, TRUE, 3); -- cgit v1.2.3