1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
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>
23 #include "gnm-cell-combo.h"
24 #include "sheet-view.h"
26 #include <gsf/gsf-impl-utils.h>
33 static GObjectClass
*gcc_parent_klass
;
36 gnm_cell_combo_set_sv (GnmCellCombo
*ccombo
, SheetView
*sv
)
41 if (NULL
!= ccombo
->sv
)
42 gnm_sheet_view_weak_unref (&ccombo
->sv
);
46 gnm_sheet_view_weak_ref (sv
, &ccombo
->sv
);
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
);
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
);
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
) {
73 SheetView
*sv
= g_value_get_object (value
);
74 gnm_cell_combo_set_sv (ccombo
, sv
);
79 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj
, property_id
, pspec
);
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
) {
91 g_value_set_object (value
, ccombo
->sv
);
94 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj
, property_id
, pspec
);
99 gnm_cell_combo_init (SheetObject
*so
)
101 /* keep the arrows from wandering with their cells */
102 so
->flags
&= ~SHEET_OBJECT_MOVE_WITH_CELLS
;
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
,