Treeview: Add API for setting the search string.
This commit is contained in:
parent
a59646cbf8
commit
34e61df8eb
|
@ -4839,6 +4839,29 @@ int treeview_get_height(treeview *tree)
|
|||
return height + search_height;
|
||||
}
|
||||
|
||||
/* Exported interface, documented in treeview.h */
|
||||
nserror treeview_set_search_string(
|
||||
treeview *tree,
|
||||
const char *string)
|
||||
{
|
||||
if (!(tree->flags & TREEVIEW_SEARCHABLE)) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if (string == NULL || strlen(string) == 0) {
|
||||
tree->search.active = false;
|
||||
tree->search.search = false;
|
||||
return treeview__search(tree, "", 0);
|
||||
}
|
||||
|
||||
tree->search.active = true;
|
||||
tree->search.search = true;
|
||||
if (!textarea_set_text(tree->search.textarea, string)) {
|
||||
return NSERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the plot styles from CSS system colour values.
|
||||
|
|
|
@ -495,4 +495,15 @@ void treeview_edit_selection(treeview *tree);
|
|||
*/
|
||||
int treeview_get_height(treeview *tree);
|
||||
|
||||
|
||||
/**
|
||||
* Set the search string for a treeview with \ref TREEVIEW_SEARCHABLE
|
||||
*
|
||||
* \param tree Tree to set the search string for.
|
||||
* \return NSERROR_OK on success, appropriate error otherwise
|
||||
*/
|
||||
nserror treeview_set_search_string(
|
||||
treeview *tree,
|
||||
const char *string);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue