Commit 0c91d7d6 authored by Sven Neumann's avatar Sven Neumann
Browse files

n2005-04-12 Sven Neumann <sven@gimp.org>

	* app/core/gimpcontainer.[ch]: added gimp_container_is_empty().

	* app/core/gimpcontext.c
	* app/core/gimpimage.c
	* app/dialogs/palette-import-dialog.c
	* app/text/gimptextlayer.c
	* app/widgets/gimpimagedock.c: use the new function.
parent 74296d79
2005-04-12 Sven Neumann <sven@gimp.org>
* app/core/gimpcontainer.[ch]: added gimp_container_is_empty().
* app/core/gimpcontext.c
* app/core/gimpimage.c
* app/dialogs/palette-import-dialog.c
* app/text/gimptextlayer.c
* app/widgets/gimpimagedock.c: use the new function.
2005-04-12 Michael Natterer <mitch@gimp.org>
* app/core/gimp-transform-utils.c
......
......@@ -768,6 +768,14 @@ gimp_container_clear (GimpContainer *container)
}
}
gboolean
gimp_container_is_empty (const GimpContainer *container)
{
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
return (container->num_children == 0);
}
gboolean
gimp_container_have (const GimpContainer *container,
GimpObject *object)
......
......@@ -103,6 +103,7 @@ void gimp_container_thaw (GimpContainer *container);
gboolean gimp_container_frozen (GimpContainer *container);
void gimp_container_clear (GimpContainer *container);
gboolean gimp_container_is_empty (const GimpContainer *container);
gboolean gimp_container_have (const GimpContainer *container,
GimpObject *object);
void gimp_container_foreach (const GimpContainer *container,
......
......@@ -3259,7 +3259,7 @@ gimp_context_find_object (GimpContext *context,
if (object_name)
object = gimp_container_get_child_by_name (container, object_name);
if (! object && gimp_container_num_children (container) > 0)
if (! object && ! gimp_container_is_empty (container))
object = gimp_container_get_child_by_index (container, 0);
if (! object)
......
......@@ -1497,7 +1497,7 @@ gimp_image_is_empty (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), TRUE);
return (gimp_container_num_children (gimage->layers) == 0);
return gimp_container_is_empty (gimage->layers);
}
GimpLayer *
......
......@@ -245,7 +245,7 @@ palette_import_dialog_new (Gimp *gimp)
import_dialog);
gtk_widget_set_sensitive (import_dialog->image_radio,
gimp_container_num_children (gimp->images) > 0);
! gimp_container_is_empty (gimp->images));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (import_dialog->image_radio));
......
......@@ -574,7 +574,7 @@ gimp_text_layer_render (GimpTextLayer *layer)
item = GIMP_ITEM (layer);
image = gimp_item_get_image (item);
if (gimp_container_num_children (image->gimp->fonts) == 0)
if (gimp_container_is_empty (image->gimp->fonts))
{
g_message (_("Due to lack of any fonts, "
"text functionality is not available."));
......
......@@ -587,11 +587,11 @@ gimp_image_dock_image_changed (GimpContext *context,
GimpDock *dock)
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
GimpContainer *container = image_dock->image_container;
if (gimage == NULL &&
gimp_container_num_children (image_dock->image_container) > 0)
if (gimage == NULL && ! gimp_container_is_empty (container))
{
gimage = GIMP_IMAGE (gimp_container_get_child_by_index (image_dock->image_container, 0));
gimage = GIMP_IMAGE (gimp_container_get_child_by_index (container, 0));
if (gimage)
{
......@@ -606,8 +606,7 @@ gimp_image_dock_image_changed (GimpContext *context,
g_signal_stop_emission_by_name (context, "image_changed");
}
}
else if (gimage != NULL &&
gimp_container_num_children (image_dock->display_container) > 0)
else if (gimage != NULL && ! gimp_container_is_empty (container))
{
GimpObject *gdisp;
GimpImage *gdisp_gimage;
......@@ -632,7 +631,7 @@ gimp_image_dock_image_changed (GimpContext *context,
{
GList *list;
for (list = GIMP_LIST (image_dock->display_container)->list;
for (list = GIMP_LIST (container)->list;
list;
list = g_list_next (list))
{
......
......@@ -587,11 +587,11 @@ gimp_image_dock_image_changed (GimpContext *context,
GimpDock *dock)
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
GimpContainer *container = image_dock->image_container;
if (gimage == NULL &&
gimp_container_num_children (image_dock->image_container) > 0)
if (gimage == NULL && ! gimp_container_is_empty (container))
{
gimage = GIMP_IMAGE (gimp_container_get_child_by_index (image_dock->image_container, 0));
gimage = GIMP_IMAGE (gimp_container_get_child_by_index (container, 0));
if (gimage)
{
......@@ -606,8 +606,7 @@ gimp_image_dock_image_changed (GimpContext *context,
g_signal_stop_emission_by_name (context, "image_changed");
}
}
else if (gimage != NULL &&
gimp_container_num_children (image_dock->display_container) > 0)
else if (gimage != NULL && ! gimp_container_is_empty (container))
{
GimpObject *gdisp;
GimpImage *gdisp_gimage;
......@@ -632,7 +631,7 @@ gimp_image_dock_image_changed (GimpContext *context,
{
GList *list;
for (list = GIMP_LIST (image_dock->display_container)->list;
for (list = GIMP_LIST (container)->list;
list;
list = g_list_next (list))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment