Add notification for property setters

This commit is contained in:
Gergely Polonkai 2014-08-11 13:21:26 +02:00
parent 6e736c9b87
commit 5d028b5e17
1 changed files with 46 additions and 28 deletions

View File

@ -30,6 +30,7 @@ enum {
PROP_COUNTRY,
PROP_CITY,
PROP_NOTE,
PROP_LAST
};
typedef enum {
@ -42,6 +43,8 @@ G_DEFINE_QUARK(ag_chart_error_quark, ag_chart_error);
G_DEFINE_TYPE_WITH_PRIVATE(AgChart, ag_chart, GSWE_TYPE_MOMENT);
static GParamSpec *properties[PROP_LAST];
#define ag_g_variant_unref(v) \
if ((v) != NULL) { \
g_variant_unref((v)); \
@ -66,49 +69,56 @@ ag_chart_class_init(AgChartClass *klass)
gobject_class->get_property = ag_chart_get_property;
gobject_class->finalize = ag_chart_finalize;
properties[PROP_NAME] = g_param_spec_string(
"name",
"Chart name",
"Name of the person on this chart",
NULL,
G_PARAM_READWRITE
);
g_object_class_install_property(
gobject_class,
PROP_NAME,
g_param_spec_string(
"name",
"Chart name",
"Name of the person on this chart",
NULL,
G_PARAM_READWRITE
)
properties[PROP_NAME]
);
properties[PROP_COUNTRY] = g_param_spec_string(
"country",
"Country",
"Name of the country of birth",
NULL,
G_PARAM_READWRITE
);
g_object_class_install_property(
gobject_class,
PROP_COUNTRY,
g_param_spec_string(
"country",
"Country name",
"Name of the country of birth",
NULL,
G_PARAM_READWRITE
)
properties[PROP_COUNTRY]
);
properties[PROP_CITY] = g_param_spec_string(
"city",
"City name",
"Name of the city of birth",
NULL,
G_PARAM_READWRITE
);
g_object_class_install_property(
gobject_class,
PROP_CITY,
g_param_spec_string(
"city",
"City name",
"Name of the city of birth",
NULL,
G_PARAM_READWRITE
)
properties[PROP_CITY]
);
properties[PROP_NOTE] = g_param_spec_string(
"note",
"Note",
"Chart notes",
NULL,
G_PARAM_READWRITE
);
g_object_class_install_property(
gobject_class,
PROP_NOTE,
g_param_spec_string(
"note",
"Note",
"Chart notes",
NULL,
G_PARAM_READWRITE
)
properties[PROP_NOTE]
);
}
@ -388,6 +398,8 @@ ag_chart_set_name(AgChart *chart, const gchar *name)
}
priv->name = g_strdup(name);
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_NAME]);
}
gchar *
@ -408,6 +420,8 @@ ag_chart_set_country(AgChart *chart, const gchar *country)
}
priv->country = g_strdup(country);
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_COUNTRY]);
}
gchar *
@ -428,6 +442,8 @@ ag_chart_set_city(AgChart *chart, const gchar *city)
}
priv->city = g_strdup(city);
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_CITY]);
}
gchar *
@ -1868,6 +1884,8 @@ ag_chart_set_note(AgChart *chart, const gchar *note)
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
priv->note = g_strdup(note);
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_NOTE]);
}
const gchar *ag_chart_get_note(AgChart *chart)