diff options
author | Not Zed <NotZed@Ximian.com> | 2001-03-15 14:55:22 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-03-15 14:55:22 +0800 |
commit | e8fad70e9ff924c66434cab62775478617550476 (patch) | |
tree | fd0cd5cc07a37fede475c884205a11586528ff50 | |
parent | d365f590272614905f8d3e6445370645a61ad80c (diff) | |
download | gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.tar gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.tar.gz gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.tar.bz2 gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.tar.lz gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.tar.xz gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.tar.zst gsoc2013-evolution-e8fad70e9ff924c66434cab62775478617550476.zip |
Changed the edit_filter to be a standalone window rather than a widget, so
2001-03-15 Not Zed <NotZed@Ximian.com>
* filter.glade: Changed the edit_filter to be a standalone window
rather than a widget, so we can get the rule editor part out
separately. Same for vfolder editor, and new score, and basic rule
editors.
* score-editor.c (score_editor_new): Turned back on object
stuff, subclass rule-editor, and removed most of the code.
* filter-editor.c (filter_editor_new): Turned into an object,
subclass rule-editor, removed most of the code. Now we accept the
source list during create, and plug that into the glade.
* vfolder-editor.c (vfolder_editor_new): Turned back on object
stuff, subclass rule-editor, and removed most of the code.
* Makefile.am (libfilter_la_SOURCES): Added rule-editor.[ch].
* filter-filter.c (validate): inherit the validate function and
also validate the actions part of a filterfilter.
* filter-rule.c (filter_rule_validate): New method so that filter
rules can validate themselves.
(validate): Default implementation, validates base rules.
* rule-editor.h: New generic rule editor, to be used for filter
editor/vfolder editor/score editor/saved searches editor.
svn path=/trunk/; revision=8729
-rw-r--r-- | filter/ChangeLog | 29 | ||||
-rw-r--r-- | filter/Makefile.am | 2 | ||||
-rw-r--r-- | filter/filter-editor.c | 421 | ||||
-rw-r--r-- | filter/filter-editor.h | 20 | ||||
-rw-r--r-- | filter/filter-filter.c | 21 | ||||
-rw-r--r-- | filter/filter-rule.c | 25 | ||||
-rw-r--r-- | filter/filter-rule.h | 4 | ||||
-rw-r--r-- | filter/filter.glade | 153 | ||||
-rw-r--r-- | filter/rule-editor.c | 475 | ||||
-rw-r--r-- | filter/rule-editor.h | 74 | ||||
-rw-r--r-- | filter/score-editor.c | 296 | ||||
-rw-r--r-- | filter/score-editor.h | 19 | ||||
-rw-r--r-- | filter/vfolder-editor.c | 312 | ||||
-rw-r--r-- | filter/vfolder-editor.h | 20 |
14 files changed, 943 insertions, 928 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index 507984e576..7e4776dd6f 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,32 @@ +2001-03-15 Not Zed <NotZed@Ximian.com> + + * filter.glade: Changed the edit_filter to be a standalone window + rather than a widget, so we can get the rule editor part out + separately. Same for vfolder editor, and new score, and basic rule + editors. + + * score-editor.c (score_editor_new): Turned back on object + stuff, subclass rule-editor, and removed most of the code. + + * filter-editor.c (filter_editor_new): Turned into an object, + subclass rule-editor, removed most of the code. Now we accept the + source list during create, and plug that into the glade. + + * vfolder-editor.c (vfolder_editor_new): Turned back on object + stuff, subclass rule-editor, and removed most of the code. + + * Makefile.am (libfilter_la_SOURCES): Added rule-editor.[ch]. + + * filter-filter.c (validate): inherit the validate function and + also validate the actions part of a filterfilter. + + * filter-rule.c (filter_rule_validate): New method so that filter + rules can validate themselves. + (validate): Default implementation, validates base rules. + + * rule-editor.h: New generic rule editor, to be used for filter + editor/vfolder editor/score editor/saved searches editor. + 2001-03-15 Gediminas Paulauskas <menesis@delfi.lt> * filter-system-flag.c: translate status flag title. diff --git a/filter/Makefile.am b/filter/Makefile.am index 89a9c2f257..f844559fb4 100644 --- a/filter/Makefile.am +++ b/filter/Makefile.am @@ -55,6 +55,8 @@ libfilter_la_SOURCES = \ filter-url.h \ rule-context.c \ rule-context.h \ + rule-editor.c \ + rule-editor.h \ score-context.c \ score-context.h \ score-editor.c \ diff --git a/filter/filter-editor.c b/filter/filter-editor.c index 1c6c46291b..66891e0c2c 100644 --- a/filter/filter-editor.c +++ b/filter/filter-editor.c @@ -1,5 +1,5 @@ /* - * 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> @@ -30,7 +30,8 @@ #define d(x) -#if 0 +static FilterRule * create_rule(RuleEditor *re); + static void filter_editor_class_init (FilterEditorClass *class); static void filter_editor_init (FilterEditor *gspaper); static void filter_editor_finalise (GtkObject *obj); @@ -64,7 +65,7 @@ filter_editor_get_type (void) (GtkArgGetFunc)NULL }; - type = gtk_type_unique (gnome_dialog_get_type (), &type_info); + type = gtk_type_unique (rule_editor_get_type (), &type_info); } return type; @@ -73,14 +74,16 @@ filter_editor_get_type (void) static void filter_editor_class_init (FilterEditorClass *class) { - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class (gnome_dialog_get_type ()); + GtkObjectClass *object_class = (GtkObjectClass *)class; + RuleEditorClass *re_class = (RuleEditorClass *)class; + + parent_class = gtk_type_class(gnome_dialog_get_type ()); object_class->finalize = filter_editor_finalise; + /* override methods */ - + re_class->create_rule = create_rule; + /* signals */ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); @@ -97,6 +100,8 @@ filter_editor_finalise (GtkObject *obj) { FilterEditor *o = (FilterEditor *)obj; + g_free(o->priv); + ((GtkObjectClass *)(parent_class))->finalize(obj); } @@ -108,388 +113,68 @@ filter_editor_finalise (GtkObject *obj) * Return value: A new #FilterEditor object. **/ FilterEditor * -filter_editor_new (void) +filter_editor_new(FilterContext *f, const char **source_names) { FilterEditor *o = (FilterEditor *)gtk_type_new (filter_editor_get_type ()); - return o; -} - -#endif - - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _editor_data { - RuleContext *f; - FilterRule *current; - GtkList *list; - GtkButton *buttons[BUTTON_LAST]; - char *current_source; -}; + GladeXML *gui; + GtkWidget *w; -static void set_sensitive (struct _editor_data *data); + gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "rule_editor"); + filter_editor_construct(o, f, gui, source_names); -static void -rule_add (GtkWidget *widget, struct _editor_data *data) -{ - FilterFilter *rule; - int result; - GtkWidget *gd; - GtkWidget *w; - FilterPart *part; - gboolean done = FALSE; - - d(printf ("add rule\n")); - /* create a new rule with 1 match and 1 action */ - rule = filter_filter_new (); - filter_rule_set_source ((FilterRule *)rule, data->current_source); - - part = rule_context_next_part (data->f, NULL); - filter_rule_add_part ((FilterRule *)rule, filter_part_clone (part)); - part = filter_context_next_action ((FilterContext *)data->f, NULL); - filter_filter_add_action (rule, filter_part_clone (part)); - - w = filter_rule_get_widget ((FilterRule *)rule, data->f); - gd = gnome_dialog_new (_("Add Filter Rule"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0); - - gtk_widget_show (gd); - - while (!done) { - result = gnome_dialog_run (GNOME_DIALOG (gd)); - - if (result == 0) { - GtkWidget *item; - GList *parts, *l = NULL; - gchar *s; - - done = TRUE; - - /* validate rule parts */ - parts = ((FilterRule *)rule)->parts; - while (parts && done) { - done = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - /* validate action parts */ - parts = rule->actions; - while (parts && done) { - done = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - if (done) { - s = e_utf8_to_gtk_string (GTK_WIDGET (data->list), ((FilterRule *)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 (item); - - l = g_list_append (l, GTK_LIST_ITEM (item)); - - gtk_list_append_items (data->list, l); - gtk_list_select_child (data->list, item); - - data->current = (FilterRule *)rule; - rule_context_add_rule (data->f, (FilterRule *)rule); - - set_sensitive (data); - gtk_widget_destroy (gd); - } - } else { - gtk_widget_destroy (gd); - gtk_object_unref (GTK_OBJECT (rule)); - done = TRUE; - } - } -} + w = glade_xml_get_widget(gui, "rule_frame"); + gtk_frame_set_label((GtkFrame *)w, _("Filter Rules")); -static void -rule_edit (GtkWidget *widget, struct _editor_data *data) -{ - GtkWidget *w; - int result; - GtkWidget *gd; - FilterRule *rule; - gboolean done = FALSE; - int pos; - - d(printf ("edit rule\n")); - rule = data->current; - w = filter_rule_get_widget (rule, data->f); - gd = gnome_dialog_new (_("Edit Filter Rule"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0); - - gtk_widget_show (gd); - - while (!done) { - result = gnome_dialog_run (GNOME_DIALOG (gd)); - - if (result == 0) { - GList *parts; - - done = TRUE; - - /* validate rule parts */ - parts = rule->parts; - while (parts && done) { - done = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - /* validate action parts */ - parts = ((FilterFilter *)rule)->actions; - while (parts && done) { - done = filter_part_validate ((FilterPart *) parts->data); - parts = parts->next; - } - - if (done) { - pos = rule_context_get_rank_rule (data->f, data->current, data->current_source); - if (pos != -1) { - GtkListItem *item = g_list_nth_data (data->list->children, pos); - gchar *s = e_utf8_to_gtk_string (GTK_WIDGET (item), data->current->name); - gtk_label_set_text (GTK_LABEL (GTK_BIN (item)->child), s); - g_free (s); - } - gtk_widget_destroy (gd); - } - } else { - gtk_widget_destroy (gd); - done = TRUE; - } - } -} + gtk_object_unref((GtkObject *)gui); -static void -rule_delete (GtkWidget *widget, struct _editor_data *data) -{ - int pos; - GList *l; - GtkListItem *item; - - d(printf("delete rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current, data->current_source); - if (pos != -1) { - rule_context_remove_rule (data->f, data->current); - - item = g_list_nth_data (data->list->children, pos); - l = g_list_append (NULL, item); - gtk_list_remove_items (data->list, l); - g_list_free (l); - - gtk_object_unref (GTK_OBJECT (data->current)); - data->current = NULL; - } - - set_sensitive (data); + return o; } static void -rule_move (struct _editor_data *data, int from, int to) +select_source (GtkMenuItem *mi, FilterEditor *fe) { - GList *l; - GtkListItem *item; - - d(printf("moving %d to %d\n", from, to)); - rule_context_rank_rule (data->f, data->current, to); + char *source; - item = g_list_nth_data (data->list->children, from); - l = g_list_append (NULL, item); - gtk_list_remove_items_no_unref (data->list, l); - gtk_list_insert_items (data->list, l, to); - gtk_list_select_child (data->list, GTK_WIDGET (item)); - set_sensitive (data); -} + source = gtk_object_get_data(GTK_OBJECT(mi), "source"); + g_assert(source); -static void -rule_up (GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("up rule\n")); - pos = rule_context_get_rank_rule (data->f, data->current, data->current_source); - if (pos > 0) { - rule_move (data, pos, pos - 1); - } + rule_editor_set_source((RuleEditor *)fe, source); } -static void -rule_down (GtkWidget *widget, struct _editor_data *data) +void +filter_editor_construct(FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names) { - int pos; - - d(printf ("down rule\n")); - pos = rule_context_get_rank_rule (data->f, data->current, data->current_source); - rule_move (data, pos, pos + 1); -} + GtkWidget *menu, *item, *omenu; + int i; -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "rule_add", rule_add }, - { "rule_edit", rule_edit }, - { "rule_delete", rule_delete }, - { "rule_up", rule_up }, - { "rule_down", rule_down }, -}; + omenu = glade_xml_get_widget (gui, "filter_source"); + menu = GTK_OPTION_MENU(omenu)->menu; + for (i=0;source_names[i];i++) { + item = gtk_menu_item_new_with_label(_(source_names[i])); + gtk_object_set_data_full(GTK_OBJECT(item), "source", g_strdup(source_names[i]), g_free); + gtk_menu_append(GTK_MENU(menu), item); + gtk_widget_show((GtkWidget *)item); + gtk_signal_connect(GTK_OBJECT(item), "activate", select_source, fe); -static void -set_sensitive (struct _editor_data *data) -{ - FilterRule *rule = NULL; - int index = -1, count = 0; - - while ((rule = rule_context_next_rule (data->f, rule, data->current_source))) { - if (rule == data->current) - index = count; - count++; } - - d(printf ("index = %d count=%d\n", index, count)); - - count--; - - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_EDIT]), index != -1); - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_DELETE]), index != -1); - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_UP]), index > 0); - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_DOWN]), index >= 0 && index < count); -} + gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu); + gtk_widget_show((GtkWidget *)omenu); -static void -select_rule (GtkWidget *w, GtkWidget *child, struct _editor_data *data) -{ - data->current = gtk_object_get_data (GTK_OBJECT (child), "rule"); - - if (data->current) - d(printf ("selected rule: %s\n", data->current->name)); - else - d(printf ("bad data?\n")); - - set_sensitive (data); + rule_editor_construct((RuleEditor *)fe, (RuleContext *)fc, gui, source_names[0]); } -static void -double_click (GtkWidget *widget, GdkEventButton *event, struct _editor_data *data) +static FilterRule * +create_rule(RuleEditor *re) { - if (data->current && event->type == GDK_2BUTTON_PRESS) - rule_edit (widget, data); -} - -/* FIXME: we need a way to change a rule from one source type - * to a different type. Maybe keep the selected ones? - */ - -static void -select_source (GtkMenuItem *mi, struct _editor_data *data) -{ - FilterRule *rule = NULL; - GList *newitems = NULL; - char *source; - - source = gtk_object_get_data (GTK_OBJECT (mi), "source"); - - gtk_list_clear_items (GTK_LIST (data->list), 0, -1); - - d(printf ("Checking for rules that are of type %d\n", source)); - while ((rule = rule_context_next_rule (data->f, rule, source)) != NULL) { - GtkWidget *item; - char *s; - - d(printf (" hit %s (%d)\n", rule->name, source)); - s = e_utf8_to_gtk_string (GTK_WIDGET (data->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 (data->list, newitems); - data->current_source = source; - data->current = NULL; - set_sensitive (data); -} + FilterRule *rule = filter_rule_new(); + FilterPart *part; -/* these strings must not be internationalised!!!! */ -static char *source_names[] = { - "incoming", - /*"demand",*/ - "outgoing" -}; + /* create a rule with 1 part & 1 action in it */ + rule = (FilterRule *)filter_filter_new(); + part = rule_context_next_part(re->context, NULL); + filter_rule_add_part(rule, filter_part_clone(part)); + part = filter_context_next_action ((FilterContext *)re->context, NULL); + filter_filter_add_action((FilterFilter *)rule, filter_part_clone (part)); -GtkWidget * -filter_editor_construct (struct _FilterContext *f) -{ - GladeXML *gui; - GtkWidget *d, *w, *b, *firstitem = NULL; - GList *l; - struct _editor_data *data; - int i; - - g_assert (IS_FILTER_CONTEXT (f)); - - data = g_malloc0 (sizeof (*data)); - data->f = (RuleContext *)f; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "edit_filter"); - d = glade_xml_get_widget (gui, "edit_filter"); - gtk_object_set_data_full (GTK_OBJECT (d), "data", data, g_free); - - gtk_window_set_title (GTK_WINDOW (d), _("Edit Filters")); - for (i = 0; i < BUTTON_LAST; i++) { - data->buttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect (GTK_OBJECT (w), "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "filter_source"); - l = GTK_MENU_SHELL (GTK_OPTION_MENU (w)->menu)->children; - i = 0; - while (l) { - b = GTK_WIDGET (l->data); - - if (i == 0) - firstitem = b; - - /* 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", source_names[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, data); - - i++; - l = l->next; - } - - w = glade_xml_get_widget (gui, "rule_list"); - data->list = GTK_LIST (w); - gtk_signal_connect (GTK_OBJECT (w), "select_child", select_rule, data); - gtk_signal_connect (GTK_OBJECT (w), "button_press_event", double_click, data); - select_source (GTK_MENU_ITEM (firstitem), data); - - set_sensitive (data); - - gtk_object_unref (GTK_OBJECT (gui)); - - return d; + return rule; } diff --git a/filter/filter-editor.h b/filter/filter-editor.h index 20369a9536..44f99a7df6 100644 --- a/filter/filter-editor.h +++ b/filter/filter-editor.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Helix Code Inc. + * Copyright (C) 2000, 2001 Ximian Inc. * * Authors: Not Zed <notzed@lostzed.mmc.com.au> * @@ -22,10 +22,7 @@ #define _FILTER_EDITOR_H #include <gtk/gtk.h> -#include <libgnomeui/gnome-dialog.h> - -#if 0 -/* NOTE: object stuff not used (yet?), this is just a holder file for a static factory */ +#include "rule-editor.h" #define FILTER_EDITOR(obj) GTK_CHECK_CAST (obj, filter_editor_get_type (), FilterEditor) #define FILTER_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_editor_get_type (), FilterEditorClass) @@ -35,27 +32,24 @@ typedef struct _FilterEditor FilterEditor; typedef struct _FilterEditorClass FilterEditorClass; struct _FilterEditor { - GnomeDialog parent; + RuleEditor parent; struct _FilterEditorPrivate *priv; }; struct _FilterEditorClass { - GnomeDialogClass parent_class; + RuleEditorClass parent_class; /* virtual methods */ /* signals */ }; -guint filter_editor_get_type (void); -FilterEditor *filter_editor_new (void); -#endif - struct _FilterContext; -/* methods */ -GtkWidget *filter_editor_construct (struct _FilterContext *f); +guint filter_editor_get_type (void); +FilterEditor *filter_editor_new(struct _FilterContext *f, const char **source_names); +void filter_editor_construct(FilterEditor *fe, struct _FilterContext *fc, struct _GladeXML *gui, const char **source_names); #endif /* ! _FILTER_EDITOR_H */ diff --git a/filter/filter-filter.c b/filter/filter-filter.c index bcd92d8534..ebd3560863 100644 --- a/filter/filter-filter.c +++ b/filter/filter-filter.c @@ -29,6 +29,7 @@ #define d(x) +static int validate(FilterRule *); static xmlNodePtr xml_encode (FilterRule *); static int xml_decode (FilterRule *, xmlNodePtr, struct _RuleContext *f); /*static void build_code(FilterRule *, GString *out);*/ @@ -85,6 +86,7 @@ filter_filter_class_init (FilterFilterClass *class) object_class->finalize = filter_filter_finalise; /* override methods */ + filter_rule->validate = validate; filter_rule->xml_encode = xml_encode; filter_rule->xml_decode = xml_decode; /*filter_rule->build_code = build_code;*/ @@ -167,6 +169,25 @@ filter_filter_build_action (FilterFilter *fr, GString *out) g_string_append (out, ")\n"); } +static int +validate(FilterRule *fr) +{ + int valid; + GList *parts; + FilterFilter *ff = (FilterFilter *)fr; + + valid = ((FilterRuleClass *)(parent_class))->validate(fr); + + /* validate rule actions */ + parts = ff->actions; + while (parts && valid) { + valid = filter_part_validate((FilterPart *)parts->data); + parts = parts->next; + } + + return valid; +} + static xmlNodePtr xml_encode (FilterRule *fr) { diff --git a/filter/filter-rule.c b/filter/filter-rule.c index f99c79e89b..e63e7df5fd 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -30,6 +30,7 @@ #define d(x) +static int validate(FilterRule *); static xmlNodePtr xml_encode (FilterRule *); static int xml_decode (FilterRule *, xmlNodePtr, RuleContext *); static void build_code (FilterRule *, GString * out); @@ -86,6 +87,7 @@ filter_rule_class_init (FilterRuleClass * class) object_class->finalize = filter_rule_finalise; /* override methods */ + class->validate = validate; class->xml_encode = xml_encode; class->xml_decode = xml_decode; class->build_code = build_code; @@ -174,6 +176,29 @@ filter_rule_set_source (FilterRule *fr, const char *source) fr->source = g_strdup (source); } +int filter_rule_validate (FilterRule *fr) +{ + g_assert(IS_FILTER_RULE(fr)); + + return ((FilterRuleClass *) ((GtkObject *) fr)->klass)->validate(fr); +} + +static int +validate(FilterRule *fr) +{ + int valid = TRUE; + GList *parts; + + /* validate rule parts */ + parts = fr->parts; + while (parts && valid) { + valid = filter_part_validate((FilterPart *)parts->data); + parts = parts->next; + } + + return valid; +} + xmlNodePtr filter_rule_xml_encode (FilterRule *fr) { diff --git a/filter/filter-rule.h b/filter/filter-rule.h index 3fc00fe598..8f194f54c8 100644 --- a/filter/filter-rule.h +++ b/filter/filter-rule.h @@ -60,6 +60,8 @@ struct _FilterRuleClass { GtkObjectClass parent_class; /* virtual methods */ + int (*validate)(FilterRule *); + xmlNodePtr (*xml_encode)(FilterRule *); int (*xml_decode)(FilterRule *, xmlNodePtr, struct _RuleContext *); @@ -79,6 +81,8 @@ FilterRule *filter_rule_clone (FilterRule *base, struct _RuleContext *f); void filter_rule_set_name (FilterRule *fr, const char *name); void filter_rule_set_source (FilterRule *fr, const char *source); +int filter_rule_validate (FilterRule *fr); + xmlNodePtr filter_rule_xml_encode (FilterRule *fr); int filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, struct _RuleContext *f); diff --git a/filter/filter.glade b/filter/filter.glade index 259234acbe..478ed32ad2 100644 --- a/filter/filter.glade +++ b/filter/filter.glade @@ -14,7 +14,7 @@ <widget> <class>GnomeDialog</class> - <name>edit_filter</name> + <name>edit_filter_2</name> <title>Edit Filters</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> @@ -205,7 +205,7 @@ Outgoing <widget> <class>GnomeDialog</class> - <name>edit_vfolder</name> + <name>edit_vfolder_2</name> <title>Edit VFolders</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> @@ -569,4 +569,153 @@ with all local and active remote folders </widget> </widget> +<widget> + <class>GtkWindow</class> + <name>edit_filter</name> + <title>window1</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <modal>False</modal> + <allow_shrink>False</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + + <widget> + <class>GtkVBox</class> + <name>rule_editor</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkOptionMenu</class> + <name>filter_source</name> + <visible>False</visible> + <can_focus>True</can_focus> + <items>Incoming +</items> + <initial_choice>0</initial_choice> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + + <widget> + <class>GtkFrame</class> + <name>rule_frame</name> + <label>Filter Rules</label> + <label_xalign>0</label_xalign> + <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkHBox</class> + <name>hbox4</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkScrolledWindow</class> + <name>scrolledwindow4</name> + <width>256</width> + <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> + <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> + <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> + <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkViewport</class> + <name>viewport4</name> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkList</class> + <name>rule_list</name> + <selection_mode>GTK_SELECTION_SINGLE</selection_mode> + </widget> + </widget> + </widget> + + <widget> + <class>GtkVBox</class> + <name>vbox5</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>GtkVButtonBox</class> + <name>vbuttonbox4</name> + <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> + <spacing>0</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>6</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + + <widget> + <class>GtkButton</class> + <name>rule_add</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>Add</label> + </widget> + + <widget> + <class>GtkButton</class> + <name>rule_edit</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>Edit</label> + </widget> + + <widget> + <class>GtkButton</class> + <name>rule_delete</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>Delete</label> + </widget> + + <widget> + <class>GtkButton</class> + <name>rule_up</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_UP</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>rule_down</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_DOWN</stock_button> + </widget> + </widget> + </widget> + </widget> + </widget> + </widget> +</widget> + </GTK-Interface> diff --git a/filter/rule-editor.c b/filter/rule-editor.c new file mode 100644 index 0000000000..dbe8a5d117 --- /dev/null +++ b/filter/rule-editor.c @@ -0,0 +1,475 @@ +/* + * Copyright (C) 2000 Helix Code Inc. + * + * Authors: Not Zed <notzed@lostzed.mmc.com.au> + * Jeffrey Stedfast <fejj@helixcode.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> +#include <gnome.h> +#include <glade/glade.h> + +#include <gal/widgets/e-unicode.h> +#include "rule-editor.h" +#include "rule-context.h" +#include "filter-rule.h" + +#define d(x) + +static void set_source(RuleEditor *re, const char *source); +static void set_sensitive(RuleEditor *re); +static FilterRule *create_rule(RuleEditor *re); + +static void rule_editor_class_init(RuleEditorClass *class); +static void rule_editor_init(RuleEditor *gspaper); +static void rule_editor_finalise(GtkObject *obj); + +#define _PRIVATE(x)(((RuleEditor *)(x))->priv) + +enum { + BUTTON_ADD, + BUTTON_EDIT, + BUTTON_DELETE, + BUTTON_UP, + BUTTON_DOWN, + BUTTON_LAST +}; + +struct _RuleEditorPrivate { + GtkButton *buttons[BUTTON_LAST]; +}; + +static GnomeDialogClass *parent_class; + +enum { + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +guint +rule_editor_get_type(void) +{ + static guint type = 0; + + if(!type) { + GtkTypeInfo type_info = { + "RuleEditor", + sizeof(RuleEditor), + sizeof(RuleEditorClass), + (GtkClassInitFunc)rule_editor_class_init, + (GtkObjectInitFunc)rule_editor_init, + (GtkArgSetFunc)NULL, + (GtkArgGetFunc)NULL + }; + + type = gtk_type_unique(gnome_dialog_get_type(), &type_info); + } + + return type; +} + +static void +rule_editor_class_init(RuleEditorClass *class) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass *)class; + parent_class = gtk_type_class(gnome_dialog_get_type()); + + object_class->finalize = rule_editor_finalise; + + /* override methods */ + class->set_source = set_source; + class->set_sensitive = set_sensitive; + class->create_rule = create_rule; + + /* signals */ + + gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); +} + +static void +rule_editor_init(RuleEditor *o) +{ + o->priv = g_malloc0(sizeof(*o->priv)); +} + +static void +rule_editor_finalise(GtkObject *obj) +{ + RuleEditor *o = (RuleEditor *)obj; + + gtk_object_unref((GtkObject *)o->context); + + g_free(o->priv); + + ((GtkObjectClass *)(parent_class))->finalize(obj); +} + +/** + * rule_editor_new: + * + * Create a new RuleEditor object. + * + * Return value: A new #RuleEditor object. + **/ +RuleEditor * +rule_editor_new(RuleContext *f, const char *source) +{ + GladeXML *gui; + RuleEditor *o = (RuleEditor *)gtk_type_new(rule_editor_get_type()); + GtkWidget *w; + + gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "rule_editor"); + rule_editor_construct(o, f, gui, source); + + w = glade_xml_get_widget(gui, "rule_frame"); + gtk_frame_set_label((GtkFrame *)w, _("Rules")); + + gtk_object_unref((GtkObject *)gui); + + return o; +} + +/* used internally by implementations if required */ +void +rule_editor_set_sensitive(RuleEditor *re) +{ + return ((RuleEditorClass *)((GtkObject *)re)->klass)->set_sensitive(re); +} + +/* used internally by implementations */ +void +rule_editor_set_source(RuleEditor *re, const char *source) +{ + return ((RuleEditorClass *)((GtkObject *)re)->klass)->set_source(re, source); +} + +/* factory method for "add" button */ +FilterRule * +rule_editor_create_rule(RuleEditor *re) +{ + return ((RuleEditorClass *)((GtkObject *)re)->klass)->create_rule(re); +} + +static FilterRule * +create_rule(RuleEditor *re) +{ + FilterRule *rule = filter_rule_new(); + FilterPart *part; + + /* create a rule with 1 part in it */ + part = rule_context_next_part(re->context, NULL); + filter_rule_add_part(rule, filter_part_clone(part)); + + return rule; +} + +static void +add_editor_clicked(GtkWidget *widget, int button, RuleEditor *re) +{ + GtkWidget *item; + GList *l = NULL; + char *s; + + switch (button) { + case 0: + if (!filter_rule_validate(re->edit)) { + /* FIXME: popup an error or somelthing? */ + return; + } + + gtk_object_ref((GtkObject *)re->edit); + s = e_utf8_to_gtk_string(GTK_WIDGET(re->list), re->edit->name); + item = gtk_list_item_new_with_label(s); + g_free(s); + + gtk_object_set_data(GTK_OBJECT(item), "rule", re->edit); + gtk_widget_show(item); + + l = g_list_append(l, GTK_LIST_ITEM(item)); + + gtk_list_append_items(re->list, l); + gtk_list_select_child(re->list, item); + + re->current = re->edit; + rule_context_add_rule(re->context, re->current); + + rule_editor_set_sensitive(re); + case 1: + default: + gnome_dialog_close((GnomeDialog *)widget); + case -1: + gtk_object_unref((GtkObject *)re->edit); + re->edit = FALSE; + gtk_widget_set_sensitive((GtkWidget *)re, TRUE); + } +} + +static void +rule_add(GtkWidget *widget, RuleEditor *re) +{ + GtkWidget *gd; + GtkWidget *w; + + d(printf("add rule\n")); + + if (re->edit != NULL) + return; + + re->edit = rule_editor_create_rule(re); + filter_rule_set_source(re->edit, re->source); + w = filter_rule_get_widget(re->edit, re->context); + + gd = gnome_dialog_new(_("Add Rule"), + GNOME_STOCK_BUTTON_OK, + GNOME_STOCK_BUTTON_CANCEL, + NULL); + gtk_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE); + gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(gd)->vbox), w, TRUE, TRUE, 0); + gtk_signal_connect((GtkObject *)gd, "clicked", add_editor_clicked, re); + + gtk_widget_set_sensitive((GtkWidget *)re, FALSE); + + gtk_widget_show(gd); +} + +static void +edit_editor_clicked(GtkWidget *widget, int button, RuleEditor *re) +{ + GtkWidget *item; + char *s; + int pos; + + switch (button) { + case 0: + if (!filter_rule_validate(re->edit)) { + /* FIXME: popup an error or somelthing? */ + return; + } + + pos = rule_context_get_rank_rule(re->context, re->current, re->source); + if(pos != -1) { + item = g_list_nth_data(((GtkList *)re->list)->children, pos); + s = e_utf8_to_gtk_string(GTK_WIDGET(item), re->current->name); + gtk_label_set_text(GTK_LABEL(GTK_BIN(item)->child), s); + g_free(s); + } + case 1: + default: + gnome_dialog_close((GnomeDialog *)widget); + case -1: + gtk_object_unref((GtkObject *)re->edit); + re->edit = FALSE; + gtk_widget_set_sensitive((GtkWidget *)re, TRUE); + } +} + +static void +rule_edit(GtkWidget *widget, RuleEditor *re) +{ + GtkWidget *w; + GtkWidget *gd; + + if (re->edit != NULL || re->current == NULL) + return; + + re->edit = re->current; + w = filter_rule_get_widget(re->current, re->context); + gd = gnome_dialog_new(_("Edit Rule"), + GNOME_STOCK_BUTTON_OK, + GNOME_STOCK_BUTTON_CANCEL, + NULL); + gtk_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE); + gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(gd)->vbox), w, TRUE, TRUE, 0); + gtk_signal_connect((GtkObject *)gd, "clicked", edit_editor_clicked, re); + + gtk_widget_set_sensitive((GtkWidget *)re, FALSE); + + gtk_widget_show(gd); +} + +static void +rule_delete(GtkWidget *widget, RuleEditor *re) +{ + int pos; + GList *l; + GtkListItem *item; + + d(printf("delete rule\n")); + pos = rule_context_get_rank_rule(re->context, re->current, re->source); + if(pos != -1) { + rule_context_remove_rule(re->context, re->current); + + item = g_list_nth_data(((GtkList *)re->list)->children, pos); + l = g_list_append(NULL, item); + gtk_list_remove_items(re->list, l); + g_list_free(l); + + gtk_object_unref(GTK_OBJECT(re->current)); + re->current = NULL; + } + + rule_editor_set_sensitive(re); +} + +static void +rule_move(RuleEditor *re, int from, int to) +{ + GList *l; + GtkListItem *item; + + d(printf("moving %d to %d\n", from, to)); + rule_context_rank_rule(re->context, re->current, to); + + item = g_list_nth_data(re->list->children, from); + l = g_list_append(NULL, item); + gtk_list_remove_items_no_unref(re->list, l); + gtk_list_insert_items(re->list, l, to); + gtk_list_select_child(re->list, GTK_WIDGET(item)); + + rule_editor_set_sensitive(re); +} + +static void +rule_up(GtkWidget *widget, RuleEditor *re) +{ + int pos; + + d(printf("up rule\n")); + pos = rule_context_get_rank_rule(re->context, re->current, re->source); + if(pos > 0) + rule_move(re, pos, pos - 1); +} + +static void +rule_down(GtkWidget *widget, RuleEditor *re) +{ + int pos; + + d(printf("down rule\n")); + pos = rule_context_get_rank_rule(re->context, re->current, re->source); + rule_move(re, pos, pos + 1); +} + +static struct { + char *name; + GtkSignalFunc func; +} edit_buttons[] = { + { "rule_add", rule_add }, + { "rule_edit", rule_edit }, + { "rule_delete", rule_delete }, + { "rule_up", rule_up }, + { "rule_down", rule_down }, +}; + +static void +set_sensitive(RuleEditor *re) +{ + FilterRule *rule = NULL; + int index = -1, count = 0; + + while ((rule = rule_context_next_rule(re->context, rule, re->source))) { + if(rule == re->current) + index = count; + count++; + } + + d(printf("index = %d count=%d\n", index, count)); + + 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); +} + + +static void +select_rule(GtkWidget *w, GtkWidget *child, RuleEditor *re) +{ + re->current = gtk_object_get_data(GTK_OBJECT(child), "rule"); + + g_assert(re->current); + + rule_editor_set_sensitive(re); +} + +static void +double_click(GtkWidget *widget, GdkEventButton *event, RuleEditor *re) +{ + if(re->current && event->type == GDK_2BUTTON_PRESS) + rule_edit(widget, re); +} + +static void +set_source(RuleEditor *re, const char *source) +{ + FilterRule *rule = NULL; + GList *newitems = NULL; + + gtk_list_clear_items(GTK_LIST(re->list), 0, -1); + + d(printf("Checking for rules that are of type %s\n", source)); + while ((rule = rule_context_next_rule(re->context, rule, source)) != NULL) { + GtkWidget *item; + 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); + } + + gtk_list_append_items(re->list, newitems); + g_free(re->source); + re->source = g_strdup(source); + re->current = NULL; + rule_editor_set_sensitive(re); +} + +void +rule_editor_construct(RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source) +{ + GtkWidget *w; + int i; + + re->context = context; + gtk_object_ref((GtkObject *)context); + + w = glade_xml_get_widget(gui, "rule_editor"); + gtk_box_pack_start((GtkBox *)GNOME_DIALOG(re)->vbox, w, TRUE, TRUE, 0); + + for (i=0; i<BUTTON_LAST; i++) { + re->priv->buttons[i] = (GtkButton *)w = glade_xml_get_widget(gui, edit_buttons[i].name); + gtk_signal_connect(GTK_OBJECT(w), "clicked", edit_buttons[i].func, re); + } + + re->list = (GtkList *) w = glade_xml_get_widget(gui, "rule_list"); + gtk_signal_connect(GTK_OBJECT(w), "select_child", select_rule, re); + gtk_signal_connect(GTK_OBJECT(w), "button_press_event", double_click, re); + + rule_editor_set_source(re, source); + + gnome_dialog_append_buttons((GnomeDialog *)re, GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, 0); +} + diff --git a/filter/rule-editor.h b/filter/rule-editor.h new file mode 100644 index 0000000000..9b45c8b41c --- /dev/null +++ b/filter/rule-editor.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2000 Helix Code Inc. + * + * Authors: Not Zed <notzed@lostzed.mmc.com.au> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _RULE_EDITOR_H +#define _RULE_EDITOR_H + +#include <gtk/gtk.h> +#include <libgnomeui/gnome-dialog.h> + +#define RULE_EDITOR(obj) GTK_CHECK_CAST (obj, rule_editor_get_type (), RuleEditor) +#define RULE_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, rule_editor_get_type (), RuleEditorClass) +#define IS_RULE_EDITOR(obj) GTK_CHECK_TYPE (obj, rule_editor_get_type ()) + +typedef struct _RuleEditor RuleEditor; +typedef struct _RuleEditorClass RuleEditorClass; + +struct _RuleEditor { + GnomeDialog parent; + + GtkList *list; + struct _RuleContext *context; + struct _FilterRule *current; + struct _FilterRule *edit; /* for editing/adding rules, so we only do 1 at a time */ + + char *source; + + struct _RuleEditorPrivate *priv; +}; + +struct _RuleEditorClass { + GnomeDialogClass parent_class; + + /* virtual methods */ + void (*set_sensitive)(RuleEditor *); + void (*set_source)(RuleEditor *, const char *source); + + struct _FilterRule *(*create_rule)(RuleEditor *); + + /* signals */ +}; + +struct _GladeXML; +struct _RuleContext; + +guint rule_editor_get_type (void); +RuleEditor *rule_editor_new (struct _RuleContext *, const char *source); +void rule_editor_construct (RuleEditor *re, struct _RuleContext *context, struct _GladeXML *gui, const char *source); + +/* methods */ +void rule_editor_set_source(RuleEditor *re, const char *source); +/* calculates the sensitivity of the editor */ +void rule_editor_set_sensitive(RuleEditor *re); +/* used internally to create a new rule appropriate for the editor */ +struct _FilterRule *rule_editor_create_rule(RuleEditor *re); + +#endif /* ! _RULE_EDITOR_H */ + diff --git a/filter/score-editor.c b/filter/score-editor.c index 57dbb434f3..8f20b97381 100644 --- a/filter/score-editor.c +++ b/filter/score-editor.c @@ -1,7 +1,8 @@ /* - * Copyright (C) 2000 Helix Code Inc. + * Copyright (C) 2001 Ximian Inc. * * Authors: Not Zed <notzed@lostzed.mmc.com.au> + * Jeffrey Stedfast <fejj@helixcode.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License @@ -29,11 +30,24 @@ #define d(x) -#if 0 -static void score_editor_class_init (ScoreEditorClass *class); +static FilterRule * create_rule(RuleEditor *re); + +static void score_editor_class_init (ScoreEditorClass *class); static void score_editor_init (ScoreEditor *gspaper); +static void score_editor_finalise (GtkObject *obj); + +#define _PRIVATE(x) (((ScoreEditor *)(x))->priv) + +struct _ScoreEditorPrivate { +}; -static GnomeDialogClass *parent_class; +static RuleEditorClass *parent_class; + +enum { + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; guint score_editor_get_type (void) @@ -51,7 +65,7 @@ score_editor_get_type (void) (GtkArgGetFunc)NULL }; - type = gtk_type_unique(gnome_dialog_get_type (), &type_info); + type = gtk_type_unique (rule_editor_get_type (), &type_info); } return type; @@ -60,18 +74,35 @@ score_editor_get_type (void) static void score_editor_class_init (ScoreEditorClass *class) { - GtkObjectClass *object_class; + GtkObjectClass *object_class = (GtkObjectClass *)class; + RuleEditorClass *re_class = (RuleEditorClass *)class; + + parent_class = gtk_type_class (rule_editor_get_type ()); - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(gnome_dialog_get_type ()); + object_class->finalize = score_editor_finalise; /* override methods */ + re_class->create_rule = create_rule; + /* signals */ + + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } static void score_editor_init (ScoreEditor *o) { + o->priv = g_malloc0 (sizeof (*o->priv)); +} + +static void +score_editor_finalise(GtkObject *obj) +{ + ScoreEditor *o = (ScoreEditor *)obj; + + g_free(o->priv); + + ((GtkObjectClass *)(parent_class))->finalize(obj); } /** @@ -82,246 +113,33 @@ score_editor_init (ScoreEditor *o) * Return value: A new #ScoreEditor object. **/ ScoreEditor * -score_editor_new(void) -{ - ScoreEditor *o = (ScoreEditor *)gtk_type_new(score_editor_get_type ()); - return o; -} -#endif - - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _editor_data { - RuleContext *f; - FilterRule *current; - GtkList *list; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void set_sensitive(struct _editor_data *data); - -static void rule_add(GtkWidget *widget, struct _editor_data *data) -{ - ScoreRule *rule; - int result; - GnomeDialog *gd; - GtkWidget *w; - FilterPart *part; - - d(printf("add rule\n")); - /* create a new rule with 1 match and 1 action */ - rule = score_rule_new(); - - part = rule_context_next_part(data->f, NULL); - filter_rule_add_part((FilterRule *)rule, filter_part_clone(part)); - - w = filter_rule_get_widget((FilterRule *)rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Add Rule"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE); - gtk_box_pack_start((GtkBox *)gd->vbox, w, TRUE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - if (result == 0) { - GtkListItem *item; - GList *l = NULL; - gchar *s; - - s = e_utf8_to_gtk_string ((GtkWidget *) data->list, ((FilterRule *) rule)->name); - item = (GtkListItem *)gtk_list_item_new_with_label (s); - g_free (s); - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - gtk_list_append_items(data->list, l); - gtk_list_select_child(data->list, (GtkWidget *)item); - data->current = (FilterRule *)rule; - rule_context_add_rule(data->f, (FilterRule *)rule); - set_sensitive(data); - } else { - gtk_object_unref((GtkObject *)rule); - } -} - -static void rule_edit(GtkWidget *widget, struct _editor_data *data) +score_editor_new(ScoreContext *f) { + GladeXML *gui; + ScoreEditor *o = (ScoreEditor *)gtk_type_new (score_editor_get_type ()); GtkWidget *w; - int result; - GnomeDialog *gd; - FilterRule *rule; - int pos; - - d(printf("edit rule\n")); - rule = data->current; - w = filter_rule_get_widget(rule, data->f); - gd = (GnomeDialog *)gnome_dialog_new(_("Edit Score Rule"), GNOME_STOCK_BUTTON_OK, NULL); - gtk_window_set_policy(GTK_WINDOW(gd), FALSE, TRUE, FALSE); - gtk_box_pack_start((GtkBox *)gd->vbox, w, TRUE, TRUE, 0); - gtk_widget_show((GtkWidget *)gd); - result = gnome_dialog_run_and_close(gd); - - if (result == 0) { - pos = rule_context_get_rank_rule(data->f, data->current, NULL); - if (pos != -1) { - GtkListItem *item = g_list_nth_data(data->list->children, pos); - gchar *s = e_utf8_to_gtk_string ((GtkWidget *) data->list, data->current->name); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), s); - g_free (s); - } - } -} -static void rule_delete(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - GList *l; - GtkListItem *item; - - d(printf("ddelete rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current, NULL); - if (pos != -1) { - rule_context_remove_rule(data->f, data->current); - - item = g_list_nth_data(data->list->children, pos); - l = g_list_append(NULL, item); - gtk_list_remove_items(data->list, l); - g_list_free(l); + gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "rule_editor"); + rule_editor_construct((RuleEditor *)o, (RuleContext *)f, gui, NULL); - gtk_object_unref((GtkObject *)data->current); - data->current = NULL; - } - set_sensitive(data); -} + w = glade_xml_get_widget(gui, "rule_frame"); + gtk_frame_set_label((GtkFrame *)w, _("Score Rules")); -static void rule_move(struct _editor_data *data, int from, int to) -{ - GList *l; - GtkListItem *item; - - d(printf("moving %d to %d\n", from, to)); - rule_context_rank_rule(data->f, data->current, to); + gtk_object_unref((GtkObject *)gui); - item = g_list_nth_data(data->list->children, from); - l = g_list_append(NULL, item); - gtk_list_remove_items_no_unref(data->list, l); - gtk_list_insert_items(data->list, l, to); - gtk_list_select_child(data->list, (GtkWidget *)item); - set_sensitive(data); -} - -static void rule_up(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("up rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current, NULL); - if (pos>0) { - rule_move(data, pos, pos-1); - } -} - -static void rule_down(GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf("down rule\n")); - pos = rule_context_get_rank_rule(data->f, data->current, NULL); - rule_move(data, pos, pos+1); -} - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "rule_add", rule_add }, - { "rule_edit", rule_edit }, - { "rule_delete", rule_delete }, - { "rule_up", rule_up }, - { "rule_down", rule_down }, -}; - -static void -set_sensitive(struct _editor_data *data) -{ - FilterRule *rule = NULL; - int index=-1, count=0; - - while ((rule = rule_context_next_rule(data->f, rule, NULL))) { - if (rule == data->current) - index=count; - count++; - } - d(printf("index = %d count=%d\n", index, count)); - count--; - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_EDIT], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DELETE], index != -1); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_UP], index > 0); - gtk_widget_set_sensitive((GtkWidget *)data->buttons[BUTTON_DOWN], index >=0 && index<count); -} - -static void -select_rule(GtkWidget *w, GtkWidget *child, struct _editor_data *data) -{ - data->current = gtk_object_get_data((GtkObject *)child, "rule"); - if (data->current) - d(printf("seledct rule: %s\n", data->current->name)); - else - d(printf("bad data?\n")); - set_sensitive(data); + return o; } -GtkWidget *score_editor_construct (struct _ScoreContext *f) +static FilterRule * +create_rule(RuleEditor *re) { - GladeXML *gui; - GtkWidget *d, *w; - GList *l; - FilterRule *rule = NULL; - struct _editor_data *data; - int i; - - g_assert(IS_SCORE_CONTEXT(f)); - - data = g_malloc0(sizeof(*data)); - data->f = (RuleContext *)f; - - gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "edit_vfolder"); - d = glade_xml_get_widget (gui, "edit_vfolder"); - gtk_object_set_data_full((GtkObject *)d, "data", data, g_free); - - gtk_window_set_title((GtkWindow *)d, "Edit Score List"); - for (i=0;i<BUTTON_LAST;i++) { - data->buttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect((GtkObject *)w, "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "rule_list"); - data->list = (GtkList *)w; - l = NULL; - while ((rule = rule_context_next_rule((RuleContext *)f, rule, NULL))) { - GtkListItem *item; - gchar *s; - - s = e_utf8_to_gtk_string ((GtkWidget *) data->list, rule->name); - item = (GtkListItem *)gtk_list_item_new_with_label (s); - g_free (s); - gtk_object_set_data((GtkObject *)item, "rule", rule); - gtk_widget_show((GtkWidget *)item); - l = g_list_append(l, item); - } - gtk_list_append_items(data->list, l); - gtk_signal_connect((GtkObject *)w, "select_child", select_rule, data); + FilterRule *rule = filter_rule_new(); + FilterPart *part; - set_sensitive(data); - gtk_object_unref((GtkObject *)gui); + /* create a rule with 1 part in it */ + rule = (FilterRule *)score_rule_new (); + part = rule_context_next_part(re->context, NULL); + filter_rule_add_part(rule, filter_part_clone(part)); - return d; + return rule; } diff --git a/filter/score-editor.h b/filter/score-editor.h index cb78d465f0..686963c879 100644 --- a/filter/score-editor.h +++ b/filter/score-editor.h @@ -22,10 +22,7 @@ #define _SCORE_EDITOR_H #include <gtk/gtk.h> -#include <libgnomeui/gnome-dialog.h> - -#if 0 -/* NOTE: object stuff not used (yet?), this is just a holder file for a static factory */ +#include "rule-editor.h" #define SCORE_EDITOR(obj) GTK_CHECK_CAST (obj, score_editor_get_type (), ScoreEditor) #define SCORE_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, score_editor_get_type (), ScoreEditorClass) @@ -35,25 +32,23 @@ typedef struct _ScoreEditor ScoreEditor; typedef struct _ScoreEditorClass ScoreEditorClass; struct _ScoreEditor { - GnomeDialog parent; + RuleEditor parent; + + struct _ScoreEditorPrivate *priv; }; struct _ScoreEditorClass { - GnomeDialogClass parent_class; + RuleEditorClass parent_class; /* virtual methods */ /* signals */ }; -guint score_editor_get_type (void); -ScoreEditor *score_editor_new (void); -#endif - struct _ScoreContext; -/* methods */ -GtkWidget *score_editor_construct (struct _ScoreContext *f); +guint score_editor_get_type (void); +ScoreEditor *score_editor_new (struct _ScoreContext *f); #endif /* ! _SCORE_EDITOR_H */ diff --git a/filter/vfolder-editor.c b/filter/vfolder-editor.c index caa9069ac5..7251de6bf7 100644 --- a/filter/vfolder-editor.c +++ b/filter/vfolder-editor.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Helix Code Inc. + * Copyright (C) 2001 Ximian Inc. * * Authors: Not Zed <notzed@lostzed.mmc.com.au> * Jeffrey Stedfast <fejj@helixcode.com> @@ -30,7 +30,8 @@ #define d(x) -#if 0 +static FilterRule * create_rule(RuleEditor *re); + static void vfolder_editor_class_init (VfolderEditorClass *class); static void vfolder_editor_init (VfolderEditor *gspaper); static void vfolder_editor_finalise (GtkObject *obj); @@ -40,7 +41,7 @@ static void vfolder_editor_finalise (GtkObject *obj); struct _VfolderEditorPrivate { }; -static GnomeDialogClass *parent_class; +static RuleEditorClass *parent_class; enum { LAST_SIGNAL @@ -64,7 +65,7 @@ vfolder_editor_get_type (void) (GtkArgGetFunc)NULL }; - type = gtk_type_unique (gnome_dialog_get_type (), &type_info); + type = gtk_type_unique (rule_editor_get_type (), &type_info); } return type; @@ -73,14 +74,16 @@ vfolder_editor_get_type (void) static void vfolder_editor_class_init (VfolderEditorClass *class) { - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class (gnome_dialog_get_type ()); + GtkObjectClass *object_class = (GtkObjectClass *)class; + RuleEditorClass *re_class = (RuleEditorClass *)class; + + parent_class = gtk_type_class (rule_editor_get_type ()); object_class->finalize = vfolder_editor_finalise; + /* override methods */ - + re_class->create_rule = create_rule; + /* signals */ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); @@ -97,6 +100,8 @@ vfolder_editor_finalise(GtkObject *obj) { VfolderEditor *o = (VfolderEditor *)obj; + g_free(o->priv); + ((GtkObjectClass *)(parent_class))->finalize(obj); } @@ -108,288 +113,33 @@ vfolder_editor_finalise(GtkObject *obj) * Return value: A new #VfolderEditor object. **/ VfolderEditor * -vfolder_editor_new(void) +vfolder_editor_new(VfolderContext *f) { + GladeXML *gui; VfolderEditor *o = (VfolderEditor *)gtk_type_new (vfolder_editor_get_type ()); - return o; -} -#endif - - - -enum { - BUTTON_ADD, - BUTTON_EDIT, - BUTTON_DELETE, - BUTTON_UP, - BUTTON_DOWN, - BUTTON_LAST -}; - -struct _editor_data { - RuleContext *f; - FilterRule *current; - GtkList *list; - GtkButton *buttons[BUTTON_LAST]; -}; - -static void set_sensitive (struct _editor_data *data); - -static void -rule_add (GtkWidget *widget, struct _editor_data *data) -{ - FilterRule *rule; - int result; - GtkWidget *gd; GtkWidget *w; - FilterPart *part; - - d(printf ("add rule\n")); - /* create a new rule with 1 match and 1 action */ - rule = (FilterRule *) vfolder_rule_new (); - - part = rule_context_next_part (data->f, NULL); - filter_rule_add_part (rule, filter_part_clone (part)); - - w = filter_rule_get_widget (rule, data->f); - gd = gnome_dialog_new (_("Add VFolder Rule"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0); - - gtk_widget_show (gd); - - result = gnome_dialog_run_and_close (GNOME_DIALOG (gd)); - - if (result == 0) { - GtkWidget *item; - GList *l = NULL; - gchar *s; - - s = e_utf8_to_gtk_string (GTK_WIDGET (data->list), rule->name); - item = gtk_list_item_new_with_label (rule->name); - g_free (s); - - gtk_object_set_data (GTK_OBJECT (item), "rule", rule); - gtk_widget_show (item); - - l = g_list_append (l, GTK_LIST_ITEM (item)); - - gtk_list_append_items (data->list, l); - gtk_list_select_child (data->list, item); - - data->current = rule; - rule_context_add_rule (data->f, rule); - - set_sensitive (data); - } else { - gtk_object_unref (GTK_OBJECT (rule)); - } -} -static void -rule_edit (GtkWidget *widget, struct _editor_data *data) -{ - GtkWidget *w; - int result; - GtkWidget *gd; - FilterRule *rule; - int pos; - - d(printf ("edit rule\n")); - rule = data->current; - w = filter_rule_get_widget (rule, data->f); - gd = gnome_dialog_new (_("Edit VFolder Rule"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0); - - gtk_widget_show (gd); - - result = gnome_dialog_run_and_close (GNOME_DIALOG (gd)); - - if (result == 0) { - pos = rule_context_get_rank_rule (data->f, data->current, NULL); - if (pos != -1) { - GtkListItem *item = g_list_nth_data (data->list->children, pos); - gchar *s = e_utf8_to_gtk_string (GTK_WIDGET (item), data->current->name); - gtk_label_set_text (GTK_LABEL (GTK_BIN (item)->child), s); - g_free (s); - } - } -} + gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "rule_editor"); + rule_editor_construct((RuleEditor *)o, (RuleContext *)f, gui, NULL); -static void -rule_delete (GtkWidget *widget, struct _editor_data *data) -{ - int pos, len; - GList *l; - GtkListItem *item; - - d(printf ("delete rule\n")); - pos = rule_context_get_rank_rule (data->f, data->current, NULL); - if (pos != -1) { - rule_context_remove_rule (data->f, data->current); - - item = g_list_nth_data (data->list->children, pos); - l = g_list_append (NULL, item); - gtk_list_remove_items (data->list, l); - g_list_free (l); - - gtk_object_unref (GTK_OBJECT (data->current)); - data->current = NULL; - - /* select the item in the same position or 1-up */ - len = g_list_length (data->list->children); - pos = pos >= len ? len - 1: pos; - gtk_list_select_item (data->list, pos); - } - - set_sensitive (data); -} + w = glade_xml_get_widget(gui, "rule_frame"); + gtk_frame_set_label((GtkFrame *)w, _("Virtual Folders")); -static void -rule_move (struct _editor_data *data, int from, int to) -{ - GList *l; - GtkListItem *item; - - d(printf ("moving %d to %d\n", from, to)); - rule_context_rank_rule (data->f, data->current, to); - - item = g_list_nth_data (data->list->children, from); - l = g_list_append (NULL, item); - gtk_list_remove_items_no_unref (data->list, l); - gtk_list_insert_items (data->list, l, to); - gtk_list_select_child (data->list, GTK_WIDGET (item)); - set_sensitive (data); -} - -static void -rule_up (GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf ("up rule\n")); - pos = rule_context_get_rank_rule (data->f, data->current, NULL); - if (pos > 0) { - rule_move (data, pos, pos - 1); - } -} - -static void -rule_down (GtkWidget *widget, struct _editor_data *data) -{ - int pos; - - d(printf ("down rule\n")); - pos = rule_context_get_rank_rule (data->f, data->current, NULL); - rule_move (data, pos, pos + 1); -} - -static struct { - char *name; - GtkSignalFunc func; -} edit_buttons[] = { - { "rule_add", rule_add }, - { "rule_edit", rule_edit }, - { "rule_delete", rule_delete }, - { "rule_up", rule_up }, - { "rule_down", rule_down }, -}; - -static void -set_sensitive (struct _editor_data *data) -{ - FilterRule *rule = NULL; - int index = -1, count = 0; - - while ((rule = rule_context_next_rule (data->f, rule, NULL))) { - if (rule == data->current) - index = count; - count++; - } + gtk_object_unref((GtkObject *)gui); - d(printf ("index = %d count=%d\n", index, count)); - - count--; - - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_EDIT]), index != -1); - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_DELETE]), index != -1); - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_UP]), index > 0); - gtk_widget_set_sensitive (GTK_WIDGET (data->buttons[BUTTON_DOWN]), index >= 0 && index < count); + return o; } -static void -select_rule (GtkWidget *w, GtkWidget *child, struct _editor_data *data) +static FilterRule * +create_rule(RuleEditor *re) { - data->current = gtk_object_get_data (GTK_OBJECT (child), "rule"); - - if (data->current) - d(printf ("selected rule: %s\n", data->current->name)); - else - d(printf ("bad data?\n")); - - set_sensitive (data); -} + FilterRule *rule = filter_rule_new(); + FilterPart *part; -static void -double_click (GtkWidget *widget, GdkEventButton *event, struct _editor_data *data) -{ - if (data->current && event->type == GDK_2BUTTON_PRESS) - rule_edit (widget, data); -} + /* create a rule with 1 part in it */ + rule = (FilterRule *)vfolder_rule_new (); + part = rule_context_next_part(re->context, NULL); + filter_rule_add_part(rule, filter_part_clone(part)); -GtkWidget * -vfolder_editor_construct (struct _VfolderContext *f) -{ - GladeXML *gui; - GtkWidget *d, *w; - GList *l; - FilterRule *rule = NULL; - struct _editor_data *data; - int i; - - g_assert (IS_VFOLDER_CONTEXT (f)); - - data = g_malloc0 (sizeof (*data)); - data->f = (RuleContext *)f; - - gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "edit_vfolder"); - d = glade_xml_get_widget (gui, "edit_vfolder"); - gtk_object_set_data_full (GTK_OBJECT (d), "data", data, g_free); - - gtk_window_set_title (GTK_WINDOW (d), "Edit VFolders"); - for (i = 0; i < BUTTON_LAST; i++) { - data->buttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name); - gtk_signal_connect (GTK_OBJECT (w), "clicked", edit_buttons[i].func, data); - } - - w = glade_xml_get_widget (gui, "rule_list"); - data->list = GTK_LIST (w); - l = NULL; - while ((rule = rule_context_next_rule ((RuleContext *)f, rule, NULL))) { - GtkWidget *item; - - gchar *s = e_utf8_to_gtk_string (GTK_WIDGET (data->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)); - l = g_list_append (l, GTK_LIST_ITEM (item)); - } - - gtk_list_append_items (data->list, l); - gtk_signal_connect (GTK_OBJECT (w), "select_child", select_rule, data); - gtk_signal_connect (GTK_OBJECT (w), "button_press_event", double_click, data); - - set_sensitive (data); - - gtk_object_unref (GTK_OBJECT (gui)); - - return d; + return rule; } diff --git a/filter/vfolder-editor.h b/filter/vfolder-editor.h index 2ff2b261dc..115ebdbc74 100644 --- a/filter/vfolder-editor.h +++ b/filter/vfolder-editor.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Helix Code Inc. + * Copyright (C) 2000, 2001 Ximian Inc. * * Authors: Not Zed <notzed@lostzed.mmc.com.au> * @@ -22,10 +22,7 @@ #define _VFOLDER_EDITOR_H #include <gtk/gtk.h> -#include <libgnomeui/gnome-dialog.h> - -#if 0 -/* NOTE: object stuff not used (yet?), this is just a holder file for a static factory */ +#include "rule-editor.h" #define VFOLDER_EDITOR(obj) GTK_CHECK_CAST (obj, vfolder_editor_get_type (), VfolderEditor) #define VFOLDER_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, vfolder_editor_get_type (), VfolderEditorClass) @@ -35,27 +32,24 @@ typedef struct _VfolderEditor VfolderEditor; typedef struct _VfolderEditorClass VfolderEditorClass; struct _VfolderEditor { - GnomeDialog parent; + RuleEditor parent; + struct _VfolderEditorPrivate *priv; }; struct _VfolderEditorClass { - GnomeDialogClass parent_class; + RuleEditorClass parent_class; /* virtual methods */ /* signals */ }; -guint vfolder_editor_get_type (void); -VfolderEditor *vfolder_editor_new (void); -#endif - struct _VfolderContext; -/* methods */ -GtkWidget *vfolder_editor_construct (struct _VfolderContext *f); +guint vfolder_editor_get_type (void); +VfolderEditor *vfolder_editor_new (struct _VfolderContext *); #endif /* ! _VFOLDER_EDITOR_H */ |