KatzeArray

KatzeArray — A type aware item container

Synopsis

#include <katze/katze.h>

struct              KatzeArray;
struct              KatzeArrayClass;
KatzeArray *        katze_array_new                     (GType type);
gboolean            katze_array_is_a                    (KatzeArray *array,
                                                         GType is_a_type);
void                katze_array_add_item                (KatzeArray *array,
                                                         gpointer item);
void                katze_array_remove_item             (KatzeArray *array,
                                                         gpointer item);
gpointer            katze_array_get_nth_item            (KatzeArray *array,
                                                         guint n);
gboolean            katze_array_is_empty                (KatzeArray *array);
gint                katze_array_get_item_index          (KatzeArray *array,
                                                         gpointer item);
gpointer            katze_array_find_token              (KatzeArray *array,
                                                         const gchar *token);
gpointer            katze_array_find_uri                (KatzeArray *array,
                                                         const gchar *uri);
guint               katze_array_get_length              (KatzeArray *array);
void                katze_array_move_item               (KatzeArray *array,
                                                         gpointer item,
                                                         gint position);
GList *             katze_array_get_items               (KatzeArray *array);
GList *             katze_array_peek_items              (KatzeArray *array);
extern GList*       kalistglobal;
#define             KATZE_ARRAY_FOREACH_ITEM            (kaitem,
                                                         kaarray)
#define             KATZE_ARRAY_FOREACH_ITEM_L          (kaitem,
                                                         kaarray,
                                                         kalist)
void                katze_array_clear                   (KatzeArray *array);
void                katze_array_update                  (KatzeArray *array);

Description

KatzeArray is a type aware container for items.

Details

struct KatzeArray

struct KatzeArray {
    KatzeItem parent_instance;

    KatzeArrayPrivate* priv;
};

struct KatzeArrayClass

struct KatzeArrayClass {
    KatzeItemClass parent_class;

    /* Signals */
    void
    (*add_item)               (KatzeArray* array,
                               gpointer    item);
    void
    (*remove_item)            (KatzeArray* array,
                               gpointer    item);
    void
    (*move_item)              (KatzeArray* array,
                               gpointer    item,
                               gint        index);
    void
    (*clear)                  (KatzeArray* array);

    void
    (*update)                 (KatzeArray* array);
};

katze_array_new ()

KatzeArray *        katze_array_new                     (GType type);

Creates a new KatzeArray for type items.

The array will keep a reference on each object until it is removed from the array.

type :

the expected item type

Returns :

a new KatzeArray

katze_array_is_a ()

gboolean            katze_array_is_a                    (KatzeArray *array,
                                                         GType is_a_type);

Checks whether the array is compatible with items of the specified type.

Retur value: TRUE if array is compatible with is_a_type

array :

a KatzeArray

is_a_type :

type to compare with

katze_array_add_item ()

void                katze_array_add_item                (KatzeArray *array,
                                                         gpointer item);

Adds an item to the array.

If item is a KatzeItem its parent is set accordingly.

array :

a KatzeArray

item :

an item

katze_array_remove_item ()

void                katze_array_remove_item             (KatzeArray *array,
                                                         gpointer item);

Removes an item from the array.

If item is a KatzeItem its parent is unset accordingly.

array :

a KatzeArray

item :

an item

katze_array_get_nth_item ()

gpointer            katze_array_get_nth_item            (KatzeArray *array,
                                                         guint n);

Retrieves the item in array at the position n.

array :

a KatzeArray

n :

an index in the array

Returns :

an item, or NULL

katze_array_is_empty ()

gboolean            katze_array_is_empty                (KatzeArray *array);

Determines whether array is empty.

array :

a KatzeArray

Returns :

an item, or NULL

katze_array_get_item_index ()

gint                katze_array_get_item_index          (KatzeArray *array,
                                                         gpointer item);

Retrieves the index of the item in array.

array :

a KatzeArray

item :

an item in the array

Returns :

an item, or -1

katze_array_find_token ()

gpointer            katze_array_find_token              (KatzeArray *array,
                                                         const gchar *token);

Looks up an item in the array which has the specified token.

This function will fail if the type of the list is not based on KatzeItem children.

Note that token is by definition unique to one item.

Since 0.4.4 token can be a "token keywords" string.

array :

a KatzeArray

token :

a token string, or "token keywords" string

Returns :

an item, or NULL

katze_array_find_uri ()

gpointer            katze_array_find_uri                (KatzeArray *array,
                                                         const gchar *uri);

Looks up an item in the array which has the specified URI.

This function will fail if the type of the list is not based on KatzeItem children.

array :

a KatzeArray

uri :

an URI

Returns :

an item, or NULL

Since 0.2.0


katze_array_get_length ()

guint               katze_array_get_length              (KatzeArray *array);

Retrieves the number of items in array.

array :

a KatzeArray

Returns :

the length of the list

katze_array_move_item ()

void                katze_array_move_item               (KatzeArray *array,
                                                         gpointer item,
                                                         gint position);

Moves item to the position position.

array :

a KatzeArray

item :

the item being moved

position :

the new position of the item

Since 0.1.6


katze_array_get_items ()

GList *             katze_array_get_items               (KatzeArray *array);

Retrieves the items as a list.

array :

a KatzeArray

Returns :

a newly allocated GList of items

Since 0.2.5


katze_array_peek_items ()

GList *             katze_array_peek_items              (KatzeArray *array);

kalistglobal

extern GList* kalistglobal;

KATZE_ARRAY_FOREACH_ITEM()

#define             KATZE_ARRAY_FOREACH_ITEM(kaitem, kaarray)

KATZE_ARRAY_FOREACH_ITEM_L()

#define             KATZE_ARRAY_FOREACH_ITEM_L(kaitem, kaarray, kalist)

katze_array_clear ()

void                katze_array_clear                   (KatzeArray *array);

Deletes all items currently contained in array.

array :

a KatzeArray

katze_array_update ()

void                katze_array_update                  (KatzeArray *array);

Indicates that the array changed and any display widgets should be updated.

array :

a KatzeArray

Since 0.3.0

See Also

KatzeList