## GwyInventoryStore

GwyInventoryStore — GtkTreeModel wrapper around GwyInventory

## Functions

GwyInventoryStore * | gwy_inventory_store_new ()
GwyInventory * | gwy_inventory_store_get_inventory ()
gint | gwy_inventory_store_get_column_by_name ()
gboolean | gwy_inventory_store_get_iter ()
gboolean | gwy_inventory_store_iter_is_valid ()

## Types and Values

struct | GwyInventoryStore
struct | GwyInventoryStoreClass

## Object Hierarchy

        GObject
        ╰── GwyInventoryStore

## Implemented Interfaces

GwyInventoryStore implements GtkTreeModel.

## Includes

    #include <libgwydgets/gwydgets.h>

## Description

GwyInventoryStore is a simple adaptor class that wraps GwyInventory in GtkTreeModel interface. It is list-only and has persistent iterators. It offers no methods to manipulate items, this should be done on the underlying inventory.

GwyInventoryStore maps inventory item traits to virtual GtkTreeModel columns. Zeroth column is always of type `G_TYPE_POINTER` and contains item itself. It exists even if item don't export any traits. Columns from 1 onward are formed by item traits. You can obtain column id of a named item trait with `gwy_inventory_store_get_column_by_name()`.

## Functions

### gwy_inventory_store_new ()

    GwyInventoryStore *
    gwy_inventory_store_new (GwyInventory *inventory);

Creates a new GtkTreeModel wrapper around a GwyInventory.

#### Parameters

inventory | An inventory. |

#### Returns

The newly created inventory store.

### gwy_inventory_store_get_inventory ()

    GwyInventory *
    gwy_inventory_store_get_inventory (GwyInventoryStore *store);

Gets the inventory a inventory store wraps.

#### Parameters

store | An inventory store. |

#### Returns

The underlying inventory (its reference count is not increased).

### gwy_inventory_store_get_column_by_name ()

    gint
    gwy_inventory_store_get_column_by_name
                                   (GwyInventoryStore *store,
                                    const gchar *name);

Gets tree model column corresponding to a trait name.

The underlying inventory must support trait names, except for `name` `"item"` which always works (and always maps to 0).

#### Parameters

store | An inventory store. |
name | Trait (column) name. |

#### Returns

The underlying inventory (its reference count is not increased).

### gwy_inventory_store_get_iter ()

    gboolean
    gwy_inventory_store_get_iter (GwyInventoryStore *store,
                                  const gchar *name,
                                  GtkTreeIter *iter);

Initializes a tree iterator to row corresponding to a inventory item.

#### Parameters

store | An inventory store. |
name | Item name. |
iter | Tree iterator to set to point to item named `name` . |

#### Returns

`TRUE` if `iter` is valid, that is the item exists, `FALSE` if `iter` was not set.

### gwy_inventory_store_iter_is_valid ()

    gboolean
    gwy_inventory_store_iter_is_valid (GwyInventoryStore *store,
                                       GtkTreeIter *iter);

Checks if the given iter is a valid iter for this inventory store.

This function is slow. Only use it for debugging and/or testing purposes.

#### Parameters

store | An inventory store. |
iter | A GtkTreeIter. |

#### Returns

`TRUE` if the iter is valid, `FALSE` if the iter is invalid.

## Types and Values

### struct GwyInventoryStore

    struct GwyInventoryStore;

### struct GwyInventoryStoreClass

    struct GwyInventoryStoreClass {
        GObjectClass parent_class;

        void (*reserved1)(void);
    };

## See Also

GwyInventory -- the actual data container, GtkListStore, GtkTreeStore -- Gtk+ tree model implementations