gui: New type PsppireEmptyListStore.
[pspp] / src / ui / gui / psppire-empty-list-store.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2011, 2012 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef PSPPIRE_EMPTY_LIST_STORE_H
18 #define PSPPIRE_EMPTY_LIST_STORE_H 1
19
20 /* PsppireEmptyListStore is an GtkTreeModel implementation that has a
21    client-specified number of rows and zero columns.  It is a useful model for
22    GtkTreeView or PsppSheetView when the client can easily synthesize cell data
23    using a callback set with gtk_tree_view_column_set_cell_data_func().  In
24    that situation, GtkListStore can be wasteful (because it uses a lot of
25    memory to store what does not need to be stored) and situation-specific
26    custom models require additional boilerplate. */
27
28 #include <glib-object.h>
29 #include <gtk/gtk.h>
30
31 G_BEGIN_DECLS
32
33 #define PSPPIRE_TYPE_EMPTY_LIST_STORE             (psppire_empty_list_store_get_type())
34 #define PSPPIRE_EMPTY_LIST_STORE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj),PSPPIRE_TYPE_EMPTY_LIST_STORE,PsppireEmptyListStore))
35 #define PSPPIRE_EMPTY_LIST_STORE_CLASS(class)     (G_TYPE_CHECK_CLASS_CAST ((class),PSPPIRE_TYPE_EMPTY_LIST_STORE,PsppireEmptyListStoreClass))
36 #define PSPPIRE_IS_EMPTY_LIST_STORE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj),PSPPIRE_TYPE_EMPTY_LIST_STORE))
37 #define PSPPIRE_IS_EMPTY_LIST_STORE_CLASS(class)  (G_TYPE_CHECK_CLASS_TYPE ((class),PSPPIRE_TYPE_EMPTY_LIST_STORE))
38 #define PSPPIRE_EMPTY_LIST_STORE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),PSPPIRE_TYPE_EMPTY_LIST_STORE,PsppireEmptyListStoreClass))
39
40 typedef struct _PsppireEmptyListStore      PsppireEmptyListStore;
41 typedef struct _PsppireEmptyListStoreClass PsppireEmptyListStoreClass;
42
43 struct _PsppireEmptyListStore {
44   GObject parent;
45   gint n_rows;
46 };
47
48 struct _PsppireEmptyListStoreClass {
49   GObjectClass parent_class;
50 };
51
52 GType psppire_empty_list_store_get_type (void) G_GNUC_CONST;
53 PsppireEmptyListStore* psppire_empty_list_store_new (gint n_rows);
54
55 gint psppire_empty_list_store_get_n_rows (const PsppireEmptyListStore *);
56 void psppire_empty_list_store_set_n_rows (PsppireEmptyListStore *,
57                                           gint n_rows);
58
59 void psppire_empty_list_store_row_inserted (PsppireEmptyListStore *,
60                                             gint row);
61 void psppire_empty_list_store_row_deleted (PsppireEmptyListStore *,
62                                            gint row);
63
64 gint empty_list_store_iter_to_row (const GtkTreeIter *);
65
66 G_END_DECLS
67
68 #endif /* PSPPIRE_EMPTY_LIST_STORE_H */