mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Enhance the component manager so that you can optionally attach a
session to a component. Provide an interface to close components by session so they can be closed before the entire book/set of accounts is deleted. #102531. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7783 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f0e602fa65
commit
b5641d333c
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2003-01-05 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/app-utils/gnc-component-manager.c: New functions for
|
||||
attaching a session to a component, for finding all components
|
||||
with a given session, and for closing all components with a given
|
||||
session.
|
||||
|
||||
* src/gnome-utils/dialog-account.c: Attach session values to the
|
||||
components for "New Account" and "Edit Account" windows. #103531
|
||||
|
||||
* src/app-file/gnc-file.c (gnc_file_new): Before destroying the
|
||||
session, call new routine to close any open components related to
|
||||
this session. #102531
|
||||
|
||||
2003-01-05 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/scm/main.scm -- mention bugzilla in the unstable message
|
||||
|
@ -278,6 +278,7 @@ gnc_file_new (void)
|
||||
gw_wcp_assimilate_ptr (session, gh_eval_str("<gnc:Session*>")) :
|
||||
SCM_BOOL_F));
|
||||
|
||||
gnc_close_gui_component_by_session (session);
|
||||
gnc_session_destroy (session);
|
||||
|
||||
/* start a new book */
|
||||
|
@ -58,6 +58,7 @@ typedef struct
|
||||
|
||||
char *component_class;
|
||||
gint component_id;
|
||||
gpointer session;
|
||||
} ComponentInfo;
|
||||
|
||||
|
||||
@ -366,6 +367,23 @@ find_components_by_data (gpointer user_data)
|
||||
return list;
|
||||
}
|
||||
|
||||
static GList *
|
||||
find_components_by_session (gpointer session)
|
||||
{
|
||||
GList *list = NULL;
|
||||
GList *node;
|
||||
|
||||
for (node = components; node; node = node->next)
|
||||
{
|
||||
ComponentInfo *ci = node->data;
|
||||
|
||||
if (ci->session == session)
|
||||
list = g_list_prepend (list, ci);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static ComponentInfo *
|
||||
gnc_register_gui_component_internal (const char * component_class)
|
||||
{
|
||||
@ -392,6 +410,7 @@ gnc_register_gui_component_internal (const char * component_class)
|
||||
|
||||
ci->component_class = g_strdup (component_class);
|
||||
ci->component_id = component_id;
|
||||
ci->session = NULL;
|
||||
|
||||
components = g_list_prepend (components, ci);
|
||||
|
||||
@ -815,6 +834,39 @@ gnc_close_gui_component_by_data (const char *component_class,
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_gui_component_set_session (gint component_id, gpointer session)
|
||||
{
|
||||
ComponentInfo *ci;
|
||||
|
||||
ci = find_component (component_id);
|
||||
if (!ci)
|
||||
{
|
||||
PERR ("component not found");
|
||||
return;
|
||||
}
|
||||
|
||||
ci->session = session;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_close_gui_component_by_session (gpointer session)
|
||||
{
|
||||
GList *list;
|
||||
GList *node;
|
||||
|
||||
list = find_components_by_session (session);
|
||||
|
||||
for (node = list; node; node = node->next)
|
||||
{
|
||||
ComponentInfo *ci = node->data;
|
||||
|
||||
gnc_close_gui_component (ci->component_id);
|
||||
}
|
||||
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
GList *
|
||||
gnc_find_gui_components (const char *component_class,
|
||||
GNCComponentFindHandler find_handler,
|
||||
|
@ -162,6 +162,15 @@ gint gnc_register_gui_component_scm (const char * component_class,
|
||||
SCM refresh_handler,
|
||||
SCM close_handler);
|
||||
|
||||
/* gnc_gui_component_set_session
|
||||
* Set the associated session of this component
|
||||
*
|
||||
* component_id: id of component which is watching the entity
|
||||
* session: the session this component is associated with
|
||||
*/
|
||||
void
|
||||
gnc_gui_component_set_session (gint component_id, gpointer session);
|
||||
|
||||
/* gnc_gui_component_watch_entity
|
||||
* Add an entity to the list of those being watched by the component.
|
||||
* Only entities with refresh handlers should add watches.
|
||||
@ -288,6 +297,15 @@ void gnc_close_gui_component (gint component_id);
|
||||
void gnc_close_gui_component_by_data (const char *component_class,
|
||||
gpointer user_data);
|
||||
|
||||
/* gnc_close_gui_component_by_session
|
||||
* Invoke the close handler for components with the given session
|
||||
*
|
||||
* session: session to close
|
||||
* all components with that session
|
||||
* are closed.
|
||||
*/
|
||||
void gnc_close_gui_component_by_session (gpointer session);
|
||||
|
||||
/* gnc_find_gui_components
|
||||
* Search for components in the specified class.
|
||||
*
|
||||
|
@ -1806,6 +1806,7 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
||||
refresh_handler,
|
||||
close_handler, aw);
|
||||
|
||||
gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
|
||||
gnc_gui_component_watch_entity_type (aw->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
@ -2045,6 +2046,7 @@ gnc_ui_edit_account_window(Account *account)
|
||||
refresh_handler,
|
||||
close_handler, aw);
|
||||
|
||||
gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
|
||||
gnc_gui_component_watch_entity_type (aw->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
|
Loading…
Reference in New Issue
Block a user