1 /*
2  * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  * Copyright (C) 2010 Murray Cumming <murrayc@murrayc.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301, USA.
19  */
20 
21 #ifndef __GDAUI_DATA_STORE__
22 #define __GDAUI_DATA_STORE__
23 
24 #include <gtk/gtk.h>
25 #include <libgda/gda-data-model.h>
26 #include <libgda/gda-data-proxy.h>
27 
28 G_BEGIN_DECLS
29 
30 #define GDAUI_TYPE_DATA_STORE          (gdaui_data_store_get_type())
31 #define GDAUI_DATA_STORE(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, gdaui_data_store_get_type(), GdauiDataStore)
32 #define GDAUI_DATA_STORE_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, gdaui_data_store_get_type (), GdauiDataStoreClass)
33 #define GDAUI_IS_DATA_STORE(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, gdaui_data_store_get_type ())
34 
35 typedef struct _GdauiDataStore GdauiDataStore;
36 typedef struct _GdauiDataStoreClass GdauiDataStoreClass;
37 typedef struct _GdauiDataStorePriv GdauiDataStorePriv;
38 
39 enum {
40 	GDAUI_DATA_STORE_COL_MODEL_N_COLUMNS = -2, /* number of columns in the GdaDataModel */
41 	GDAUI_DATA_STORE_COL_MODEL_POINTER = -3, /* pointer to the GdaDataModel */
42 	GDAUI_DATA_STORE_COL_MODEL_ROW = -4, /* row number in the GdaDataModel, or -1 for new rows */
43 	GDAUI_DATA_STORE_COL_MODIFIED = -5, /* TRUE if row has been modified */
44 	GDAUI_DATA_STORE_COL_TO_DELETE = -6 /* TRUE if row is marked to be deleted */
45 };
46 
47 #ifndef GDA_DISABLE_DEPRECATED
48 #define DATA_STORE_COL_MODEL_N_COLUMNS GDAUI_DATA_STORE_COL_MODEL_N_COLUMNS
49 #define DATA_STORE_COL_MODEL_POINTER GDAUI_DATA_STORE_COL_MODEL_POINTER
50 #define DATA_STORE_COL_MODEL_ROW GDAUI_DATA_STORE_COL_MODEL_ROW
51 #define DATA_STORE_COL_MODIFIED GDAUI_DATA_STORE_COL_MODIFIED
52 #define DATA_STORE_COL_TO_DELETE GDAUI_DATA_STORE_COL_TO_DELETE
53 #endif
54 
55 /* struct for the object's data */
56 struct _GdauiDataStore
57 {
58 	GObject                object;
59 
60 	GdauiDataStorePriv  *priv;
61 };
62 
63 /* struct for the object's class */
64 struct _GdauiDataStoreClass
65 {
66 	GObjectClass           parent_class;
67 };
68 
69 /**
70  * SECTION:gdaui-data-store
71  * @short_description: Bridge between a #GdaDataModel and a #GtkTreeModel
72  * @title: GdauiDataStore
73  * @stability: Stable
74  * @Image:
75  * @see_also:
76  *
77  * The #GdauiDataStore object implements the #GtkTreeModel interface
78  * on top of a #GdaDataModel to be able to display its contents
79  * in a #GtkTreeView.
80  */
81 
82 GType           gdaui_data_store_get_type             (void) G_GNUC_CONST;
83 GtkTreeModel   *gdaui_data_store_new                  (GdaDataModel *model);
84 
85 GdaDataProxy   *gdaui_data_store_get_proxy            (GdauiDataStore *store);
86 gint            gdaui_data_store_get_row_from_iter    (GdauiDataStore *store, GtkTreeIter *iter);
87 gboolean        gdaui_data_store_get_iter_from_values (GdauiDataStore *store, GtkTreeIter *iter,
88 						       GSList *values, gint *cols_index);
89 
90 gboolean        gdaui_data_store_set_value            (GdauiDataStore *store, GtkTreeIter *iter,
91 						       gint col, const GValue *value);
92 void            gdaui_data_store_delete               (GdauiDataStore *store, GtkTreeIter *iter);
93 void            gdaui_data_store_undelete             (GdauiDataStore *store, GtkTreeIter *iter);
94 gboolean        gdaui_data_store_append               (GdauiDataStore *store, GtkTreeIter *iter);
95 
96 G_END_DECLS
97 
98 #endif
99