GwyInventoryStore

GwyInventoryStore — GtkTreeModel wrapper around GwyInventory

Synopsis




                    GwyInventoryStore;
                    GwyInventoryStoreClass;
GwyInventoryStore*  gwy_inventory_store_new             (GwyInventory *inventory);
GwyInventory*       gwy_inventory_store_get_inventory   (GwyInventoryStore *store);
gint                gwy_inventory_store_get_column_by_name
                                                        (GwyInventoryStore *store,
                                                         const gchar *name);
gboolean            gwy_inventory_store_get_iter        (GwyInventoryStore *store,
                                                         const gchar *name,
                                                         GtkTreeIter *iter);
gboolean            gwy_inventory_store_iter_is_valid   (GwyInventoryStore *store,
                                                         GtkTreeIter *iter);

Object Hierarchy


  GObject
   +----GwyInventoryStore

Implemented Interfaces

GwyInventoryStore implements GtkTreeModel.

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().

Details

GwyInventoryStore

typedef struct _GwyInventoryStore GwyInventoryStore;


GwyInventoryStoreClass

typedef struct {
    GObjectClass parent_class;

    void (*reserved1)(void);
} GwyInventoryStoreClass;


gwy_inventory_store_new ()

GwyInventoryStore*  gwy_inventory_store_new             (GwyInventory *inventory);

Creates a new GtkTreeModel wrapper around a GwyInventory.

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.

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).

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.

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.

Warning

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

store : An inventory store.
iter : A GtkTreeIter.
Returns : TRUE if the iter is valid, FALSE if the iter is invalid.

See Also

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