Change view and scroll to position on header double click
[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 "efficient-sheet/jmd-axis-model.h"
25 #include "efficient-sheet/jmd-datum.h"
26
27
28 static guint
29 gni (GListModel *list)
30 {
31   return 11;
32 }
33
34 static GType
35 git (GListModel *list)
36 {
37   return JMD_TYPE_DATUM;
38 }
39
40 static gpointer
41 gi (GListModel *list, guint position)
42 {
43   JmdDatum *gd = JMD_DATUM (g_object_new (JMD_TYPE_DATUM, NULL));
44
45   switch (position)
46     {
47     case 0:
48       gd->text = g_strdup ("Name");
49       break;
50     case 1:
51       gd->text = g_strdup ("Type");
52       break;
53     case 2:
54       gd->text = g_strdup ("Width");
55       break;
56     case 3:
57       gd->text = g_strdup ("Decimal");
58       break;
59     case 4:
60       gd->text = g_strdup ("Label");
61       break;
62     case 5:
63       gd->text = g_strdup ("Value Labels");
64       break;
65     case 6:
66       gd->text = g_strdup ("Missing Values");
67       break;
68     case 7:
69       gd->text = g_strdup ("Columns");
70       break;
71     case 8:
72       gd->text = g_strdup ("Align");
73       break;
74     case 9:
75       gd->text = g_strdup ("Measure");
76       break;
77     case 10:
78       gd->text = g_strdup ("Role");
79       break;
80     default:
81       //      g_assert_not_reached ();
82       g_print ("Bug: Request for item %d\n", position);
83       break;
84     }
85
86   return gd;
87 }
88
89
90 static void
91 psppire_init_iface (GListModelInterface *iface)
92 {
93   iface->get_n_items = gni;
94   iface->get_item = gi;
95   iface->get_item_type = git;
96 }
97
98
99 G_DEFINE_TYPE_WITH_CODE (PsppireVarSheetHeader, psppire_var_sheet_header,
100                          G_TYPE_OBJECT,
101                          G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, psppire_init_iface));
102
103 static void
104 psppire_var_sheet_header_init (PsppireVarSheetHeader *d)
105 {
106 }
107
108
109
110 static void
111 psppire_var_sheet_header_class_init (PsppireVarSheetHeaderClass *dc)
112 {
113 }
114