I have this code.
file 1:
/* finance-list-box.c
*
* Copyright 2020 Danilo Fernandes Galete <galetedanilo@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "finance-list-box.h"
struct _FinanceListBox
{
GtkListBox parent_instance;
/* The Properties */
gpointer pane;
};
G_DEFINE_TYPE (FinanceListBox, finance_list_box, GTK_TYPE_LIST_BOX)
enum {
PROP_0,
PROP_PANE,
N_PROPS
};
static GParamSpec *properties [N_PROPS] = { NULL, };
FinanceListBox *
finance_list_box_new ()
{
return g_object_new (FINANCE_TYPE_LIST_BOX, NULL);
}
static void
finance_list_box_finalize (GObject *object)
{
FinanceListBox *self = (FinanceListBox *)object;
G_OBJECT_CLASS (finance_list_box_parent_class)->finalize (object);
}
static void
finance_list_box_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
FinanceListBox *self = FINANCE_LIST_BOX (object);
switch (prop_id)
{
case PROP_PANE:
g_value_set_pointer (value, self->pane);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
finance_list_box_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
FinanceListBox *self = FINANCE_LIST_BOX (object);
switch (prop_id)
{
case PROP_PANE:
g_assert (self->pane == NULL);
self->pane = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
finance_list_box_class_init (FinanceListBoxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = finance_list_box_finalize;
object_class->get_property = finance_list_box_get_property;
object_class->set_property = finance_list_box_set_property;
properties[PROP_PANE] = g_param_spec_pointer ("pane",
"the gpointer to pane",
"A gpointer to pane",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, N_PROPS, properties);
}
static void
finance_list_box_init (FinanceListBox *self)
{
}
file 2:
/* Create the GtkListBox with the categories */
static void
finance_category_pane_create_rows (FinanceCategoryPane *self)
{
if (self->list_box != NULL)
gtk_widget_destroy (GTK_WIDGET (self->list_box));
self->list_box = finance_list_box_new ();
g_object_set_property (G_OBJECT (self->list_box), "pane", self);
gtk_container_add (GTK_CONTAINER (self->viewport), GTK_WIDGET (self->list_box));
gtk_widget_show_all (GTK_WIDGET (self->viewport));
}
This error:
(finance:2): GLib-GObject-CRITICAL **: 20:50:29.745: validate_pspec_to_install: assertion âG_IS_PARAM_SPEC (pspec)â failed
(finance:2): GLib-GObject-WARNING **: 20:50:29.749: g_object_set_is_valid_property: object class âFinanceListBoxâ has no property named âpaneâ