GdauiDataStore

GdauiDataStore — Bridge between a GdaDataModel and a GtkTreeModel

Stability Level

Stable, unless otherwise indicated

Functions

Properties

gpointer model Read / Write / Construct Only
gboolean prepend-null-entry Read / Write
gpointer proxy Read

Types and Values

Object Hierarchy

    GObject
    ╰── GdauiDataStore

Implemented Interfaces

GdauiDataStore implements GtkTreeModel.

Description

The GdauiDataStore object implements the GtkTreeModel interface on top of a GdaDataModel to be able to display its contents in a GtkTreeView (however you should not directly a GdauiTreeStore with a GtkTreeView but use a GdauiRauGrid or GdauiGrid instead, see explanatione below). You should probably not have to create you own GdauiDataStore, but use the ones returned by gtk_tree_view_get_model() (on a GdauiRawGrid).

The values returned by gtk_tree_model_get() are pointers to GValue which do actually contain the values (i.e. gtk_tree_model_get() does not return strings, integers, or booleans directly). The returned values are the same as returned by gda_data_model_get_value_at() or similar functions (i.e. there can be NULL values, or errors). Here is for example a correct way to use the GdauiDataStore object (assuming for example that column 0 is supposed to hold a string):

GMainContext *context;
GdauiDataStore *store;
GtkTreeIter iter;

store = ...
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) {
    GValue *value;
    gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &value, -1);
    if (value == NULL) {
        // an error occured while getting the value, see gda_data_model_get() for details
    }
    else if (G_VALUE_HOLDS (value, G_TYPE_STRING)) {
        gchar *str;
        str = g_value_get_string (value);
        ...
    }
    else if (GDA_VALUE_HOLDS_NULL (value)) {
        ...
    }
    else {
        // this should not happen if column 0 is supposed to hold a string
        g_assert_not_reached ();
    }
}

Functions

gdaui_data_store_new ()

GtkTreeModel *
gdaui_data_store_new (GdaDataModel *model);

Creates a GtkTreeModel interface with a GdaDataModel

Parameters

model

a GdaDataModel object

 

Returns

the new object.

[transfer full]

Since: 4.2


gdaui_data_store_get_proxy ()

GdaDataProxy *
gdaui_data_store_get_proxy (GdauiDataStore *store);

Parameters

store

a GdauiDataStore object

 

Returns

the internal GdaDataProxy being used by store .

[transfer none]

Since: 4.2


gdaui_data_store_get_row_from_iter ()

gint
gdaui_data_store_get_row_from_iter (GdauiDataStore *store,
                                    GtkTreeIter *iter);

Get the number of the row represented by iter

Parameters

store

a GdauiDataStore object

 

iter

a valid GtkTreeIter

 

Returns

the row number, or -1 if an error occurred

Since: 4.2


gdaui_data_store_get_iter_from_values ()

gboolean
gdaui_data_store_get_iter_from_values (GdauiDataStore *store,
                                       GtkTreeIter *iter,
                                       GSList *values,
                                       gint *cols_index);

Sets iter to the first row where all the values in values at the columns identified at cols_index match. If the row can't be identified, then the contents of iter is not modified.

NOTE: the cols_index array MUST contain a column index for each value in values

Parameters

store

a GdauiDataStore object

 

iter

an unset GtkTreeIter to set to the requested row.

[out]

values

a list of GValue values.

[element-type GValue]

cols_index

an array of gint containing the column number to match each value of values

 

Returns

TRUE if the row has been identified iter was set

Since: 4.2


gdaui_data_store_set_value ()

gboolean
gdaui_data_store_set_value (GdauiDataStore *store,
                            GtkTreeIter *iter,
                            gint col,
                            const GValue *value);

Stores a value in the store data model.

Parameters

store

a GdauiDataStore object

 

iter

the considered row

 

col

the data model column

 

value

the value to store (gets copied)

 

Returns

TRUE on success

Since: 4.2


gdaui_data_store_delete ()

void
gdaui_data_store_delete (GdauiDataStore *store,
                         GtkTreeIter *iter);

Marks the row pointed by iter to be deleted

Parameters

store

a GdauiDataStore object

 

iter

the considered row

 

Since: 4.2


gdaui_data_store_undelete ()

void
gdaui_data_store_undelete (GdauiDataStore *store,
                           GtkTreeIter *iter);

Remove the "to be deleted" mark the row pointed by iter , if it existed.

Parameters

store

a GdauiDataStore object

 

iter

the considered row

 

Since: 4.2


gdaui_data_store_append ()

gboolean
gdaui_data_store_append (GdauiDataStore *store,
                         GtkTreeIter *iter);

Appends a new row.

Parameters

store

a GdauiDataStore object

 

iter

an unset GtkTreeIter to set to the appended row

 

Returns

TRUE if no error occurred

Since: 4.2

Types and Values

GDAUI_TYPE_DATA_STORE

#define GDAUI_TYPE_DATA_STORE          (gdaui_data_store_get_type())

DATA_STORE_COL_MODEL_N_COLUMNS

#define DATA_STORE_COL_MODEL_N_COLUMNS GDAUI_DATA_STORE_COL_MODEL_N_COLUMNS

DATA_STORE_COL_MODEL_POINTER

#define DATA_STORE_COL_MODEL_POINTER GDAUI_DATA_STORE_COL_MODEL_POINTER

DATA_STORE_COL_MODEL_ROW

#define DATA_STORE_COL_MODEL_ROW GDAUI_DATA_STORE_COL_MODEL_ROW

DATA_STORE_COL_MODIFIED

#define DATA_STORE_COL_MODIFIED GDAUI_DATA_STORE_COL_MODIFIED

DATA_STORE_COL_TO_DELETE

#define DATA_STORE_COL_TO_DELETE GDAUI_DATA_STORE_COL_TO_DELETE

struct GdauiDataStoreClass

struct GdauiDataStoreClass {
	GObjectClass  parent_class;
	gpointer      padding[12];
};

GdauiDataStore

typedef struct _GdauiDataStore GdauiDataStore;

Property Details

The “model” property

  “model”                    gpointer

Owner: GdauiDataStore

Flags: Read / Write / Construct Only


The “prepend-null-entry” property

  “prepend-null-entry”       gboolean

Owner: GdauiDataStore

Flags: Read / Write

Default value: FALSE


The “proxy” property

  “proxy”                    gpointer

Owner: GdauiDataStore

Flags: Read