Move AgChartPrivate to ag-chart.c completely

This commit is contained in:
Gergely Polonkai 2014-07-19 10:46:41 +02:00
parent de4cc09354
commit cad657c1b1
2 changed files with 99 additions and 81 deletions

View File

@ -12,14 +12,14 @@
#include "ag-chart.h" #include "ag-chart.h"
struct _AgChartPrivate { typedef struct _AgChartPrivate {
gchar *name; gchar *name;
gchar *country; gchar *country;
gchar *city; gchar *city;
gchar *save_buffer; gchar *save_buffer;
GList *planet_list; GList *planet_list;
gchar *note; gchar *note;
}; } AgChartPrivate;
enum { enum {
PROP_0, PROP_0,
@ -100,12 +100,13 @@ ag_chart_class_init(AgChartClass *klass)
static void static void
ag_chart_init(AgChart *chart) ag_chart_init(AgChart *chart)
{ {
chart->priv = ag_chart_get_instance_private(chart); AgChartPrivate *priv = ag_chart_get_instance_private(chart);
chart->priv->name = NULL;
chart->priv->country = NULL; priv->name = NULL;
chart->priv->city = NULL; priv->country = NULL;
chart->priv->save_buffer = NULL; priv->city = NULL;
chart->priv->planet_list = NULL; priv->save_buffer = NULL;
priv->planet_list = NULL;
} }
static void static void
@ -138,19 +139,21 @@ ag_chart_get_property(GObject *gobject,
GValue *value, GValue *value,
GParamSpec *param_spec) GParamSpec *param_spec)
{ {
AgChartPrivate *priv = ag_chart_get_instance_private(AG_CHART(gobject));
switch (prop_id) { switch (prop_id) {
case PROP_NAME: case PROP_NAME:
g_value_set_string(value, AG_CHART(gobject)->priv->name); g_value_set_string(value, priv->name);
break; break;
case PROP_COUNTRY: case PROP_COUNTRY:
g_value_set_string(value, AG_CHART(gobject)->priv->country); g_value_set_string(value, priv->country);
break; break;
case PROP_CITY: case PROP_CITY:
g_value_set_string(value, AG_CHART(gobject)->priv->city); g_value_set_string(value, priv->city);
break; break;
@ -161,162 +164,165 @@ static void
ag_chart_finalize(GObject *gobject) ag_chart_finalize(GObject *gobject)
{ {
AgChart *chart = AG_CHART(gobject); AgChart *chart = AG_CHART(gobject);
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
if (chart->priv->name != NULL) { if (priv->name != NULL) {
g_free(chart->priv->name); g_free(priv->name);
} }
if (chart->priv->country != NULL) { if (priv->country != NULL) {
g_free(chart->priv->country); g_free(priv->country);
} }
if (chart->priv->city != NULL) { if (priv->city != NULL) {
g_free(chart->priv->city); g_free(priv->city);
} }
if (chart->priv->save_buffer != NULL) { if (priv->save_buffer != NULL) {
g_free(chart->priv->save_buffer); g_free(priv->save_buffer);
} }
} }
void void
ag_chart_add_planets(AgChart *chart) ag_chart_add_planets(AgChart *chart)
{ {
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CHARIKLO, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CHARIKLO, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_CHARIKLO) GINT_TO_POINTER(GSWE_PLANET_CHARIKLO)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VESTA, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VESTA, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_VESTA) GINT_TO_POINTER(GSWE_PLANET_VESTA)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_JUNO, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_JUNO, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_JUNO) GINT_TO_POINTER(GSWE_PLANET_JUNO)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PALLAS, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PALLAS, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_PALLAS) GINT_TO_POINTER(GSWE_PLANET_PALLAS)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CERES, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CERES, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_CERES) GINT_TO_POINTER(GSWE_PLANET_CERES)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_NESSUS, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_NESSUS, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_NESSUS) GINT_TO_POINTER(GSWE_PLANET_NESSUS)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PHOLUS, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PHOLUS, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_PHOLUS) GINT_TO_POINTER(GSWE_PLANET_PHOLUS)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CHIRON, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CHIRON, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_CHIRON) GINT_TO_POINTER(GSWE_PLANET_CHIRON)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON_APOGEE, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON_APOGEE, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MOON_APOGEE) GINT_TO_POINTER(GSWE_PLANET_MOON_APOGEE)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON_NODE, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON_NODE, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MOON_NODE) GINT_TO_POINTER(GSWE_PLANET_MOON_NODE)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PLUTO, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PLUTO, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_PLUTO) GINT_TO_POINTER(GSWE_PLANET_PLUTO)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_NEPTUNE, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_NEPTUNE, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_NEPTUNE) GINT_TO_POINTER(GSWE_PLANET_NEPTUNE)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_URANUS, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_URANUS, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_URANUS) GINT_TO_POINTER(GSWE_PLANET_URANUS)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_SATURN, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_SATURN, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_SATURN) GINT_TO_POINTER(GSWE_PLANET_SATURN)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_JUPITER, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_JUPITER, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_JUPITER) GINT_TO_POINTER(GSWE_PLANET_JUPITER)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MARS, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MARS, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MARS) GINT_TO_POINTER(GSWE_PLANET_MARS)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VENUS, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VENUS, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_VENUS) GINT_TO_POINTER(GSWE_PLANET_VENUS)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MERCURY, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MERCURY, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MERCURY) GINT_TO_POINTER(GSWE_PLANET_MERCURY)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MOON) GINT_TO_POINTER(GSWE_PLANET_MOON)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_SUN, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_SUN, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_SUN) GINT_TO_POINTER(GSWE_PLANET_SUN)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VERTEX, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VERTEX, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_VERTEX) GINT_TO_POINTER(GSWE_PLANET_VERTEX)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_ASCENDANT, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_ASCENDANT, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_ASCENDANT) GINT_TO_POINTER(GSWE_PLANET_ASCENDANT)
); );
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MC, NULL); gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MC, NULL);
chart->priv->planet_list = g_list_prepend( priv->planet_list = g_list_prepend(
chart->priv->planet_list, priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MC) GINT_TO_POINTER(GSWE_PLANET_MC)
); );
} }
@ -351,49 +357,61 @@ ag_chart_new_full(GsweTimestamp *timestamp,
void void
ag_chart_set_name(AgChart *chart, const gchar *name) ag_chart_set_name(AgChart *chart, const gchar *name)
{ {
if (chart->priv->name != NULL) { AgChartPrivate *priv = ag_chart_get_instance_private(chart);
g_free(chart->priv->name);
if (priv->name != NULL) {
g_free(priv->name);
} }
chart->priv->name = g_strdup(name); priv->name = g_strdup(name);
} }
gchar * gchar *
ag_chart_get_name(AgChart *chart) ag_chart_get_name(AgChart *chart)
{ {
return g_strdup(chart->priv->name); AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return g_strdup(priv->name);
} }
void void
ag_chart_set_country(AgChart *chart, const gchar *country) ag_chart_set_country(AgChart *chart, const gchar *country)
{ {
if (chart->priv->country != NULL) { AgChartPrivate *priv = ag_chart_get_instance_private(chart);
g_free(chart->priv->country);
if (priv->country != NULL) {
g_free(priv->country);
} }
chart->priv->country = g_strdup(country); priv->country = g_strdup(country);
} }
gchar * gchar *
ag_chart_get_country(AgChart *chart) ag_chart_get_country(AgChart *chart)
{ {
return g_strdup(chart->priv->country); AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return g_strdup(priv->country);
} }
void void
ag_chart_set_city(AgChart *chart, const gchar *city) ag_chart_set_city(AgChart *chart, const gchar *city)
{ {
if (chart->priv->city != NULL) { AgChartPrivate *priv = ag_chart_get_instance_private(chart);
g_free(chart->priv->city);
if (priv->city != NULL) {
g_free(priv->city);
} }
chart->priv->city = g_strdup(city); priv->city = g_strdup(city);
} }
gchar * gchar *
ag_chart_get_city(AgChart *chart) ag_chart_get_city(AgChart *chart)
{ {
return g_strdup(chart->priv->city); AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return g_strdup(priv->city);
} }
/** /**
@ -1413,7 +1431,9 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
GList * GList *
ag_chart_get_planets(AgChart *chart) ag_chart_get_planets(AgChart *chart)
{ {
return chart->priv->planet_list; AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return priv->planet_list;
} }
void void

View File

@ -26,11 +26,9 @@ typedef enum {
typedef struct _AgChart AgChart; typedef struct _AgChart AgChart;
typedef struct _AgChartClass AgChartClass; typedef struct _AgChartClass AgChartClass;
typedef struct _AgChartPrivate AgChartPrivate;
struct _AgChart { struct _AgChart {
GsweMoment parent_instance; GsweMoment parent_instance;
AgChartPrivate *priv;
}; };
struct _AgChartClass { struct _AgChartClass {