diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-06-01 07:05:41 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-06-01 07:05:41 +0800 |
commit | be88a44705a7decc5cf3fb87704f1d6608fea857 (patch) | |
tree | 3838b802677649ef4b231c99683c1b34ee8277f7 /addressbook/gui | |
parent | e86a28e484c9adc8a755f2df7ed9f682e47c32d5 (diff) | |
download | gsoc2013-evolution-be88a44705a7decc5cf3fb87704f1d6608fea857.tar.gz gsoc2013-evolution-be88a44705a7decc5cf3fb87704f1d6608fea857.tar.zst gsoc2013-evolution-be88a44705a7decc5cf3fb87704f1d6608fea857.zip |
Added fields for the GalViewMenus and GalViewCollection; we need to keep
2001-05-31 Federico Mena Quintero <federico@ximian.com>
* gui/widgets/e-addressbook-view.h (EAddressbookView): Added
fields for the GalViewMenus and GalViewCollection; we need to keep
them around while the component is active.
* gui/widgets/e-addressbook-view.c
(e_addressbook_view_setup_menus): Plug leak; unref the spec.
Unref the factories. Do not unref the collection, since we need
it for the signal emission (okay, so the views object adds a
reference to it, but if we are interested in it we should keep a
reference anyways).
(e_addressbook_view_setup_menus): Create the collection and views
on the EAddressbookView's fields so that we can keep them around.
(e_addressbook_view_discard_menus): New function; gets rid of the
collection and views objects.
* gui/component/addressbook.c (control_activate_cb): Call
e_addressbook_view_discard_menus().
svn path=/trunk/; revision=10074
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/addressbook.c | 4 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 77 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.h | 7 |
3 files changed, 69 insertions, 19 deletions
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index c572bfc097..a3df7a300e 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -349,8 +349,10 @@ control_activate_cb (BonoboControl *control, if (activate) control_activate (control, uic, view); - else + else { bonobo_ui_component_unset_container (uic); + e_addressbook_view_discard_menus (view->view); + } } static void diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index f04c9c37c3..6b12c95e73 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -39,8 +39,6 @@ #include <libgnomeprint/gnome-print-master.h> #include <libgnomeprint/gnome-print-master-preview.h> -#include "widgets/menus/gal-view-menus.h" - #include "addressbook/printing/e-contact-print.h" #include "addressbook/printing/e-contact-print-envelope.h" @@ -200,6 +198,9 @@ e_addressbook_view_init (EAddressbookView *eav) eav->object = NULL; eav->widget = NULL; + eav->view_collection = NULL; + eav->view_menus = NULL; + eav->invisible = gtk_invisible_new (); gtk_selection_add_target (eav->invisible, @@ -230,6 +231,16 @@ e_addressbook_view_destroy (GtkObject *object) gtk_object_unref(GTK_OBJECT(eav->book)); g_free(eav->query); + if (eav->view_collection) { + gtk_object_unref (GTK_OBJECT (eav->view_collection)); + eav->view_collection = NULL; + } + + if (eav->view_menus) { + gtk_object_unref (GTK_OBJECT (eav->view_menus)); + eav->view_menus = NULL; + } + if (eav->clipboard_cards) { g_list_foreach (eav->clipboard_cards, (GFunc)gtk_object_unref, NULL); g_list_free (eav->clipboard_cards); @@ -1012,16 +1023,23 @@ void e_addressbook_view_setup_menus (EAddressbookView *view, BonoboUIComponent *uic) { - GalViewCollection *collection; - GalViewMenus *views; GalViewFactory *factory; ETableSpecification *spec; char *galview; - collection = gal_view_collection_new(); + g_return_if_fail (view != NULL); + g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); + g_return_if_fail (uic != NULL); + g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); + g_return_if_fail (view->view_collection == NULL); + + g_assert (view->view_collection == NULL); + g_assert (view->view_menus == NULL); + + view->view_collection = gal_view_collection_new(); galview = gnome_util_prepend_user_home("/evolution/views/addressbook/"); - gal_view_collection_set_storage_directories(collection, + gal_view_collection_set_storage_directories(view->view_collection, EVOLUTION_DATADIR "/evolution/views/addressbook/", galview); g_free(galview); @@ -1029,23 +1047,46 @@ e_addressbook_view_setup_menus (EAddressbookView *view, spec = e_table_specification_new(); e_table_specification_load_from_string(spec, SPEC); - 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 (view->view_collection, factory); + gtk_object_unref (GTK_OBJECT (factory)); - factory = gal_view_factory_minicard_new(); - gal_view_collection_add_factory(collection, factory); - gtk_object_sink(GTK_OBJECT(factory)); + factory = gal_view_factory_minicard_new (); + gal_view_collection_add_factory (view->view_collection, factory); + gtk_object_unref (GTK_OBJECT (factory)); - gal_view_collection_load(collection); + gal_view_collection_load(view->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", + view->view_menus = gal_view_menus_new(view->view_collection); + gal_view_menus_apply(view->view_menus, uic, NULL); + gtk_signal_connect(GTK_OBJECT(view->view_collection), "display_view", display_view, view); - /* gtk_object_sink(GTK_OBJECT(views)); */ +} + +/** + * e_addressbook_view_discard_menus: + * @view: An addressbook view. + * + * Makes an addressbook view discard its GAL view menus and its views collection + * objects. This should be called when the corresponding Bonobo component is + * deactivated. + **/ +void +e_addressbook_view_discard_menus (EAddressbookView *view) +{ + g_return_if_fail (view != NULL); + g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); + g_return_if_fail (view->view_collection); + + g_assert (view->view_collection != NULL); + g_assert (view->view_menus != NULL); + + gtk_object_unref (GTK_OBJECT (view->view_collection)); + view->view_collection = NULL; - gtk_object_sink(GTK_OBJECT(collection)); + gtk_object_unref (GTK_OBJECT (view->view_menus)); + view->view_menus = NULL; } static ESelectionModel* diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h index 049376c96f..d97cd58f55 100644 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ b/addressbook/gui/widgets/e-addressbook-view.h @@ -23,7 +23,9 @@ #include <gtk/gtktable.h> #include <bonobo/bonobo-ui-component.h> +#include <gal/menus/gal-view-collection.h> #include "e-addressbook-model.h" +#include "widgets/menus/gal-view-menus.h" #include "addressbook/backend/ebook/e-book.h" #ifdef __cplusplus @@ -75,6 +77,10 @@ struct _EAddressbookView GtkWidget *widget; GtkWidget *vbox; + + /* Menus handler and the view collection */ + GalViewCollection *view_collection; + GalViewMenus *view_menus; }; struct _EAddressbookViewClass @@ -93,6 +99,7 @@ GtkType e_addressbook_view_get_type (void); void e_addressbook_view_setup_menus (EAddressbookView *view, BonoboUIComponent *uic); +void e_addressbook_view_discard_menus (EAddressbookView *view); void e_addressbook_view_print (EAddressbookView *view); void e_addressbook_view_delete_selection (EAddressbookView *view); |