Commit dc95e16b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added enum GimpContainerPolicy.

2003-08-25  Michael Natterer  <mitch@gimp.org>

	* app/core/core-enums.[ch]: added enum GimpContainerPolicy.

	* app/core/gimpcontainer.[ch]: removed it here.  Added new virtual
	function GimpContainer::clear() which removes all items. Cleanup.

	* app/core/gimplist.c: implement GimpContainer::clear(). Cleanup.
parent 9209b3f7
2003-08-25 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.[ch]: added enum GimpContainerPolicy.
* app/core/gimpcontainer.[ch]: removed it here. Added new virtual
function GimpContainer::clear() which removes all items. Cleanup.
* app/core/gimplist.c: implement GimpContainer::clear(). Cleanup.
2003-08-25 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpitemfactory.[ch]
......@@ -115,6 +115,25 @@ gimp_channel_type_get_type (void)
}
static const GEnumValue gimp_container_policy_enum_values[] =
{
{ GIMP_CONTAINER_POLICY_STRONG, "GIMP_CONTAINER_POLICY_STRONG", "strong" },
{ GIMP_CONTAINER_POLICY_WEAK, "GIMP_CONTAINER_POLICY_WEAK", "weak" },
{ 0, NULL, NULL }
};
GType
gimp_container_policy_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpContainerPolicy", gimp_container_policy_enum_values);
return enum_type;
}
static const GEnumValue gimp_convert_dither_type_enum_values[] =
{
{ GIMP_NO_DITHER, N_("No Color Dithering"), "no-dither" },
......
......@@ -21,18 +21,18 @@
#if 0
This file is parsed by two scripts, enumgen.pl in tools/pdbgen,
and gimp-mkenums. All enums that are not marked with
and gimp-mkenums. All enums that are not marked with
/*< pdb-skip >*/ are exported to libgimp and the PDB. Enums that are
not marked with /*< skip >*/ are registered with the GType system.
If you want the enum to be skipped by both scripts, you have to use
/*< pdb-skip, skip >*/.
not marked with /*< skip >*/ are registered with the GType system.
If you want the enum to be skipped by both scripts, you have to use
/*< pdb-skip, skip >*/.
All enum values that are marked with /*< skip >*/ are skipped for
both targets.
#endif
/*
/*
* these enums that are registered with the type system
*/
......@@ -103,6 +103,17 @@ typedef enum
} GimpChannelType;
#define GIMP_TYPE_CONTAINER_POLICY (gimp_container_policy_get_type ())
GType gimp_container_policy_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_CONTAINER_POLICY_STRONG,
GIMP_CONTAINER_POLICY_WEAK
} GimpContainerPolicy;
#define GIMP_TYPE_CONVERT_DITHER_TYPE (gimp_convert_dither_type_get_type ())
GType gimp_convert_dither_type_get_type (void) G_GNUC_CONST;
......@@ -142,7 +153,7 @@ GType gimp_fill_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_FOREGROUND_FILL, /*< desc="Foreground" >*/
GIMP_FOREGROUND_FILL, /*< desc="Foreground" >*/
GIMP_BACKGROUND_FILL, /*< desc="Background" >*/
GIMP_WHITE_FILL, /*< desc="White" >*/
GIMP_TRANSPARENT_FILL, /*< desc="Transparent" >*/
......@@ -156,7 +167,7 @@ GType gimp_gradient_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_LINEAR, /*< desc="Linear" >*/
GIMP_LINEAR, /*< desc="Linear" >*/
GIMP_BILINEAR, /*< desc="Bi-Linear" >*/
GIMP_RADIAL, /*< desc="Radial" >*/
GIMP_SQUARE, /*< desc="Square" >*/
......
......@@ -113,32 +113,11 @@ static void gimp_container_disconnect_callback (GimpObject *object,
gpointer data);
static guint container_signals[LAST_SIGNAL] = { 0 };
static guint container_signals[LAST_SIGNAL] = { 0, };
static GimpObjectClass *parent_class = NULL;
GType
gimp_container_policy_get_type (void)
{
static GType policy_type = 0;
if (! policy_type)
{
static const GEnumValue container_policy_values[] =
{
{ GIMP_CONTAINER_POLICY_STRONG, "GIMP_CONTAINER_POLICY_STRONG", "strong" },
{ GIMP_CONTAINER_POLICY_WEAK, "GIMP_CONTAINER_POLICY_WEAK", "weak" },
{ 0, NULL, NULL }
};
policy_type = g_enum_register_static ("GimpContainerPolicy",
container_policy_values);
}
return policy_type;
}
GType
gimp_container_get_type (void)
{
......@@ -158,7 +137,7 @@ gimp_container_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) gimp_container_init,
};
static const GInterfaceInfo config_iface_info =
static const GInterfaceInfo config_iface_info =
{
(GInterfaceInitFunc) gimp_container_config_iface_init,
NULL, /* iface_finalize */
......@@ -166,7 +145,7 @@ gimp_container_get_type (void)
};
container_type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpContainer",
"GimpContainer",
&container_info, 0);
g_type_add_interface_static (container_type,
......@@ -249,6 +228,7 @@ gimp_container_class_init (GimpContainerClass *klass)
klass->freeze = NULL;
klass->thaw = NULL;
klass->clear = NULL;
klass->have = NULL;
klass->foreach = NULL;
klass->get_child_by_name = NULL;
......@@ -296,11 +276,9 @@ gimp_container_dispose (GObject *object)
container = GIMP_CONTAINER (object);
while (container->handlers)
{
gimp_container_remove_handler (container,
((GimpContainerHandler *)
container->handlers->data)->quark);
}
gimp_container_remove_handler (container,
((GimpContainerHandler *)
container->handlers->data)->quark);
if (container->children_type != G_TYPE_NONE)
{
......@@ -372,13 +350,11 @@ gimp_container_get_memsize (GimpObject *object,
for (list = container->handlers; list; list = g_list_next (list))
{
GimpContainerHandler *handler;
handler = (GimpContainerHandler *) list->data;
GimpContainerHandler *handler = list->data;
memsize += (sizeof (GList) +
sizeof (GimpContainerHandler) +
strlen (handler->signame));
strlen (handler->signame) + 1);
}
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
......@@ -677,8 +653,8 @@ gimp_container_remove (GimpContainer *container,
{
handler = (GimpContainerHandler *) list->data;
handler_id = GPOINTER_TO_UINT
(g_object_get_qdata (G_OBJECT (object), handler->quark));
handler_id = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (object),
handler->quark));
if (handler_id)
{
......@@ -799,6 +775,19 @@ gimp_container_frozen (GimpContainer *container)
return (container->freeze_count > 0) ? TRUE : FALSE;
}
void
gimp_container_clear (GimpContainer *container)
{
g_return_if_fail (GIMP_IS_CONTAINER (container));
if (container->num_children > 0)
{
gimp_container_freeze (container);
GIMP_CONTAINER_GET_CLASS (container)->clear (container);
gimp_container_thaw (container);
}
}
gboolean
gimp_container_have (GimpContainer *container,
GimpObject *object)
......@@ -819,10 +808,8 @@ gimp_container_foreach (GimpContainer *container,
g_return_if_fail (GIMP_IS_CONTAINER (container));
g_return_if_fail (func != NULL);
if (container->num_children < 1)
return;
GIMP_CONTAINER_GET_CLASS (container)->foreach (container, func, user_data);
if (container->num_children > 0)
GIMP_CONTAINER_GET_CLASS (container)->foreach (container, func, user_data);
}
GimpObject *
......@@ -925,9 +912,8 @@ gimp_container_remove_handler_foreach_func (GimpObject *object,
{
gulong handler_id;
handler_id =
GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (object),
handler->quark));
handler_id = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (object),
handler->quark));
if (handler_id)
{
......
......@@ -26,14 +26,6 @@
#include "gimpobject.h"
typedef enum
{
GIMP_CONTAINER_POLICY_STRONG,
GIMP_CONTAINER_POLICY_WEAK
} GimpContainerPolicy;
#define GIMP_TYPE_CONTAINER_POLICY (gimp_container_policy_get_type ())
#define GIMP_TYPE_CONTAINER (gimp_container_get_type ())
#define GIMP_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTAINER, GimpContainer))
#define GIMP_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER, GimpContainerClass))
......@@ -74,6 +66,7 @@ struct _GimpContainerClass
void (* thaw) (GimpContainer *container);
/* virtual functions */
void (* clear) (GimpContainer *container);
gboolean (* have) (const GimpContainer *container,
const GimpObject *object);
void (* foreach) (const GimpContainer *container,
......@@ -88,8 +81,6 @@ struct _GimpContainerClass
};
GType gimp_container_policy_get_type (void) G_GNUC_CONST;
GType gimp_container_get_type (void) G_GNUC_CONST;
GType gimp_container_children_type (const GimpContainer *container);
......@@ -111,6 +102,7 @@ void gimp_container_freeze (GimpContainer *container);
void gimp_container_thaw (GimpContainer *container);
gboolean gimp_container_frozen (GimpContainer *container);
void gimp_container_clear (GimpContainer *container);
gboolean gimp_container_have (GimpContainer *container,
GimpObject *object);
void gimp_container_foreach (GimpContainer *container,
......
......@@ -46,6 +46,7 @@ static void gimp_list_remove (GimpContainer *container
static void gimp_list_reorder (GimpContainer *container,
GimpObject *object,
gint new_index);
static void gimp_list_clear (GimpContainer *container);
static gboolean gimp_list_have (const GimpContainer *container,
const GimpObject *object);
static void gimp_list_foreach (const GimpContainer *container,
......@@ -110,6 +111,7 @@ gimp_list_class_init (GimpListClass *klass)
container_class->add = gimp_list_add;
container_class->remove = gimp_list_remove;
container_class->reorder = gimp_list_reorder;
container_class->clear = gimp_list_clear;
container_class->have = gimp_list_have;
container_class->foreach = gimp_list_foreach;
container_class->get_child_by_name = gimp_list_get_child_by_name;
......@@ -131,10 +133,7 @@ gimp_list_dispose (GObject *object)
list = GIMP_LIST (object);
while (list->list)
{
gimp_container_remove (GIMP_CONTAINER (list),
GIMP_OBJECT (list->list->data));
}
gimp_container_remove (GIMP_CONTAINER (list), list->list->data);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
......@@ -203,6 +202,17 @@ gimp_list_reorder (GimpContainer *container,
list->list = g_list_insert (list->list, object, new_index);
}
static void
gimp_list_clear (GimpContainer *container)
{
GimpList *list;
list = GIMP_LIST (container);
while (list->list)
gimp_container_remove (container, list->list->data);
}
static gboolean
gimp_list_have (const GimpContainer *container,
const GimpObject *object)
......@@ -301,9 +311,7 @@ gimp_list_reverse (GimpList *list)
if (GIMP_CONTAINER (list)->num_children > 1)
{
gimp_container_freeze (GIMP_CONTAINER (list));
list->list = g_list_reverse (list->list);
gimp_container_thaw (GIMP_CONTAINER (list));
}
}
......@@ -318,9 +326,7 @@ gimp_list_sort (GimpList *list,
if (GIMP_CONTAINER (list)->num_children > 1)
{
gimp_container_freeze (GIMP_CONTAINER (list));
list->list = g_list_sort (list->list, compare_func);
gimp_container_thaw (GIMP_CONTAINER (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