aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-03-03 06:21:55 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-03-03 06:21:55 +0800
commit9cf31d6b063eacf768ea835fad15377aaddf6dc1 (patch)
tree8294058eb116e1a82fd7b8659ddb049eca7ea12d
parent8e356d0601866c7f7d8139b1135a628fd4362462 (diff)
downloadgsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.tar
gsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.tar.gz
gsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.tar.bz2
gsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.tar.lz
gsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.tar.xz
gsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.tar.zst
gsoc2013-evolution-9cf31d6b063eacf768ea835fad15377aaddf6dc1.zip
Disconnect the list signal, so we dont get spurious emits during destroy.
2000-03-02 NotZed <NotZed@HelixCode.com> * filter-druid.c (object_destroy): Disconnect the list signal, so we dont get spurious emits during destroy. (arg_changed): Callback to update filter arg asynchronously. (arg_link_clicked): Edit the value non-modally. * filter-arg.c (filter_arg_edit_values_1): Changed to use non-modal interface. svn path=/trunk/; revision=2015
-rw-r--r--filter/ChangeLog10
-rw-r--r--filter/filter-arg-types.c8
-rw-r--r--filter/filter-arg.c104
-rw-r--r--filter/filter-arg.h2
-rw-r--r--filter/filter-druid.c42
-rw-r--r--filter/filter-editor.c35
-rw-r--r--filter/filter-xml.c3
7 files changed, 163 insertions, 41 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index b8445aee42..7eec85d5ee 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,13 @@
+2000-03-02 NotZed <NotZed@HelixCode.com>
+
+ * filter-druid.c (object_destroy): Disconnect the list signal, so
+ we dont get spurious emits during destroy.
+ (arg_changed): Callback to update filter arg asynchronously.
+ (arg_link_clicked): Edit the value non-modally.
+
+ * filter-arg.c (filter_arg_edit_values_1): Changed to use
+ non-modal interface.
+
2000-03-01 Ettore Perazzoli <ettore@helixcode.com>
* Makefile.am: New file.
diff --git a/filter/filter-arg-types.c b/filter/filter-arg-types.c
index ea58bf36ae..ec5cb7b960 100644
--- a/filter/filter-arg-types.c
+++ b/filter/filter-arg-types.c
@@ -648,7 +648,7 @@ arg_folder_values_get_xml(FilterArg *argin)
cur = xmlNewChild(value, NULL, "folder", NULL);
if (a)
- xmlSetProp(cur, "folder", a);
+ xmlSetProp(cur, "name", a);
l = g_list_next(l);
}
@@ -665,7 +665,11 @@ arg_folder_values_add_xml(FilterArg *arg, xmlNodePtr node)
n = node->childs;
while (n) {
if (!strcmp(n->name, "folder")) {
- filter_arg_folder_add(arg, xmlGetProp(n, "name"));
+ char *name = xmlGetProp(n, "name");
+ if (name)
+ filter_arg_folder_add(arg, name);
+ else
+ g_warning("no xml prop 'name' on '%s'\n", n->name);
} else {
g_warning("Loading folders from xml, wrong node encountered: %s\n", n->name);
}
diff --git a/filter/filter-arg.c b/filter/filter-arg.c
index 8adfb5576e..1a1852fdf2 100644
--- a/filter/filter-arg.c
+++ b/filter/filter-arg.c
@@ -29,6 +29,13 @@
static void filter_arg_class_init (FilterArgClass *class);
static void filter_arg_init (FilterArg *gspaper);
+#define _PRIVATE(x) (((FilterArg *)(x))->priv)
+
+struct _FilterArgPrivate {
+ GtkWidget *dialogue; /* editor widget */
+ xmlNodePtr *oldargs;
+};
+
static GtkObjectClass *parent_class;
enum {
@@ -140,6 +147,7 @@ static void
filter_arg_init (FilterArg *arg)
{
arg->values = NULL;
+ arg->priv = g_malloc0(sizeof(*arg->priv));
}
/**
@@ -320,6 +328,8 @@ filter_arg_edit_add(GtkWidget *w, struct filter_arg_edit *edata)
printf("adding new item\n");
+ printf("editing ...\n");
+
i = filter_arg_edit_value(edata->arg, -1);
if (i>=0) {
gtk_list_remove_items_no_unref(edata->list, edata->items);
@@ -424,6 +434,50 @@ filter_arg_edit_unselect(GtkWidget *w, GtkListItem *list, struct filter_arg_edit
edit_sensitise(edata);
}
+static void
+filter_arg_edit_clicked(GnomeDialog *d, int button, struct filter_arg_edit *edata)
+{
+ struct _FilterArgPrivate *p = _PRIVATE(edata->arg);
+
+ printf("window finished\n");
+ if (button==0) {
+ gtk_signal_emit(GTK_OBJECT(edata->arg), signals[CHANGED]);
+ } else {
+ /* cancel button, restore old values ... */
+ printf("cancel button\n");
+ while (edata->arg->values) {
+ filter_arg_remove(edata->arg, edata->arg->values->data);
+ }
+ filter_arg_values_add_xml(edata->arg, p->oldargs);
+ }
+ xmlFreeNodeList(p->oldargs);
+ p->oldargs = NULL;
+ g_free(edata);
+ p->dialogue = NULL;
+ gnome_dialog_close(d);
+}
+
+static void
+filter_arg_edit_destroy(GnomeDialog *d, struct filter_arg_edit *edata)
+{
+ struct _FilterArgPrivate *p = _PRIVATE(edata->arg);
+
+ if (p->oldargs) {
+ while (edata->arg->values) {
+ filter_arg_remove(edata->arg, edata->arg->values->data);
+ }
+ filter_arg_values_add_xml(edata->arg, p->oldargs);
+ xmlFreeNodeList(p->oldargs);
+ p->oldargs = NULL;
+ }
+
+ if (p->dialogue) {
+ p->dialogue = NULL;
+ gnome_dialog_close(d);
+ }
+ g_free(edata);
+}
+
void
filter_arg_edit_values_1(FilterArg *arg)
{
@@ -436,20 +490,33 @@ filter_arg_edit_values_1(FilterArg *arg)
GtkVBox *vbox;
GtkWidget *button;
GtkWidget *scrolled_window, *frame;
- struct filter_arg_edit edata;
+ struct filter_arg_edit * edata;
+ struct _FilterArgPrivate *p = _PRIVATE(arg);
- edata.item_current = NULL;
- edata.arg = arg;
+ /* dont show more than 1 editor for each type */
+ if (p->dialogue) {
+ gdk_window_raise(GTK_WIDGET(p->dialogue)->window);
+ return;
+ }
+
+ /* copy the current state */
+ p->oldargs= filter_arg_values_get_xml(arg);
+
+ edata = g_malloc0(sizeof(*edata));
+ edata->item_current = NULL;
+ edata->arg = arg;
dialogue = (GnomeDialog *)gnome_dialog_new("Edit values", "Ok", "Cancel", 0);
- edata.dialogue = dialogue;
+ edata->dialogue = dialogue;
+
+ p->dialogue = dialogue;
hbox = (GtkHBox *)gtk_hbox_new(FALSE, 0);
list = (GtkList *)gtk_list_new();
- edata.list = list;
- edata.items = NULL;
- fill_list(&edata);
+ edata->list = list;
+ edata->items = NULL;
+ fill_list(edata);
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
frame = gtk_frame_new("Option values");
@@ -466,29 +533,32 @@ filter_arg_edit_values_1(FilterArg *arg)
button = gtk_button_new_with_label ("Add");
gtk_box_pack_start((GtkBox *)vbox, button, FALSE, TRUE, 0);
- edata.add = button;
+ edata->add = button;
button = gtk_button_new_with_label ("Remove");
gtk_box_pack_start((GtkBox *)vbox, button, FALSE, TRUE, 0);
- edata.remove = button;
+ edata->remove = button;
button = gtk_button_new_with_label ("Edit");
gtk_box_pack_start((GtkBox *)vbox, button, FALSE, TRUE, 0);
- edata.edit = button;
+ edata->edit = button;
gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)vbox, FALSE, FALSE, 0);
- gtk_signal_connect((GtkObject *)edata.add, "clicked", filter_arg_edit_add, &edata);
- gtk_signal_connect((GtkObject *)edata.edit, "clicked", filter_arg_edit_edit, &edata);
- gtk_signal_connect((GtkObject *)edata.remove, "clicked", filter_arg_edit_delete, &edata);
- gtk_signal_connect((GtkObject *)edata.list, "select_child", filter_arg_edit_select, &edata);
- gtk_signal_connect((GtkObject *)edata.list, "unselect_child", filter_arg_edit_unselect, &edata);
+ gtk_signal_connect((GtkObject *)edata->add, "clicked", filter_arg_edit_add, edata);
+ gtk_signal_connect((GtkObject *)edata->edit, "clicked", filter_arg_edit_edit, edata);
+ gtk_signal_connect((GtkObject *)edata->remove, "clicked", filter_arg_edit_delete, edata);
+ gtk_signal_connect((GtkObject *)edata->list, "select_child", filter_arg_edit_select, edata);
+ gtk_signal_connect((GtkObject *)edata->list, "unselect_child", filter_arg_edit_unselect, edata);
gtk_widget_show(GTK_WIDGET(list));
gtk_widget_show_all(GTK_WIDGET(hbox));
gtk_box_pack_start((GtkBox *)dialogue->vbox, (GtkWidget *)hbox, TRUE, TRUE, 0);
- edit_sensitise(&edata);
+ gtk_signal_connect((GtkObject *)dialogue, "clicked", filter_arg_edit_clicked, edata);
+ gtk_signal_connect((GtkObject *)dialogue, "destroy", filter_arg_edit_destroy, edata);
+
+ edit_sensitise(edata);
- gnome_dialog_run_and_close(dialogue);
+ gtk_widget_show(dialogue);
}
diff --git a/filter/filter-arg.h b/filter/filter-arg.h
index 78ce067bbc..5409940e22 100644
--- a/filter/filter-arg.h
+++ b/filter/filter-arg.h
@@ -37,6 +37,8 @@ typedef struct _FilterArgClass FilterArgClass;
struct _FilterArg {
GtkObject object;
+ struct _FilterArgPrivate *priv;
+
char *name;
GList *values;
};
diff --git a/filter/filter-druid.c b/filter/filter-druid.c
index 14ad65f335..4b7951a7c2 100644
--- a/filter/filter-druid.c
+++ b/filter/filter-druid.c
@@ -95,17 +95,17 @@ filter_druid_get_type (void)
}
static void
-object_finalize(FilterDruid *obj)
+object_destroy(FilterDruid *obj)
{
struct _FilterDruidPrivate *p = _PRIVATE(obj);
g_free(p->default_html);
- printf("\n druid finalize!\n\n");
+ gtk_signal_disconnect_by_data((GtkObject *)p->list0, obj);
/* FIXME: free lists? */
- GTK_OBJECT_CLASS(filter_druid_parent)->finalize(obj);
+ GTK_OBJECT_CLASS(filter_druid_parent)->destroy(obj);
}
static void
@@ -115,7 +115,7 @@ filter_druid_class_init (FilterDruidClass *klass)
filter_druid_parent = gtk_type_class (gtk_notebook_get_type ());
- object_class->finalize = object_finalize;
+ object_class->destroy = object_destroy;
signals[OPTION_SELECTED] =
gtk_signal_new ("option_selected",
@@ -367,7 +367,7 @@ select_option_child(GtkList *list, GtkWidget *child, FilterDruid *f)
while (optionsl) {
GList *op = optionsl;
optionsl = g_list_next(optionsl);
- g_free(op->data);
+ filter_clone_optionrule_free(op->data);
}
g_list_free(f->option_current->options);
g_free(f->option_current);
@@ -403,10 +403,28 @@ select_option_child(GtkList *list, GtkWidget *child, FilterDruid *f)
static void
unselect_option_child(GtkList *list, GtkWidget *child, FilterDruid *f)
{
+ printf("unselect option child\n");
select_option_child(list, NULL, f);
}
static void
+arg_changed(FilterArg *arg, FilterDruid *f)
+{
+ FilterArg *orig;
+
+ printf("value changed!!!\n");
+
+ orig = gtk_object_get_data(arg, "origin");
+ if (orig) {
+ filter_arg_copy(orig, arg);
+ update_display(f, 0);
+ } else {
+ /* FIXME: uh, what the fuck to do here? */
+ update_display(f, 0);
+ }
+}
+
+static void
arg_link_clicked(GtkHTML *html, const char *url, FilterDruid *f)
{
printf("url clicked: %s\n", url);
@@ -419,17 +437,9 @@ arg_link_clicked(GtkHTML *html, const char *url, FilterDruid *f)
FilterArg *orig;
printf("arg = %p\n", arg);
- filter_arg_edit_values(arg);
- /* insert the new value into the existing one */
- orig = gtk_object_get_data(arg, "origin");
- if (orig) {
- filter_arg_copy(orig, arg);
- } else {
- g_warning("unknown object loaded");
- }
- /* should have a changed signal which propagates the rewrite */
- update_display(f, 0);
+ gtk_signal_connect((GtkObject *)arg, "changed", arg_changed, f);
+ filter_arg_edit_values(arg);
}
}
}
@@ -564,7 +574,7 @@ filter_druid_set_rules(FilterDruid *f, GList *options, GList *rules, struct filt
if (current) {
/* FIXME: free this list if it isn't empty ... */
- /* clone the 'current' option */
+ /* clone the 'current' option */
new = g_malloc(sizeof(*new));
new->type = current->type;
new->description = current->description;
diff --git a/filter/filter-editor.c b/filter/filter-editor.c
index 24e2514057..82e57afb4e 100644
--- a/filter/filter-editor.c
+++ b/filter/filter-editor.c
@@ -69,12 +69,25 @@ filter_editor_get_type (void)
}
static void
+object_destroy(FilterEditor *obj)
+{
+ struct _FilterEditorPrivate *p = _PRIVATE(obj);
+
+ if (p->druid_druid)
+ gtk_object_unref((GtkObject *)p->druid_dialogue);
+
+ GTK_OBJECT_CLASS(filter_editor_parent)->destroy(obj);
+}
+
+static void
filter_editor_class_init (FilterEditorClass *klass)
{
GtkObjectClass *object_class = (GtkObjectClass *) klass;
filter_editor_parent = gtk_type_class (gnome_dialog_get_type ());
+ object_class->destroy = object_destroy;
+
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
@@ -125,25 +138,30 @@ druid_dialogue_clicked(GnomeDialog *d, int button, FilterEditor *e)
case 2:
printf("Finish!\n");
if (p->druid_druid->option_current) {
- /* FIXME: this should be copied? */
+ struct filrt_optionrule *or;
+
+ printf("refcount = %d\n", ((GtkObject *)p->druid_druid)->ref_count);
+
+ or = p->druid_druid->option_current;
if (p->druid_option) {
GList *node;
node = g_list_find(e->useroptions, p->druid_option);
if (node) {
- /* FIXME: memleak, should copy */
- node->data = p->druid_druid->option_current;
+ /* fixme: free old one */
+ node->data = or;
} else {
g_warning("Cannot find node I edited, appending instead");
- e->useroptions = g_list_append(e->useroptions, p->druid_druid->option_current);
+ e->useroptions = g_list_append(e->useroptions, or);
}
} else {
- e->useroptions = g_list_append(e->useroptions, p->druid_druid->option_current);
+ e->useroptions = g_list_append(e->useroptions, or);
}
- filter_druid_set_rules(p->druid, e->useroptions, e->rules, NULL);
+ filter_druid_set_rules(p->druid, e->useroptions, e->rules, or);
}
case 3:
printf("cancel!\n");
+ p->druid_dialogue = NULL;
gnome_dialog_close(d);
return;
}
@@ -169,6 +187,11 @@ add_or_edit(FilterEditor *e, struct filter_option *option)
FilterDruid *druid;
struct _FilterEditorPrivate *p = _PRIVATE(e);
+ if (p->druid_dialogue) {
+ gdk_window_raise(GTK_WIDGET(p->druid_dialogue)->window);
+ return;
+ }
+
dialogue = gnome_dialog_new(option?"Edit Filter":"Create filter", "Prev", "Next", "Finish", "Cancel", 0);
p->druid_dialogue = dialogue;
diff --git a/filter/filter-xml.c b/filter/filter-xml.c
index 7615350acf..83bfe06131 100644
--- a/filter/filter-xml.c
+++ b/filter/filter-xml.c
@@ -414,6 +414,9 @@ filter_clone_optionrule_free(struct filter_optionrule *or)
GList *argl;
struct filter_optionrule *rule;
+ printf("---- free optionrule\n");
+ return;
+
argl = or->args;
while (argl) {
gtk_object_unref(GTK_OBJECT(argl->data));