aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-16 17:04:02 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-16 17:04:02 +0800
commit03f6e29a121581cc5e6fc8ec6132df55104f109d (patch)
tree3aa6a118f63aaf24f7c46aebdfcf32a166a29a7a /addressbook/gui/widgets
parent730bac3fbb1493d34b4a9d053ee94f740cc6af4b (diff)
downloadgsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.tar
gsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.tar.gz
gsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.tar.bz2
gsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.tar.lz
gsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.tar.xz
gsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.tar.zst
gsoc2013-evolution-03f6e29a121581cc5e6fc8ec6132df55104f109d.zip
Got rid of a memory leak. Rearranged a couple functions.
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.) svn path=/trunk/; revision=3076
Diffstat (limited to 'addressbook/gui/widgets')
-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
3 files changed, 38 insertions, 20 deletions
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