GUI: Move .ui files from goffice resources to glib resources
[gnumeric.git] / src / gnm-cell-combo.c
blob07621fb80e8e2ae1f5ed8875ba7c1a1d72a25efe
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * gnm-cell-combo.c: Base class the models of in cell combos (e.g. validation and sheetslicer)
5 * Copyright (C) Jody Goldberg <jody@gnome.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
21 #include <gnumeric-config.h>
22 #include "gnumeric.h"
23 #include "gnm-cell-combo.h"
24 #include "sheet-view.h"
26 #include <gsf/gsf-impl-utils.h>
28 enum {
29 PROP_0,
30 PROP_SV,
33 static GObjectClass *gcc_parent_klass;
35 static void
36 gnm_cell_combo_set_sv (GnmCellCombo *ccombo, SheetView *sv)
38 if (ccombo->sv == sv)
39 return;
41 if (NULL != ccombo->sv)
42 gnm_sheet_view_weak_unref (&ccombo->sv);
44 ccombo->sv = sv;
45 if (sv)
46 gnm_sheet_view_weak_ref (sv, &ccombo->sv);
49 static void
50 gnm_cell_combo_finalize (GObject *object)
52 GnmCellCombo *ccombo = GNM_CELL_COMBO (object);
53 gnm_cell_combo_set_sv (ccombo, NULL);
54 gcc_parent_klass->finalize (object);
57 static void
58 gnm_cell_combo_dispose (GObject *object)
60 GnmCellCombo *ccombo = GNM_CELL_COMBO (object);
61 gnm_cell_combo_set_sv (ccombo, NULL);
62 gcc_parent_klass->dispose (object);
65 static void
66 gnm_cell_combo_set_property (GObject *obj, guint property_id,
67 GValue const *value, GParamSpec *pspec)
69 GnmCellCombo *ccombo = (GnmCellCombo *)obj;
71 switch (property_id) {
72 case PROP_SV: {
73 SheetView *sv = g_value_get_object (value);
74 gnm_cell_combo_set_sv (ccombo, sv);
75 break;
78 default:
79 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
83 static void
84 gnm_cell_combo_get_property (GObject *obj, guint property_id,
85 GValue *value, GParamSpec *pspec)
87 GnmCellCombo const *ccombo = (GnmCellCombo const *)obj;
89 switch (property_id) {
90 case PROP_SV:
91 g_value_set_object (value, ccombo->sv);
92 break;
93 default:
94 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
98 static void
99 gnm_cell_combo_init (SheetObject *so)
101 /* keep the arrows from wandering with their cells */
102 so->flags &= ~SHEET_OBJECT_MOVE_WITH_CELLS;
105 static void
106 gnm_cell_combo_class_init (GObjectClass *gobject_class)
108 SheetObjectClass *so_class = GNM_SO_CLASS (gobject_class);
110 gcc_parent_klass = g_type_class_peek_parent (gobject_class);
112 gobject_class->dispose = gnm_cell_combo_dispose;
113 gobject_class->finalize = gnm_cell_combo_finalize;
114 gobject_class->get_property = gnm_cell_combo_get_property;
115 gobject_class->set_property = gnm_cell_combo_set_property;
116 so_class->write_xml_sax = NULL;
117 so_class->prep_sax_parser = NULL;
118 so_class->copy = NULL;
120 g_object_class_install_property (gobject_class, PROP_SV,
121 g_param_spec_object ("sheet-view", NULL, NULL,
122 GNM_SHEET_VIEW_TYPE, GSF_PARAM_STATIC | G_PARAM_READWRITE));
125 GSF_CLASS_ABSTRACT (GnmCellCombo, gnm_cell_combo,
126 gnm_cell_combo_class_init, gnm_cell_combo_init,
127 GNM_SO_TYPE)