diff --git a/src/gswe-antiscion-axis-info.c b/src/gswe-antiscion-axis-info.c index 10bb9aa..1046ce9 100644 --- a/src/gswe-antiscion-axis-info.c +++ b/src/gswe-antiscion-axis-info.c @@ -30,7 +30,12 @@ * The #GsweAntiscionAxisInfo stores information about an antiscion axis. */ -G_DEFINE_BOXED_TYPE(GsweAntiscionAxisInfo, gswe_antiscion_axis_info, (GBoxedCopyFunc)gswe_antiscion_axis_info_ref, (GBoxedFreeFunc)gswe_antiscion_axis_info_unref); +G_DEFINE_BOXED_TYPE( + GsweAntiscionAxisInfo, + gswe_antiscion_axis_info, + (GBoxedCopyFunc)gswe_antiscion_axis_info_ref, + (GBoxedFreeFunc)gswe_antiscion_axis_info_unref + ); static void gswe_antiscion_axis_info_free(GsweAntiscionAxisInfo *antiscion_axis_info) @@ -84,7 +89,8 @@ gswe_antiscion_axis_info_ref(GsweAntiscionAxisInfo *antiscion_axis_info) * gswe_antiscion_axis_info_unref: * @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo * - * Decreases reference count on @antiscion_axis_info. If reference count reaches zero, @antiscion_axis_info is freed. + * Decreases reference count on @antiscion_axis_info. If reference count + * reaches zero, @antiscion_axis_info is freed. */ void gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info) @@ -102,7 +108,9 @@ gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info) * Sets the axis ID. */ void -gswe_antiscion_axis_info_set_axis(GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionAxis axis) +gswe_antiscion_axis_info_set_axis( + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweAntiscionAxis axis) { antiscion_axis_info->axis = axis; } @@ -124,12 +132,15 @@ gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info) /** * gswe_antiscion_axis_info_set_start_sign_info: * @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo - * @sign_info: a #GsweSignInfo to set as the starting sign of @antiscion_axis_info + * @sign_info: a #GsweSignInfo to set as the starting sign of + * @antiscion_axis_info * * Sets the starting sign of the axis. */ void -gswe_antiscion_axis_info_set_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info, GsweSignInfo *sign_info) +gswe_antiscion_axis_info_set_start_sign_info( + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweSignInfo *sign_info) { if (antiscion_axis_info->start_sign != NULL) { gswe_sign_info_unref(antiscion_axis_info->start_sign); @@ -144,10 +155,12 @@ gswe_antiscion_axis_info_set_start_sign_info(GsweAntiscionAxisInfo *antiscion_ax * * Gets the starting sign of the axis. * - * Returns: (transfer none): the #GsweSignInfo of the sign in which this axis starts + * Returns: (transfer none): the #GsweSignInfo of the sign in which this axis + * starts */ GsweSignInfo * -gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info) +gswe_antiscion_axis_info_get_start_sign_info( + GsweAntiscionAxisInfo *antiscion_axis_info) { return antiscion_axis_info->start_sign; } @@ -165,13 +178,23 @@ gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_ax * be found. */ void -gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info, GsweZodiac sign, GError **err) +gswe_antiscion_axis_info_set_start_sign( + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweZodiac sign, + GError **err) { GsweSignInfo *sign_info; - if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER(sign))) == NULL) { + if ((sign_info = g_hash_table_lookup( + gswe_sign_info_table, + GINT_TO_POINTER(sign) + )) == NULL) { g_warning("Trying to fetch an unregistered sign"); - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "The requested sign is not registered"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, + "The requested sign is not registered" + ); return; } @@ -192,7 +215,8 @@ gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_in * Returns: the corresponding sign ID */ GsweZodiac -gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info) +gswe_antiscion_axis_info_get_start_sign( + GsweAntiscionAxisInfo *antiscion_axis_info) { if (antiscion_axis_info->start_sign) { return antiscion_axis_info->start_sign->sign; @@ -209,7 +233,9 @@ gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_in * Sets the name of the axis */ void -gswe_antiscion_axis_info_set_name(GsweAntiscionAxisInfo *antiscion_axis_info, const gchar *name) +gswe_antiscion_axis_info_set_name( + GsweAntiscionAxisInfo *antiscion_axis_info, + const gchar *name) { if (antiscion_axis_info->name != NULL) { g_free(antiscion_axis_info->name); @@ -240,7 +266,9 @@ gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info) * Sets the offset at which the axis starts. */ void -gswe_antiscion_axis_info_set_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info, gdouble sign_offset) +gswe_antiscion_axis_info_set_sign_offset( + GsweAntiscionAxisInfo *antiscion_axis_info, + gdouble sign_offset) { antiscion_axis_info->sign_offset = sign_offset; } @@ -254,7 +282,8 @@ gswe_antiscion_axis_info_set_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_i * Returns: the offset, in degrees */ gdouble -gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info) +gswe_antiscion_axis_info_get_sign_offset( + GsweAntiscionAxisInfo *antiscion_axis_info) { return antiscion_axis_info->sign_offset; } diff --git a/src/gswe-antiscion-axis-info.h b/src/gswe-antiscion-axis-info.h index b49107c..d6b383a 100644 --- a/src/gswe-antiscion-axis-info.h +++ b/src/gswe-antiscion-axis-info.h @@ -28,8 +28,8 @@ G_BEGIN_DECLS /** * GsweAntiscionAxisInfo: * - * GsweAntiscionAxisInfo is an opaque structure whose members - * cannot be accessed directly. + * GsweAntiscionAxisInfo is an opaque structure whose + * members cannot be accessed directly. * * Since: 1.1 */ @@ -40,23 +40,47 @@ GType gswe_antiscion_axis_info_get_type(void); GsweAntiscionAxisInfo *gswe_antiscion_axis_info_new(void); -GsweAntiscionAxisInfo *gswe_antiscion_axis_info_ref(GsweAntiscionAxisInfo *antiscion_axis_info); -void gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info); +GsweAntiscionAxisInfo *gswe_antiscion_axis_info_ref( + GsweAntiscionAxisInfo *antiscion_axis_info); -void gswe_antiscion_axis_info_set_axis(GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionAxis axis); -GsweAntiscionAxis gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info); +void gswe_antiscion_axis_info_unref( + GsweAntiscionAxisInfo *antiscion_axis_info); -void gswe_antiscion_axis_info_set_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info, GsweSignInfo *sign_info); -GsweSignInfo *gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info); +void gswe_antiscion_axis_info_set_axis( + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweAntiscionAxis axis); -void gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info, GsweZodiac sign, GError **err); -GsweZodiac gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info); +GsweAntiscionAxis gswe_antiscion_axis_info_get_axis( + GsweAntiscionAxisInfo *antiscion_axis_info); -void gswe_antiscion_axis_info_set_name(GsweAntiscionAxisInfo *antiscion_axis_info, const gchar *name); -const gchar *gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info); +void gswe_antiscion_axis_info_set_start_sign_info( + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweSignInfo *sign_info); -void gswe_antiscion_axis_info_set_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info, gdouble sign_offset); -gdouble gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info); +GsweSignInfo *gswe_antiscion_axis_info_get_start_sign_info( + GsweAntiscionAxisInfo *antiscion_axis_info); + +void gswe_antiscion_axis_info_set_start_sign( + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweZodiac sign, + GError **err); + +GsweZodiac gswe_antiscion_axis_info_get_start_sign( + GsweAntiscionAxisInfo *antiscion_axis_info); + +void gswe_antiscion_axis_info_set_name( + GsweAntiscionAxisInfo *antiscion_axis_info, + const gchar *name); + +const gchar *gswe_antiscion_axis_info_get_name( + GsweAntiscionAxisInfo *antiscion_axis_info); + +void gswe_antiscion_axis_info_set_sign_offset( + GsweAntiscionAxisInfo *antiscion_axis_info, + gdouble sign_offset); + +gdouble gswe_antiscion_axis_info_get_sign_offset( + GsweAntiscionAxisInfo *antiscion_axis_info); G_END_DECLS diff --git a/src/gswe-antiscion-data-private.h b/src/gswe-antiscion-data-private.h index fab89f6..16fee11 100644 --- a/src/gswe-antiscion-data-private.h +++ b/src/gswe-antiscion-data-private.h @@ -33,7 +33,8 @@ struct _GsweAntiscionData { /* the #GsweAntiscionAxisInfo structure associated with this antiscion */ GsweAntiscionAxisInfo *antiscion_axis_info; - /* the difference in degrees between an exact antiscion and this given antiscion */ + /* the difference in degrees between an exact antiscion and this given + * antiscion */ gdouble difference; /* reference count */ diff --git a/src/gswe-antiscion-data.c b/src/gswe-antiscion-data.c index d07c61f..c46c47f 100644 --- a/src/gswe-antiscion-data.c +++ b/src/gswe-antiscion-data.c @@ -35,7 +35,12 @@ * between two planets, based on a specified axis. */ -G_DEFINE_BOXED_TYPE(GsweAntiscionData, gswe_antiscion_data, (GBoxedCopyFunc)gswe_antiscion_data_ref, (GBoxedFreeFunc)gswe_antiscion_data_unref); +G_DEFINE_BOXED_TYPE( + GsweAntiscionData, + gswe_antiscion_data, + (GBoxedCopyFunc)gswe_antiscion_data_ref, + (GBoxedFreeFunc)gswe_antiscion_data_unref + ); static void gswe_antiscion_data_free(GsweAntiscionData *antiscion_data) @@ -74,15 +79,20 @@ gswe_antiscion_data_new(void) /* * find_antiscion: * @axis_p: a pointer made with GINT_TO_POINTER(), holding the antiscion axis ID - * @antiscion_axis_info: a GsweAntiscionAxisInfo, which will be checked against @antiscion_data - * @antiscion_data: a GsweAntiscionData, whose planets' positions will be checked against @antiscion_axis_info + * @antiscion_axis_info: a GsweAntiscionAxisInfo, which will be checked against + * @antiscion_data + * @antiscion_data: a GsweAntiscionData, whose planets' positions will be + * checked against @antiscion_axis_info * * This function is called internally by gswe_antiscion_data_calculate() to * check if the two planets in @antiscion_data are antiscia of each other on * the axis in @antiscion_axis_info */ static gboolean -find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionData *antiscion_data) +find_antiscion( + gpointer axis_p, + GsweAntiscionAxisInfo *antiscion_axis_info, + GsweAntiscionData *antiscion_data) { GsweAntiscionAxis axis; gdouble start_point, @@ -93,7 +103,10 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, Gswe return FALSE; } - planet_orb = fmin(antiscion_data->planet1->planet_info->orb, antiscion_data->planet2->planet_info->orb); + planet_orb = fmin( + antiscion_data->planet1->planet_info->orb, + antiscion_data->planet2->planet_info->orb + ); start_point = (antiscion_axis_info->start_sign->sign - 1) * 30.0; start_point += antiscion_axis_info->sign_offset; @@ -104,7 +117,9 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, Gswe axis_position += 360.0; } - if ((antiscion_data->difference = fabs(antiscion_data->planet2->position - axis_position)) <= planet_orb) { + if ((antiscion_data->difference = fabs( + antiscion_data->planet2->position - axis_position + )) <= planet_orb) { antiscion_data->antiscion_axis_info = antiscion_axis_info; return TRUE; @@ -137,8 +152,17 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, Gswe void gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data) { - if ((antiscion_data->antiscion_axis_info = g_hash_table_find(gswe_antiscion_axis_info_table, (GHRFunc)find_antiscion, antiscion_data)) == NULL) { - antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE))); + if ((antiscion_data->antiscion_axis_info = g_hash_table_find( + gswe_antiscion_axis_info_table, + (GHRFunc)find_antiscion, + antiscion_data + )) == NULL) { + antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref( + g_hash_table_lookup( + gswe_antiscion_axis_info_table, + GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE) + ) + ); } else { gswe_antiscion_axis_info_ref(antiscion_data->antiscion_axis_info); } @@ -155,7 +179,9 @@ gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data) * Returns: (transfer full): a new #GsweAntiscionData */ GsweAntiscionData * -gswe_antiscion_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2) +gswe_antiscion_data_new_with_planets( + GswePlanetData *planet1, + GswePlanetData *planet2) { GsweAntiscionData *ret; @@ -188,7 +214,8 @@ gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data) * gswe_antiscion_data_unref: * @antiscion_data: (in): a #GsweAntiscionData * - * Decreases reference count on @antiscion_data. If reference count reaches zero, @antiscion_data is freed. + * Decreases reference count on @antiscion_data. If reference count reaches + * zero, @antiscion_data is freed. */ void gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data) @@ -206,7 +233,9 @@ gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data) * Sets @planet1 as the first planet of the antiscion. */ void -gswe_antiscion_data_set_planet1(GsweAntiscionData *antiscion_data, GswePlanetData *planet1) +gswe_antiscion_data_set_planet1( + GsweAntiscionData *antiscion_data, + GswePlanetData *planet1) { if (antiscion_data->planet1) { gswe_planet_data_unref(antiscion_data->planet1); @@ -221,7 +250,8 @@ gswe_antiscion_data_set_planet1(GsweAntiscionData *antiscion_data, GswePlanetDat * * Gets the first in the antiscion relationship. * - * Returns: (transfer none): The #GswePlanetData associated with the first planet. + * Returns: (transfer none): The #GswePlanetData associated with the first + * planet. */ GswePlanetData * gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data) @@ -237,7 +267,9 @@ gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data) * Sets @planet2 as the second planet of the antiscion. */ void -gswe_antiscion_data_set_planet2(GsweAntiscionData *antiscion_data, GswePlanetData *planet2) +gswe_antiscion_data_set_planet2( + GsweAntiscionData *antiscion_data, + GswePlanetData *planet2) { if (antiscion_data->planet2) { gswe_planet_data_unref(antiscion_data->planet2); @@ -252,7 +284,8 @@ gswe_antiscion_data_set_planet2(GsweAntiscionData *antiscion_data, GswePlanetDat * * Gets the second in the antiscion relationship. * - * Returns: (transfer none): The #GswePlanetData associated with the second planet. + * Returns: (transfer none): The #GswePlanetData associated with the second + * planet. */ GswePlanetData * gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data) @@ -271,12 +304,22 @@ gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data) * the axis is not known. */ void -gswe_antiscion_data_set_axis(GsweAntiscionData *antiscion_data, GsweAntiscionAxis axis, GError **err) +gswe_antiscion_data_set_axis( + GsweAntiscionData *antiscion_data, + GsweAntiscionAxis axis, + GError **err) { GsweAntiscionAxisInfo *antiscion_axis_info; - if ((antiscion_axis_info = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(axis))) == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, "Unknown antiscion axis"); + if ((antiscion_axis_info = g_hash_table_lookup( + gswe_antiscion_axis_info_table, + GINT_TO_POINTER(axis) + )) == NULL) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, + "Unknown antiscion axis" + ); return; } @@ -285,7 +328,9 @@ gswe_antiscion_data_set_axis(GsweAntiscionData *antiscion_data, GsweAntiscionAxi gswe_antiscion_axis_info_unref(antiscion_data->antiscion_axis_info); } - antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(antiscion_axis_info); + antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref( + antiscion_axis_info + ); } /** @@ -314,13 +359,17 @@ gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data) * Sets @antiscion_axis_info as the axis of this #GsweAntiscionData. */ void -gswe_antiscion_data_set_antiscion_axis_info(GsweAntiscionData *antiscion_data, GsweAntiscionAxisInfo *antiscion_axis_info) +gswe_antiscion_data_set_antiscion_axis_info( + GsweAntiscionData *antiscion_data, + GsweAntiscionAxisInfo *antiscion_axis_info) { if (antiscion_data->antiscion_axis_info) { gswe_antiscion_axis_info_unref(antiscion_data->antiscion_axis_info); } - antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(antiscion_axis_info); + antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref( + antiscion_axis_info + ); } /** @@ -329,7 +378,8 @@ gswe_antiscion_data_set_antiscion_axis_info(GsweAntiscionData *antiscion_data, G * * Gets the axis information related to the antiscion relationship's axis. * - * Returns: (transfer none): the #GsweAntiscionAxisInfo associated with this axis + * Returns: (transfer none): the #GsweAntiscionAxisInfo associated with this + * axis */ GsweAntiscionAxisInfo * gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data) @@ -345,7 +395,9 @@ gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data) * Sets the difference of this antiscion from an exact antiscion. */ void -gswe_antiscion_data_set_difference(GsweAntiscionData *antiscion_data, gdouble difference) +gswe_antiscion_data_set_difference( + GsweAntiscionData *antiscion_data, + gdouble difference) { antiscion_data->difference = difference; } @@ -354,7 +406,8 @@ gswe_antiscion_data_set_difference(GsweAntiscionData *antiscion_data, gdouble di * gswe_antiscion_data_get_difference: * @antiscion_data: (in): a #GsweAntiscionData * - * Gets the difference between an exact antiscion and this antiscion relationship. + * Gets the difference between an exact antiscion and this antiscion + * relationship. * * Returns: the difference, in degrees */ diff --git a/src/gswe-antiscion-data.h b/src/gswe-antiscion-data.h index 6c143f6..a898b8d 100644 --- a/src/gswe-antiscion-data.h +++ b/src/gswe-antiscion-data.h @@ -28,8 +28,8 @@ G_BEGIN_DECLS /** * GsweAntiscionData: * - * GsweAntiscionData is an opaque structure whose members - * cannot be accessed directly. + * GsweAntiscionData is an opaque structure whose + * members cannot be accessed directly. * * Since: 1.1 */ @@ -39,21 +39,37 @@ GType gswe_antiscion_data_get_type(void); #define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type()) GsweAntiscionData *gswe_antiscion_data_new(void); -GsweAntiscionData *gswe_antiscion_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2); + +GsweAntiscionData *gswe_antiscion_data_new_with_planets( + GswePlanetData *planet1, + GswePlanetData *planet2); GsweAntiscionData *gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data); + void gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data); void gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data); -void gswe_antiscion_data_set_planet1(GsweAntiscionData *antiscion_data, GswePlanetData *planet1); -GswePlanetData *gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data); +void gswe_antiscion_data_set_planet1( + GsweAntiscionData *antiscion_data, + GswePlanetData *planet1); -void gswe_antiscion_data_set_planet2(GsweAntiscionData *antiscion_data, GswePlanetData *planet2); -GswePlanetData *gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data); +GswePlanetData *gswe_antiscion_data_get_planet1( + GsweAntiscionData *antiscion_data); + +void gswe_antiscion_data_set_planet2( + GsweAntiscionData *antiscion_data, + GswePlanetData *planet2); + +GswePlanetData *gswe_antiscion_data_get_planet2( + GsweAntiscionData *antiscion_data); + +GsweAntiscionAxis gswe_antiscion_data_get_axis( + GsweAntiscionData *antiscion_data); + +GsweAntiscionAxisInfo *gswe_antiscion_data_get_antiscion_axis_info( + GsweAntiscionData *antiscion_data); -GsweAntiscionAxis gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data); -GsweAntiscionAxisInfo *gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data); gdouble gswe_antiscion_data_get_difference(GsweAntiscionData *antiscion_data); G_END_DECLS diff --git a/src/gswe-aspect-data-private.h b/src/gswe-aspect-data-private.h index fa8ffef..8e90617 100644 --- a/src/gswe-aspect-data-private.h +++ b/src/gswe-aspect-data-private.h @@ -35,7 +35,8 @@ struct _GsweAspectData { /* the #GsweAspectInfo structure associated with the aspect */ GsweAspectInfo *aspect_info; - /* the difference in percent between an exact aspect and this given aspect */ + /* the difference in percent between an exact aspect and this given + * aspect */ gdouble difference; /* reference count */ diff --git a/src/gswe-aspect-data.c b/src/gswe-aspect-data.c index 2ef5b4c..a6fc6f2 100644 --- a/src/gswe-aspect-data.c +++ b/src/gswe-aspect-data.c @@ -38,7 +38,12 @@ * #GsweAspectData is a structure that represents two planets relation to each * other, like their aspect and the aspect's difference from an exact aspect. */ -G_DEFINE_BOXED_TYPE(GsweAspectData, gswe_aspect_data, (GBoxedCopyFunc)gswe_aspect_data_ref, (GBoxedFreeFunc)gswe_aspect_data_unref); +G_DEFINE_BOXED_TYPE( + GsweAspectData, + gswe_aspect_data, + (GBoxedCopyFunc)gswe_aspect_data_ref, + (GBoxedFreeFunc)gswe_aspect_data_unref + ); static void gswe_aspect_data_free(GsweAspectData *aspect_data) @@ -62,20 +67,27 @@ gswe_aspect_data_free(GsweAspectData *aspect_data) * find_aspect: * @aspect_p: a pointer made with GINT_TO_POINTER(), holding the aspect ID * @aspect_info: a GsweAspectInfo, which will be checked against @aspect_data - * @aspect_data: a GsweAspectData, whose planets' positions will be checked against @aspect_info + * @aspect_data: a GsweAspectData, whose planets' positions will be checked + * against @aspect_info * * This function is called internally by gswe_aspect_data_calculate() to check * if the two planets in @aspect_data are in aspect according to @aspect_info */ static gboolean -find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspect_data) +find_aspect( + gpointer aspect_p, + GsweAspectInfo *aspect_info, + GsweAspectData *aspect_data) { gdouble diff, planet_orb, aspect_orb; diff = fabs(aspect_info->size - aspect_data->distance); - planet_orb = fmin(aspect_data->planet1->planet_info->orb, aspect_data->planet2->planet_info->orb); + planet_orb = fmin( + aspect_data->planet1->planet_info->orb, + aspect_data->planet2->planet_info->orb + ); aspect_orb = fmax(1.0, planet_orb - aspect_info->orb_modifier); if (diff < aspect_orb) { @@ -84,7 +96,8 @@ find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspe if (aspect_info->size == 0) { aspect_data->difference = (1 - ((360.0 - diff) / 360.0)) * 100.0; } else { - aspect_data->difference = (1 - ((aspect_info->size - diff) / aspect_info->size)) * 100.0; + aspect_data->difference = (1 + - ((aspect_info->size - diff) / aspect_info->size)) * 100.0; } return TRUE; @@ -96,12 +109,23 @@ find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspe void gswe_aspect_data_calculate(GsweAspectData *aspect_data) { - if ((aspect_data->distance = fabs(aspect_data->planet1->position - aspect_data->planet2->position)) > 180.0) { + if ((aspect_data->distance = fabs( + aspect_data->planet1->position + - aspect_data->planet2->position + )) > 180.0) { aspect_data->distance = 360.0 - aspect_data->distance; } - if ((aspect_data->aspect_info = g_hash_table_find(gswe_aspect_info_table, (GHRFunc)find_aspect, aspect_data)) == NULL) { - aspect_data->aspect_info = gswe_aspect_info_ref(g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(GSWE_ASPECT_NONE))); + if ((aspect_data->aspect_info = g_hash_table_find( + gswe_aspect_info_table, + (GHRFunc)find_aspect, aspect_data + )) == NULL) { + aspect_data->aspect_info = gswe_aspect_info_ref( + g_hash_table_lookup( + gswe_aspect_info_table, + GINT_TO_POINTER(GSWE_ASPECT_NONE) + ) + ); } else { gswe_aspect_info_ref(aspect_data->aspect_info); } @@ -138,7 +162,9 @@ gswe_aspect_data_new(void) * Returns: (transfer full): a new #GsweAspectData with all data set. */ GsweAspectData * -gswe_aspect_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2) +gswe_aspect_data_new_with_planets( + GswePlanetData *planet1, + GswePlanetData *planet2) { GsweAspectData *ret; @@ -171,7 +197,8 @@ gswe_aspect_data_ref(GsweAspectData *aspect_data) * gswe_aspect_data_unref: * @aspect_data: (in): a #GsweAspectData * - * Decreases reference count on @aspect_data. If reference count reaches zero, @aspect_data is freed. + * Decreases reference count on @aspect_data. If reference count reaches zero, + * @aspect_data is freed. */ void gswe_aspect_data_unref(GsweAspectData *aspect_data) @@ -189,7 +216,9 @@ gswe_aspect_data_unref(GsweAspectData *aspect_data) * Sets @planet1 as the first planet of the aspect. */ void -gswe_aspect_data_set_planet1(GsweAspectData *aspect_data, GswePlanetData *planet1) +gswe_aspect_data_set_planet1( + GsweAspectData *aspect_data, + GswePlanetData *planet1) { if (aspect_data->planet1) { gswe_planet_data_unref(aspect_data->planet1); @@ -208,7 +237,8 @@ gswe_aspect_data_set_planet1(GsweAspectData *aspect_data, GswePlanetData *planet * * Gets the first planet in the aspect. * - * Returns: (transfer none): The #GswePlanetData associated with the first planet + * Returns: (transfer none): The #GswePlanetData associated with the first + * planet */ GswePlanetData * gswe_aspect_data_get_planet1(GsweAspectData *aspect_data) @@ -224,7 +254,9 @@ gswe_aspect_data_get_planet1(GsweAspectData *aspect_data) * Sets @planet2 as the second planet of the aspect. */ void -gswe_aspect_data_set_planet2(GsweAspectData *aspect_data, GswePlanetData *planet2) +gswe_aspect_data_set_planet2( + GsweAspectData *aspect_data, + GswePlanetData *planet2) { if (aspect_data->planet2) { gswe_planet_data_unref(aspect_data->planet2); @@ -243,7 +275,8 @@ gswe_aspect_data_set_planet2(GsweAspectData *aspect_data, GswePlanetData *planet * * Gets the second planet in the aspect. * - * Returns: (transfer none): The #GswePlanetData associated with the second planet + * Returns: (transfer none): The #GswePlanetData associated with the second + * planet */ GswePlanetData * gswe_aspect_data_get_planet2(GsweAspectData *aspect_data) diff --git a/src/gswe-aspect-data.h b/src/gswe-aspect-data.h index 079e9c4..fab92a9 100644 --- a/src/gswe-aspect-data.h +++ b/src/gswe-aspect-data.h @@ -37,23 +37,37 @@ G_BEGIN_DECLS typedef struct _GsweAspectData GsweAspectData; GType gswe_aspect_data_get_type(void); + #define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type()) GsweAspectData *gswe_aspect_data_new(void); -GsweAspectData *gswe_aspect_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2); + +GsweAspectData *gswe_aspect_data_new_with_planets( + GswePlanetData *planet1, + GswePlanetData *planet2); GsweAspectData *gswe_aspect_data_ref(GsweAspectData *aspect_data); + void gswe_aspect_data_unref(GsweAspectData *aspect_data); -void gswe_aspect_data_set_planet1(GsweAspectData *aspect_data, GswePlanetData *planet1); +void gswe_aspect_data_set_planet1( + GsweAspectData *aspect_data, + GswePlanetData *planet1); + GswePlanetData *gswe_aspect_data_get_planet1(GsweAspectData *aspect_data); -void gswe_aspect_data_set_planet2(GsweAspectData *aspect_data, GswePlanetData *planet2); +void gswe_aspect_data_set_planet2( + GsweAspectData *aspect_data, + GswePlanetData *planet2); + GswePlanetData *gswe_aspect_data_get_planet2(GsweAspectData *aspect_data); gdouble gswe_aspect_data_get_distance(GsweAspectData *aspect_data); + GsweAspect gswe_aspect_data_get_aspect(GsweAspectData *aspect_data); + GsweAspectInfo *gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data); + gdouble gswe_aspect_data_get_difference(GsweAspectData *aspect_data); G_END_DECLS diff --git a/src/gswe-aspect-info-private.h b/src/gswe-aspect-info-private.h index 804ac16..fb5a2f1 100644 --- a/src/gswe-aspect-info-private.h +++ b/src/gswe-aspect-info-private.h @@ -32,7 +32,8 @@ struct _GsweAspectInfo { /* the size of the aspect, in degrees */ guint size; - /* the modifier of the orb (the maximum allowable difference from an exact orb) */ + /* the modifier of the orb (the maximum allowable difference from an exact + * orb) */ gdouble orb_modifier; /* shows whether this aspect is harmonic or not */ diff --git a/src/gswe-aspect-info.c b/src/gswe-aspect-info.c index e306597..c110791 100644 --- a/src/gswe-aspect-info.c +++ b/src/gswe-aspect-info.c @@ -37,7 +37,12 @@ * possible; until then, you should never use such functions. */ -G_DEFINE_BOXED_TYPE(GsweAspectInfo, gswe_aspect_info, (GBoxedCopyFunc)gswe_aspect_info_ref, (GBoxedFreeFunc)gswe_aspect_info_unref); +G_DEFINE_BOXED_TYPE( + GsweAspectInfo, + gswe_aspect_info, + (GBoxedCopyFunc)gswe_aspect_info_ref, + (GBoxedFreeFunc)gswe_aspect_info_unref + ); static void gswe_aspect_info_free(GsweAspectInfo *aspect_info) @@ -194,7 +199,9 @@ gswe_aspect_info_get_size(GsweAspectInfo *aspect_info) * between two positions exceeds this limit, the aspect is not considered. */ void -gswe_aspect_info_set_orb_modifier(GsweAspectInfo *aspect_info, gdouble orb_modifier) +gswe_aspect_info_set_orb_modifier( + GsweAspectInfo *aspect_info, + gdouble orb_modifier) { aspect_info->orb_modifier = orb_modifier; } @@ -217,7 +224,8 @@ gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info) /** * gswe_aspect_info_set_harmonic: * @aspect_info: (in): a #GsweAspectInfo - * @harmonic: TRUE, if @aspect_info should be considered harmonic; FALSE otherwise + * @harmonic: TRUE, if @aspect_info should be considered harmonic; FALSE + * otherwise * * Sets the harmonic state of @aspect_info. */ @@ -244,11 +252,13 @@ gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info) /** * gswe_aspect_info_set_major: * @aspect_info: (in): a #GsweAspectInfo - * @major: TRUE, if @aspect_info should be considered major (Ptolemaic); FALSE otherwise + * @major: TRUE, if @aspect_info should be considered major (Ptolemaic); FALSE + * otherwise * * Sets the major state of @aspect_info. * - * As all Ptolemaic aspects are registered during gswe_init(), you should never set @major to TRUE on new aspects. + * As all Ptolemaic aspects are registered during gswe_init(), you + * should never set @major to TRUE on new aspects. */ void gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major) diff --git a/src/gswe-aspect-info.h b/src/gswe-aspect-info.h index d54c6f6..b53e50e 100644 --- a/src/gswe-aspect-info.h +++ b/src/gswe-aspect-info.h @@ -40,21 +40,33 @@ GType gswe_aspect_info_get_type(void); GsweAspectInfo *gswe_aspect_info_new(void); GsweAspectInfo *gswe_aspect_info_ref(GsweAspectInfo *aspect_info); + void gswe_aspect_info_unref(GsweAspectInfo *aspect_info); -void gswe_aspect_info_set_aspect(GsweAspectInfo *aspect_info, GsweAspect aspect); +void gswe_aspect_info_set_aspect( + GsweAspectInfo *aspect_info, + GsweAspect aspect); + GsweAspect gswe_aspect_info_get_aspect(GsweAspectInfo *aspect_info); void gswe_aspect_info_set_name(GsweAspectInfo *aspect_info, const gchar *name); + const gchar *gswe_aspect_info_get_name(GsweAspectInfo *aspect_info); void gswe_aspect_info_set_size(GsweAspectInfo *aspect_info, gdouble size); + gdouble gswe_aspect_info_get_size(GsweAspectInfo *aspect_info); -void gswe_aspect_info_set_orb_modifier(GsweAspectInfo *aspect_info, gdouble orb_modifier); +void gswe_aspect_info_set_orb_modifier( + GsweAspectInfo *aspect_info, + gdouble orb_modifier); + gdouble gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info); -void gswe_aspect_info_set_harmonic(GsweAspectInfo *aspect_info, gboolean harmonic); +void gswe_aspect_info_set_harmonic( + GsweAspectInfo *aspect_info, + gboolean harmonic); + gboolean gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info); void gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major); diff --git a/src/gswe-enumtypes.c.template b/src/gswe-enumtypes.c.template index d20e822..c3bb9bc 100644 --- a/src/gswe-enumtypes.c.template +++ b/src/gswe-enumtypes.c.template @@ -39,14 +39,21 @@ GType /*** END value-header ***/ /*** BEGIN value-production ***/ - { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, + { + @VALUENAME@, + "@VALUENAME@", + "@valuenick@" + }, /*** END value-production ***/ /*** BEGIN value-tail ***/ { 0, NULL, NULL } }; - GType g_define_type_id = g_@type@_register_static(g_intern_static_string("@EnumName@"), values); + GType g_define_type_id = g_@type@_register_static( + g_intern_static_string("@EnumName@"), + values + ); g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); } diff --git a/src/gswe-house-data-private.h b/src/gswe-house-data-private.h index c32a47e..f5e9528 100644 --- a/src/gswe-house-data-private.h +++ b/src/gswe-house-data-private.h @@ -22,13 +22,15 @@ #include "gswe-house-data.h" struct _GsweHouseData { - /* the number of the house (usually in the range [1;12]. Sometimes may be [1;36]) */ + /* the number of the house (usually in the range [1;12]. Sometimes may be + * [1;36]) */ guint house; /* the position of the house's cusp on the sky */ gdouble cusp_position; - /* the #GsweSignInfo structure associated with the sign in which the house cusp is in */ + /* the #GsweSignInfo structure associated with the sign in which the house + * cusp is in */ GsweSignInfo *sign_info; /* reference count */ diff --git a/src/gswe-house-data.c b/src/gswe-house-data.c index f92d145..0fead03 100644 --- a/src/gswe-house-data.c +++ b/src/gswe-house-data.c @@ -33,7 +33,12 @@ * #GsweHouseData is a structure that represents a house's position. */ -G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_ref, (GBoxedFreeFunc)gswe_house_data_unref); +G_DEFINE_BOXED_TYPE( + GsweHouseData, + gswe_house_data, + (GBoxedCopyFunc)gswe_house_data_ref, + (GBoxedFreeFunc)gswe_house_data_unref + ); static void gswe_house_data_free(GsweHouseData *house_data) @@ -83,7 +88,8 @@ gswe_house_data_ref(GsweHouseData *house_data) * gswe_house_data_unref: * @house_data: a #GsweHouseData * - * Decreases reference count on @house_data by one. If reference count drops to zero, @house_data is freed. + * Decreases reference count on @house_data by one. If reference count drops to + * zero, @house_data is freed. */ void gswe_house_data_unref(GsweHouseData *house_data) diff --git a/src/gswe-house-system-info-private.h b/src/gswe-house-system-info-private.h index c10009d..be62f4c 100644 --- a/src/gswe-house-system-info-private.h +++ b/src/gswe-house-system-info-private.h @@ -27,7 +27,8 @@ struct _GsweHouseSystemInfo { /* the house system's ID */ GsweHouseSystem house_system; - /* the character value that represents this house system in the Swiss Ephemeris library */ + /* the character value that represents this house system in the Swiss + * Ephemeris library */ gchar sweph_id; /* the name of this house system */ diff --git a/src/gswe-house-system-info.c b/src/gswe-house-system-info.c index 552cc9a..1ddad35 100644 --- a/src/gswe-house-system-info.c +++ b/src/gswe-house-system-info.c @@ -29,7 +29,12 @@ * #GsweHouseSystemInfo stores information of a house system. */ -G_DEFINE_BOXED_TYPE(GsweHouseSystemInfo, gswe_house_system_info, (GBoxedCopyFunc)gswe_house_system_info_ref, (GBoxedFreeFunc)gswe_house_system_info_unref); +G_DEFINE_BOXED_TYPE( + GsweHouseSystemInfo, + gswe_house_system_info, + (GBoxedCopyFunc)gswe_house_system_info_ref, + (GBoxedFreeFunc)gswe_house_system_info_unref + ); static void gswe_house_system_info_free(GsweHouseSystemInfo *house_system_info) @@ -98,7 +103,9 @@ gswe_house_system_info_unref(GsweHouseSystemInfo *house_system_info) * Sets up @house_system_info to represent @house_system. */ void -gswe_house_system_info_set_house_system(GsweHouseSystemInfo *house_system_info, GsweHouseSystem house_system) +gswe_house_system_info_set_house_system( + GsweHouseSystemInfo *house_system_info, + GsweHouseSystem house_system) { house_system_info->house_system = house_system; } @@ -126,7 +133,9 @@ gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info) * marked by @sweph_id. */ void -gswe_house_system_info_set_sweph_id(GsweHouseSystemInfo *house_system_info, gchar sweph_id) +gswe_house_system_info_set_sweph_id( + GsweHouseSystemInfo *house_system_info, + gchar sweph_id) { house_system_info->sweph_id = sweph_id; } @@ -153,7 +162,9 @@ gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info) * Sets the name of @house_system_info. */ void -gswe_house_system_info_set_name(GsweHouseSystemInfo *house_system_info, const gchar *name) +gswe_house_system_info_set_name( + GsweHouseSystemInfo *house_system_info, + const gchar *name) { if (house_system_info->name) { g_free(house_system_info->name); diff --git a/src/gswe-house-system-info.h b/src/gswe-house-system-info.h index e2de9b4..9546aba 100644 --- a/src/gswe-house-system-info.h +++ b/src/gswe-house-system-info.h @@ -27,8 +27,8 @@ G_BEGIN_DECLS /** * GsweHouseSystemInfo: * - * GsweHouseSystemInfo is an opaque structure whose members - * cannot be accessed directly. + * GsweHouseSystemInfo is an opaque structure whose + * members cannot be accessed directly. * * Since: 1.1 */ @@ -39,17 +39,31 @@ GType gswe_house_system_info_get_type(void); GsweHouseSystemInfo *gswe_house_system_info_new(void); -GsweHouseSystemInfo *gswe_house_system_info_ref(GsweHouseSystemInfo *house_system_info); +GsweHouseSystemInfo *gswe_house_system_info_ref( + GsweHouseSystemInfo *house_system_info); + void gswe_house_system_info_unref(GsweHouseSystemInfo *house_system_info); -void gswe_house_system_info_set_house_system(GsweHouseSystemInfo *house_system_info, GsweHouseSystem house_system); -GsweHouseSystem gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info); +void gswe_house_system_info_set_house_system( + GsweHouseSystemInfo *house_system_info, + GsweHouseSystem house_system); -void gswe_house_system_info_set_sweph_id(GsweHouseSystemInfo *house_system_info, gchar sweph_id); -gchar gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info); +GsweHouseSystem gswe_house_system_info_get_house_system( + GsweHouseSystemInfo *house_system_info); -void gswe_house_system_info_set_name(GsweHouseSystemInfo *house_system_info, const gchar *name); -const gchar *gswe_house_system_info_get_name(GsweHouseSystemInfo *house_system_info); +void gswe_house_system_info_set_sweph_id( + GsweHouseSystemInfo *house_system_info, + gchar sweph_id); + +gchar gswe_house_system_info_get_sweph_id( + GsweHouseSystemInfo *house_system_info); + +void gswe_house_system_info_set_name( + GsweHouseSystemInfo *house_system_info, + const gchar *name); + +const gchar *gswe_house_system_info_get_name( + GsweHouseSystemInfo *house_system_info); G_END_DECLS diff --git a/src/gswe-moment.c b/src/gswe-moment.c index 9dc37d6..43a8601 100644 --- a/src/gswe-moment.c +++ b/src/gswe-moment.c @@ -34,7 +34,10 @@ * one given point on Earth at a given time. */ -#define GSWE_MOMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSWE_TYPE_MOMENT, GsweMomentPrivate)) +#define GSWE_MOMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE( \ + (obj), \ + GSWE_TYPE_MOMENT, \ + GsweMomentPrivate)) /** * GsweMomentPrivate: @@ -102,9 +105,20 @@ struct GsweAspectFinder { static guint gswe_moment_signals[SIGNAL_LAST] = {0}; static void gswe_moment_dispose(GObject *gobject); + static void gswe_moment_finalize(GObject *gobject); -static void gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); + +static void gswe_moment_set_property( + GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + +static void gswe_moment_get_property( + GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); G_DEFINE_TYPE(GsweMoment, gswe_moment, G_TYPE_OBJECT); @@ -124,30 +138,72 @@ gswe_moment_class_init(GsweMomentClass *klass) * GsweMoment::changed: * @moment: the GsweMoment object that received the signal * - * The ::changed signal is emitted each time the time or coordinates are changed + * The ::changed signal is emitted each time the time or coordinates are + * changed */ - gswe_moment_signals[SIGNAL_CHANGED] = g_signal_new("changed", G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0); + gswe_moment_signals[SIGNAL_CHANGED] = g_signal_new( + "changed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + g_cclosure_marshal_generic, + G_TYPE_NONE, + 0 + ); /** * GsweMoment:timestamp: * * The timestamp associated with this moment */ - g_object_class_install_property(gobject_class, PROP_TIMESTAMP, g_param_spec_object("timestamp", "Timestamp", "Timestamp of this moment", GSWE_TYPE_TIMESTAMP, G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_TIMESTAMP, + g_param_spec_object( + "timestamp", + "Timestamp", + "Timestamp of this moment", + GSWE_TYPE_TIMESTAMP, + G_PARAM_READWRITE + ) + ); /** * GsweMoment:coordinates: * * The geographical coordinates associated with this moment */ - g_object_class_install_property(gobject_class, PROP_COORDINATES, g_param_spec_boxed("coordinates", "Coordinates", "Geographical coordinates", GSWE_TYPE_COORDINATES, G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_COORDINATES, + g_param_spec_boxed( + "coordinates", + "Coordinates", + "Geographical coordinates", + GSWE_TYPE_COORDINATES, + G_PARAM_READWRITE + ) + ); /** * GsweMoment:house-system: * * The house system associated with this moment */ - g_object_class_install_property(gobject_class, PROP_HOUSE_SYSTEM, g_param_spec_enum("house-system", "House System", "Astrological house system", GSWE_TYPE_HOUSE_SYSTEM, GSWE_HOUSE_SYSTEM_PLACIDUS, G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_HOUSE_SYSTEM, + g_param_spec_enum( + "house-system", + "House System", + "Astrological house system", + GSWE_TYPE_HOUSE_SYSTEM, + GSWE_HOUSE_SYSTEM_PLACIDUS, + G_PARAM_READWRITE + ) + ); } static void @@ -167,8 +223,14 @@ gswe_moment_init(GsweMoment *moment) moment->priv->aspect_list = NULL; moment->priv->antiscia_list = NULL; moment->priv->moon_phase = gswe_moon_phase_data_new(); - moment->priv->element_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); - moment->priv->quality_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); + moment->priv->element_points = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, NULL + ); + moment->priv->quality_points = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, NULL + ); moment->priv->house_revision = 0; moment->priv->points_revision = 0; moment->priv->moon_phase_revision = 0; @@ -189,7 +251,11 @@ gswe_moment_dispose(GObject *gobject) { GsweMoment *moment = GSWE_MOMENT(gobject); - g_signal_handlers_disconnect_by_func(moment->priv->timestamp, gswe_moment_timestamp_changed, NULL); + g_signal_handlers_disconnect_by_func( + moment->priv->timestamp, + gswe_moment_timestamp_changed, + NULL + ); g_clear_object(&moment->priv->timestamp); @@ -201,10 +267,22 @@ gswe_moment_finalize(GObject *gobject) { GsweMoment *moment = GSWE_MOMENT(gobject); - g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref); - g_list_free_full(moment->priv->planet_list, (GDestroyNotify)gswe_planet_data_unref); - g_list_free_full(moment->priv->aspect_list, (GDestroyNotify)gswe_aspect_data_unref); - g_list_free_full(moment->priv->antiscia_list, (GDestroyNotify)gswe_antiscion_data_unref); + g_list_free_full( + moment->priv->house_list, + (GDestroyNotify)gswe_house_data_unref + ); + g_list_free_full( + moment->priv->planet_list, + (GDestroyNotify)gswe_planet_data_unref + ); + g_list_free_full( + moment->priv->aspect_list, + (GDestroyNotify)gswe_aspect_data_unref + ); + g_list_free_full( + moment->priv->antiscia_list, + (GDestroyNotify)gswe_antiscion_data_unref + ); g_object_unref(moment->priv->timestamp); gswe_moon_phase_data_unref(moment->priv->moon_phase); g_hash_table_unref(moment->priv->element_points); @@ -214,7 +292,11 @@ gswe_moment_finalize(GObject *gobject) } static void -gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gswe_moment_set_property( + GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { GsweMoment *moment = GSWE_MOMENT(object); @@ -228,7 +310,12 @@ gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GP { GsweCoordinates *coords = g_value_get_boxed(value); - gswe_moment_set_coordinates(moment, coords->longitude, coords->latitude, coords->altitude); + gswe_moment_set_coordinates( + moment, + coords->longitude, + coords->latitude, + coords->altitude + ); } break; @@ -247,7 +334,12 @@ gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GP } static void -gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gswe_moment_get_property( + GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec + ) { GsweMoment *moment = GSWE_MOMENT(object); GsweMomentPrivate *priv = moment->priv; @@ -260,7 +352,9 @@ gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSp case PROP_COORDINATES: { - GsweCoordinates *coords = gswe_coordinates_copy(&(priv->coordinates)); + GsweCoordinates *coords = gswe_coordinates_copy( + &(priv->coordinates) + ); g_value_set_boxed(value, coords); } @@ -294,14 +388,23 @@ void gswe_moment_set_timestamp(GsweMoment *moment, GsweTimestamp *timestamp) { if (moment->priv->timestamp != NULL) { - g_signal_handlers_disconnect_by_func(moment->priv->timestamp, gswe_moment_timestamp_changed, NULL); + g_signal_handlers_disconnect_by_func( + moment->priv->timestamp, + gswe_moment_timestamp_changed, + NULL + ); g_clear_object(&moment->priv->timestamp); } moment->priv->revision++; moment->priv->timestamp = timestamp; g_object_ref(timestamp); - g_signal_connect(G_OBJECT(timestamp), "changed", G_CALLBACK(gswe_moment_timestamp_changed), moment); + g_signal_connect( + G_OBJECT(timestamp), + "changed", + G_CALLBACK(gswe_moment_timestamp_changed), + moment + ); /* Emit the changed signal to notify registrants of the change */ gswe_moment_emit_changed(moment); @@ -338,7 +441,11 @@ gswe_moment_get_timestamp(GsweMoment *moment) * re-fetched after changing it. */ void -gswe_moment_set_coordinates(GsweMoment *moment, gdouble longitude, gdouble latitude, gdouble altitude) +gswe_moment_set_coordinates( + GsweMoment *moment, + gdouble longitude, + gdouble latitude, + gdouble altitude) { moment->priv->coordinates.longitude = longitude; moment->priv->coordinates.latitude = latitude; @@ -420,18 +527,30 @@ gswe_moment_new(void) * you want to create a *really* precise chart * @house_system: the house system you want to use * - * Creates a new GsweMoment object with the timestamp, coordinates and house system set. This is the preferred way to create a GsweMoment object. + * Creates a new GsweMoment object with the timestamp, coordinates and house + * system set. This is the preferred way to create a GsweMoment object. * - * Returns: (transfer full): a new GsweMoment object, which is usable out of the box + * Returns: (transfer full): a new GsweMoment object, which is usable out of + * the box */ GsweMoment * -gswe_moment_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system) +gswe_moment_new_full( + GsweTimestamp *timestamp, + gdouble longitude, + gdouble latitude, + gdouble altitude, + GsweHouseSystem house_system) { GsweMoment *moment = gswe_moment_new(); moment->priv->timestamp = timestamp; g_object_ref(timestamp); - g_signal_connect(G_OBJECT(timestamp), "changed", G_CALLBACK(gswe_moment_timestamp_changed), moment); + g_signal_connect( + G_OBJECT(timestamp), + "changed", + G_CALLBACK(gswe_moment_timestamp_changed), + moment + ); moment->priv->coordinates.longitude = longitude; moment->priv->coordinates.latitude = latitude; moment->priv->coordinates.altitude = altitude; @@ -455,14 +574,22 @@ find_planet_by_id(GswePlanetData *planet_data, GswePlanet *planet) } static void -calculate_data_by_position(GsweMoment *moment, GswePlanet planet, gdouble position, GError **err) +calculate_data_by_position( + GsweMoment *moment, + GswePlanet planet, + gdouble position, + GError **err) { GswePlanetData *planet_data; GsweZodiac sign; GsweSignInfo *sign_info; GList *result; - if ((result = g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id)) == NULL) { + if ((result = g_list_find_custom( + moment->priv->planet_list, + &planet, + (GCompareFunc)find_planet_by_id + )) == NULL) { return; } @@ -482,7 +609,10 @@ calculate_data_by_position(GsweMoment *moment, GswePlanet planet, gdouble positi sign = GSWE_SIGN_ARIES; } - if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER(sign))) == NULL) { + if ((sign_info = g_hash_table_lookup( + gswe_sign_info_table, + GINT_TO_POINTER(sign) + )) == NULL) { g_error("Calculations brought an unknown sign!"); } @@ -506,7 +636,10 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err) return; } - g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref); + g_list_free_full( + moment->priv->house_list, + (GDestroyNotify)gswe_house_data_unref + ); moment->priv->house_list = NULL; // If no house system is set, we need no calculations at all. Just leave @@ -517,8 +650,15 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err) return; } - if ((house_system_info = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(moment->priv->house_system))) == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, "Unknown house system"); + if ((house_system_info = g_hash_table_lookup( + gswe_house_system_info_table, + GINT_TO_POINTER(moment->priv->house_system) + )) == NULL) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, + "Unknown house system" + ); return; } @@ -531,7 +671,14 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err) return; } - swe_houses(jd, moment->priv->coordinates.latitude, moment->priv->coordinates.longitude, house_system_info->sweph_id, cusps, ascmc); + swe_houses( + jd, + moment->priv->coordinates.latitude, + moment->priv->coordinates.longitude, + house_system_info->sweph_id, + cusps, + ascmc + ); /* TODO: SWE house system 'G' (Gauquelin sector cusps) have 36 houses; we * should detect that somehow (house system 'G' is not implemented yet in @@ -544,17 +691,30 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err) house_data->house = i; house_data->cusp_position = cusps[i]; - if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) { - g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref); + if ((sign_info = g_hash_table_lookup( + gswe_sign_info_table, + GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)) + )) == NULL) { + g_list_free_full( + moment->priv->house_list, + (GDestroyNotify)gswe_house_data_unref + ); moment->priv->house_list = NULL; moment->priv->house_revision = 0; - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, + "Calculation brought an unknown sign" + ); return; } house_data->sign_info = gswe_sign_info_ref(sign_info); - moment->priv->house_list = g_list_prepend(moment->priv->house_list, house_data); + moment->priv->house_list = g_list_prepend( + moment->priv->house_list, + house_data + ); } moment->priv->house_revision = moment->priv->revision; @@ -562,7 +722,12 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err) // The Ascendant, MC and Vertex points are also calculated by swe_houses(), // so let's update them. if (gswe_moment_has_planet(moment, GSWE_PLANET_ASCENDANT)) { - calculate_data_by_position(moment, GSWE_PLANET_ASCENDANT, ascmc[0], err); + calculate_data_by_position( + moment, + GSWE_PLANET_ASCENDANT, + ascmc[0], + err + ); } if (gswe_moment_has_planet(moment, GSWE_PLANET_MC)) { @@ -579,9 +744,11 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err) * @moment: The GsweMoment object to operate on * @err: a #GError * - * Calculate house cusp positions based on the house system, location and time set in @moment. + * Calculate house cusp positions based on the house system, location and time + * set in @moment. * - * Returns: (element-type GsweHouseData) (transfer none): a GList of #GsweHouseData + * Returns: (element-type GsweHouseData) (transfer none): a GList of + * #GsweHouseData */ GList * gswe_moment_get_house_cusps(GsweMoment *moment, GError **err) @@ -598,14 +765,19 @@ gswe_moment_get_house_cusps(GsweMoment *moment, GError **err) * @moment: a GsweMoment * @planet: the planet whose existence is queried * - * Checks if @planet is added to @moment, e.g. its position and related data is calculated. + * Checks if @planet is added to @moment, e.g. its position and related data is + * calculated. * * Returns: #TRUE if @planet is already added to @moment, #FALSE otherwise */ gboolean gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet) { - return (g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id) != NULL); + return (g_list_find_custom( + moment->priv->planet_list, + &planet, + (GCompareFunc)find_planet_by_id + ) != NULL); } /** @@ -627,8 +799,15 @@ gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet, GError **err) return; } - if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Unknown planet"); + if ((planet_info = g_hash_table_lookup( + gswe_planet_info_table, + GINT_TO_POINTER(planet) + )) == NULL) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Unknown planet" + ); return; } @@ -637,7 +816,10 @@ gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet, GError **err) planet_data->planet_info = gswe_planet_info_ref(planet_info); planet_data->revision = 0; - moment->priv->planet_list = g_list_append(moment->priv->planet_list, planet_data); + moment->priv->planet_list = g_list_append( + moment->priv->planet_list, + planet_data + ); } static void @@ -661,9 +843,17 @@ gswe_moment_add_all_planets(GsweMoment *moment) } static void -gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err) +gswe_moment_calculate_planet( + GsweMoment *moment, + GswePlanet planet, + GError **err) { - GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id)->data); + // TODO: g_list_find_custom may return NULL here. SEGFAULT possibility! + GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom( + moment->priv->planet_list, + &planet, + (GCompareFunc)find_planet_by_id + )->data); gchar serr[AS_MAXCH]; gint ret; gdouble x2[6], @@ -678,7 +868,11 @@ gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err return; } - swe_set_topo(moment->priv->coordinates.longitude, moment->priv->coordinates.latitude, moment->priv->coordinates.altitude); + swe_set_topo( + moment->priv->coordinates.longitude, + moment->priv->coordinates.latitude, + moment->priv->coordinates.altitude + ); jd = gswe_timestamp_get_julian_day_et(moment->priv->timestamp, err); if (planet_data->planet_info->real_body == FALSE) { @@ -687,7 +881,11 @@ gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err && (planet_data->planet_info->planet != GSWE_PLANET_MC) && (planet_data->planet_info->planet != GSWE_PLANET_VERTEX) ) { - g_warning("The position data of planet %d can not be calculated by this function", planet); + g_warning( + "The position data of planet %d can not be " + "calculated by this function", + planet + ); return; } else { @@ -703,12 +901,28 @@ gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err return; } - if ((ret = swe_calc(jd, planet_data->planet_info->sweph_id, SEFLG_SPEED | SEFLG_TOPOCTR, x2, serr)) < 0) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr); + if ((ret = swe_calc( + jd, + planet_data->planet_info->sweph_id, + SEFLG_SPEED | SEFLG_TOPOCTR, + x2, + serr + )) < 0) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_SWE_FATAL, + "Swiss Ephemeris error: %s", + serr + ); return; } else if (ret != (SEFLG_SPEED | SEFLG_TOPOCTR)) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_NONFATAL, "Swiss Ephemeris error: %s", serr); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_SWE_NONFATAL, + "Swiss Ephemeris error: %s", + serr + ); } calculate_data_by_position(moment, planet, x2[0], &calc_err); @@ -728,9 +942,16 @@ static void calculate_planet(GswePlanetData *planet_data, GsweMoment *moment) { if (planet_data->planet_info) { - gswe_moment_calculate_planet(moment, planet_data->planet_info->planet, NULL); + gswe_moment_calculate_planet( + moment, + planet_data->planet_info->planet, + NULL + ); } else { - g_warning("planet_data holds no planet. This is a possible bug in SWE-GLib, or in your application."); + g_warning( + "planet_data holds no planet. This is a possible " + "bug in SWE-GLib, or in your application." + ); } } @@ -746,7 +967,8 @@ gswe_moment_calculate_all_planets(GsweMoment *moment) * * Get all the planets added to @moment. * - * Returns: (element-type GswePlanetData) (transfer none): A #GList of #GswePlanetData. + * Returns: (element-type GswePlanetData) (transfer none): A #GList of + * #GswePlanetData. */ GList * gswe_moment_get_all_planets(GsweMoment *moment) @@ -827,7 +1049,8 @@ gswe_moment_get_house_planets(GsweMoment *moment, guint house) * * Returns the number of the house in which @position is. * - * Returns: the number of the house in which @position is. This function always yields 0 if the associated house system is #GSWE_HOUSE_SYSTEM_NONE. + * Returns: the number of the house in which @position is. This function always + * yields 0 if the associated house system is #GSWE_HOUSE_SYSTEM_NONE. */ gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err) @@ -846,8 +1069,14 @@ gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err) * this should not cause trouble yet, though) */ for (i = 1; i <= 12; i++) { gint j = (i < 12) ? i + 1 : 1; - gdouble cusp_i = *(gdouble *)g_list_nth_data(moment->priv->house_list, i - 1), - cusp_j = *(gdouble *)g_list_nth_data(moment->priv->house_list, j - 1); + gdouble cusp_i = *(gdouble *)g_list_nth_data( + moment->priv->house_list, + i - 1 + ), + cusp_j = *(gdouble *)g_list_nth_data( + moment->priv->house_list, + j - 1 + ); if (cusp_j < cusp_i) { if ((position >= cusp_i) || (position < cusp_j)) { @@ -886,14 +1115,22 @@ gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err) GList *planet_element; GswePlanetData *planet_data; - if ((planet_element = g_list_find_custom(moment->priv->planet_list, &planet, (GCompareFunc)find_planet_by_id)) == NULL) { + if ((planet_element = g_list_find_custom( + moment->priv->planet_list, + &planet, + (GCompareFunc)find_planet_by_id + )) == NULL) { return NULL; } planet_data = (GswePlanetData *)(planet_element->data); if (planet_data == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Specified planet is not added to the moment object" + ); return NULL; } @@ -908,13 +1145,31 @@ add_points(GswePlanetData *planet_data, GsweMoment *moment) { guint point; - gswe_moment_calculate_planet(moment, planet_data->planet_info->planet, NULL); + gswe_moment_calculate_planet( + moment, + planet_data->planet_info->planet, + NULL + ); - point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign_info->element))) + planet_data->planet_info->points; - g_hash_table_replace(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign_info->element), GINT_TO_POINTER(point)); + point = GPOINTER_TO_INT(g_hash_table_lookup( + moment->priv->element_points, + GINT_TO_POINTER(planet_data->sign_info->element) + )) + planet_data->planet_info->points; + g_hash_table_replace( + moment->priv->element_points, + GINT_TO_POINTER(planet_data->sign_info->element), + GINT_TO_POINTER(point) + ); - point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign_info->quality))) + planet_data->planet_info->points; - g_hash_table_replace(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign_info->quality), GINT_TO_POINTER(point)); + point = GPOINTER_TO_INT(g_hash_table_lookup( + moment->priv->quality_points, + GINT_TO_POINTER(planet_data->sign_info->quality) + )) + planet_data->planet_info->points; + g_hash_table_replace( + moment->priv->quality_points, + GINT_TO_POINTER(planet_data->sign_info->quality), + GINT_TO_POINTER(point) + ); } static void @@ -948,7 +1203,10 @@ gswe_moment_get_element_points(GsweMoment *moment, GsweElement element) gswe_moment_calculate_points(moment); - point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(element))); + point = GPOINTER_TO_INT(g_hash_table_lookup( + moment->priv->element_points, + GINT_TO_POINTER(element) + )); return point; } @@ -969,7 +1227,10 @@ gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality) gswe_moment_calculate_points(moment); - point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(quality))); + point = GPOINTER_TO_INT(g_hash_table_lookup( + moment->priv->quality_points, + GINT_TO_POINTER(quality) + )); return point; } @@ -981,7 +1242,8 @@ gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality) * * Gets the phase of the Moon. * - * Returns: (transfer full): a #GsweMoonPhaseData representing the phase of the Moon + * Returns: (transfer full): a #GsweMoonPhaseData representing the phase of the + * Moon */ GsweMoonPhaseData * gswe_moment_get_moon_phase(GsweMoment *moment, GError **err) @@ -990,7 +1252,11 @@ gswe_moment_get_moon_phase(GsweMoment *moment, GError **err) return moment->priv->moon_phase; } - gswe_moon_phase_data_calculate_by_timestamp(moment->priv->moon_phase, moment->priv->timestamp, err); + gswe_moon_phase_data_calculate_by_timestamp( + moment->priv->moon_phase, + moment->priv->timestamp, + err + ); if (!err || !*err) { moment->priv->moon_phase_revision = moment->priv->revision; @@ -1000,7 +1266,9 @@ gswe_moment_get_moon_phase(GsweMoment *moment, GError **err) } static gint -find_aspect_by_both_planets(GsweAspectData *aspect, struct GsweAspectFinder *aspect_finder) +find_aspect_by_both_planets( + GsweAspectData *aspect, + struct GsweAspectFinder *aspect_finder) { if ( ( @@ -1029,29 +1297,50 @@ gswe_moment_calculate_aspects(GsweMoment *moment) } gswe_moment_calculate_all_planets(moment); - g_list_free_full(moment->priv->aspect_list, (GDestroyNotify)gswe_aspect_data_unref); + g_list_free_full( + moment->priv->aspect_list, + (GDestroyNotify)gswe_aspect_data_unref + ); moment->priv->aspect_list = NULL; - for (oplanet = moment->priv->planet_list; oplanet; oplanet = g_list_next(oplanet)) { - for (iplanet = moment->priv->planet_list; iplanet; iplanet = g_list_next(iplanet)) { + for ( + oplanet = moment->priv->planet_list; + oplanet; + oplanet = g_list_next(oplanet)) { + for ( + iplanet = moment->priv->planet_list; + iplanet; + iplanet = g_list_next(iplanet)) { GswePlanetData *outer_planet = oplanet->data, *inner_planet = iplanet->data; struct GsweAspectFinder aspect_finder; GsweAspectData *aspect_data; GList *aspect_data_element; - if (outer_planet->planet_info->planet == inner_planet->planet_info->planet) { + if (outer_planet->planet_info->planet + == inner_planet->planet_info->planet + ) { continue; } aspect_finder.planet1 = outer_planet->planet_info->planet; aspect_finder.planet2 = inner_planet->planet_info->planet; - if ((aspect_data_element = g_list_find_custom(moment->priv->aspect_list, &aspect_finder, (GCompareFunc)find_aspect_by_both_planets)) != NULL) { + if ((aspect_data_element = g_list_find_custom( + moment->priv->aspect_list, + &aspect_finder, + (GCompareFunc)find_aspect_by_both_planets + )) != NULL) { gswe_aspect_data_calculate(aspect_data_element->data); } else { - aspect_data = gswe_aspect_data_new_with_planets(inner_planet, outer_planet); - moment->priv->aspect_list = g_list_prepend(moment->priv->aspect_list, aspect_data); + aspect_data = gswe_aspect_data_new_with_planets( + inner_planet, + outer_planet + ); + moment->priv->aspect_list = g_list_prepend( + moment->priv->aspect_list, + aspect_data + ); } } } @@ -1094,20 +1383,31 @@ gswe_moment_get_all_aspects(GsweMoment *moment) * returns NULL. */ GList * -gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **err) +gswe_moment_get_planet_aspects( + GsweMoment *moment, + GswePlanet planet, + GError **err) { GList *ret = NULL, *aspect; if (!gswe_moment_has_planet(moment, planet)) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Specified planet is not added to the moment object" + ); return NULL; } gswe_moment_calculate_aspects(moment); - for (aspect = moment->priv->aspect_list; aspect; aspect = g_list_next(aspect)) { + for ( + aspect = moment->priv->aspect_list; + aspect; + aspect = g_list_next(aspect) + ) { GsweAspectData *aspect_data = aspect->data; if ( @@ -1137,13 +1437,24 @@ gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **e * accordingly. */ GsweAspectData * -gswe_moment_get_aspect_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err) +gswe_moment_get_aspect_by_planets( + GsweMoment *moment, + GswePlanet planet1, + GswePlanet planet2, + GError **err) { struct GsweAspectFinder aspect_finder; GList *aspect_data_element; - if (!gswe_moment_has_planet(moment, planet1) || !gswe_moment_has_planet(moment, planet2)) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "One of the requested planets is not found in the planet list"); + if ( + !gswe_moment_has_planet(moment, planet1) + || !gswe_moment_has_planet(moment, planet2) + ) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "One of the requested planets is not found in the planet list" + ); return NULL; } @@ -1151,7 +1462,11 @@ gswe_moment_get_aspect_by_planets(GsweMoment *moment, GswePlanet planet1, GswePl aspect_finder.planet1 = planet1; aspect_finder.planet2 = planet2; - if ((aspect_data_element = g_list_find_custom(moment->priv->aspect_list, &aspect_finder, (GCompareFunc)find_aspect_by_both_planets)) != NULL) { + if ((aspect_data_element = g_list_find_custom( + moment->priv->aspect_list, + &aspect_finder, + (GCompareFunc)find_aspect_by_both_planets + )) != NULL) { return aspect_data_element->data; } @@ -1159,16 +1474,22 @@ gswe_moment_get_aspect_by_planets(GsweMoment *moment, GswePlanet planet1, GswePl } static gint -find_antiscion_by_both_planets(GsweAntiscionData *antiscion, struct GsweAspectFinder *antiscion_finder) +find_antiscion_by_both_planets( + GsweAntiscionData *antiscion, + struct GsweAspectFinder *antiscion_finder) { if ( ( - (antiscion->planet1->planet_info->planet == antiscion_finder->planet1) - && (antiscion->planet2->planet_info->planet == antiscion_finder->planet2) + (antiscion->planet1->planet_info->planet + == antiscion_finder->planet1) + && (antiscion->planet2->planet_info->planet + == antiscion_finder->planet2) ) || ( - (antiscion->planet1->planet_info->planet == antiscion_finder->planet2) - && (antiscion->planet2->planet_info->planet == antiscion_finder->planet1) + (antiscion->planet1->planet_info->planet + == antiscion_finder->planet2) + && (antiscion->planet2->planet_info->planet + == antiscion_finder->planet1) ) ) { return 0; @@ -1188,29 +1509,52 @@ gswe_moment_calculate_antiscia(GsweMoment *moment) } gswe_moment_calculate_all_planets(moment); - g_list_free_full(moment->priv->antiscia_list, (GDestroyNotify)gswe_antiscion_data_unref); + g_list_free_full( + moment->priv->antiscia_list, + (GDestroyNotify)gswe_antiscion_data_unref + ); moment->priv->antiscia_list = NULL; - for (oplanet = moment->priv->planet_list; oplanet; oplanet = g_list_next(oplanet)) { - for (iplanet = moment->priv->planet_list; iplanet; iplanet = g_list_next(iplanet)) { + for ( + oplanet = moment->priv->planet_list; + oplanet; + oplanet = g_list_next(oplanet) + ) { + for ( + iplanet = moment->priv->planet_list; + iplanet; + iplanet = g_list_next(iplanet) + ) { GswePlanetData *outer_planet = oplanet->data, *inner_planet = iplanet->data; struct GsweAspectFinder antiscion_finder; GsweAntiscionData *antiscion_data; GList *antiscion_data_element; - if (outer_planet->planet_info->planet == inner_planet->planet_info->planet) { + if (outer_planet->planet_info->planet + == inner_planet->planet_info->planet + ) { continue; } antiscion_finder.planet1 = outer_planet->planet_info->planet; antiscion_finder.planet2 = inner_planet->planet_info->planet; - if ((antiscion_data_element = g_list_find_custom(moment->priv->antiscia_list, &antiscion_finder, (GCompareFunc)find_antiscion_by_both_planets)) != NULL) { + if ((antiscion_data_element = g_list_find_custom( + moment->priv->antiscia_list, + &antiscion_finder, + (GCompareFunc)find_antiscion_by_both_planets) + ) != NULL) { gswe_antiscion_data_calculate(antiscion_data_element->data); } else { - antiscion_data = gswe_antiscion_data_new_with_planets(inner_planet, outer_planet); - moment->priv->antiscia_list = g_list_prepend(moment->priv->antiscia_list, antiscion_data); + antiscion_data = gswe_antiscion_data_new_with_planets( + inner_planet, + outer_planet + ); + moment->priv->antiscia_list = g_list_prepend( + moment->priv->antiscia_list, + antiscion_data + ); } } } @@ -1250,13 +1594,20 @@ gswe_moment_get_all_antiscia(GsweMoment *moment) * @moment, returns NULL. */ GList * -gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err) +gswe_moment_get_all_planet_antiscia( + GsweMoment *moment, + GswePlanet planet, + GError **err) { GList *ret = NULL, *antiscion_l; if (!gswe_moment_has_planet(moment, planet)) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Specified planet is not added to the moment object" + ); return NULL; } @@ -1266,7 +1617,10 @@ gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GErro glforeach (antiscion_l, moment->priv->antiscia_list) { GsweAntiscionData *antiscion_data = antiscion_l->data; - if ((antiscion_data->planet1->planet_info->planet == planet) || (antiscion_data->planet2->planet_info->planet == planet)) { + if ( + (antiscion_data->planet1->planet_info->planet == planet) + || (antiscion_data->planet2->planet_info->planet == planet) + ) { ret = g_list_prepend(ret, antiscion_data); } } @@ -1282,9 +1636,9 @@ gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GErro * Get all the antiscion planets on the specified axis @axis. * * Returns: (element-type GsweAntiscionData) (transfer container): a #GList of - * #GsweAntiscionData. The GsweAntiscionData structures belong to @moment, - * but the GList should be freed using g_list_free(). If there are - * no antiscion planets on the given axis, returns NULL. + * #GsweAntiscionData. The GsweAntiscionData structures belong to + * @moment, but the GList should be freed using g_list_free(). If + * there are no antiscion planets on the given axis, returns NULL. */ GList * gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis) @@ -1315,19 +1669,27 @@ gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis) * Get the antiscion planets of @planet as seen in @axis. * * Returns: (element-type GsweAntiscionData) (transfer container): a #GList of - * #GsweAntiscionData. The GsweAntiscionData structires belong to @moment, - * but the GList should be freed using g_list_free(). If the planet - * has no antiscia, or the planet has not been added to @moment, - * returns NULL. + * #GsweAntiscionData. The GsweAntiscionData structires belong to + * @moment, but the GList should be freed using g_list_free(). If the + * planet has no antiscia, or the planet has not been added to + * @moment, returns NULL. */ GList * -gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err) +gswe_moment_get_axis_planet_antiscia( + GsweMoment *moment, + GsweAntiscionAxis axis, + GswePlanet planet, + GError **err) { GList *ret = NULL, *antiscion_l; if (!gswe_moment_has_planet(moment, planet)) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Specified planet is not added to the moment object"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Specified planet is not added to the moment object" + ); return NULL; } @@ -1367,13 +1729,24 @@ gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, * accordingly. */ GsweAntiscionData * -gswe_moment_get_antiscion_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err) +gswe_moment_get_antiscion_by_planets( + GsweMoment *moment, + GswePlanet planet1, + GswePlanet planet2, + GError **err) { struct GsweAspectFinder antiscion_finder; GList *antiscion_data_element; - if (!gswe_moment_has_planet(moment, planet1) || !gswe_moment_has_planet(moment, planet2)) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "One of the planets is not found in the planet list"); + if ( + !gswe_moment_has_planet(moment, planet1) + || !gswe_moment_has_planet(moment, planet2) + ) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "One of the planets is not found in the planet list" + ); return NULL; } @@ -1381,7 +1754,11 @@ gswe_moment_get_antiscion_by_planets(GsweMoment *moment, GswePlanet planet1, Gsw antiscion_finder.planet1 = planet1; antiscion_finder.planet2 = planet2; - if ((antiscion_data_element = g_list_find_custom(moment->priv->antiscia_list, &antiscion_finder, (GCompareFunc)find_antiscion_by_both_planets)) != NULL) { + if ((antiscion_data_element = g_list_find_custom( + moment->priv->antiscia_list, + &antiscion_finder, + (GCompareFunc)find_antiscion_by_both_planets + )) != NULL) { return antiscion_data_element->data; } diff --git a/src/gswe-moment.h b/src/gswe-moment.h index 9909cf4..8d6a4fd 100644 --- a/src/gswe-moment.h +++ b/src/gswe-moment.h @@ -26,11 +26,24 @@ #include "gswe-types.h" #define GSWE_TYPE_MOMENT (gswe_moment_get_type()) -#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment)) -#define GSWE_IS_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_MOMENT)) -#define GSWE_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_MOMENT, GsweMomentClass)) -#define GSWE_IS_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_MOMENT)) -#define GSWE_MOMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_MOMENT, GsweMomentClass)) +#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST( \ + (obj), \ + GSWE_TYPE_MOMENT, \ + GsweMoment)) +#define GSWE_IS_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE( \ + (obj), \ + GSWE_TYPE_MOMENT)) +#define GSWE_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST( \ + (klass), \ + GSWE_TYPE_MOMENT, \ + GsweMomentClass)) +#define GSWE_IS_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE( \ + (klass), \ + GSWE_TYPE_MOMENT)) +#define GSWE_MOMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS( \ + (obj), \ + GSWE_TYPE_MOMENT, \ + GsweMomentClass)) typedef struct _GsweMoment GsweMoment; typedef struct _GsweMomentClass GsweMomentClass; @@ -90,42 +103,97 @@ GType gswe_moment_get_type(void); /* Method definitions */ GsweMoment *gswe_moment_new(void); -GsweMoment *gswe_moment_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system); + +GsweMoment *gswe_moment_new_full( + GsweTimestamp *timestamp, + gdouble longitude, + gdouble latitude, + gdouble altitude, + GsweHouseSystem house_system); void gswe_moment_set_timestamp(GsweMoment *moment, GsweTimestamp *timestamp); + GsweTimestamp *gswe_moment_get_timestamp(GsweMoment *moment); -void gswe_moment_set_coordinates(GsweMoment *moment, gdouble longitude, gdouble latitude, gdouble altitude); +void gswe_moment_set_coordinates( + GsweMoment *moment, + gdouble longitude, + gdouble latitude, + gdouble altitude); + GsweCoordinates *gswe_moment_get_coordinates(GsweMoment *moment); -void gswe_moment_set_house_system(GsweMoment *moment, GsweHouseSystem house_system); +void gswe_moment_set_house_system( + GsweMoment *moment, + GsweHouseSystem house_system); + GsweHouseSystem gswe_moment_get_house_system(GsweMoment *moment); GList *gswe_moment_get_house_cusps(GsweMoment *moment, GError **err); + gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err); gboolean gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet); -void gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet, GError **err); + +void gswe_moment_add_planet( + GsweMoment *moment, + GswePlanet planet, + GError **err); + void gswe_moment_add_all_planets(GsweMoment *moment); + GList *gswe_moment_get_all_planets(GsweMoment *moment); -GswePlanetData *gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err); + +GswePlanetData *gswe_moment_get_planet( + GsweMoment *moment, + GswePlanet planet, + GError **err); + GList *gswe_moment_get_sign_planets(GsweMoment *moment, GsweZodiac sign); + GList *gswe_moment_get_house_planets(GsweMoment *moment, guint house); guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element); + guint gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality); GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment, GError **err); GList *gswe_moment_get_all_aspects(GsweMoment *moment); -GList *gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **err); -GsweAspectData *gswe_moment_get_aspect_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err); + +GList *gswe_moment_get_planet_aspects( + GsweMoment *moment, + GswePlanet planet, + GError **err); + +GsweAspectData *gswe_moment_get_aspect_by_planets( + GsweMoment *moment, + GswePlanet planet1, + GswePlanet planet2, + GError **err); GList *gswe_moment_get_all_antiscia(GsweMoment *moment); -GList *gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GError **err); -GList *gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis); -GList *gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err); -GsweAntiscionData *gswe_moment_get_antiscion_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err); + +GList *gswe_moment_get_all_planet_antiscia( + GsweMoment *moment, + GswePlanet planet, + GError **err); + +GList *gswe_moment_get_axis_all_antiscia( + GsweMoment *moment, + GsweAntiscionAxis axis); + +GList *gswe_moment_get_axis_planet_antiscia( + GsweMoment *moment, + GsweAntiscionAxis axis, + GswePlanet planet, + GError **err); + +GsweAntiscionData *gswe_moment_get_antiscion_by_planets( + GsweMoment *moment, + GswePlanet planet1, + GswePlanet planet2, + GError **err); #endif /* __GSWE_MOMENT_H__ */ diff --git a/src/gswe-moon-phase-data.c b/src/gswe-moon-phase-data.c index 1faabf8..62029f5 100644 --- a/src/gswe-moon-phase-data.c +++ b/src/gswe-moon-phase-data.c @@ -38,7 +38,11 @@ * Moon, including its illumination percentage. */ -G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_ref, (GBoxedFreeFunc)gswe_moon_phase_data_unref); +G_DEFINE_BOXED_TYPE( + GsweMoonPhaseData, + gswe_moon_phase_data, + (GBoxedCopyFunc)gswe_moon_phase_data_ref, + (GBoxedFreeFunc)gswe_moon_phase_data_unref); /** * gswe_moon_phase_data_new: @@ -78,7 +82,8 @@ gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data) * gswe_moon_phase_data_unref: * @moon_phase_data: (in): a #GsweMoonPhaseData * - * Decreases reference count on @moon_phase_data by one. If reference count drops to zero, @moon_phase_data is freed. + * Decreases reference count on @moon_phase_data by one. If reference count + * drops to zero, @moon_phase_data is freed. */ void gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data) @@ -97,7 +102,10 @@ gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data) * Calculates the moon at a given time, specified by @jd. */ void -gswe_moon_phase_data_calculate_by_jd(GsweMoonPhaseData *moon_phase_data, gdouble jd, GError **err) +gswe_moon_phase_data_calculate_by_jd( + GsweMoonPhaseData *moon_phase_data, + gdouble jd, + GError **err) { gdouble jdb, phase_percent; @@ -148,7 +156,10 @@ gswe_moon_phase_data_calculate_by_jd(GsweMoonPhaseData *moon_phase_data, gdouble * Calculates the moon at a given time, specified by @timestamp. */ void -gswe_moon_phase_data_calculate_by_timestamp(GsweMoonPhaseData *moon_phase_data, GsweTimestamp *timestamp, GError **err) +gswe_moon_phase_data_calculate_by_timestamp( + GsweMoonPhaseData *moon_phase_data, + GsweTimestamp *timestamp, + GError **err) { gdouble jd; diff --git a/src/gswe-moon-phase-data.h b/src/gswe-moon-phase-data.h index 68c943f..8a3dd08 100644 --- a/src/gswe-moon-phase-data.h +++ b/src/gswe-moon-phase-data.h @@ -28,8 +28,8 @@ G_BEGIN_DECLS /** * GsweMoonPhaseData: * - * GsweMoonPhaseData is an opaque structure whose members - * cannot be accessed directly. + * GsweMoonPhaseData is an opaque structure whose + * members cannot be accessed directly. * * Since: 1.1 */ @@ -38,13 +38,24 @@ typedef struct _GsweMoonPhaseData GsweMoonPhaseData; GsweMoonPhaseData *gswe_moon_phase_data_new(void); GsweMoonPhaseData *gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data); + void gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data); -void gswe_moon_phase_data_calculate_by_jd(GsweMoonPhaseData *moon_phase_data, gdouble jd, GError **err); -void gswe_moon_phase_data_calculate_by_timestamp(GsweMoonPhaseData *moon_phase_data, GsweTimestamp *timestamp, GError **err); +void gswe_moon_phase_data_calculate_by_jd( + GsweMoonPhaseData *moon_phase_data, + gdouble jd, + GError **err); -GsweMoonPhase gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data); -gdouble gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data); +void gswe_moon_phase_data_calculate_by_timestamp( + GsweMoonPhaseData *moon_phase_data, + GsweTimestamp *timestamp, + GError **err); + +GsweMoonPhase gswe_moon_phase_data_get_phase( + GsweMoonPhaseData *moon_phase_data); + +gdouble gswe_moon_phase_data_get_illumination( + GsweMoonPhaseData *moon_phase_data); GType gswe_moon_phase_data_get_type(void); #define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type()) diff --git a/src/gswe-planet-data-private.h b/src/gswe-planet-data-private.h index 72197f9..d625543 100644 --- a/src/gswe-planet-data-private.h +++ b/src/gswe-planet-data-private.h @@ -35,7 +35,8 @@ struct _GswePlanetData { /* Number of the house in which the planet is in */ gint house; - /* A GsweSignInfo structure, holding every information about the sign the planet is in */ + /* A GsweSignInfo structure, holding every information about the sign the + * planet is in */ GsweSignInfo *sign_info; /* An internal version number of the calculation */ diff --git a/src/gswe-planet-data.c b/src/gswe-planet-data.c index 4a9c23e..11c47ed 100644 --- a/src/gswe-planet-data.c +++ b/src/gswe-planet-data.c @@ -35,7 +35,11 @@ * is in. */ -G_DEFINE_BOXED_TYPE(GswePlanetData, gswe_planet_data, (GBoxedCopyFunc)gswe_planet_data_ref, (GBoxedFreeFunc)gswe_planet_data_unref); +G_DEFINE_BOXED_TYPE( + GswePlanetData, + gswe_planet_data, + (GBoxedCopyFunc)gswe_planet_data_ref, + (GBoxedFreeFunc)gswe_planet_data_unref); static void gswe_planet_data_free(GswePlanetData *planet_data) @@ -89,7 +93,8 @@ gswe_planet_data_ref(GswePlanetData *planet_data) * gswe_planet_data_unref: * @planet_data: a #GswePlanetData * - * Decreases reference count on @planet_data by one. If reference count drops to zero, @planet_data is freed. + * Decreases reference count on @planet_data by one. If reference count drops + * to zero, @planet_data is freed. */ void gswe_planet_data_unref(GswePlanetData *planet_data) @@ -110,12 +115,21 @@ gswe_planet_data_unref(GswePlanetData *planet_data) * GSWE_ERROR_UNKNOWN_PLANET, and the planet ID is not set. */ void -gswe_planet_data_set_planet(GswePlanetData *planet_data, GswePlanet planet, GError **err) +gswe_planet_data_set_planet( + GswePlanetData *planet_data, + GswePlanet planet, + GError **err) { GswePlanetInfo *planet_info; - if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Planet is unknown"); + if ((planet_info = g_hash_table_lookup( + gswe_planet_info_table, + GINT_TO_POINTER(planet) + )) == NULL) { + g_set_error(err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Planet is unknown" + ); return; } @@ -157,7 +171,9 @@ gswe_planet_data_get_planet(GswePlanetData *planet_data) * Sets @planet_info as the planet information for @planet_data. */ void -gswe_planet_data_set_planet_info(GswePlanetData *planet_data, GswePlanetInfo *planet_info) +gswe_planet_data_set_planet_info( + GswePlanetData *planet_data, + GswePlanetInfo *planet_info) { if (planet_data == NULL) { return; @@ -247,7 +263,8 @@ gswe_planet_data_get_house(GswePlanetData *planet_data) * gswe_planet_data_get_sign: * @planet_data: a #GswePlanetData * - * Gets the zodiac sign in which the planet is currently in. If the planet's data is not calculated yet, this function yields GSWE_PLANET_NONE. + * Gets the zodiac sign in which the planet is currently in. If the planet's + * data is not calculated yet, this function yields GSWE_PLANET_NONE. * * Returns: a #GsweZodiac, which @planet_data is currently in */ diff --git a/src/gswe-planet-data.h b/src/gswe-planet-data.h index ac4dd9e..0cfb669 100644 --- a/src/gswe-planet-data.h +++ b/src/gswe-planet-data.h @@ -42,18 +42,30 @@ GType gswe_planet_data_get_type(void); GswePlanetData *gswe_planet_data_new(void); GswePlanetData *gswe_planet_data_ref(GswePlanetData *planet_data); + void gswe_planet_data_unref(GswePlanetData *planet_data); -void gswe_planet_data_set_planet(GswePlanetData *planet_data, GswePlanet planet, GError **err); +void gswe_planet_data_set_planet( + GswePlanetData *planet_data, + GswePlanet planet, + GError **err); + GswePlanet gswe_planet_data_get_planet(GswePlanetData *planet_data); -void gswe_planet_data_set_planet_info(GswePlanetData *planet_data, GswePlanetInfo *planet_info); +void gswe_planet_data_set_planet_info( + GswePlanetData *planet_data, + GswePlanetInfo *planet_info); + GswePlanetInfo *gswe_planet_data_get_planet_info(GswePlanetData *planet_data); gdouble gswe_planet_data_get_position(GswePlanetData *planet_data); + gboolean gswe_planet_data_get_retrograde(GswePlanetData *planet_data); + guint gswe_planet_data_get_house(GswePlanetData *planet_data); + GsweZodiac gswe_planet_data_get_sign(GswePlanetData *planet_data); + GsweSignInfo *gswe_planet_data_get_sign_info(GswePlanetData *planet_data); G_END_DECLS diff --git a/src/gswe-planet-info-private.h b/src/gswe-planet-info-private.h index aed7909..606382a 100644 --- a/src/gswe-planet-info-private.h +++ b/src/gswe-planet-info-private.h @@ -26,10 +26,13 @@ struct _GswePlanetInfo { /* the planet ID */ GswePlanet planet; - /* the planet ID according to the Swiss Ephemeris libarary (or -1, if the planet has no such ID) */ + /* the planet ID according to the Swiss Ephemeris libarary (or -1, if the + * planet has no such ID) */ gint32 sweph_id; - /* TRUE if the planet is a "real" celestial body on the sky. Please note that this will be true for Dark Moon (Lilith). Everything that has a planet ID in Swiss Ephemeris is treated as a real celestial body. */ + /* TRUE if the planet is a "real" celestial body on the sky. Please note + * that this will be true for Dark Moon (Lilith). Everything that has a + * planet ID in Swiss Ephemeris is treated as a real celestial body. */ gboolean real_body; /* the planet's “personal” orb */ diff --git a/src/gswe-planet-info.c b/src/gswe-planet-info.c index 4916816..b9da1c7 100644 --- a/src/gswe-planet-info.c +++ b/src/gswe-planet-info.c @@ -30,7 +30,11 @@ * The #GswePlanetInfo structure stores information about a planet. */ -G_DEFINE_BOXED_TYPE(GswePlanetInfo, gswe_planet_info, (GBoxedCopyFunc)gswe_planet_info_ref, (GBoxedFreeFunc)gswe_planet_info_unref); +G_DEFINE_BOXED_TYPE( + GswePlanetInfo, + gswe_planet_info, + (GBoxedCopyFunc)gswe_planet_info_ref, + (GBoxedFreeFunc)gswe_planet_info_unref); /** * gswe_planet_info_new: @@ -80,7 +84,8 @@ gswe_planet_info_free(GswePlanetInfo *planet_info) * gswe_planet_info_unref: * @planet_info: a #GswePlanetInfo * - * Decreases reference count on @planet_info. If reference count reaches zero, @planet_info is freed. + * Decreases reference count on @planet_info. If reference count reaches zero, + * @planet_info is freed. */ void gswe_planet_info_unref(GswePlanetInfo *planet_info) @@ -150,7 +155,8 @@ gswe_planet_info_get_sweph_id(GswePlanetInfo *planet_info) * @real_body: a boolean that indicates if this planet is an object recognized * by Swiss Ephemeris * - * Sets whether this planet is an object recognized by the Swiss Ephemeris library. + * Sets whether this planet is an object recognized by the Swiss Ephemeris + * library. */ void gswe_planet_info_set_real_body(GswePlanetInfo *planet_info, gboolean real_body) @@ -162,7 +168,8 @@ gswe_planet_info_set_real_body(GswePlanetInfo *planet_info, gboolean real_body) * gswe_planet_info_get_real_body: * @planet_info: (in): A #GswePlanetInfo * - * Checks weather this planet is a real celestial body (e.g. it has a Swiss Ephemeris planet ID) or not. + * Checks weather this planet is a real celestial body (e.g. it has a Swiss + * Ephemeris planet ID) or not. * * Returns: TRUE if the planet has a Swiss Ephemeris planet ID; FALSE otherwise */ @@ -236,7 +243,8 @@ gswe_planet_info_get_name(GswePlanetInfo *planet_info) * @planet_info: a #GswePlanetInfo * @points: the new point value * - * Sets the point value of @planet_info. This value is used in points calculations. + * Sets the point value of @planet_info. This value is used in points + * calculations. */ void gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points) diff --git a/src/gswe-planet-info.h b/src/gswe-planet-info.h index 5e1e26f..f1f01d7 100644 --- a/src/gswe-planet-info.h +++ b/src/gswe-planet-info.h @@ -40,24 +40,37 @@ GType gswe_planet_info_get_type(void); GswePlanetInfo *gswe_planet_info_new(void); GswePlanetInfo *gswe_planet_info_ref(GswePlanetInfo *planet_info); + void gswe_planet_info_unref(GswePlanetInfo *planet_info); -void gswe_planet_info_set_planet(GswePlanetInfo *planet_info, GswePlanet planet); +void gswe_planet_info_set_planet( + GswePlanetInfo *planet_info, + GswePlanet planet); + GswePlanet gswe_planet_info_get_planet(GswePlanetInfo *planet_info); -void gswe_planet_info_set_sweph_id(GswePlanetInfo *planet_info, gint32 sweph_id); +void gswe_planet_info_set_sweph_id( + GswePlanetInfo *planet_info, + gint32 sweph_id); + gint32 gswe_planet_info_get_sweph_id(GswePlanetInfo *planet_info); -void gswe_planet_info_set_real_body(GswePlanetInfo *planet_info, gboolean real_body); +void gswe_planet_info_set_real_body( + GswePlanetInfo *planet_info, + gboolean real_body); + gboolean gswe_planet_info_get_real_body(GswePlanetInfo *planet_info); void gswe_planet_info_set_orb(GswePlanetInfo *planet_info, gdouble orb); + gdouble gswe_planet_info_get_orb(GswePlanetInfo *planet_info); void gswe_planet_info_set_name(GswePlanetInfo *planet_info, const gchar *name); + const gchar *gswe_planet_info_get_name(GswePlanetInfo *planet_info); void gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points); + gint gswe_planet_info_get_points(GswePlanetInfo *planet_info); G_END_DECLS diff --git a/src/gswe-sign-info.c b/src/gswe-sign-info.c index c2ca1d8..3a963ed 100644 --- a/src/gswe-sign-info.c +++ b/src/gswe-sign-info.c @@ -30,7 +30,10 @@ * The #GsweSignInfo stores information about a zodiac sign. */ -G_DEFINE_BOXED_TYPE(GsweSignInfo, gswe_sign_info, (GBoxedCopyFunc)gswe_sign_info_ref, (GBoxedFreeFunc)gswe_sign_info_unref); +G_DEFINE_BOXED_TYPE(GsweSignInfo, + gswe_sign_info, + (GBoxedCopyFunc)gswe_sign_info_ref, + (GBoxedFreeFunc)gswe_sign_info_unref); static void gswe_sign_info_free(GsweSignInfo *sign_info) @@ -80,7 +83,8 @@ gswe_sign_info_ref(GsweSignInfo *sign_info) * gswe_sign_info_unref: * @sign_info: a #GsweSignInfo * - * Decreases reference count or @sign_info. If reference count reaches zero, @sign_info is freed. + * Decreases reference count or @sign_info. If reference count reaches zero, + * @sign_info is freed. */ void gswe_sign_info_unref(GsweSignInfo *sign_info) diff --git a/src/gswe-timestamp.c b/src/gswe-timestamp.c index 9f255e5..7f53e24 100644 --- a/src/gswe-timestamp.c +++ b/src/gswe-timestamp.c @@ -34,7 +34,11 @@ * This object converts Gregorian dates to Julian days and vice versa. */ -#define GSWE_TIMESTAMP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSWE_TYPE_TIMESTAMP, GsweTimestampPrivate)) +#define GSWE_TIMESTAMP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE( \ + (obj), \ + GSWE_TYPE_TIMESTAMP, \ + GsweTimestampPrivate \ + )) typedef enum { VALID_GREGORIAN = 1 << 0, @@ -80,13 +84,35 @@ enum { static guint gswe_timestamp_signals[SIGNAL_LAST] = { 0 }; -static void gswe_timestamp_dispose(GObject *gobject); -static void gswe_timestamp_finalize(GObject *gobject); -static void gswe_timestamp_set_property(GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gswe_timestamp_get_property(GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec); -static void gswe_timestamp_calculate_all(GsweTimestamp *timestamp, GError **err); -static void gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err); -static void gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err); +static void gswe_timestamp_dispose( + GObject *gobject); + +static void gswe_timestamp_finalize( + GObject *gobject); + +static void gswe_timestamp_set_property( + GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + +static void gswe_timestamp_get_property( + GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +static void gswe_timestamp_calculate_all( + GsweTimestamp *timestamp, + GError **err); + +static void gswe_timestamp_calculate_gregorian( + GsweTimestamp *timestamp, + GError **err); + +static void gswe_timestamp_calculate_julian( + GsweTimestamp *timestamp, + GError **err); G_DEFINE_TYPE(GsweTimestamp, gswe_timestamp, G_TYPE_OBJECT); @@ -109,7 +135,12 @@ gswe_timestamp_class_init(GsweTimestampClass *klass) * * The ::changed signal is emitted each time the timestamp is changed */ - gswe_timestamp_signals[SIGNAL_CHANGED] = g_signal_new("changed", G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0); + gswe_timestamp_signals[SIGNAL_CHANGED] = g_signal_new( + "changed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_generic, G_TYPE_NONE, 0); /** * GsweTimestamp:instant-recalc: @@ -119,7 +150,16 @@ gswe_timestamp_class_init(GsweTimestampClass *klass) * Otherwise, the values are recalculated only upon request (e.g. on * calling gswe_timestamp_get_julian_day()). */ - g_object_class_install_property(gobject_class, PROP_INSTANT_RECALC, g_param_spec_boolean("instant-recalc", "Instant recalculation", "Instantly recalculate values upon parameter change", FALSE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_INSTANT_RECALC, + g_param_spec_boolean( + "instant-recalc", + "Instant recalculation", + "Instantly recalculate values upon parameter change", + FALSE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-valid: @@ -129,56 +169,136 @@ gswe_timestamp_class_init(GsweTimestampClass *klass) * Otherwise, the Gregorian date components will be recalculated upon * request. */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_VALID, g_param_spec_boolean("gregorian-valid", "Gregorian date is valid", "TRUE if the Gregorian date components are considered as valid.", TRUE, G_PARAM_READABLE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_VALID, + g_param_spec_boolean( + "gregorian-valid", + "Gregorian date is valid", + "TRUE if the Gregorian date components " + "are considered as valid.", + TRUE, G_PARAM_READABLE + ) + ); /** * GsweTimestamp:gregorian-year: * * The Gregorian year of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_YEAR, g_param_spec_int("gregorian-year", "Gregorian year", "The year according to the Gregorian calendar", G_MININT, G_MAXINT, g_date_time_get_year(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_YEAR, + g_param_spec_int( + "gregorian-year", + "Gregorian year", + "The year according to the Gregorian calendar", + G_MININT, G_MAXINT, g_date_time_get_year(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-month: * * The Gregorian month of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_MONTH, g_param_spec_int("gregorian-month", "Gregorian month", "The month according to the Gregorian calendar", 1, 12, g_date_time_get_month(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_MONTH, + g_param_spec_int( + "gregorian-month", + "Gregorian month", + "The month according to the Gregorian calendar", + 1, 12, g_date_time_get_month(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-day: * * The Gregorian day of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_DAY, g_param_spec_int("gregorian-day", "Gregorian day", "The day according to the Gregorian calendar", 1, 31, g_date_time_get_day_of_month(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_DAY, + g_param_spec_int( + "gregorian-day", + "Gregorian day", + "The day according to the Gregorian calendar", + 1, 31, g_date_time_get_day_of_month(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-hour: * * The Gregorian hour of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_HOUR, g_param_spec_int("gregorian-hour", "Gregorian hour", "The hour according to the Gregorian calendar", 0, 23, g_date_time_get_hour(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_HOUR, + g_param_spec_int( + "gregorian-hour", + "Gregorian hour", + "The hour according to the Gregorian calendar", + 0, 23, g_date_time_get_hour(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-minute: * * The Gregorian minute of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_MINUTE, g_param_spec_int("gregorian-minute", "Gregorian minute", "The minute according to the Gregorian calendar", 0, 59, g_date_time_get_minute(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_MINUTE, + g_param_spec_int( + "gregorian-minute", + "Gregorian minute", + "The minute according to the Gregorian calendar", + 0, 59, g_date_time_get_minute(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-second: * * The Gregorian second of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_SECOND, g_param_spec_int("gregorian-second", "Gregorian second", "The second according to the Gregorian calendar", 0, 61, g_date_time_get_second(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_SECOND, + g_param_spec_int( + "gregorian-second", + "Gregorian second", + "The second according to the Gregorian calendar", + 0, 61, g_date_time_get_second(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-microsecond: * * The Gregorian microsecond of the timestamp */ - g_object_class_install_property(gobject_class, PROP_GREGORIAN_MICROSECOND, g_param_spec_int("gregorian-microsecond", "Gregorian microsecond", "The microsecond according to the Gregorian calendar", 0, G_MAXINT, g_date_time_get_microsecond(local_time), G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_object_class_install_property( + gobject_class, + PROP_GREGORIAN_MICROSECOND, + g_param_spec_int( + "gregorian-microsecond", + "Gregorian microsecond", + "The microsecond according to the Gregorian calendar", + 0, G_MAXINT, g_date_time_get_microsecond(local_time), + G_PARAM_CONSTRUCT | G_PARAM_READWRITE + ) + ); /** * GsweTimestamp:gregorian-timezone-offset: @@ -205,7 +325,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass) * currently considered as valid, thus, no recalculation is needed. * Otherwise, the Julian day components will be recalculated upon request. */ - g_object_class_install_property(gobject_class, PROP_JULIAN_DAY_VALID, g_param_spec_boolean("julian-day-valid", "Julian day is valid", "TRUE if the Julian day components are considered as valid.", TRUE, G_PARAM_READABLE)); + g_object_class_install_property( + gobject_class, + PROP_JULIAN_DAY_VALID, + g_param_spec_boolean( + "julian-day-valid", + "Julian day is valid", + "TRUE if the Julian day components " + "are considered as valid.", + TRUE, G_PARAM_READABLE + ) + ); g_date_time_unref(local_time); } @@ -235,7 +365,11 @@ gswe_timestamp_finalize(GObject *gobject) } static void -gswe_timestamp_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gswe_timestamp_set_property( + GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { GsweTimestamp *timestamp = GSWE_TIMESTAMP(object); @@ -246,42 +380,74 @@ gswe_timestamp_set_property(GObject *object, guint prop_id, const GValue *value, break; case PROP_GREGORIAN_YEAR: - gswe_timestamp_set_gregorian_year(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_year( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_MONTH: - gswe_timestamp_set_gregorian_month(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_month( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_DAY: - gswe_timestamp_set_gregorian_day(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_day( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_HOUR: - gswe_timestamp_set_gregorian_hour(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_hour( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_MINUTE: - gswe_timestamp_set_gregorian_minute(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_minute( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_SECOND: - gswe_timestamp_set_gregorian_second(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_second( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_MICROSECOND: - gswe_timestamp_set_gregorian_microsecond(timestamp, g_value_get_int(value), NULL); + gswe_timestamp_set_gregorian_microsecond( + timestamp, + g_value_get_int(value), + NULL + ); break; case PROP_GREGORIAN_TIMEZONE_OFFSET: - gswe_timestamp_set_gregorian_timezone(timestamp, g_value_get_double(value), NULL); + gswe_timestamp_set_gregorian_timezone( + timestamp, + g_value_get_double(value), + NULL + ); break; @@ -293,7 +459,11 @@ gswe_timestamp_set_property(GObject *object, guint prop_id, const GValue *value, } static void -gswe_timestamp_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gswe_timestamp_get_property( + GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { GsweTimestamp *timestamp = GSWE_TIMESTAMP(object); @@ -304,7 +474,11 @@ gswe_timestamp_get_property(GObject *object, guint prop_id, GValue *value, GPara break; case PROP_GREGORIAN_VALID: - g_value_set_boolean(value, ((timestamp->priv->valid_dates & VALID_GREGORIAN) == VALID_GREGORIAN)); + g_value_set_boolean( + value, + ((timestamp->priv->valid_dates & VALID_GREGORIAN) + == VALID_GREGORIAN) + ); break; @@ -351,12 +525,18 @@ gswe_timestamp_get_property(GObject *object, guint prop_id, GValue *value, GPara break; case PROP_GREGORIAN_TIMEZONE_OFFSET: - g_value_set_double(value, timestamp->priv->gregorian_timezone_offset); + g_value_set_double( + value, + timestamp->priv->gregorian_timezone_offset); break; case PROP_JULIAN_DAY_VALID: - g_value_set_boolean(value, ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) == VALID_JULIAN_DAY)); + g_value_set_boolean( + value, + ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) + == VALID_JULIAN_DAY) + ); break; @@ -395,11 +575,22 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err) } if (timestamp->priv->valid_dates == 0) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, "This timestamp object holds no valid values"); + g_set_error( + err, + GSWE_ERROR, + GSWE_ERROR_NO_VALID_VALUE, + "This timestamp object holds no valid values" + ); + return; } - swe_jdet_to_utc(timestamp->priv->julian_day, SE_GREG_CAL, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second); + swe_jdet_to_utc( + timestamp->priv->julian_day, + SE_GREG_CAL, + &utc_year, &utc_month, &utc_day, + &utc_hour, &utc_minute, &utc_second + ); swe_utc_time_zone( utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, @@ -412,7 +603,9 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err) &local_second ); timestamp->priv->gregorian_second = floor(local_second); - timestamp->priv->gregorian_microsecond = (local_second - floor(local_second)) * 1000; + timestamp->priv->gregorian_microsecond = ( + local_second - floor(local_second)) + * 1000; } /** @@ -421,12 +614,16 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err) * @instant_recalc: the new value * @err: a #GError * - * Sets the value of the instant-recalc property. For details, see the - * property's description. @err is populated with calculation errors if - * @instant_recalc is TRUE and a calculation error happens. + * Sets the value of the instant-recalc property. For + * details, see the property's description. @err is populated with calculation + * errors if @instant_recalc is TRUE and a calculation error happens. */ void -gswe_timestamp_set_instant_recalc(GsweTimestamp *timestamp, gboolean instant_recalc, GError **err) +gswe_timestamp_set_instant_recalc( + GsweTimestamp *timestamp, + gboolean instant_recalc, + GError **err) { timestamp->priv->instant_recalc = instant_recalc; @@ -468,7 +665,12 @@ gswe_timestamp_get_instant_recalc(GsweTimestamp *timestamp) * TRUE */ void -gswe_timestamp_set_gregorian_full(GsweTimestamp *timestamp, gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset, GError **err) +gswe_timestamp_set_gregorian_full( + GsweTimestamp *timestamp, + gint year, gint month, gint day, + gint hour, gint minute, gint second, gint microsecond, + gdouble time_zone_offset, + GError **err) { timestamp->priv->gregorian_year = year; timestamp->priv->gregorian_month = month; @@ -494,10 +696,15 @@ gswe_timestamp_set_gregorian_full(GsweTimestamp *timestamp, gint year, gint mont * @err: a #GError * * Sets the Gregorian year of @timestamp. @err is populated with calculation - * errors if the instant-recalc property is TRUE + * errors if the instant-recalc property is + * TRUE */ void -gswe_timestamp_set_gregorian_year(GsweTimestamp *timestamp, gint gregorian_year, GError **err) +gswe_timestamp_set_gregorian_year( + GsweTimestamp *timestamp, + gint gregorian_year, + GError **err) { timestamp->priv->gregorian_year = gregorian_year; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -538,7 +745,10 @@ gswe_timestamp_get_gregorian_year(GsweTimestamp *timestamp, GError **err) * TRUE */ void -gswe_timestamp_set_gregorian_month(GsweTimestamp *timestamp, gint gregorian_month, GError **err) +gswe_timestamp_set_gregorian_month( + GsweTimestamp *timestamp, + gint gregorian_month, + GError **err) { timestamp->priv->gregorian_month = gregorian_month; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -579,7 +789,10 @@ gswe_timestamp_get_gregorian_month(GsweTimestamp *timestamp, GError **err) * TRUE */ void -gswe_timestamp_set_gregorian_day(GsweTimestamp *timestamp, gint gregorian_day, GError **err) +gswe_timestamp_set_gregorian_day( + GsweTimestamp *timestamp, + gint gregorian_day, + GError **err) { timestamp->priv->gregorian_day = gregorian_day; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -620,7 +833,10 @@ gswe_timestamp_get_gregorian_day(GsweTimestamp *timestamp, GError **err) * TRUE */ void -gswe_timestamp_set_gregorian_hour(GsweTimestamp *timestamp, gint gregorian_hour, GError **err) +gswe_timestamp_set_gregorian_hour( + GsweTimestamp *timestamp, + gint gregorian_hour, + GError **err) { timestamp->priv->gregorian_hour = gregorian_hour; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -661,7 +877,10 @@ gswe_timestamp_get_gregorian_hour(GsweTimestamp *timestamp, GError **err) * TRUE */ void -gswe_timestamp_set_gregorian_minute(GsweTimestamp *timestamp, gint gregorian_minute, GError **err) +gswe_timestamp_set_gregorian_minute( + GsweTimestamp *timestamp, + gint gregorian_minute, + GError **err) { timestamp->priv->gregorian_minute = gregorian_minute; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -702,7 +921,10 @@ gswe_timestamp_get_gregorian_minute(GsweTimestamp *timestamp, GError **err) * TRUE. */ void -gswe_timestamp_set_gregorian_second(GsweTimestamp *timestamp, gint gregorian_second, GError **err) +gswe_timestamp_set_gregorian_second( + GsweTimestamp *timestamp, + gint gregorian_second, + GError **err) { timestamp->priv->gregorian_second = gregorian_second; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -743,7 +965,10 @@ gswe_timestamp_get_gregorian_second(GsweTimestamp *timestamp, GError **err) * TRUE */ void -gswe_timestamp_set_gregorian_microsecond(GsweTimestamp *timestamp, gint gregorian_microsecond, GError **err) +gswe_timestamp_set_gregorian_microsecond( + GsweTimestamp *timestamp, + gint gregorian_microsecond, + GError **err) { timestamp->priv->gregorian_microsecond = gregorian_microsecond; timestamp->priv->valid_dates = VALID_GREGORIAN; @@ -779,11 +1004,15 @@ gswe_timestamp_get_gregorian_microsecond(GsweTimestamp *timestamp, GError **err) * @err: a #GError * * Sets the time zone used in Gregorian date calculations. @err is populated - * with calculation errors if the instant-recalc property's value is TRUE and a - * calculation error happens. + * with calculation errors if the instant-recalc property's + * value is TRUE and a calculation error happens. */ void -gswe_timestamp_set_gregorian_timezone(GsweTimestamp *timestamp, gdouble gregorian_timezone_offset, GError **err) +gswe_timestamp_set_gregorian_timezone( + GsweTimestamp *timestamp, + gdouble gregorian_timezone_offset, + GError **err) { timestamp->priv->gregorian_timezone_offset = gregorian_timezone_offset; @@ -824,7 +1053,12 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err) } if (timestamp->priv->valid_dates == 0) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, "This timestamp object holds no valid values"); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, + "This timestamp object holds no valid values" + ); + return; } @@ -834,14 +1068,24 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err) timestamp->priv->gregorian_day, timestamp->priv->gregorian_hour, timestamp->priv->gregorian_minute, - timestamp->priv->gregorian_second + timestamp->priv->gregorian_microsecond / 1000.0, + timestamp->priv->gregorian_second + + timestamp->priv->gregorian_microsecond / 1000.0, timestamp->priv->gregorian_timezone_offset, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second ); - if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, SE_GREG_CAL, dret, serr)) == ERR) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr); + if ( + (retval = swe_utc_to_jd( + utc_year, utc_month, utc_day, + utc_hour, utc_minute, utc_second, + SE_GREG_CAL, dret, serr) + ) == ERR) { + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_SWE_FATAL, + "Swiss Ephemeris error: %s", serr + ); } else { timestamp->priv->julian_day = dret[0]; timestamp->priv->julian_day_ut = dret[1]; @@ -891,7 +1135,10 @@ gswe_timestamp_get_julian_day(GsweTimestamp *timestamp, GError **err) * Since: 2.1 */ void -gswe_timestamp_set_julian_day_et(GsweTimestamp *timestamp, gdouble julian_day, GError **err) +gswe_timestamp_set_julian_day_et( + GsweTimestamp *timestamp, + gdouble julian_day, + GError **err) { GError *err_local = NULL; @@ -960,7 +1207,10 @@ gswe_timestamp_get_julian_day_et(GsweTimestamp *timestamp, GError **err) * with the error details. */ void -gswe_timestamp_set_julian_day_ut(GsweTimestamp *timestamp, gdouble julian_day, GError **err) +gswe_timestamp_set_julian_day_ut( + GsweTimestamp *timestamp, + gdouble julian_day, + GError **err) { GError *err_local = NULL; @@ -1074,12 +1324,16 @@ gswe_timestamp_new(void) * @microsecond: the microsecond * @time_zone_offset: the time zone offset in hours * - * Creates a new GsweTimestamp object, initialized with the Gregorian date specified by the function parameters. + * Creates a new GsweTimestamp object, initialized with the Gregorian date + * specified by the function parameters. * * Returns: a new GsweTimestamp object. */ GsweTimestamp * -gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset) +gswe_timestamp_new_from_gregorian_full( + gint year, gint month, gint day, + gint hour, gint minute, gint second, gint microsecond, + gdouble time_zone_offset) { GsweTimestamp *timestamp; diff --git a/src/gswe-timestamp.h b/src/gswe-timestamp.h index 4f751a4..18f31d9 100644 --- a/src/gswe-timestamp.h +++ b/src/gswe-timestamp.h @@ -22,11 +22,23 @@ #include #define GSWE_TYPE_TIMESTAMP (gswe_timestamp_get_type()) -#define GSWE_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_TIMESTAMP, GsweTimestamp)) -#define GSWE_IS_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_TIMESTAMP)) -#define GSWE_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_TIMESTAMP, GsweTimestampClass)) -#define GSWE_IS_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_TIMESTAMP)) -#define GSWE_TIMESTAMP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_TIMESTAMP, GsweTimestampClass)) +#define GSWE_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_CAST( \ + (obj), \ + GSWE_TYPE_TIMESTAMP, \ + GsweTimestamp)) +#define GSWE_IS_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_TYPE( \ + (obj), \ + GSWE_TYPE_TIMESTAMP)) +#define GSWE_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST( \ + (klass), \ + GSWE_TYPE_TIMESTAMP, \ + GsweTimestampClass)) +#define GSWE_IS_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE( \ + (klass), \ + GSWE_TYPE_TIMESTAMP)) +#define GSWE_TIMESTAMP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \ + GSWE_TYPE_TIMESTAMP, \ + GsweTimestampClass)) typedef struct _GsweTimestamp GsweTimestamp; typedef struct _GsweTimestampClass GsweTimestampClass; @@ -85,41 +97,123 @@ GType gswe_timestamp_get_type(void); /* Method definitions */ GsweTimestamp *gswe_timestamp_new(void); + GsweTimestamp *gswe_timestamp_new_from_julian_day(gdouble julian_day); -GsweTimestamp * gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset); -void gswe_timestamp_set_gregorian_full(GsweTimestamp *timestamp, gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset, GError **err); -void gswe_timestamp_set_instant_recalc(GsweTimestamp *timestamp, gboolean instant_recalc, GError **err); + +GsweTimestamp * gswe_timestamp_new_from_gregorian_full( + gint year, gint month, gint day, + gint hour, gint minute, gint second, gint microsecond, + gdouble time_zone_offset); + +void gswe_timestamp_set_gregorian_full( + GsweTimestamp *timestamp, + gint year, gint month, gint day, + gint hour, gint minute, gint second, gint microsecond, + gdouble time_zone_offset, + GError **err); + +void gswe_timestamp_set_instant_recalc( + GsweTimestamp *timestamp, + gboolean instant_recalc, + GError **err); + gboolean gswe_timestamp_get_instant_recalc(GsweTimestamp *timestamp); -void gswe_timestamp_set_gregorian_year(GsweTimestamp *timestamp, gint gregorian_year, GError **err); + +void gswe_timestamp_set_gregorian_year( + GsweTimestamp *timestamp, + gint gregorian_year, + GError **err); + gint gswe_timestamp_get_gregorian_year(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_month(GsweTimestamp *timestamp, gint gregorian_month, GError **err); + +void gswe_timestamp_set_gregorian_month( + GsweTimestamp *timestamp, + gint gregorian_month, + GError **err); + gint gswe_timestamp_get_gregorian_month(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_day(GsweTimestamp *timestamp, gint gregorian_day, GError **err); + +void gswe_timestamp_set_gregorian_day( + GsweTimestamp *timestamp, + gint gregorian_day, + GError **err); + gint gswe_timestamp_get_gregorian_day(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_hour(GsweTimestamp *timestamp, gint gregorian_hour, GError **err); + +void gswe_timestamp_set_gregorian_hour( + GsweTimestamp *timestamp, + gint gregorian_hour, + GError **err); + gint gswe_timestamp_get_gregorian_hour(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_minute(GsweTimestamp *timestamp, gint gregorian_minute, GError **err); -gint gswe_timestamp_get_gregorian_minute(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_second(GsweTimestamp *timestamp, gint gregorian_second, GError **err); -gint gswe_timestamp_get_gregorian_second(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_microsecond(GsweTimestamp *timestamp, gint gregorian_microsecond, GError **err); -gint gswe_timestamp_get_gregorian_microsecond(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_gregorian_timezone(GsweTimestamp *timestamp, gdouble gregorian_timezone_offset, GError **err); + +void gswe_timestamp_set_gregorian_minute( + GsweTimestamp *timestamp, + gint gregorian_minute, + GError **err); + +gint gswe_timestamp_get_gregorian_minute( + GsweTimestamp *timestamp, + GError **err); + +void gswe_timestamp_set_gregorian_second( + GsweTimestamp *timestamp, + gint gregorian_second, + GError **err); + +gint gswe_timestamp_get_gregorian_second( + GsweTimestamp *timestamp, + GError **err); + +void gswe_timestamp_set_gregorian_microsecond( + GsweTimestamp *timestamp, + gint gregorian_microsecond, + GError **err); + +gint gswe_timestamp_get_gregorian_microsecond( + GsweTimestamp *timestamp, + GError **err); + +void gswe_timestamp_set_gregorian_timezone( + GsweTimestamp *timestamp, + gdouble gregorian_timezone_offset, + GError **err); + gdouble gswe_timestamp_get_gregorian_timezone(GsweTimestamp *timestamp); #ifndef GSWE_DISABLE_DEPRECATED G_DEPRECATED_FOR(gswe_timestamp_set_julian_day_et) -void gswe_timestamp_set_julian_day(GsweTimestamp *timestamp, gdouble julian_day); +void gswe_timestamp_set_julian_day( + GsweTimestamp *timestamp, + gdouble julian_day); G_DEPRECATED_FOR(gswe_timestamp_get_julian_day_et) -gdouble gswe_timestamp_get_julian_day(GsweTimestamp *timestamp, GError **err); +gdouble gswe_timestamp_get_julian_day( + GsweTimestamp *timestamp, + GError **err); #endif -void gswe_timestamp_set_julian_day_et(GsweTimestamp *timestamp, gdouble julian_day, GError **err); -gdouble gswe_timestamp_get_julian_day_et(GsweTimestamp *timestamp, GError **err); -void gswe_timestamp_set_julian_day_ut(GsweTimestamp *timestamp, gdouble julian_day, GError **err); -gdouble gswe_timestamp_get_julian_day_ut(GsweTimestamp *timestamp, GError **err); -gdouble gswe_timestamp_get_sidereal_time(GsweTimestamp *timestamp, GError **err); +void gswe_timestamp_set_julian_day_et( + GsweTimestamp *timestamp, + gdouble julian_day, + GError **err); + +gdouble gswe_timestamp_get_julian_day_et( + GsweTimestamp *timestamp, + GError **err); + +void gswe_timestamp_set_julian_day_ut( + GsweTimestamp *timestamp, + gdouble julian_day, + GError **err); + +gdouble gswe_timestamp_get_julian_day_ut( + GsweTimestamp *timestamp, + GError **err); + +gdouble gswe_timestamp_get_sidereal_time( + GsweTimestamp *timestamp, + GError **err); #endif /* __SWE_GLIB_GSWE_TIMESTAMP_H__ */ diff --git a/src/gswe-types.c b/src/gswe-types.c index 0aa35d4..105e7c9 100644 --- a/src/gswe-types.c +++ b/src/gswe-types.c @@ -37,5 +37,9 @@ gswe_coordinates_copy(GsweCoordinates *coordinates) return ret; } -G_DEFINE_BOXED_TYPE(GsweCoordinates, gswe_coordinates, (GBoxedCopyFunc)gswe_coordinates_copy, (GBoxedFreeFunc)g_free); +G_DEFINE_BOXED_TYPE( + GsweCoordinates, + gswe_coordinates, + (GBoxedCopyFunc)gswe_coordinates_copy, + (GBoxedFreeFunc)g_free); diff --git a/src/gswe-version.c b/src/gswe-version.c index 3176026..4c877b0 100644 --- a/src/gswe-version.c +++ b/src/gswe-version.c @@ -71,7 +71,10 @@ * Returns: TRUE if the required version is satisfied; FALSE otherwise. */ gboolean -gswe_check_version(guint required_major, guint required_minor, guint required_micro) +gswe_check_version( + guint required_major, + guint required_minor, + guint required_micro) { return (GSWE_CHECK_VERSION(required_major, required_minor, required_micro)); } diff --git a/src/gswe-version.h.in b/src/gswe-version.h.in index 20e9b08..b76263b 100644 --- a/src/gswe-version.h.in +++ b/src/gswe-version.h.in @@ -22,7 +22,10 @@ #define GSWE_MINOR_VERSION @SWE_GLIB_MINOR_VERSION@ #define GSWE_MICRO_VERSION @SWE_GLIB_MICRO_VERSION@ -gboolean gswe_check_version(guint required_major, guint required_minor, guint required_micro); +gboolean gswe_check_version( + guint required_major, + guint required_minor, + guint required_micro); #define GSWE_CHECK_VERSION(major,minor,micro) \ (GSWE_MAJOR_VERSION > (major) || \ diff --git a/src/swe-glib.c b/src/swe-glib.c index 577e5c7..cd6fafb 100644 --- a/src/swe-glib.c +++ b/src/swe-glib.c @@ -139,89 +139,508 @@ void gswe_init_with_dir(gchar *directory) bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - gswe_planet_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_planet_info_unref); + gswe_planet_info_table = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify)gswe_planet_info_unref + ); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ASCENDANT, -1, FALSE, _("Ascendant"), 9.0, 2); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MC, -1, FALSE, _("Midheaven"), 5.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VERTEX, -1, FALSE, _("Vertex"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_NODE, SE_MEAN_NODE, TRUE, _("Ascending Moon Node"), 2.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_APOGEE, SE_MEAN_APOG, TRUE, _("Dark Moon"), 2.0, 0); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_ASCENDANT, + -1, + FALSE, + _("Ascendant"), + 9.0, + 2 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_MC, + -1, + FALSE, + _("Midheaven"), + 5.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_VERTEX, + -1, + FALSE, + _("Vertex"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_MOON_NODE, + SE_MEAN_NODE, + TRUE, + _("Ascending Moon Node"), + 2.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_MOON_APOGEE, + SE_MEAN_APOG, + TRUE, + _("Dark Moon"), + 2.0, + 0 + ); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SUN, SE_SUN, TRUE, _("Sun"), 13.0, 2); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON, SE_MOON, TRUE, _("Moon"), 9.0, 2); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MERCURY, SE_MERCURY, TRUE, _("Mercury"), 7.0, 2); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VENUS, SE_VENUS, TRUE, _("Venus"), 7.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MARS, SE_MARS, TRUE, _("Mars"), 7.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUPITER, SE_JUPITER, TRUE, _("Jupiter"), 9.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SATURN, SE_SATURN, TRUE, _("Saturn"), 7.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_URANUS, SE_URANUS, TRUE, _("Uranus"), 5.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_NEPTUNE, SE_NEPTUNE, TRUE, _("Neptune"), 5.0, 1); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PLUTO, SE_PLUTO, TRUE, _("Pluto"), 3.0, 1); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_SUN, + SE_SUN, + TRUE, + _("Sun"), + 13.0, + 2 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_MOON, + SE_MOON, + TRUE, + _("Moon"), + 9.0, + 2 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_MERCURY, + SE_MERCURY, + TRUE, + _("Mercury"), + 7.0, + 2 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_VENUS, + SE_VENUS, + TRUE, + _("Venus"), + 7.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_MARS, + SE_MARS, + TRUE, + _("Mars"), + 7.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_JUPITER, + SE_JUPITER, + TRUE, + _("Jupiter"), + 9.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_SATURN, + SE_SATURN, + TRUE, + _("Saturn"), + 7.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_URANUS, + SE_URANUS, + TRUE, + _("Uranus"), + 5.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_NEPTUNE, + SE_NEPTUNE, + TRUE, + _("Neptune"), + 5.0, + 1 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_PLUTO, + SE_PLUTO, + TRUE, + _("Pluto"), + 3.0, + 1 + ); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CHIRON, SE_CHIRON, TRUE, _("Chiron"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CERES, SE_CERES, TRUE, _("Ceres"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PALLAS, SE_PALLAS, TRUE, _("Pallas"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUNO, SE_JUNO, TRUE, _("Juno"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VESTA, SE_VESTA, TRUE, _("Vesta"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PHOLUS, SE_PHOLUS, TRUE, _("Pholus"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_NESSUS, SE_AST_OFFSET + 7066, TRUE, _("Nessus"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CHARIKLO, SE_AST_OFFSET + 10199, TRUE, _("Chariklo"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SEDNA, SE_AST_OFFSET + 90377, TRUE, _("Sedna"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ERIS, SE_AST_OFFSET + 136199, TRUE, _("Eris"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_DEJANIRA, SE_AST_OFFSET + 157, TRUE, _("Dejanira"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CIRCE, SE_AST_OFFSET + 34, TRUE, _("Circe"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ORCUS, SE_AST_OFFSET + 90482, TRUE, _("Orcus"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ASBOLUS, SE_AST_OFFSET + 8405, TRUE, _("Asbolus"), 2.0, 0); - ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_HYGIEA, SE_AST_OFFSET + 10, TRUE, _("Hygiea"), 2.0, 0); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_CHIRON, + SE_CHIRON, + TRUE, + _("Chiron"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_CERES, + SE_CERES, + TRUE, + _("Ceres"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_PALLAS, + SE_PALLAS, + TRUE, + _("Pallas"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_JUNO, + SE_JUNO, + TRUE, + _("Juno"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_VESTA, + SE_VESTA, + TRUE, + _("Vesta"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_PHOLUS, + SE_PHOLUS, + TRUE, + _("Pholus"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_NESSUS, + SE_AST_OFFSET + 7066, + TRUE, + _("Nessus"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_CHARIKLO, + SE_AST_OFFSET + 10199, + TRUE, + _("Chariklo"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_SEDNA, + SE_AST_OFFSET + 90377, + TRUE, + _("Sedna"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_ERIS, + SE_AST_OFFSET + 136199, + TRUE, + _("Eris"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_DEJANIRA, + SE_AST_OFFSET + 157, + TRUE, + _("Dejanira"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_CIRCE, + SE_AST_OFFSET + 34, + TRUE, + _("Circe"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_ORCUS, + SE_AST_OFFSET + 90482, + TRUE, + _("Orcus"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_ASBOLUS, + SE_AST_OFFSET + 8405, + TRUE, + _("Asbolus"), + 2.0, + 0 + ); + ADD_PLANET(gswe_planet_info_table, planet_info, + GSWE_PLANET_HYGIEA, + SE_AST_OFFSET + 10, + TRUE, + _("Hygiea"), + 2.0, + 0 + ); - gswe_sign_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_sign_info_unref); + gswe_sign_info_table = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify)gswe_sign_info_unref + ); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_ARIES, _("Aries"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_CARDINAL); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_TAURUS, _("Taurus"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_FIX); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_GEMINI, _("Gemini"), GSWE_ELEMENT_AIR, GSWE_QUALITY_MUTABLE); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_CANCER, _("Cancer"), GSWE_ELEMENT_WATER, GSWE_QUALITY_CARDINAL); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_LEO, _("Leo"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_FIX); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_VIRGO, _("Virgo"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_MUTABLE); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_LIBRA, _("Libra"), GSWE_ELEMENT_AIR, GSWE_QUALITY_CARDINAL); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_SCORPIO, _("Scorpio"), GSWE_ELEMENT_WATER, GSWE_QUALITY_FIX); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_SAGITTARIUS, _("Sagittarius"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_MUTABLE); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_CAPRICORN, _("Capricorn"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_CARDINAL); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_AQUARIUS, _("Aquarius"), GSWE_ELEMENT_AIR, GSWE_QUALITY_FIX); - ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_PISCES, _("Pisces"), GSWE_ELEMENT_WATER, GSWE_QUALITY_MUTABLE); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_ARIES, + _("Aries"), + GSWE_ELEMENT_FIRE, + GSWE_QUALITY_CARDINAL + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_TAURUS, + _("Taurus"), + GSWE_ELEMENT_EARTH, + GSWE_QUALITY_FIX + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_GEMINI, + _("Gemini"), + GSWE_ELEMENT_AIR, + GSWE_QUALITY_MUTABLE + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_CANCER, + _("Cancer"), + GSWE_ELEMENT_WATER, + GSWE_QUALITY_CARDINAL + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_LEO, + _("Leo"), + GSWE_ELEMENT_FIRE, + GSWE_QUALITY_FIX + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_VIRGO, + _("Virgo"), + GSWE_ELEMENT_EARTH, + GSWE_QUALITY_MUTABLE + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_LIBRA, + _("Libra"), + GSWE_ELEMENT_AIR, + GSWE_QUALITY_CARDINAL + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_SCORPIO, + _("Scorpio"), + GSWE_ELEMENT_WATER, + GSWE_QUALITY_FIX + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_SAGITTARIUS, + _("Sagittarius"), + GSWE_ELEMENT_FIRE, + GSWE_QUALITY_MUTABLE + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_CAPRICORN, + _("Capricorn"), + GSWE_ELEMENT_EARTH, + GSWE_QUALITY_CARDINAL + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_AQUARIUS, + _("Aquarius"), + GSWE_ELEMENT_AIR, + GSWE_QUALITY_FIX + ); + ADD_SIGN(gswe_sign_info_table, sign_info, + GSWE_SIGN_PISCES, + _("Pisces"), + GSWE_ELEMENT_WATER, + GSWE_QUALITY_MUTABLE + ); - gswe_house_system_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_house_system_info_unref); + gswe_house_system_info_table = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify)gswe_house_system_info_unref + ); - ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_NONE, 0, _("None")); - ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_PLACIDUS, 'P', _("Placidus")); - ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_KOCH, 'K', _("Koch")); - ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_EQUAL, 'E', _("Equal")); + ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, + GSWE_HOUSE_SYSTEM_NONE, + 0, + _("None") + ); + ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, + GSWE_HOUSE_SYSTEM_PLACIDUS, + 'P', + _("Placidus") + ); + ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, + GSWE_HOUSE_SYSTEM_KOCH, + 'K', + _("Koch") + ); + ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, + GSWE_HOUSE_SYSTEM_EQUAL, + 'E', + _("Equal") + ); - gswe_aspect_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_aspect_info_unref); + gswe_aspect_info_table = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify)gswe_aspect_info_unref + ); // Note that because all aspects must be <= 180°, GSWE_ASPECT_NONE can // never really exist. It is provided for name fetching purposes only. - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_NONE, _("None"), 360, 4, FALSE, FALSE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_CONJUCTION, _("Conjuction"), 0, 0, TRUE, TRUE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_OPPOSITION, _("Opposition"), 180, 0, TRUE, TRUE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_TRINE, _("Trine"), 120, 0, TRUE, TRUE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SQUARE, _("Square"), 90, 0, FALSE, TRUE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEXTILE, _("Sextile"), 60, 1, TRUE, TRUE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINCUNX, _("Quincunx"), 150, 2, FALSE, FALSE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEMISEXTILE, _("Semi-sextile"), 30, 2, TRUE, FALSE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEMISQUARE, _("Semi-square"), 45, 2, FALSE, FALSE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SESQUISQUARE, _("Sesqui-square"), 135, 2, FALSE, FALSE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINTILE, _("Quintile"), 72, 3, TRUE, FALSE); - ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_BIQUINTILE, _("Bi-quintile"), 144, 3, TRUE, FALSE); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_NONE, + _("None"), + 360, + 4, + FALSE, + FALSE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_CONJUCTION, + _("Conjuction"), + 0, + 0, + TRUE, + TRUE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_OPPOSITION, + _("Opposition"), + 180, + 0, + TRUE, + TRUE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_TRINE, + _("Trine"), + 120, + 0, + TRUE, + TRUE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_SQUARE, + _("Square"), + 90, + 0, + FALSE, + TRUE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_SEXTILE, + _("Sextile"), + 60, + 1, + TRUE, + TRUE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_QUINCUNX, + _("Quincunx"), + 150, + 2, + FALSE, + FALSE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_SEMISEXTILE, + _("Semi-sextile"), + 30, + 2, + TRUE, + FALSE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_SEMISQUARE, + _("Semi-square"), + 45, + 2, + FALSE, + FALSE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_SESQUISQUARE, + _("Sesqui-square"), + 135, + 2, + FALSE, + FALSE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_QUINTILE, + _("Quintile"), + 72, + 3, + TRUE, + FALSE + ); + ADD_ASPECT(gswe_aspect_info_table, aspect_info, + GSWE_ASPECT_BIQUINTILE, + _("Bi-quintile"), + 144, + 3, + TRUE, + FALSE + ); - gswe_antiscion_axis_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gswe_antiscion_axis_info_unref); + gswe_antiscion_axis_info_table = g_hash_table_new_full( + g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify)gswe_antiscion_axis_info_unref + ); - ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_NONE, _("None"), GSWE_SIGN_NONE, 0.0); - ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_ARIES, _("Aries/Libra"), GSWE_SIGN_ARIES, 0.0); - ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_TAURUS, _("mid Taurus/Scorpio"), GSWE_SIGN_TAURUS, 15.0); - ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_CANCER, _("Cancer/Capricorn"), GSWE_SIGN_CANCER, 0.0); - ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, gswe_sign_info_table, sign_info, GSWE_ANTISCION_AXIS_MID_LEO, _("mid Leo/Aquarius"), GSWE_SIGN_LEO, 15.0); + ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, + gswe_sign_info_table, sign_info, + GSWE_ANTISCION_AXIS_NONE, + _("None"), + GSWE_SIGN_NONE, + 0.0 + ); + ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, + gswe_sign_info_table, sign_info, + GSWE_ANTISCION_AXIS_ARIES, + _("Aries/Libra"), + GSWE_SIGN_ARIES, + 0.0 + ); + ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, + gswe_sign_info_table, sign_info, + GSWE_ANTISCION_AXIS_MID_TAURUS, + _("mid Taurus/Scorpio"), + GSWE_SIGN_TAURUS, + 15.0 + ); + ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, + gswe_sign_info_table, sign_info, + GSWE_ANTISCION_AXIS_CANCER, + _("Cancer/Capricorn"), + GSWE_SIGN_CANCER, + 0.0 + ); + ADD_ANTISCION(gswe_antiscion_axis_info_table, antiscion_axis_info, + gswe_sign_info_table, sign_info, + GSWE_ANTISCION_AXIS_MID_LEO, + _("mid Leo/Aquarius"), + GSWE_SIGN_LEO, + 15.0 + ); - gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full(2005, 5, 8, 3, 48, 0, 0, 0.0); + gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full( + 2005, 5, 8, + 3, 48, 0, 0, + 0.0 + ); gswe_ephe_path = g_strdup(directory); swe_set_ephe_path(directory); @@ -250,10 +669,17 @@ gswe_init(void) GswePlanetInfo * gswe_find_planet_info_by_id(GswePlanet planet, GError **err) { - GswePlanetInfo *ret = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet)); + GswePlanetInfo *ret = g_hash_table_lookup( + gswe_planet_info_table, + GINT_TO_POINTER(planet) + ); if (ret == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Planet %d is not registered", planet); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, + "Planet %d is not registered", planet + ); } return ret; @@ -269,10 +695,17 @@ gswe_find_planet_info_by_id(GswePlanet planet, GError **err) GsweSignInfo * gswe_find_sign_info_by_id(GsweZodiac sign, GError **err) { - GsweSignInfo *ret = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER(sign)); + GsweSignInfo *ret = g_hash_table_lookup( + gswe_sign_info_table, + GINT_TO_POINTER(sign) + ); if (ret == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Sign %d is not registered", sign); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, + "Sign %d is not registered", sign + ); } return ret; @@ -288,10 +721,17 @@ gswe_find_sign_info_by_id(GsweZodiac sign, GError **err) GsweHouseSystemInfo * gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err) { - GsweHouseSystemInfo *ret = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(house_system)); + GsweHouseSystemInfo *ret = g_hash_table_lookup( + gswe_house_system_info_table, + GINT_TO_POINTER(house_system) + ); if (ret == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, "House system %d is not registered", house_system); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, + "House system %d is not registered", house_system + ); } return ret; @@ -307,10 +747,17 @@ gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err) GsweAspectInfo * gswe_find_aspect_info_by_id(GsweAspect aspect, GError **err) { - GsweAspectInfo *ret = g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(aspect)); + GsweAspectInfo *ret = g_hash_table_lookup( + gswe_aspect_info_table, + GINT_TO_POINTER(aspect) + ); if (ret == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ASPECT, "Aspect system %d is not registered", aspect); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_ASPECT, + "Aspect system %d is not registered", aspect + ); } return ret; @@ -321,15 +768,25 @@ gswe_find_aspect_info_by_id(GsweAspect aspect, GError **err) * @antiscion_axis: an antiscion axis ID registered with SWE-GLib * @err: a GError * - * Find the #GsweAntiscionAxisInfo record registered with the id @antiscion_axis. + * Find the #GsweAntiscionAxisInfo record registered with the id + * @antiscion_axis. */ GsweAntiscionAxisInfo * -gswe_find_antiscion_axis_info_by_id(GsweAntiscionAxis antiscion_axis, GError **err) +gswe_find_antiscion_axis_info_by_id( + GsweAntiscionAxis antiscion_axis, + GError **err) { - GsweAntiscionAxisInfo *ret = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(antiscion_axis)); + GsweAntiscionAxisInfo *ret = g_hash_table_lookup( + gswe_antiscion_axis_info_table, + GINT_TO_POINTER(antiscion_axis) + ); if (ret == NULL) { - g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, "Antiscion axis system %d is not registered", antiscion_axis); + g_set_error( + err, + GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, + "Antiscion axis system %d is not registered", antiscion_axis + ); } return ret; diff --git a/src/swe-glib.h b/src/swe-glib.h index adf1257..ff9dfc6 100644 --- a/src/swe-glib.h +++ b/src/swe-glib.h @@ -76,11 +76,20 @@ typedef enum { GQuark gswe_error_quark(void); void gswe_init(); + GswePlanetInfo *gswe_find_planet_info_by_id(GswePlanet planet, GError **err); + GsweSignInfo *gswe_find_sign_info_by_id(GsweZodiac sign, GError **err); -GsweHouseSystemInfo *gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err); + +GsweHouseSystemInfo *gswe_find_house_system_info_by_id( + GsweHouseSystem house_system, + GError **err); + GsweAspectInfo *gswe_find_aspect_info_by_id(GsweAspect aspect, GError **err); -GsweAntiscionAxisInfo *gswe_find_antiscion_axis_info_by_id(GsweAntiscionAxis antiscion_axis, GError **err); + +GsweAntiscionAxisInfo *gswe_find_antiscion_axis_info_by_id( + GsweAntiscionAxis antiscion_axis, + GError **err); #endif /* __SWE_GLIB_H__ */