aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog15
-rw-r--r--mail/folder-browser-factory.c44
-rw-r--r--mail/folder-browser.c13
-rw-r--r--mail/folder-browser.h5
4 files changed, 62 insertions, 15 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 95066728c8..8bdc7bb67b 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,18 @@
+2001-06-01 Federico Mena Quintero <federico@ximian.com>
+
+ * folder-browser.h (FolderBrowser): Added fields for the
+ GalViewMenus and GalViewCollection, since we need to keep them
+ around while the component is active.
+
+ * folder-browser-factory.c (folder_browser_setup_view_menus): Plug
+ leaks; unref the spec and factory. Set the view collection and
+ the view menus on the FolderBrowser object.
+ (folder_browser_discard_view_menus): New function.
+ (control_deactivate): Discard the menus.
+
+ * folder-browser.c (folder_browser_destroy): Destroy the view
+ collection and the view menus.
+
2001-06-01 Ettore Perazzoli <ettore@ximian.com>
* Makefile.am (evolution_mail_LDADD): Add `$(DB3_LDADD)'.
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index e9bd4adc87..c8964babc1 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -151,18 +151,18 @@ static void
folder_browser_setup_view_menus (FolderBrowser *fb,
BonoboUIComponent *uic)
{
- GalViewCollection *collection;
- GalViewMenus *views;
GalViewFactory *factory;
ETableSpecification *spec;
char *local_dir;
- collection = gal_view_collection_new();
- /* FIXME: Memory leak. */
+ g_assert (fb->view_collection == NULL);
+ g_assert (fb->view_menus == NULL);
+
+ fb->view_collection = gal_view_collection_new();
+
local_dir = gnome_util_prepend_user_home ("/evolution/views/mail/");
-
gal_view_collection_set_storage_directories(
- collection,
+ fb->view_collection,
EVOLUTION_DATADIR "/evolution/views/mail/",
local_dir);
g_free (local_dir);
@@ -170,19 +170,31 @@ folder_browser_setup_view_menus (FolderBrowser *fb,
spec = e_table_specification_new();
e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
- factory = gal_view_factory_etable_new(spec);
- gal_view_collection_add_factory(collection, factory);
- gtk_object_sink(GTK_OBJECT(factory));
+ factory = gal_view_factory_etable_new (spec);
+ gtk_object_unref (GTK_OBJECT (spec));
+ gal_view_collection_add_factory (fb->view_collection, factory);
+ gtk_object_unref (GTK_OBJECT (factory));
- gal_view_collection_load(collection);
+ gal_view_collection_load(fb->view_collection);
- views = gal_view_menus_new(collection);
- gal_view_menus_apply(views, uic, NULL); /* This function probably needs to sink the views object. */
- gtk_signal_connect(GTK_OBJECT(collection), "display_view",
+ fb->view_menus = gal_view_menus_new(fb->view_collection);
+ gal_view_menus_apply(fb->view_menus, uic, NULL);
+ gtk_signal_connect(GTK_OBJECT(fb->view_collection), "display_view",
display_view, fb);
- /* gtk_object_sink(GTK_OBJECT(views)); */
+}
- gtk_object_sink(GTK_OBJECT(collection));
+/* Gets rid of the view collection and view menus objects */
+static void
+folder_browser_discard_view_menus (FolderBrowser *fb)
+{
+ g_assert (fb->view_collection != NULL);
+ g_assert (fb->view_menus != NULL);
+
+ gtk_object_unref (GTK_OBJECT (fb->view_collection));
+ fb->view_collection = NULL;
+
+ gtk_object_unref (GTK_OBJECT (fb->view_menus));
+ fb->view_menus = NULL;
}
static void
@@ -293,6 +305,8 @@ control_deactivate (BonoboControl *control,
if (fb->folder)
mail_sync_folder (fb->folder, NULL, NULL);
+
+ folder_browser_discard_view_menus (fb);
}
static void
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 81c27f450f..e29f406a67 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -108,6 +108,16 @@ folder_browser_destroy (GtkObject *object)
CORBA_exception_free (&ev);
+ if (folder_browser->view_collection) {
+ gtk_object_unref (GTK_OBJECT (folder_browser->view_collection));
+ folder_browser->view_collection = NULL;
+ }
+
+ if (folder_browser->view_menus) {
+ gtk_object_unref (GTK_OBJECT (folder_browser->view_menus));
+ folder_browser->view_menus = NULL;
+ }
+
folder_browser_parent_class->destroy (object);
}
@@ -1152,6 +1162,9 @@ my_folder_browser_init (GtkObject *object)
{
FolderBrowser *fb = FOLDER_BROWSER (object);
+ fb->view_collection = NULL;
+ fb->view_menus = NULL;
+
/*
* Setup parent class fields.
*/
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index 8794753c62..c41562153e 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -9,6 +9,7 @@
#include <bonobo/bonobo-property-bag.h>
#include <bonobo/bonobo-ui-component.h>
#include <widgets/misc/e-filter-bar.h>
+#include "widgets/menus/gal-view-menus.h"
#include "filter/filter-rule.h"
#include "filter/filter-context.h" /*eek*/
#include "message-list.h"
@@ -58,6 +59,10 @@ struct _FolderBrowser {
FilterRule *search_full; /* if we have a full search active */
gboolean preview_shown;
+
+ /* View collection and the menu handler object */
+ GalViewCollection *view_collection;
+ GalViewMenus *view_menus;
};