Add another function to the plugin interface for deleting the ui

widget.  Allows the page to destroy/release anything it needs to.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9242 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2003-09-06 10:39:09 +00:00
parent 0c37526d47
commit cfa09f61a2
6 changed files with 86 additions and 6 deletions

View File

@@ -39,6 +39,22 @@
* src/gnome-utils/transfer.glade:
Convert to the new gtktreeview based account tree code.
* src/gnome-utils/dialog-transfer.c: Get this working for both the
case where it is run as a modal dialog (e.g. reconcile) and the
case where it is thrown up on the screen and forgotten
(e.g. transfer).
* src/gnome/gnc-main-window.c:
* src/gnome/gnc-plugin-page-account-tree.c:
* src/gnome/gnc-plugin-page-register.c:
* src/gnome/gnc-plugin-page.[ch]: Add another function to the
plugin interface for deleting the ui widget. Allows the page to
destroy/release anything it needs to.
* src/gnome/gnc-plugin-page-register.c:
* src/gnome/gnc-split-reg.c: Correctly clean up when closing a
register.
2003-09-01 David Hampton <hampton@employees.org>
* configure.in:

View File

@@ -323,7 +323,8 @@ gnc_main_window_open_page (GncMainWindow *window,
child, label_box);
gnc_plugin_page_inserted (page);
/*
#if 0
pos = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) - 1;
if (gtk_notebook_get_current_page (GTK_NOTEBOOK (window->priv->notebook)) == pos) {
window->priv->current_page = page;
@@ -332,7 +333,8 @@ gnc_main_window_open_page (GncMainWindow *window,
} else {
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
pos);
}*/
}
#endif
}
void
@@ -367,7 +369,10 @@ gnc_main_window_close_page (GncMainWindow *window,
egg_menu_merge_ensure_update (window->ui_merge);
/*
gnc_plugin_page_destroy_widget (page);
g_object_unref(page);
#if 0
i = gtk_notebook_get_current_page (GTK_NOTEBOOK (window->priv->notebook));
child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->priv->notebook), i);
if (child == NULL) {
@@ -381,7 +386,8 @@ gnc_main_window_close_page (GncMainWindow *window,
if (page != NULL) {
gnc_plugin_page_merge_actions (page, window->ui_merge);
gnc_plugin_page_selected (page);
}*/
}
#endif
}
GncPluginPage *

View File

@@ -68,6 +68,7 @@ static Account *gnc_plugin_page_account_tree_get_current_account (GncPluginPageA
static void gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface);
static GtkWidget *gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_account_tree_merge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static void gnc_plugin_page_account_tree_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static G_CONST_RETURN gchar *gnc_plugin_page_account_tree_get_title (GncPluginPage *plugin_page);
@@ -155,6 +156,7 @@ static const gchar *actions_requiring_account[] = {
"FileOpenSubaccountsAction",
"EditEditAccountAction",
"EditDeleteAccountAction",
"ActionsReconcileAction",
NULL
};
@@ -426,6 +428,7 @@ gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface)
{
ENTER(" ");
iface->create_widget = gnc_plugin_page_account_tree_create_widget;
iface->destroy_widget = gnc_plugin_page_account_tree_destroy_widget;
iface->merge_actions = gnc_plugin_page_account_tree_merge_actions;
iface->unmerge_actions = gnc_plugin_page_account_tree_unmerge_actions;
iface->get_title = gnc_plugin_page_account_tree_get_title;
@@ -438,7 +441,7 @@ gnc_plugin_page_account_tree_plugin_page_init (GncPluginPageIface *iface)
static GtkWidget *
gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page)
{
GncPluginPageAccountTree *page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page);
GncPluginPageAccountTree *page;
GtkTreeSelection *selection;
GtkTreeView *tree_view;
GtkWidget *scrolled_window;
@@ -478,6 +481,21 @@ gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page)
return page->priv->widget;
}
static void
gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
{
GncPluginPageAccountTree *page;
ENTER("page %p", plugin_page);
page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page);
if (page->priv->widget == NULL) {
LEAVE("no widget");
return;
}
LEAVE("widget destroyed");
}
static void
gnc_plugin_page_account_tree_merge_actions (GncPluginPage *plugin_page,
EggMenuMerge *ui_merge)

View File

@@ -44,6 +44,7 @@ static void gnc_plugin_page_register_finalize (GObject *object);
static void gnc_plugin_page_register_plugin_page_init (GncPluginPageIface *iface);
static GtkWidget *gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page);
static void gnc_plugin_page_register_merge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static void gnc_plugin_page_register_unmerge_actions (GncPluginPage *plugin_page, EggMenuMerge *ui_merge);
static G_CONST_RETURN gchar *gnc_plugin_page_register_get_title (GncPluginPage *plugin_page);
@@ -238,6 +239,7 @@ static void
gnc_plugin_page_register_plugin_page_init (GncPluginPageIface *iface)
{
iface->create_widget = gnc_plugin_page_register_create_widget;
iface->destroy_widget = gnc_plugin_page_register_destroy_widget;
iface->merge_actions = gnc_plugin_page_register_merge_actions;
iface->unmerge_actions = gnc_plugin_page_register_unmerge_actions;
iface->get_title = gnc_plugin_page_register_get_title;
@@ -276,6 +278,20 @@ gnc_plugin_page_register_create_widget (GncPluginPage *plugin_page)
return priv->widget;
}
static void
gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page)
{
GncPluginPageRegister *page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
GncPluginPageRegisterPrivate *priv = page->priv;
if (priv->widget == NULL)
return;
gtk_widget_hide(priv->widget);
gnc_ledger_display_close (priv->ld);
priv->ld = NULL;
}
static void
gnc_plugin_page_register_merge_actions (GncPluginPage *plugin_page,
EggMenuMerge *ui_merge)

View File

@@ -68,10 +68,32 @@ gnc_plugin_page_get_type (void)
GtkWidget *
gnc_plugin_page_create_widget (GncPluginPage *plugin_page)
{
GtkWidget *widget;
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
g_return_val_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->create_widget != NULL, NULL);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->create_widget (plugin_page);
widget = GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->create_widget (plugin_page);
/*
* If there is a destroy function, add a ref so that the
* widgets will exists when the destroy function is called.
* Otherwise it will be destroyed when it is removed from the
* main notebook for the window.
*/
if (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->destroy_widget)
g_object_ref(widget);
return widget;
}
void
gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page)
{
g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
g_return_if_fail (GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->destroy_widget != NULL);
return GNC_PLUGIN_PAGE_GET_IFACE (plugin_page)->destroy_widget (plugin_page);
}
void

View File

@@ -51,6 +51,7 @@ typedef struct {
/* Virtual Table */
GtkWidget *(* create_widget) (GncPluginPage *plugin_page);
void (* destroy_widget) (GncPluginPage *plugin_page);
void (* merge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge);
void (* unmerge_actions) (GncPluginPage *plugin_page, EggMenuMerge *merge);
@@ -66,6 +67,7 @@ typedef struct {
GType gnc_plugin_page_get_type (void);
GtkWidget *gnc_plugin_page_create_widget (GncPluginPage *plugin_page);
void gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page);
void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page,
EggMenuMerge *merge);