diff options
author | NotZed <NotZed@HelixCode.com> | 2000-02-22 18:09:07 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-02-22 18:09:07 +0800 |
commit | 7c6897ee95e4346e991185c014bcfce003809fd8 (patch) | |
tree | b34cb809263e9641c3311168c43b8977812e91be /filter/filter-arg-types.c | |
parent | 6b21505b40126e00636603c705b771e5c857beef (diff) | |
download | gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.gz gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.bz2 gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.lz gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.xz gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.tar.zst gsoc2013-evolution-7c6897ee95e4346e991185c014bcfce003809fd8.zip |
New utility functions for working with the internal rule format.
2000-02-22 NotZed <NotZed@HelixCode.com>
* filter-xml.c (filter_clone_optionrule):
(filter_clone_optionrule_free):
(filter_optionrule_new_from_rule): New utility functions for
working with the internal rule format.
* filter-arg.[ch]: Added new callbacks for editing a single value,
and a new editor which shows all items in a list, and allows you
to edit them via the single-edit method. This needs some cleanup
for some unused/unusable virtual methods (edit_values,
write_html?).
* Makefile: Add the druid for build.
* filter-druid.c: A 'druid' widget for editing a single filter
rule.
svn path=/trunk/; revision=1901
Diffstat (limited to 'filter/filter-arg-types.c')
-rw-r--r-- | filter/filter-arg-types.c | 103 |
1 files changed, 100 insertions, 3 deletions
diff --git a/filter/filter-arg-types.c b/filter/filter-arg-types.c index ce6eac7003..ea58bf36ae 100644 --- a/filter/filter-arg-types.c +++ b/filter/filter-arg-types.c @@ -89,7 +89,51 @@ arg_string_write_text(FilterArg *argin, GString *string) static void arg_string_edit_values(FilterArg *arg) { - printf("edit string value!\n"); + printf("edit string values!\n"); +} + +/* pop up a dialogue, asking for a new string value */ +static int +arg_string_edit_value(FilterArg *arg, int index) +{ + GnomeDialog *dialogue; + GtkHBox *hbox; + GtkLabel *label; + GtkEntry *entry; + char *text = NULL; + char *newtext; + + dialogue = (GnomeDialog *)gnome_dialog_new("Edit value", "Ok", "Cancel", 0); + + hbox = (GtkHBox *)gtk_hbox_new(FALSE, 0); + label = (GtkLabel *)gtk_label_new("Folder name"); + gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)label, FALSE, FALSE, 0); + entry = (GtkEntry *)gtk_entry_new(); + gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)entry, TRUE, TRUE, 0); + if (index>=0) { + text = filter_arg_get_value(arg, index); + } + if (text) { + gtk_entry_set_text(entry, text); + } + gtk_box_pack_start((GtkBox *)dialogue->vbox, (GtkWidget *)hbox, TRUE, TRUE, 0); + gtk_widget_show_all((GtkWidget *)hbox); + gtk_object_ref((GtkObject *)entry); /* so we can get the text back afterwards */ + if (gnome_dialog_run_and_close(dialogue) == 0) { + GList *node; + + newtext = g_strdup(gtk_entry_get_text(entry)); + gtk_object_unref((GtkObject *)entry); + if (index>=0 + && (node = g_list_find(arg->values, text))) { + node->data = newtext; + } else { + arg->values = g_list_append(arg->values, newtext); + } + g_free(text); + return g_list_index(arg->values, newtext); + } + return -1; } static xmlNodePtr @@ -161,7 +205,9 @@ filter_arg_string_class_init (FilterArgStringClass *class) class->parent_class.write_html = arg_string_write_html; class->parent_class.write_text = arg_string_write_text; class->parent_class.edit_values = arg_string_edit_values; + class->parent_class.edit_value = arg_string_edit_value; class->parent_class.free_value = arg_string_free_value; + class->parent_class.get_value_as_string = arg_string_get_value_as_string; class->parent_class.values_get_xml = arg_string_values_get_xml; class->parent_class.values_add_xml = arg_string_values_add_xml; @@ -267,6 +313,54 @@ arg_address_edit_values(FilterArg *arg) printf("edit it!\n"); } +static int +arg_address_edit_value(FilterArg *arg, int index) +{ + GnomeDialog *dialogue; + GtkHBox *hbox; + GtkLabel *label; + GtkEntry *entry; + char *text = NULL; + char *newtext; + struct filter_arg_address *ad; + + dialogue = (GnomeDialog *)gnome_dialog_new("Edit value", "Ok", "Cancel", 0); + + hbox = (GtkHBox *)gtk_hbox_new(FALSE, 0); + label = (GtkLabel *)gtk_label_new("Folder name"); + gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)label, FALSE, FALSE, 0); + entry = (GtkEntry *)gtk_entry_new(); + gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)entry, TRUE, TRUE, 0); + if (index>=0 + && (ad = filter_arg_get_value(arg, index))) { + text = ad->email; + } + if (text) { + gtk_entry_set_text(entry, text); + } + gtk_box_pack_start((GtkBox *)dialogue->vbox, (GtkWidget *)hbox, TRUE, TRUE, 0); + gtk_widget_show_all((GtkWidget *)hbox); + gtk_object_ref((GtkObject *)entry); /* so we can get the text back afterwards */ + if (gnome_dialog_run_and_close(dialogue) == 0) { + GList *node; + + newtext = g_strdup(gtk_entry_get_text(entry)); + gtk_object_unref((GtkObject *)entry); + if (index>=0 + && (node = g_list_find(arg->values, text))) { + ad = node->data; + ad->email = newtext; + } else { + ad = g_malloc0(sizeof(*ad)); + ad->email = newtext; + arg->values = g_list_append(arg->values, ad); + } + g_free(text); + return g_list_index(arg->values, ad); + } + return -1; +} + static xmlNodePtr arg_address_values_get_xml(FilterArg *argin) { @@ -319,6 +413,8 @@ arg_address_get_value_as_string(FilterArg *argin, void *data) FilterArgAddress *arg = (FilterArgAddress *)argin; struct filter_arg_address *a = (struct filter_arg_address *)data; + printf("geting address as string : %s %s\n", a->email, a->name); + if (a->email == NULL || a->email[0] == '\0') { if (a->name == NULL @@ -348,7 +444,8 @@ filter_arg_address_class_init (FilterArgAddressClass *class) class->parent_class.write_html = arg_address_write_html; class->parent_class.write_text = arg_address_write_text; - class->parent_class.edit_values = arg_address_edit_values; + class->parent_class.edit_values= arg_address_edit_values; + class->parent_class.edit_value= arg_address_edit_value; class->parent_class.free_value = arg_address_free_value; class->parent_class.values_get_xml = arg_address_values_get_xml; @@ -470,7 +567,7 @@ arg_folder_edit_values(FilterArg *argin) dialogue = gnome_dialog_new("Edit addresses", "Ok", "Cancel", NULL); text = gtk_text_new(NULL, NULL); - gtk_object_ref(text); + gtk_object_ref((GtkObject *)text); l = argin->values; while (l) { |