Update Spanish translation
[gnumeric.git] / src / gnm-cell-combo.c
blob18a590b1b8de209f644b6109bfb2a45a18b3aeb2
1 /*
2 * gnm-cell-combo.c: Base class the models of in cell combos (e.g. validation and sheetslicer)
4 * Copyright (C) Jody Goldberg <jody@gnome.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <https://www.gnu.org/licenses/>.
20 #include <gnumeric-config.h>
21 #include <gnumeric.h>
22 #include <gnm-cell-combo.h>
23 #include <sheet-view.h>
25 #include <gsf/gsf-impl-utils.h>
27 enum {
28 PROP_0,
29 PROP_SV,
32 static GObjectClass *gcc_parent_klass;
34 static void
35 gnm_cell_combo_set_sv (GnmCellCombo *ccombo, SheetView *sv)
37 if (ccombo->sv == sv)
38 return;
40 if (NULL != ccombo->sv)
41 gnm_sheet_view_weak_unref (&ccombo->sv);
43 ccombo->sv = sv;
44 if (sv)
45 gnm_sheet_view_weak_ref (sv, &ccombo->sv);
48 static void
49 gnm_cell_combo_finalize (GObject *object)
51 GnmCellCombo *ccombo = GNM_CELL_COMBO (object);
52 gnm_cell_combo_set_sv (ccombo, NULL);
53 gcc_parent_klass->finalize (object);
56 static void
57 gnm_cell_combo_dispose (GObject *object)
59 GnmCellCombo *ccombo = GNM_CELL_COMBO (object);
60 gnm_cell_combo_set_sv (ccombo, NULL);
61 gcc_parent_klass->dispose (object);
64 static void
65 gnm_cell_combo_set_property (GObject *obj, guint property_id,
66 GValue const *value, GParamSpec *pspec)
68 GnmCellCombo *ccombo = (GnmCellCombo *)obj;
70 switch (property_id) {
71 case PROP_SV: {
72 SheetView *sv = g_value_get_object (value);
73 gnm_cell_combo_set_sv (ccombo, sv);
74 break;
77 default:
78 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
82 static void
83 gnm_cell_combo_get_property (GObject *obj, guint property_id,
84 GValue *value, GParamSpec *pspec)
86 GnmCellCombo const *ccombo = (GnmCellCombo const *)obj;
88 switch (property_id) {
89 case PROP_SV:
90 g_value_set_object (value, ccombo->sv);
91 break;
92 default:
93 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
97 static void
98 gnm_cell_combo_init (SheetObject *so)
100 /* keep the arrows from wandering with their cells */
101 so->flags &= ~SHEET_OBJECT_MOVE_WITH_CELLS;
104 static void
105 gnm_cell_combo_class_init (GObjectClass *gobject_class)
107 SheetObjectClass *so_class = GNM_SO_CLASS (gobject_class);
109 gcc_parent_klass = g_type_class_peek_parent (gobject_class);
111 gobject_class->dispose = gnm_cell_combo_dispose;
112 gobject_class->finalize = gnm_cell_combo_finalize;
113 gobject_class->get_property = gnm_cell_combo_get_property;
114 gobject_class->set_property = gnm_cell_combo_set_property;
115 so_class->write_xml_sax = NULL;
116 so_class->prep_sax_parser = NULL;
117 so_class->copy = NULL;
119 g_object_class_install_property (gobject_class, PROP_SV,
120 g_param_spec_object ("sheet-view", NULL, NULL,
121 GNM_SHEET_VIEW_TYPE, GSF_PARAM_STATIC | G_PARAM_READWRITE));
124 GSF_CLASS_ABSTRACT (GnmCellCombo, gnm_cell_combo,
125 gnm_cell_combo_class_init, gnm_cell_combo_init,
126 GNM_SO_TYPE)