From 35510e02ff21e4fe00825a6fe05966fbac675d5c Mon Sep 17 00:00:00 2001 From: David Hampton Date: Sat, 20 Sep 2003 03:56:54 +0000 Subject: [PATCH] Destroy account tree page when the corresponding session is closed. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9366 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome/gnc-plugin-page-account-tree.c | 33 +++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gnome/gnc-plugin-page-account-tree.c b/src/gnome/gnc-plugin-page-account-tree.c index ec2cb64737..aa3d86d69c 100644 --- a/src/gnome/gnc-plugin-page-account-tree.c +++ b/src/gnome/gnc-plugin-page-account-tree.c @@ -44,6 +44,7 @@ #include "gnc-html.h" #include "gnc-icons.h" #include "gnc-plugin-account-tree.h" +#include "gnc-session.h" #include "gnc-split-reg.h" #include "gnc-tree-model-account.h" #include "gnc-tree-view-account.h" @@ -59,6 +60,7 @@ /* This static indicates the debugging module that this .o belongs to. */ static short module = MOD_GUI; +#define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-acct-tree" static void gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass); @@ -186,6 +188,7 @@ struct GncPluginPageAccountTreePrivate GNCOptionWin * editor_dialog; GtkWidget *options_db; + gint component_id; }; static GObjectClass *parent_class = NULL; @@ -447,6 +450,17 @@ gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface) LEAVE(" "); } +static void +gnc_plugin_page_account_tree_close_cb (gpointer user_data) +{ + GncPluginPageAccountTree *page; + GncMainWindow *window; + + page = GNC_PLUGIN_PAGE_ACCOUNT_TREE(user_data); + window = GNC_MAIN_WINDOW(g_object_get_data (G_OBJECT (page->priv->widget), "window")); + gnc_main_window_close_page (window, GNC_PLUGIN_PAGE(page)); +} + static GtkWidget * gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page) { @@ -486,6 +500,14 @@ gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page) gtk_widget_show (GTK_WIDGET (tree_view)); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view)); + page->priv->component_id = + gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS, + NULL, + gnc_plugin_page_account_tree_close_cb, + page); + gnc_gui_component_set_session (page->priv->component_id, + gnc_get_current_session()); + LEAVE("widget = %p", page->priv->widget); return page->priv->widget; } @@ -497,9 +519,14 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page) ENTER("page %p", plugin_page); page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page); - if (page->priv->widget == NULL) { - LEAVE("no widget"); - return; + if (page->priv->widget) { + g_object_unref(G_OBJECT(page->priv->widget)); + page->priv->widget = NULL; + } + + if (page->priv->component_id) { + gnc_unregister_gui_component(page->priv->component_id); + page->priv->component_id = 0; } LEAVE("widget destroyed");