e26fa95794ec1e5fde74a72180584676d092627d
[pspp] / src / ui / gui / psppire-var-sheet-header.c
1 /*
2     A candidate replacement for Pspp's sheet
3     Copyright (C) 2016  John Darrington
4
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     This program 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
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <config.h>
20 #include <gtk/gtk.h>
21
22 #include "psppire-var-sheet-header.h"
23
24 #include <ssw-axis-model.h>
25 #include <ssw-datum.h>
26
27 enum  {CHANGED,
28        n_SIGNALS};
29
30 static guint signals [n_SIGNALS];
31
32 static guint
33 gni (GListModel *list)
34 {
35   return 11;
36 }
37
38 static GType
39 git (GListModel *list)
40 {
41   return SSW_TYPE_DATUM;
42 }
43
44 static gpointer
45 gi (GListModel *list, guint position)
46 {
47   SswDatum *gd = SSW_DATUM (g_object_new (SSW_TYPE_DATUM, NULL));
48
49   switch (position)
50     {
51     case 0:
52       gd->text = g_strdup ("Name");
53       break;
54     case 1:
55       gd->text = g_strdup ("Type");
56       break;
57     case 2:
58       gd->text = g_strdup ("Width");
59       break;
60     case 3:
61       gd->text = g_strdup ("Decimal");
62       break;
63     case 4:
64       gd->text = g_strdup ("Label");
65       break;
66     case 5:
67       gd->text = g_strdup ("Value Labels");
68       break;
69     case 6:
70       gd->text = g_strdup ("Missing Values");
71       break;
72     case 7:
73       gd->text = g_strdup ("Columns");
74       break;
75     case 8:
76       gd->text = g_strdup ("Align");
77       break;
78     case 9:
79       gd->text = g_strdup ("Measure");
80       break;
81     case 10:
82       gd->text = g_strdup ("Role");
83       break;
84     default:
85       //      g_assert_not_reached ();
86       g_print ("Bug: Request for item %d\n", position);
87       break;
88     }
89
90   return gd;
91 }
92
93
94 static void
95 psppire_init_iface (GListModelInterface *iface)
96 {
97   iface->get_n_items = gni;
98   iface->get_item = gi;
99   iface->get_item_type = git;
100 }
101
102
103 G_DEFINE_TYPE_WITH_CODE (PsppireVarSheetHeader, psppire_var_sheet_header,
104                          G_TYPE_OBJECT,
105                          G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, psppire_init_iface));
106
107 static void
108 psppire_var_sheet_header_init (PsppireVarSheetHeader *d)
109 {
110 }
111
112
113
114 static void
115 psppire_var_sheet_header_class_init (PsppireVarSheetHeaderClass *dc)
116 {
117   GObjectClass *object_class = G_OBJECT_CLASS (dc);
118
119   /* This signal is never emitted.  It is just to satisfy the interface. */
120   signals [CHANGED] =
121     g_signal_new ("changed",
122                   G_TYPE_FROM_CLASS (object_class),
123                   G_SIGNAL_RUN_FIRST,
124                   0,
125                   NULL, NULL,
126                   g_cclosure_marshal_VOID__VOID,
127                   G_TYPE_NONE,
128                   0);
129 }
130