LayerSelector: Add layer_selector_contains_elements() function

This commit is contained in:
Mario Hüttel 2019-11-09 02:18:53 +01:00
parent 74eb17b2dc
commit 4e38d8f452
2 changed files with 27 additions and 0 deletions

View File

@ -118,6 +118,18 @@ void layer_selector_auto_color_layers(LayerSelector *layer_selector, ColorPalett
*/
void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean overwrite);
/**
* @brief Check if the given layer selector contains layer elements.
*
* This function checks whether there are elements present.
* If an invalid object pointer \p layer_selector is passed,
* the function returns FALSE
*
* @param[in] layer_selector Selector to check
* @return True, if there is at least one layer present inside the selector
*/
gboolean layer_selector_contains_elements(LayerSelector *layer_selector);
G_END_DECLS
#endif /* __LAYER_SELECTOR_H__ */

View File

@ -883,4 +883,19 @@ void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean ove
g_list_free(le_list);
}
gboolean layer_selector_contains_elements(LayerSelector *layer_selector)
{
GList *layer_element_list;
/* Check objects */
g_return_val_if_fail(LAYER_IS_SELECTOR(layer_selector), FALSE);
g_return_val_if_fail(GTK_IS_LIST_BOX(layer_selector->list_box), FALSE);
/* Get a list of the child elements inside the list boy associated with this selector */
layer_element_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box));
/* Return TRUE if there is an element in the list, else return FALSE */
return (layer_element_list ? TRUE : FALSE);
}
/** @} */