Add quite param to insertion calls to suppress treeview height callback.

This commit is contained in:
Michael Drake 2013-07-01 16:16:11 +01:00
parent bc37046c6c
commit 21cd01a9b3
3 changed files with 28 additions and 8 deletions

View File

@ -56,6 +56,7 @@ struct global_history_ctx {
struct global_history_folder folders[GH_N_FOLDERS];
time_t today;
int weekday;
bool built;
};
struct global_history_ctx gh_ctx;
@ -183,7 +184,8 @@ static nserror global_history_create_dir(enum global_history_folders f)
&gh_ctx.folders[f].folder,
relation, rel,
&gh_ctx.folders[f].data,
&gh_ctx.folders[f]);
&gh_ctx.folders[f],
!gh_ctx.built);
return err;
}
@ -308,7 +310,8 @@ static nserror global_history_entry_insert(struct global_history_entry *e,
}
err = treeview_create_node_entry(gh_ctx.tree, &(e->entry),
parent, TREE_REL_FIRST_CHILD, e->data, e);
parent, TREE_REL_FIRST_CHILD, e->data, e,
!gh_ctx.built);
if (err != NSERROR_OK) {
return err;
}
@ -691,6 +694,11 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
return err;
}
/* History tree is built
* We suppress the treeview height callback on entry insertion before
* the treeview is built. */
gh_ctx.built = true;
/* Expand the "Today" folder node */
err = treeview_node_expand(gh_ctx.tree,
gh_ctx.folders[GH_TODAY].folder);

View File

@ -285,7 +285,7 @@ nserror treeview_create_node_folder(struct treeview *tree,
struct treeview_node *relation,
enum treeview_relationship rel,
const struct treeview_field_data *field,
void *data)
void *data, bool quiet)
{
struct treeview_node *n;
@ -324,7 +324,8 @@ nserror treeview_create_node_folder(struct treeview *tree,
*folder = n;
/* Inform front end of change in dimensions */
tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
if (!quiet)
tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
return NSERROR_OK;
}
@ -397,7 +398,7 @@ nserror treeview_create_node_entry(struct treeview *tree,
struct treeview_node *relation,
enum treeview_relationship rel,
const struct treeview_field_data fields[],
void *data)
void *data, bool quiet)
{
bool match;
struct treeview_node_entry *e;
@ -459,7 +460,8 @@ nserror treeview_create_node_entry(struct treeview *tree,
*entry = n;
/* Inform front end of change in dimensions */
tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
if (!quiet)
tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
return NSERROR_OK;
}

View File

@ -138,6 +138,7 @@ nserror treeview_destroy(struct treeview *tree);
* \param rel Folder's relationship to relation
* \param field Field data
* \param data Client data for node event callbacks
* \param quiet True to suppress corewindow height update callback
* \return NSERROR_OK on success, appropriate error otherwise
*
* Field name must match name past in treeview_create fields[N-1].
@ -149,7 +150,7 @@ nserror treeview_create_node_folder(struct treeview *tree,
struct treeview_node *relation,
enum treeview_relationship rel,
const struct treeview_field_data *field,
void *data);
void *data, bool quiet);
/**
* Create an entry node in given treeview
@ -160,6 +161,7 @@ nserror treeview_create_node_folder(struct treeview *tree,
* \param rel Folder's relationship to relation
* \param fields Array of field data
* \param data Client data for node event callbacks
* \param quiet True to suppress corewindow height update callback
* \return NSERROR_OK on success, appropriate error otherwise
*
* Fields array names must match names past in treeview_create fields[0...N-2].
@ -171,7 +173,7 @@ nserror treeview_create_node_entry(struct treeview *tree,
struct treeview_node *relation,
enum treeview_relationship rel,
const struct treeview_field_data fields[],
void *data);
void *data, bool quiet);
/**
* Update an entry node in given treeview
@ -278,4 +280,12 @@ bool treeview_clear_selection(struct treeview *tree, struct rect *rect);
*/
bool treeview_select_all(struct treeview *tree, struct rect *rect);
/**
* Find current height of a treeview
*
* \param tree Treeview object to find height of
* \return height of treeview in px
*/
int treeview_get_height(struct treeview *tree);
#endif