KatzeArray

KatzeArray — A type aware item container

Synopsis

#include <katze/katze.h>

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

Description

KatzeArray is a type aware container for items.

Details

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)

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);
};

kalistglobal

extern GList* kalistglobal;

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. [type GObject][transfer none]

katze_array_clear ()

void                katze_array_clear                   (KatzeArray *array);

Deletes all items currently contained in array.

array :

a KatzeArray

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 and return NULL if the KatzeArray's element type is not based on KatzeItem.

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. [type GObject][transfer none]

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 and return NULL if the KatzeArray's element type is not based on KatzeItem.

array :

a KatzeArray

uri :

an URI

Returns :

an item, or NULL. [type GObject][transfer none]

Since 0.2.0


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. [type GObject]

Returns :

the index of the item, or -1 if the item is not present in the array

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. [element-type GObject][transfer container]

Since 0.2.5


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 KatzeArray

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. [type GObject][transfer none]

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.

array :

a KatzeArray

is_a_type :

type to compare with

Returns :

TRUE if array is compatible with is_a_type

katze_array_is_empty ()

gboolean            katze_array_is_empty                (KatzeArray *array);

Determines whether array is empty.

array :

a KatzeArray

Returns :

TRUE if the array is empty

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. [type GObject]

position :

the new position of the item

Since 0.1.6


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. [transfer full]

katze_array_peek_items ()

GList *             katze_array_peek_items              (KatzeArray *array);

Peeks at the KatzeArray's internal list of items.

array :

a KatzeArray

Returns :

the KatzeArray's internal GList of items. [element-type GObject][transfer none]

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. [type GObject]

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