aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-11-01 06:27:16 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-11-01 06:27:16 +0800
commit9450e20fe2e22030f1674c36935fd1603d2c065a (patch)
tree8dfe20f5ac263f7e7be9eb38d3a83e2cc832fbfa /widgets
parent9fb8bbd298dc44eb3cb4bbf1e248d959a10da9d3 (diff)
downloadgsoc2013-evolution-9450e20fe2e22030f1674c36935fd1603d2c065a.tar.gz
gsoc2013-evolution-9450e20fe2e22030f1674c36935fd1603d2c065a.tar.zst
gsoc2013-evolution-9450e20fe2e22030f1674c36935fd1603d2c065a.zip
Ref and connect to rule changed here, also clear out previous ref's.
2001-11-01 Not Zed <NotZed@Ximian.com> * e-filter-bar.c (build_items): Ref and connect to rule changed here, also clear out previous ref's. (generate_menu): No longer connect to rules, or reset rule array. (set_option): Dont reset option rules array. (context_rule_removed): Disconnect changed event on rule. (clear_rules): Fujnction to clear rules from an array. (destroy): Disconnect from context signals, and clear rules arrays. * e-filter-bar.h: Remove hash table for change id's. svn path=/trunk/; revision=14550
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/ChangeLog12
-rw-r--r--widgets/misc/e-filter-bar.c53
-rw-r--r--widgets/misc/e-filter-bar.h1
3 files changed, 38 insertions, 28 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index fd3e052441..5e0a3f9e62 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,15 @@
+2001-11-01 Not Zed <NotZed@Ximian.com>
+
+ * e-filter-bar.c (build_items): Ref and connect to rule changed
+ here, also clear out previous ref's.
+ (generate_menu): No longer connect to rules, or reset rule array.
+ (set_option): Dont reset option rules array.
+ (context_rule_removed): Disconnect changed event on rule.
+ (clear_rules): Fujnction to clear rules from an array.
+ (destroy): Disconnect from context signals, and clear rules arrays.
+
+ * e-filter-bar.h: Remove hash table for change id's.
+
2001-10-30 Damon Chaplin <damon@ximian.com>
* e-dateedit.c (e_date_edit_set_time_of_day): emit signal when time
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index af026f672e..f93a46a022 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -274,6 +274,20 @@ option_changed (ESearchBar *esb, void *data)
efb->setquery = FALSE;
}
+static void clear_rules(EFilterBar *efb, GPtrArray *rules)
+{
+ int i;
+ FilterRule *rule;
+
+ /* clear out any data on old rules */
+ for (i=0;i<rules->len;i++) {
+ rule = rules->pdata[i];
+ gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, efb);
+ gtk_object_unref((GtkObject *)rule);
+ }
+ g_ptr_array_set_size (rules, 0);
+}
+
static GArray *
build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrArray *rules)
{
@@ -283,6 +297,8 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
GArray *menu = g_array_new (FALSE, FALSE, sizeof (ESearchBarItem));
ESearchBarItem item;
char *source;
+
+ clear_rules(efb, rules);
/* find a unique starting point for the id's of our items */
for (i = 0; items[i].id != -1; i++) {
@@ -311,6 +327,8 @@ build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrA
item.text = rule->name;
item.subitems = NULL;
g_array_append_vals (menu, &item, 1);
+ gtk_object_ref((GtkObject *)rule);
+ gtk_signal_connect((GtkObject *)rule, "changed", rule_changed, efb);
g_ptr_array_add (rules, rule);
}
@@ -333,18 +351,10 @@ generate_menu (ESearchBar *esb, ESearchBarItem *items)
{
EFilterBar *efb = (EFilterBar *)esb;
GArray *menu;
- int i;
- g_ptr_array_set_size (efb->menu_rules, 0);
menu = build_items (esb, items, 0, &efb->menu_base, efb->menu_rules);
((ESearchBarClass *)parent_class)->set_menu (esb, (ESearchBarItem *)menu->data);
g_array_free (menu, TRUE);
-
- for (i=0;i<efb->menu_rules->len;i++) {
- if (g_hash_table_lookup(efb->change_ids, efb->menu_rules->pdata[i]) == 0)
- g_hash_table_insert(efb->change_ids, efb->menu_rules->pdata[i],
- (void *)gtk_signal_connect(efb->menu_rules->pdata[i], "changed", rule_changed, efb));
- }
}
static ESearchBarSubitem *
@@ -419,7 +429,6 @@ set_option (ESearchBar *esb, ESearchBarItem *items)
GArray *menu;
EFilterBar *efb = (EFilterBar *)esb;
- g_ptr_array_set_size (efb->option_rules, 0);
menu = build_items (esb, items, 1, &efb->option_base, efb->option_rules);
((ESearchBarClass *)parent_class)->set_option (esb, (ESearchBarItem *)menu->data);
g_array_free (menu, TRUE);
@@ -440,13 +449,8 @@ static void
context_rule_removed (RuleContext *context, FilterRule *rule, gpointer user_data)
{
EFilterBar *efb = E_FILTER_BAR (user_data);
- int id;
- id = (int)g_hash_table_lookup(efb->change_ids, rule);
- if (id != 0) {
- g_hash_table_remove(efb->change_ids, rule);
- gtk_signal_disconnect((GtkObject *)rule, id);
- }
+ gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, efb);
}
static void
@@ -483,14 +487,6 @@ impl_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
static void
-remove_change_handler(FilterRule *rule, void *value, EFilterBar *bar)
-{
- int id = (int)value;
-
- gtk_signal_disconnect((GtkObject *)rule, id);
-}
-
-static void
destroy (GtkObject *object)
{
EFilterBar *bar;
@@ -499,15 +495,19 @@ destroy (GtkObject *object)
g_return_if_fail (E_IS_FILTER_BAR (object));
bar = E_FILTER_BAR (object);
+
+ gtk_signal_disconnect_by_func(GTK_OBJECT (bar->context), context_changed, bar);
+ gtk_signal_disconnect_by_func(GTK_OBJECT (bar->context), context_rule_removed, bar);
+
+ clear_rules(bar, bar->menu_rules);
+ clear_rules(bar, bar->option_rules);
+
gtk_object_unref (GTK_OBJECT (bar->context));
g_ptr_array_free (bar->menu_rules, TRUE);
g_ptr_array_free (bar->option_rules, TRUE);
g_free (bar->systemrules);
g_free (bar->userrules);
- g_hash_table_foreach(bar->change_ids, (GHFunc)remove_change_handler, bar);
- g_hash_table_destroy(bar->change_ids);
-
if (bar->default_items)
free_items (bar->default_items);
@@ -564,7 +564,6 @@ init (EFilterBar *efb)
efb->menu_rules = g_ptr_array_new ();
efb->option_rules = g_ptr_array_new ();
- efb->change_ids = g_hash_table_new(NULL, NULL);
}
diff --git a/widgets/misc/e-filter-bar.h b/widgets/misc/e-filter-bar.h
index 3dbcd3dab6..45db51b7a8 100644
--- a/widgets/misc/e-filter-bar.h
+++ b/widgets/misc/e-filter-bar.h
@@ -57,7 +57,6 @@ struct _EFilterBar {
int menu_base, option_base;
GPtrArray *menu_rules, *option_rules;
- GHashTable *change_ids;
ESearchBarItem *default_items;