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>
22 #include <gnm-cell-combo.h>
23 #include <sheet-view.h>
25 #include <gsf/gsf-impl-utils.h>
32 static GObjectClass
*gcc_parent_klass
;
35 gnm_cell_combo_set_sv (GnmCellCombo
*ccombo
, SheetView
*sv
)
40 if (NULL
!= ccombo
->sv
)
41 gnm_sheet_view_weak_unref (&ccombo
->sv
);
45 gnm_sheet_view_weak_ref (sv
, &ccombo
->sv
);
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
);
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
);
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
) {
72 SheetView
*sv
= g_value_get_object (value
);
73 gnm_cell_combo_set_sv (ccombo
, sv
);
78 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj
, property_id
, pspec
);
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
) {
90 g_value_set_object (value
, ccombo
->sv
);
93 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj
, property_id
, pspec
);
98 gnm_cell_combo_init (SheetObject
*so
)
100 /* keep the arrows from wandering with their cells */
101 so
->flags
&= ~SHEET_OBJECT_MOVE_WITH_CELLS
;
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
,