aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog10
-rw-r--r--addressbook/contact-editor/e-contact-editor-categories.c26
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-categories.c26
-rw-r--r--addressbook/gui/minicard/e-minicard-view.c54
-rw-r--r--addressbook/gui/minicard/e-minicard-view.h2
-rw-r--r--addressbook/gui/minicard/e-minicard.c2
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c54
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h2
-rw-r--r--addressbook/gui/widgets/e-minicard.c2
9 files changed, 118 insertions, 60 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index ac528e9dad..c45077111a 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-16 Christopher James Lahey <clahey@helixcode.com>
+
+ * contact-editor/e-contact-editor-categories.c: Got rid of a
+ memory leak. Rearranged a couple functions.
+
+ * gui/minicard/e-minicard-view.c, gui/minicard/e-minicard-view.h:
+ Added some code to stop watching the EBook when the canvas is
+ destroyed (apparently the canvas is destroyed before our widget is
+ destroyed.)
+
2000-05-14 Christopher James Lahey <clahey@helixcode.com>
* contact-editor/e-contact-editor-categories.c: Use the correct
diff --git a/addressbook/contact-editor/e-contact-editor-categories.c b/addressbook/contact-editor/e-contact-editor-categories.c
index 89ee180d18..5568b7bc71 100644
--- a/addressbook/contact-editor/e-contact-editor-categories.c
+++ b/addressbook/contact-editor/e-contact-editor-categories.c
@@ -133,13 +133,14 @@ add_list_unique(EContactEditorCategories *categories, char *string)
for (k = 0; k < categories->list_length; k++) {
if (!strcmp(list[k], temp)) {
categories->selected_list[k] = TRUE;
- g_free(temp);
break;
}
}
if (k == categories->list_length) {
categories->selected_list[categories->list_length] = TRUE;
list[categories->list_length++] = temp;
+ } else {
+ g_free(temp);
}
}
@@ -152,6 +153,12 @@ do_parse_categories(EContactEditorCategories *categories)
int i, j;
char **list;
int count = 1;
+
+ for (i = 0; i < categories->list_length; i++)
+ g_free(categories->category_list[i]);
+ g_free(categories->category_list);
+ g_free(categories->selected_list);
+
for (i = 0; str[i]; i++) {
switch (str[i]) {
case '\\':
@@ -164,20 +171,16 @@ do_parse_categories(EContactEditorCategories *categories)
break;
}
}
-
- for (i = 0; i < categories->list_length; i++)
- g_free(categories->category_list[i]);
- g_free(categories->category_list);
list = g_new(char *, count + 1 + BUILTIN_CATEGORY_COUNT);
categories->category_list = list;
- g_free(categories->selected_list);
categories->selected_list = g_new(gboolean, count + 1 + BUILTIN_CATEGORY_COUNT);
for (count = 0; count < BUILTIN_CATEGORY_COUNT; count++) {
list[count] = g_strdup(builtin_categories[count]);
categories->selected_list[count] = 0;
}
+
categories->list_length = count;
for (i = 0, j = 0; str[i]; i++, j++) {
@@ -209,8 +212,7 @@ static void
e_contact_editor_categories_entry_change (GtkWidget *entry,
EContactEditorCategories *categories)
{
- if (categories->categories)
- g_free(categories->categories);
+ g_free(categories->categories);
categories->categories = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
do_parse_categories(categories);
}
@@ -238,6 +240,7 @@ e_contact_editor_categories_init (EContactEditorCategories *categories)
categories->list_length = 0;
categories->category_list = NULL;
categories->selected_list = NULL;
+ categories->categories = NULL;
gnome_dialog_append_button ( GNOME_DIALOG(categories),
GNOME_STOCK_BUTTON_OK);
@@ -247,7 +250,6 @@ e_contact_editor_categories_init (EContactEditorCategories *categories)
gtk_window_set_policy(GTK_WINDOW(categories), FALSE, TRUE, FALSE);
- categories->categories = NULL;
gui = glade_xml_new (EVOLUTION_GLADEDIR "/categories.glade", NULL);
categories->gui = gui;
@@ -303,7 +305,12 @@ e_contact_editor_categories_destroy (GtkObject *object)
if (e_contact_editor_categories->gui)
gtk_object_unref(GTK_OBJECT(e_contact_editor_categories->gui));
+
g_free(e_contact_editor_categories->categories);
+ for (i = 0; i < categories->list_length; i++)
+ g_free(categories->category_list[i]);
+ g_free(categories->category_list);
+ g_free(categories->selected_list);
}
GtkWidget*
@@ -432,4 +439,3 @@ e_contact_editor_categories_thaw (ETableModel *etc, gpointer data)
{
e_table_model_changed(etc);
}
-
diff --git a/addressbook/gui/contact-editor/e-contact-editor-categories.c b/addressbook/gui/contact-editor/e-contact-editor-categories.c
index 89ee180d18..5568b7bc71 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-categories.c
+++ b/addressbook/gui/contact-editor/e-contact-editor-categories.c
@@ -133,13 +133,14 @@ add_list_unique(EContactEditorCategories *categories, char *string)
for (k = 0; k < categories->list_length; k++) {
if (!strcmp(list[k], temp)) {
categories->selected_list[k] = TRUE;
- g_free(temp);
break;
}
}
if (k == categories->list_length) {
categories->selected_list[categories->list_length] = TRUE;
list[categories->list_length++] = temp;
+ } else {
+ g_free(temp);
}
}
@@ -152,6 +153,12 @@ do_parse_categories(EContactEditorCategories *categories)
int i, j;
char **list;
int count = 1;
+
+ for (i = 0; i < categories->list_length; i++)
+ g_free(categories->category_list[i]);
+ g_free(categories->category_list);
+ g_free(categories->selected_list);
+
for (i = 0; str[i]; i++) {
switch (str[i]) {
case '\\':
@@ -164,20 +171,16 @@ do_parse_categories(EContactEditorCategories *categories)
break;
}
}
-
- for (i = 0; i < categories->list_length; i++)
- g_free(categories->category_list[i]);
- g_free(categories->category_list);
list = g_new(char *, count + 1 + BUILTIN_CATEGORY_COUNT);
categories->category_list = list;
- g_free(categories->selected_list);
categories->selected_list = g_new(gboolean, count + 1 + BUILTIN_CATEGORY_COUNT);
for (count = 0; count < BUILTIN_CATEGORY_COUNT; count++) {
list[count] = g_strdup(builtin_categories[count]);
categories->selected_list[count] = 0;
}
+
categories->list_length = count;
for (i = 0, j = 0; str[i]; i++, j++) {
@@ -209,8 +212,7 @@ static void
e_contact_editor_categories_entry_change (GtkWidget *entry,
EContactEditorCategories *categories)
{
- if (categories->categories)
- g_free(categories->categories);
+ g_free(categories->categories);
categories->categories = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
do_parse_categories(categories);
}
@@ -238,6 +240,7 @@ e_contact_editor_categories_init (EContactEditorCategories *categories)
categories->list_length = 0;
categories->category_list = NULL;
categories->selected_list = NULL;
+ categories->categories = NULL;
gnome_dialog_append_button ( GNOME_DIALOG(categories),
GNOME_STOCK_BUTTON_OK);
@@ -247,7 +250,6 @@ e_contact_editor_categories_init (EContactEditorCategories *categories)
gtk_window_set_policy(GTK_WINDOW(categories), FALSE, TRUE, FALSE);
- categories->categories = NULL;
gui = glade_xml_new (EVOLUTION_GLADEDIR "/categories.glade", NULL);
categories->gui = gui;
@@ -303,7 +305,12 @@ e_contact_editor_categories_destroy (GtkObject *object)
if (e_contact_editor_categories->gui)
gtk_object_unref(GTK_OBJECT(e_contact_editor_categories->gui));
+
g_free(e_contact_editor_categories->categories);
+ for (i = 0; i < categories->list_length; i++)
+ g_free(categories->category_list[i]);
+ g_free(categories->category_list);
+ g_free(categories->selected_list);
}
GtkWidget*
@@ -432,4 +439,3 @@ e_contact_editor_categories_thaw (ETableModel *etc, gpointer data)
{
e_table_model_changed(etc);
}
-
diff --git a/addressbook/gui/minicard/e-minicard-view.c b/addressbook/gui/minicard/e-minicard-view.c
index 5f76f15689..c77fc1f6ba 100644
--- a/addressbook/gui/minicard/e-minicard-view.c
+++ b/addressbook/gui/minicard/e-minicard-view.c
@@ -30,10 +30,8 @@ static void e_minicard_view_class_init (EMinicardViewClass *klass);
static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
static void e_minicard_view_destroy (GtkObject *object);
-
-#define E_MINICARD_VIEW_DIVIDER_WIDTH 2
-#define E_MINICARD_VIEW_BORDER_WIDTH 7
-#define E_MINICARD_VIEW_FULL_GUTTER (E_MINICARD_VIEW_DIVIDER_WIDTH + E_MINICARD_VIEW_BORDER_WIDTH * 2)
+static void canvas_destroy (GtkObject *object, EMinicardView *view);
+static void disconnect_signals (EMinicardView *view);
static EReflowSortedClass *parent_class = NULL;
@@ -102,6 +100,7 @@ e_minicard_view_init (EMinicardView *view)
view->create_card_id = 0;
view->remove_card_id = 0;
view->modify_card_id = 0;
+ view->canvas_destroy_id = 0;
E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare;
E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id;
@@ -145,20 +144,21 @@ static void
book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure)
{
EMinicardView *view = closure;
- if (view->book_view && view->create_card_id)
- gtk_signal_disconnect(GTK_OBJECT (view->book_view),
- view->create_card_id);
- if (view->book_view && view->remove_card_id)
- gtk_signal_disconnect(GTK_OBJECT (view->book_view),
- view->remove_card_id);
- if (view->book_view && view->modify_card_id)
- gtk_signal_disconnect(GTK_OBJECT (view->book_view),
- view->modify_card_id);
+ disconnect_signals(view);
if (view->book_view)
gtk_object_unref(GTK_OBJECT(view->book_view));
+
+ if (!view->canvas_destroy_id)
+ view->canvas_destroy_id =
+ gtk_signal_connect(GTK_OBJECT(GNOME_CANVAS_ITEM(view)->canvas),
+ "destroy", GTK_SIGNAL_FUNC(canvas_destroy),
+ view);
+
view->book_view = book_view;
if (view->book_view)
gtk_object_ref(GTK_OBJECT(view->book_view));
+
+
view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
"card_added",
GTK_SIGNAL_FUNC(create_card),
@@ -171,6 +171,7 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
"card_changed",
GTK_SIGNAL_FUNC(modify_card),
view);
+
g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_unref, NULL);
g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL);
g_list_free(E_REFLOW(view)->items);
@@ -245,6 +246,21 @@ e_minicard_view_destroy (GtkObject *object)
if (view->get_view_idle)
g_source_remove(view->get_view_idle);
+ if (view->canvas_destroy_id)
+ gtk_signal_disconnect(GTK_OBJECT (GNOME_CANVAS_ITEM(view)->canvas),
+ view->canvas_destroy_id);
+ disconnect_signals(view);
+ if (view->book)
+ gtk_object_unref(GTK_OBJECT(view->book));
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+
+ GTK_OBJECT_CLASS(parent_class)->destroy (object);
+}
+
+static void
+disconnect_signals(EMinicardView *view)
+{
if (view->book_view && view->create_card_id)
gtk_signal_disconnect(GTK_OBJECT (view->book_view),
view->create_card_id);
@@ -254,12 +270,12 @@ e_minicard_view_destroy (GtkObject *object)
if (view->book_view && view->modify_card_id)
gtk_signal_disconnect(GTK_OBJECT (view->book_view),
view->modify_card_id);
- if (view->book)
- gtk_object_unref(GTK_OBJECT(view->book));
- if (view->book_view)
- gtk_object_unref(GTK_OBJECT(view->book_view));
-
- GTK_OBJECT_CLASS(parent_class)->destroy (object);
+}
+
+static void
+canvas_destroy(GtkObject *object, EMinicardView *view)
+{
+ disconnect_signals(view);
}
void
diff --git a/addressbook/gui/minicard/e-minicard-view.h b/addressbook/gui/minicard/e-minicard-view.h
index ab0eeb892d..780b0dde33 100644
--- a/addressbook/gui/minicard/e-minicard-view.h
+++ b/addressbook/gui/minicard/e-minicard-view.h
@@ -70,6 +70,8 @@ struct _EMinicardView
int get_view_idle;
+ int canvas_destroy_id;
+
int create_card_id, remove_card_id, modify_card_id;
};
diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c
index ed8034926b..0089adb5dd 100644
--- a/addressbook/gui/minicard/e-minicard.c
+++ b/addressbook/gui/minicard/e-minicard.c
@@ -311,7 +311,7 @@ e_minicard_unrealize (GnomeCanvasItem *item)
static void
card_changed_cb (EBook* book, EBookStatus status, gpointer user_data)
{
- g_print ("%s: %s(): a card was changed\n", __FILE__, __FUNCTION__);
+ g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status);
}
static gboolean
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 5f76f15689..c77fc1f6ba 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -30,10 +30,8 @@ static void e_minicard_view_class_init (EMinicardViewClass *klass);
static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
static void e_minicard_view_destroy (GtkObject *object);
-
-#define E_MINICARD_VIEW_DIVIDER_WIDTH 2
-#define E_MINICARD_VIEW_BORDER_WIDTH 7
-#define E_MINICARD_VIEW_FULL_GUTTER (E_MINICARD_VIEW_DIVIDER_WIDTH + E_MINICARD_VIEW_BORDER_WIDTH * 2)
+static void canvas_destroy (GtkObject *object, EMinicardView *view);
+static void disconnect_signals (EMinicardView *view);
static EReflowSortedClass *parent_class = NULL;
@@ -102,6 +100,7 @@ e_minicard_view_init (EMinicardView *view)
view->create_card_id = 0;
view->remove_card_id = 0;
view->modify_card_id = 0;
+ view->canvas_destroy_id = 0;
E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare;
E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id;
@@ -145,20 +144,21 @@ static void
book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure)
{
EMinicardView *view = closure;
- if (view->book_view && view->create_card_id)
- gtk_signal_disconnect(GTK_OBJECT (view->book_view),
- view->create_card_id);
- if (view->book_view && view->remove_card_id)
- gtk_signal_disconnect(GTK_OBJECT (view->book_view),
- view->remove_card_id);
- if (view->book_view && view->modify_card_id)
- gtk_signal_disconnect(GTK_OBJECT (view->book_view),
- view->modify_card_id);
+ disconnect_signals(view);
if (view->book_view)
gtk_object_unref(GTK_OBJECT(view->book_view));
+
+ if (!view->canvas_destroy_id)
+ view->canvas_destroy_id =
+ gtk_signal_connect(GTK_OBJECT(GNOME_CANVAS_ITEM(view)->canvas),
+ "destroy", GTK_SIGNAL_FUNC(canvas_destroy),
+ view);
+
view->book_view = book_view;
if (view->book_view)
gtk_object_ref(GTK_OBJECT(view->book_view));
+
+
view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
"card_added",
GTK_SIGNAL_FUNC(create_card),
@@ -171,6 +171,7 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
"card_changed",
GTK_SIGNAL_FUNC(modify_card),
view);
+
g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_unref, NULL);
g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL);
g_list_free(E_REFLOW(view)->items);
@@ -245,6 +246,21 @@ e_minicard_view_destroy (GtkObject *object)
if (view->get_view_idle)
g_source_remove(view->get_view_idle);
+ if (view->canvas_destroy_id)
+ gtk_signal_disconnect(GTK_OBJECT (GNOME_CANVAS_ITEM(view)->canvas),
+ view->canvas_destroy_id);
+ disconnect_signals(view);
+ if (view->book)
+ gtk_object_unref(GTK_OBJECT(view->book));
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+
+ GTK_OBJECT_CLASS(parent_class)->destroy (object);
+}
+
+static void
+disconnect_signals(EMinicardView *view)
+{
if (view->book_view && view->create_card_id)
gtk_signal_disconnect(GTK_OBJECT (view->book_view),
view->create_card_id);
@@ -254,12 +270,12 @@ e_minicard_view_destroy (GtkObject *object)
if (view->book_view && view->modify_card_id)
gtk_signal_disconnect(GTK_OBJECT (view->book_view),
view->modify_card_id);
- if (view->book)
- gtk_object_unref(GTK_OBJECT(view->book));
- if (view->book_view)
- gtk_object_unref(GTK_OBJECT(view->book_view));
-
- GTK_OBJECT_CLASS(parent_class)->destroy (object);
+}
+
+static void
+canvas_destroy(GtkObject *object, EMinicardView *view)
+{
+ disconnect_signals(view);
}
void
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index ab0eeb892d..780b0dde33 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -70,6 +70,8 @@ struct _EMinicardView
int get_view_idle;
+ int canvas_destroy_id;
+
int create_card_id, remove_card_id, modify_card_id;
};
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index ed8034926b..0089adb5dd 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -311,7 +311,7 @@ e_minicard_unrealize (GnomeCanvasItem *item)
static void
card_changed_cb (EBook* book, EBookStatus status, gpointer user_data)
{
- g_print ("%s: %s(): a card was changed\n", __FILE__, __FUNCTION__);
+ g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status);
}
static gboolean