Cope with changes to ssw_axis_model (upstream)
[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 <gettext.h>
25
26 #define _(msgid) gettext (msgid)
27 #define N_(msgid) msgid
28
29 enum  {CHANGED,
30        n_SIGNALS};
31
32 static guint signals [n_SIGNALS];
33
34 static guint
35 gni (GListModel *list)
36 {
37   return 11;
38 }
39
40 static GType
41 git (GListModel *list)
42 {
43   return GTK_TYPE_BUTTON;
44 }
45
46
47 static gpointer
48 gi (GListModel *list, guint position)
49 {
50   GtkWidget *button = gtk_button_new ();
51   gchar *text = NULL;
52
53   switch (position)
54     {
55     case 0:
56       text = N_("Name");
57       break;
58     case 1:
59       text = N_("Type");
60       break;
61     case 2:
62       text = N_("Width");
63       break;
64     case 3:
65       text = N_("Decimal");
66       break;
67     case 4:
68       text = N_("Label");
69       break;
70     case 5:
71       text = N_("Value Labels");
72       break;
73     case 6:
74       text = N_("Missing Values");
75       break;
76     case 7:
77       text = N_("Columns");
78       break;
79     case 8:
80       text = N_("Align");
81       break;
82     case 9:
83       text = N_("Measure");
84       break;
85     case 10:
86       text = N_("Role");
87       break;
88     default:
89       break;
90     }
91
92   if (text)
93     gtk_button_set_label (GTK_BUTTON (button), gettext (text));
94   
95   return button;
96 }
97
98
99 static void
100 psppire_init_iface (GListModelInterface *iface)
101 {
102   iface->get_n_items = gni;
103   iface->get_item = gi;
104   iface->get_item_type = git;
105 }
106
107
108 G_DEFINE_TYPE_WITH_CODE (PsppireVarSheetHeader, psppire_var_sheet_header,
109                          G_TYPE_OBJECT,
110                          G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, psppire_init_iface));
111
112 static void
113 psppire_var_sheet_header_init (PsppireVarSheetHeader *d)
114 {
115 }
116
117
118
119 static void
120 psppire_var_sheet_header_class_init (PsppireVarSheetHeaderClass *dc)
121 {
122   GObjectClass *object_class = G_OBJECT_CLASS (dc);
123
124   /* This signal is never emitted.  It is just to satisfy the interface. */
125   signals [CHANGED] =
126     g_signal_new ("changed",
127                   G_TYPE_FROM_CLASS (object_class),
128                   G_SIGNAL_RUN_FIRST,
129                   0,
130                   NULL, NULL,
131                   g_cclosure_marshal_VOID__VOID,
132                   G_TYPE_NONE,
133                   0);
134 }
135