Code beautification

This commit is contained in:
Gergely Polonkai 2014-07-08 10:43:54 +02:00
parent cb1fa1f67a
commit 95e89a4c25
35 changed files with 2023 additions and 439 deletions

View File

@ -30,7 +30,12 @@
* The #GsweAntiscionAxisInfo stores information about an antiscion axis. * 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 static void
gswe_antiscion_axis_info_free(GsweAntiscionAxisInfo *antiscion_axis_info) 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: * gswe_antiscion_axis_info_unref:
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo * @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 void
gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info) 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. * Sets the axis ID.
*/ */
void 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; 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: * gswe_antiscion_axis_info_set_start_sign_info:
* @antiscion_axis_info: (in): a #GsweAntiscionAxisInfo * @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. * Sets the starting sign of the axis.
*/ */
void 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) { if (antiscion_axis_info->start_sign != NULL) {
gswe_sign_info_unref(antiscion_axis_info->start_sign); 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. * 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 * 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; return antiscion_axis_info->start_sign;
} }
@ -165,13 +178,23 @@ gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_ax
* be found. * be found.
*/ */
void 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; 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_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; return;
} }
@ -192,7 +215,8 @@ gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_in
* Returns: the corresponding sign ID * Returns: the corresponding sign ID
*/ */
GsweZodiac 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) { if (antiscion_axis_info->start_sign) {
return antiscion_axis_info->start_sign->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 * Sets the name of the axis
*/ */
void 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) { if (antiscion_axis_info->name != NULL) {
g_free(antiscion_axis_info->name); 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. * Sets the offset at which the axis starts.
*/ */
void 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; 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 * Returns: the offset, in degrees
*/ */
gdouble 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; return antiscion_axis_info->sign_offset;
} }

View File

@ -28,8 +28,8 @@ G_BEGIN_DECLS
/** /**
* GsweAntiscionAxisInfo: * GsweAntiscionAxisInfo:
* *
* <structname>GsweAntiscionAxisInfo</structname> is an opaque structure whose members * <structname>GsweAntiscionAxisInfo</structname> is an opaque structure whose
* cannot be accessed directly. * members cannot be accessed directly.
* *
* Since: 1.1 * 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_new(void);
GsweAntiscionAxisInfo *gswe_antiscion_axis_info_ref(GsweAntiscionAxisInfo *antiscion_axis_info); GsweAntiscionAxisInfo *gswe_antiscion_axis_info_ref(
void gswe_antiscion_axis_info_unref(GsweAntiscionAxisInfo *antiscion_axis_info); GsweAntiscionAxisInfo *antiscion_axis_info);
void gswe_antiscion_axis_info_set_axis(GsweAntiscionAxisInfo *antiscion_axis_info, GsweAntiscionAxis axis); void gswe_antiscion_axis_info_unref(
GsweAntiscionAxis gswe_antiscion_axis_info_get_axis(GsweAntiscionAxisInfo *antiscion_axis_info); 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_axis(
GsweSignInfo *gswe_antiscion_axis_info_get_start_sign_info(GsweAntiscionAxisInfo *antiscion_axis_info); GsweAntiscionAxisInfo *antiscion_axis_info,
GsweAntiscionAxis axis);
void gswe_antiscion_axis_info_set_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info, GsweZodiac sign, GError **err); GsweAntiscionAxis gswe_antiscion_axis_info_get_axis(
GsweZodiac gswe_antiscion_axis_info_get_start_sign(GsweAntiscionAxisInfo *antiscion_axis_info); GsweAntiscionAxisInfo *antiscion_axis_info);
void gswe_antiscion_axis_info_set_name(GsweAntiscionAxisInfo *antiscion_axis_info, const gchar *name); void gswe_antiscion_axis_info_set_start_sign_info(
const gchar *gswe_antiscion_axis_info_get_name(GsweAntiscionAxisInfo *antiscion_axis_info); GsweAntiscionAxisInfo *antiscion_axis_info,
GsweSignInfo *sign_info);
void gswe_antiscion_axis_info_set_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_info, gdouble sign_offset); GsweSignInfo *gswe_antiscion_axis_info_get_start_sign_info(
gdouble gswe_antiscion_axis_info_get_sign_offset(GsweAntiscionAxisInfo *antiscion_axis_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 G_END_DECLS

View File

@ -33,7 +33,8 @@ struct _GsweAntiscionData {
/* the #GsweAntiscionAxisInfo structure associated with this antiscion */ /* the #GsweAntiscionAxisInfo structure associated with this antiscion */
GsweAntiscionAxisInfo *antiscion_axis_info; 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; gdouble difference;
/* reference count */ /* reference count */

View File

@ -35,7 +35,12 @@
* between two planets, based on a specified axis. * 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 static void
gswe_antiscion_data_free(GsweAntiscionData *antiscion_data) gswe_antiscion_data_free(GsweAntiscionData *antiscion_data)
@ -74,15 +79,20 @@ gswe_antiscion_data_new(void)
/* /*
* find_antiscion: * find_antiscion:
* @axis_p: a pointer made with GINT_TO_POINTER(), holding the antiscion axis ID * @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_axis_info: a GsweAntiscionAxisInfo, which will be checked against
* @antiscion_data: a GsweAntiscionData, whose planets' positions will be checked against @antiscion_axis_info * @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 * 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 * check if the two planets in @antiscion_data are antiscia of each other on
* the axis in @antiscion_axis_info * the axis in @antiscion_axis_info
*/ */
static gboolean 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; GsweAntiscionAxis axis;
gdouble start_point, gdouble start_point,
@ -93,7 +103,10 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, Gswe
return FALSE; 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->start_sign->sign - 1) * 30.0;
start_point += antiscion_axis_info->sign_offset; 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; 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; antiscion_data->antiscion_axis_info = antiscion_axis_info;
return TRUE; return TRUE;
@ -137,8 +152,17 @@ find_antiscion(gpointer axis_p, GsweAntiscionAxisInfo *antiscion_axis_info, Gswe
void void
gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data) 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) { if ((antiscion_data->antiscion_axis_info = g_hash_table_find(
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))); 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 { } else {
gswe_antiscion_axis_info_ref(antiscion_data->antiscion_axis_info); 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 * Returns: (transfer full): a new #GsweAntiscionData
*/ */
GsweAntiscionData * GsweAntiscionData *
gswe_antiscion_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2) gswe_antiscion_data_new_with_planets(
GswePlanetData *planet1,
GswePlanetData *planet2)
{ {
GsweAntiscionData *ret; GsweAntiscionData *ret;
@ -188,7 +214,8 @@ gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data)
* gswe_antiscion_data_unref: * gswe_antiscion_data_unref:
* @antiscion_data: (in): a #GsweAntiscionData * @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 void
gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data) 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. * Sets @planet1 as the first planet of the antiscion.
*/ */
void 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) { if (antiscion_data->planet1) {
gswe_planet_data_unref(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. * 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 * GswePlanetData *
gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data) 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. * Sets @planet2 as the second planet of the antiscion.
*/ */
void 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) { if (antiscion_data->planet2) {
gswe_planet_data_unref(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. * 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 * GswePlanetData *
gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data) 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. * the axis is not known.
*/ */
void 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; GsweAntiscionAxisInfo *antiscion_axis_info;
if ((antiscion_axis_info = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(axis))) == NULL) { if ((antiscion_axis_info = g_hash_table_lookup(
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, "Unknown antiscion axis"); 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; return;
} }
@ -285,7 +328,9 @@ gswe_antiscion_data_set_axis(GsweAntiscionData *antiscion_data, GsweAntiscionAxi
gswe_antiscion_axis_info_unref(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
);
} }
/** /**
@ -314,13 +359,17 @@ gswe_antiscion_data_get_axis(GsweAntiscionData *antiscion_data)
* Sets @antiscion_axis_info as the axis of this #GsweAntiscionData. * Sets @antiscion_axis_info as the axis of this #GsweAntiscionData.
*/ */
void 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) { if (antiscion_data->antiscion_axis_info) {
gswe_antiscion_axis_info_unref(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. * 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 * GsweAntiscionAxisInfo *
gswe_antiscion_data_get_antiscion_axis_info(GsweAntiscionData *antiscion_data) 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. * Sets the difference of this antiscion from an exact antiscion.
*/ */
void 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; antiscion_data->difference = difference;
} }
@ -354,7 +406,8 @@ gswe_antiscion_data_set_difference(GsweAntiscionData *antiscion_data, gdouble di
* gswe_antiscion_data_get_difference: * gswe_antiscion_data_get_difference:
* @antiscion_data: (in): a #GsweAntiscionData * @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 * Returns: the difference, in degrees
*/ */

View File

@ -28,8 +28,8 @@ G_BEGIN_DECLS
/** /**
* GsweAntiscionData: * GsweAntiscionData:
* *
* <structname>GsweAntiscionData</structname> is an opaque structure whose members * <structname>GsweAntiscionData</structname> is an opaque structure whose
* cannot be accessed directly. * members cannot be accessed directly.
* *
* Since: 1.1 * Since: 1.1
*/ */
@ -39,21 +39,37 @@ GType gswe_antiscion_data_get_type(void);
#define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type()) #define GSWE_TYPE_ANTISCION_DATA (gswe_antiscion_data_get_type())
GsweAntiscionData *gswe_antiscion_data_new(void); 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); GsweAntiscionData *gswe_antiscion_data_ref(GsweAntiscionData *antiscion_data);
void gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data); void gswe_antiscion_data_unref(GsweAntiscionData *antiscion_data);
void gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data); void gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data);
void gswe_antiscion_data_set_planet1(GsweAntiscionData *antiscion_data, GswePlanetData *planet1); void gswe_antiscion_data_set_planet1(
GswePlanetData *gswe_antiscion_data_get_planet1(GsweAntiscionData *antiscion_data); GsweAntiscionData *antiscion_data,
GswePlanetData *planet1);
void gswe_antiscion_data_set_planet2(GsweAntiscionData *antiscion_data, GswePlanetData *planet2); GswePlanetData *gswe_antiscion_data_get_planet1(
GswePlanetData *gswe_antiscion_data_get_planet2(GsweAntiscionData *antiscion_data); 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); gdouble gswe_antiscion_data_get_difference(GsweAntiscionData *antiscion_data);
G_END_DECLS G_END_DECLS

View File

@ -35,7 +35,8 @@ struct _GsweAspectData {
/* the #GsweAspectInfo structure associated with the aspect */ /* the #GsweAspectInfo structure associated with the aspect */
GsweAspectInfo *aspect_info; 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; gdouble difference;
/* reference count */ /* reference count */

View File

@ -38,7 +38,12 @@
* #GsweAspectData is a structure that represents two planets relation to each * #GsweAspectData is a structure that represents two planets relation to each
* other, like their aspect and the aspect's difference from an exact aspect. * 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 static void
gswe_aspect_data_free(GsweAspectData *aspect_data) gswe_aspect_data_free(GsweAspectData *aspect_data)
@ -62,20 +67,27 @@ gswe_aspect_data_free(GsweAspectData *aspect_data)
* find_aspect: * find_aspect:
* @aspect_p: a pointer made with GINT_TO_POINTER(), holding the aspect ID * @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_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 * 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 * if the two planets in @aspect_data are in aspect according to @aspect_info
*/ */
static gboolean 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, gdouble diff,
planet_orb, planet_orb,
aspect_orb; aspect_orb;
diff = fabs(aspect_info->size - aspect_data->distance); 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); aspect_orb = fmax(1.0, planet_orb - aspect_info->orb_modifier);
if (diff < aspect_orb) { if (diff < aspect_orb) {
@ -84,7 +96,8 @@ find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspe
if (aspect_info->size == 0) { if (aspect_info->size == 0) {
aspect_data->difference = (1 - ((360.0 - diff) / 360.0)) * 100.0; aspect_data->difference = (1 - ((360.0 - diff) / 360.0)) * 100.0;
} else { } 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; return TRUE;
@ -96,12 +109,23 @@ find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspe
void void
gswe_aspect_data_calculate(GsweAspectData *aspect_data) 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; 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) { if ((aspect_data->aspect_info = g_hash_table_find(
aspect_data->aspect_info = gswe_aspect_info_ref(g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(GSWE_ASPECT_NONE))); 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 { } else {
gswe_aspect_info_ref(aspect_data->aspect_info); 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. * Returns: (transfer full): a new #GsweAspectData with all data set.
*/ */
GsweAspectData * GsweAspectData *
gswe_aspect_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *planet2) gswe_aspect_data_new_with_planets(
GswePlanetData *planet1,
GswePlanetData *planet2)
{ {
GsweAspectData *ret; GsweAspectData *ret;
@ -171,7 +197,8 @@ gswe_aspect_data_ref(GsweAspectData *aspect_data)
* gswe_aspect_data_unref: * gswe_aspect_data_unref:
* @aspect_data: (in): a #GsweAspectData * @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 void
gswe_aspect_data_unref(GsweAspectData *aspect_data) 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. * Sets @planet1 as the first planet of the aspect.
*/ */
void 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) { if (aspect_data->planet1) {
gswe_planet_data_unref(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. * 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 * GswePlanetData *
gswe_aspect_data_get_planet1(GsweAspectData *aspect_data) 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. * Sets @planet2 as the second planet of the aspect.
*/ */
void 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) { if (aspect_data->planet2) {
gswe_planet_data_unref(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. * 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 * GswePlanetData *
gswe_aspect_data_get_planet2(GsweAspectData *aspect_data) gswe_aspect_data_get_planet2(GsweAspectData *aspect_data)

View File

@ -37,23 +37,37 @@ G_BEGIN_DECLS
typedef struct _GsweAspectData GsweAspectData; typedef struct _GsweAspectData GsweAspectData;
GType gswe_aspect_data_get_type(void); GType gswe_aspect_data_get_type(void);
#define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type()) #define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type())
GsweAspectData *gswe_aspect_data_new(void); 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); GsweAspectData *gswe_aspect_data_ref(GsweAspectData *aspect_data);
void gswe_aspect_data_unref(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); 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); GswePlanetData *gswe_aspect_data_get_planet2(GsweAspectData *aspect_data);
gdouble gswe_aspect_data_get_distance(GsweAspectData *aspect_data); gdouble gswe_aspect_data_get_distance(GsweAspectData *aspect_data);
GsweAspect gswe_aspect_data_get_aspect(GsweAspectData *aspect_data); GsweAspect gswe_aspect_data_get_aspect(GsweAspectData *aspect_data);
GsweAspectInfo *gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data); GsweAspectInfo *gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data);
gdouble gswe_aspect_data_get_difference(GsweAspectData *aspect_data); gdouble gswe_aspect_data_get_difference(GsweAspectData *aspect_data);
G_END_DECLS G_END_DECLS

View File

@ -32,7 +32,8 @@ struct _GsweAspectInfo {
/* the size of the aspect, in degrees */ /* the size of the aspect, in degrees */
guint size; 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; gdouble orb_modifier;
/* shows whether this aspect is harmonic or not */ /* shows whether this aspect is harmonic or not */

View File

@ -37,7 +37,12 @@
* possible; until then, you should never use such functions.</para></warning> * possible; until then, you should never use such functions.</para></warning>
*/ */
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 static void
gswe_aspect_info_free(GsweAspectInfo *aspect_info) 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. * between two positions exceeds this limit, the aspect is not considered.
*/ */
void 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; aspect_info->orb_modifier = orb_modifier;
} }
@ -217,7 +224,8 @@ gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info)
/** /**
* gswe_aspect_info_set_harmonic: * gswe_aspect_info_set_harmonic:
* @aspect_info: (in): a #GsweAspectInfo * @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. * Sets the harmonic state of @aspect_info.
*/ */
@ -244,11 +252,13 @@ gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info)
/** /**
* gswe_aspect_info_set_major: * gswe_aspect_info_set_major:
* @aspect_info: (in): a #GsweAspectInfo * @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. * Sets the major state of @aspect_info.
* *
* <note><para>As all Ptolemaic aspects are registered during gswe_init(), you should never set @major to TRUE on new aspects.</para></note> * <note><para>As all Ptolemaic aspects are registered during gswe_init(), you
* should never set @major to TRUE on new aspects.</para></note>
*/ */
void void
gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major) gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major)

View File

@ -40,21 +40,33 @@ GType gswe_aspect_info_get_type(void);
GsweAspectInfo *gswe_aspect_info_new(void); GsweAspectInfo *gswe_aspect_info_new(void);
GsweAspectInfo *gswe_aspect_info_ref(GsweAspectInfo *aspect_info); GsweAspectInfo *gswe_aspect_info_ref(GsweAspectInfo *aspect_info);
void gswe_aspect_info_unref(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); GsweAspect gswe_aspect_info_get_aspect(GsweAspectInfo *aspect_info);
void gswe_aspect_info_set_name(GsweAspectInfo *aspect_info, const gchar *name); void gswe_aspect_info_set_name(GsweAspectInfo *aspect_info, const gchar *name);
const gchar *gswe_aspect_info_get_name(GsweAspectInfo *aspect_info); const gchar *gswe_aspect_info_get_name(GsweAspectInfo *aspect_info);
void gswe_aspect_info_set_size(GsweAspectInfo *aspect_info, gdouble size); void gswe_aspect_info_set_size(GsweAspectInfo *aspect_info, gdouble size);
gdouble gswe_aspect_info_get_size(GsweAspectInfo *aspect_info); 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); 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); gboolean gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info);
void gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major); void gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major);

View File

@ -39,14 +39,21 @@ GType
/*** END value-header ***/ /*** END value-header ***/
/*** BEGIN value-production ***/ /*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" }, {
@VALUENAME@,
"@VALUENAME@",
"@valuenick@"
},
/*** END value-production ***/ /*** END value-production ***/
/*** BEGIN value-tail ***/ /*** BEGIN value-tail ***/
{ 0, NULL, NULL } { 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); g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
} }

View File

@ -22,13 +22,15 @@
#include "gswe-house-data.h" #include "gswe-house-data.h"
struct _GsweHouseData { 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; guint house;
/* the position of the house's cusp on the sky */ /* the position of the house's cusp on the sky */
gdouble cusp_position; 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; GsweSignInfo *sign_info;
/* reference count */ /* reference count */

View File

@ -33,7 +33,12 @@
* #GsweHouseData is a structure that represents a house's position. * #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 static void
gswe_house_data_free(GsweHouseData *house_data) gswe_house_data_free(GsweHouseData *house_data)
@ -83,7 +88,8 @@ gswe_house_data_ref(GsweHouseData *house_data)
* gswe_house_data_unref: * gswe_house_data_unref:
* @house_data: a #GsweHouseData * @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 void
gswe_house_data_unref(GsweHouseData *house_data) gswe_house_data_unref(GsweHouseData *house_data)

View File

@ -27,7 +27,8 @@ struct _GsweHouseSystemInfo {
/* the house system's ID */ /* the house system's ID */
GsweHouseSystem house_system; 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; gchar sweph_id;
/* the name of this house system */ /* the name of this house system */

View File

@ -29,7 +29,12 @@
* #GsweHouseSystemInfo stores information of a house system. * #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 static void
gswe_house_system_info_free(GsweHouseSystemInfo *house_system_info) 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. * Sets up @house_system_info to represent @house_system.
*/ */
void 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; 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. * marked by @sweph_id.
*/ */
void 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; 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. * Sets the name of @house_system_info.
*/ */
void 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) { if (house_system_info->name) {
g_free(house_system_info->name); g_free(house_system_info->name);

View File

@ -27,8 +27,8 @@ G_BEGIN_DECLS
/** /**
* GsweHouseSystemInfo: * GsweHouseSystemInfo:
* *
* <structname>GsweHouseSystemInfo</structname> is an opaque structure whose members * <structname>GsweHouseSystemInfo</structname> is an opaque structure whose
* cannot be accessed directly. * members cannot be accessed directly.
* *
* Since: 1.1 * 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_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_unref(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_house_system(
GsweHouseSystem gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info); GsweHouseSystemInfo *house_system_info,
GsweHouseSystem house_system);
void gswe_house_system_info_set_sweph_id(GsweHouseSystemInfo *house_system_info, gchar sweph_id); GsweHouseSystem gswe_house_system_info_get_house_system(
gchar gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info); GsweHouseSystemInfo *house_system_info);
void gswe_house_system_info_set_name(GsweHouseSystemInfo *house_system_info, const gchar *name); void gswe_house_system_info_set_sweph_id(
const gchar *gswe_house_system_info_get_name(GsweHouseSystemInfo *house_system_info); 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 G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@ -26,11 +26,24 @@
#include "gswe-types.h" #include "gswe-types.h"
#define GSWE_TYPE_MOMENT (gswe_moment_get_type()) #define GSWE_TYPE_MOMENT (gswe_moment_get_type())
#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment)) #define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST( \
#define GSWE_IS_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_MOMENT)) (obj), \
#define GSWE_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_MOMENT, GsweMomentClass)) GSWE_TYPE_MOMENT, \
#define GSWE_IS_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_MOMENT)) GsweMoment))
#define GSWE_MOMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_MOMENT, GsweMomentClass)) #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 _GsweMoment GsweMoment;
typedef struct _GsweMomentClass GsweMomentClass; typedef struct _GsweMomentClass GsweMomentClass;
@ -90,42 +103,97 @@ GType gswe_moment_get_type(void);
/* Method definitions */ /* Method definitions */
GsweMoment *gswe_moment_new(void); 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); void gswe_moment_set_timestamp(GsweMoment *moment, GsweTimestamp *timestamp);
GsweTimestamp *gswe_moment_get_timestamp(GsweMoment *moment); 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); 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); GsweHouseSystem gswe_moment_get_house_system(GsweMoment *moment);
GList *gswe_moment_get_house_cusps(GsweMoment *moment, GError **err); GList *gswe_moment_get_house_cusps(GsweMoment *moment, GError **err);
gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err); gint gswe_moment_get_house(GsweMoment *moment, gdouble position, GError **err);
gboolean gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet); 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); void gswe_moment_add_all_planets(GsweMoment *moment);
GList *gswe_moment_get_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_sign_planets(GsweMoment *moment, GsweZodiac sign);
GList *gswe_moment_get_house_planets(GsweMoment *moment, guint house); GList *gswe_moment_get_house_planets(GsweMoment *moment, guint house);
guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element); guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element);
guint gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality); guint gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality);
GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment, GError **err); GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment, GError **err);
GList *gswe_moment_get_all_aspects(GsweMoment *moment); 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_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_all_planet_antiscia(
GList *gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err); GsweMoment *moment,
GsweAntiscionData *gswe_moment_get_antiscion_by_planets(GsweMoment *moment, GswePlanet planet1, GswePlanet planet2, GError **err); 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__ */ #endif /* __GSWE_MOMENT_H__ */

View File

@ -38,7 +38,11 @@
* Moon, including its illumination percentage. * 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: * gswe_moon_phase_data_new:
@ -78,7 +82,8 @@ gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data)
* gswe_moon_phase_data_unref: * gswe_moon_phase_data_unref:
* @moon_phase_data: (in): a #GsweMoonPhaseData * @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 void
gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data) 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. * Calculates the moon at a given time, specified by @jd.
*/ */
void 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, gdouble jdb,
phase_percent; 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. * Calculates the moon at a given time, specified by @timestamp.
*/ */
void 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; gdouble jd;

View File

@ -28,8 +28,8 @@ G_BEGIN_DECLS
/** /**
* GsweMoonPhaseData: * GsweMoonPhaseData:
* *
* <structname>GsweMoonPhaseData</structname> is an opaque structure whose members * <structname>GsweMoonPhaseData</structname> is an opaque structure whose
* cannot be accessed directly. * members cannot be accessed directly.
* *
* Since: 1.1 * Since: 1.1
*/ */
@ -38,13 +38,24 @@ typedef struct _GsweMoonPhaseData GsweMoonPhaseData;
GsweMoonPhaseData *gswe_moon_phase_data_new(void); GsweMoonPhaseData *gswe_moon_phase_data_new(void);
GsweMoonPhaseData *gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data); 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_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_jd(
void gswe_moon_phase_data_calculate_by_timestamp(GsweMoonPhaseData *moon_phase_data, GsweTimestamp *timestamp, GError **err); GsweMoonPhaseData *moon_phase_data,
gdouble jd,
GError **err);
GsweMoonPhase gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data); void gswe_moon_phase_data_calculate_by_timestamp(
gdouble gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data); 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); GType gswe_moon_phase_data_get_type(void);
#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type()) #define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type())

View File

@ -35,7 +35,8 @@ struct _GswePlanetData {
/* Number of the house in which the planet is in */ /* Number of the house in which the planet is in */
gint house; 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; GsweSignInfo *sign_info;
/* An internal version number of the calculation */ /* An internal version number of the calculation */

View File

@ -35,7 +35,11 @@
* is in. * 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 static void
gswe_planet_data_free(GswePlanetData *planet_data) gswe_planet_data_free(GswePlanetData *planet_data)
@ -89,7 +93,8 @@ gswe_planet_data_ref(GswePlanetData *planet_data)
* gswe_planet_data_unref: * gswe_planet_data_unref:
* @planet_data: a #GswePlanetData * @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 void
gswe_planet_data_unref(GswePlanetData *planet_data) 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. * GSWE_ERROR_UNKNOWN_PLANET, and the planet ID is not set.
*/ */
void 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; GswePlanetInfo *planet_info;
if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) { if ((planet_info = g_hash_table_lookup(
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Planet is unknown"); gswe_planet_info_table,
GINT_TO_POINTER(planet)
)) == NULL) {
g_set_error(err,
GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET,
"Planet is unknown"
);
return; return;
} }
@ -157,7 +171,9 @@ gswe_planet_data_get_planet(GswePlanetData *planet_data)
* Sets @planet_info as the planet information for @planet_data. * Sets @planet_info as the planet information for @planet_data.
*/ */
void 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) { if (planet_data == NULL) {
return; return;
@ -247,7 +263,8 @@ gswe_planet_data_get_house(GswePlanetData *planet_data)
* gswe_planet_data_get_sign: * gswe_planet_data_get_sign:
* @planet_data: a #GswePlanetData * @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 * Returns: a #GsweZodiac, which @planet_data is currently in
*/ */

View File

@ -42,18 +42,30 @@ GType gswe_planet_data_get_type(void);
GswePlanetData *gswe_planet_data_new(void); GswePlanetData *gswe_planet_data_new(void);
GswePlanetData *gswe_planet_data_ref(GswePlanetData *planet_data); GswePlanetData *gswe_planet_data_ref(GswePlanetData *planet_data);
void gswe_planet_data_unref(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); 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); GswePlanetInfo *gswe_planet_data_get_planet_info(GswePlanetData *planet_data);
gdouble gswe_planet_data_get_position(GswePlanetData *planet_data); gdouble gswe_planet_data_get_position(GswePlanetData *planet_data);
gboolean gswe_planet_data_get_retrograde(GswePlanetData *planet_data); gboolean gswe_planet_data_get_retrograde(GswePlanetData *planet_data);
guint gswe_planet_data_get_house(GswePlanetData *planet_data); guint gswe_planet_data_get_house(GswePlanetData *planet_data);
GsweZodiac gswe_planet_data_get_sign(GswePlanetData *planet_data); GsweZodiac gswe_planet_data_get_sign(GswePlanetData *planet_data);
GsweSignInfo *gswe_planet_data_get_sign_info(GswePlanetData *planet_data); GsweSignInfo *gswe_planet_data_get_sign_info(GswePlanetData *planet_data);
G_END_DECLS G_END_DECLS

View File

@ -26,10 +26,13 @@ struct _GswePlanetInfo {
/* the planet ID */ /* the planet ID */
GswePlanet planet; 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; 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; gboolean real_body;
/* the planet's “personal” orb */ /* the planet's “personal” orb */

View File

@ -30,7 +30,11 @@
* The #GswePlanetInfo structure stores information about a planet. * 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: * gswe_planet_info_new:
@ -80,7 +84,8 @@ gswe_planet_info_free(GswePlanetInfo *planet_info)
* gswe_planet_info_unref: * gswe_planet_info_unref:
* @planet_info: a #GswePlanetInfo * @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 void
gswe_planet_info_unref(GswePlanetInfo *planet_info) 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 * @real_body: a boolean that indicates if this planet is an object recognized
* by Swiss Ephemeris * 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 void
gswe_planet_info_set_real_body(GswePlanetInfo *planet_info, gboolean real_body) 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: * gswe_planet_info_get_real_body:
* @planet_info: (in): A #GswePlanetInfo * @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 * 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 * @planet_info: a #GswePlanetInfo
* @points: the new point value * @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 void
gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points) gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points)

View File

@ -40,24 +40,37 @@ GType gswe_planet_info_get_type(void);
GswePlanetInfo *gswe_planet_info_new(void); GswePlanetInfo *gswe_planet_info_new(void);
GswePlanetInfo *gswe_planet_info_ref(GswePlanetInfo *planet_info); GswePlanetInfo *gswe_planet_info_ref(GswePlanetInfo *planet_info);
void gswe_planet_info_unref(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); 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); 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); gboolean gswe_planet_info_get_real_body(GswePlanetInfo *planet_info);
void gswe_planet_info_set_orb(GswePlanetInfo *planet_info, gdouble orb); void gswe_planet_info_set_orb(GswePlanetInfo *planet_info, gdouble orb);
gdouble gswe_planet_info_get_orb(GswePlanetInfo *planet_info); gdouble gswe_planet_info_get_orb(GswePlanetInfo *planet_info);
void gswe_planet_info_set_name(GswePlanetInfo *planet_info, const gchar *name); void gswe_planet_info_set_name(GswePlanetInfo *planet_info, const gchar *name);
const gchar *gswe_planet_info_get_name(GswePlanetInfo *planet_info); const gchar *gswe_planet_info_get_name(GswePlanetInfo *planet_info);
void gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points); void gswe_planet_info_set_points(GswePlanetInfo *planet_info, gint points);
gint gswe_planet_info_get_points(GswePlanetInfo *planet_info); gint gswe_planet_info_get_points(GswePlanetInfo *planet_info);
G_END_DECLS G_END_DECLS

View File

@ -30,7 +30,10 @@
* The #GsweSignInfo stores information about a zodiac sign. * 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 static void
gswe_sign_info_free(GsweSignInfo *sign_info) gswe_sign_info_free(GsweSignInfo *sign_info)
@ -80,7 +83,8 @@ gswe_sign_info_ref(GsweSignInfo *sign_info)
* gswe_sign_info_unref: * gswe_sign_info_unref:
* @sign_info: a #GsweSignInfo * @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 void
gswe_sign_info_unref(GsweSignInfo *sign_info) gswe_sign_info_unref(GsweSignInfo *sign_info)

View File

@ -34,7 +34,11 @@
* This object converts Gregorian dates to Julian days and vice versa. * 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 { typedef enum {
VALID_GREGORIAN = 1 << 0, VALID_GREGORIAN = 1 << 0,
@ -80,13 +84,35 @@ enum {
static guint gswe_timestamp_signals[SIGNAL_LAST] = { 0 }; static guint gswe_timestamp_signals[SIGNAL_LAST] = { 0 };
static void gswe_timestamp_dispose(GObject *gobject); static void gswe_timestamp_dispose(
static void gswe_timestamp_finalize(GObject *gobject); 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_finalize(
static void gswe_timestamp_calculate_all(GsweTimestamp *timestamp, GError **err); GObject *gobject);
static void gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err);
static void gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err); 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); 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 * 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: * GsweTimestamp:instant-recalc:
@ -119,7 +150,16 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* Otherwise, the values are recalculated only upon request (e.g. on * Otherwise, the values are recalculated only upon request (e.g. on
* calling gswe_timestamp_get_julian_day()). * 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: * GsweTimestamp:gregorian-valid:
@ -129,56 +169,136 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* Otherwise, the Gregorian date components will be recalculated upon * Otherwise, the Gregorian date components will be recalculated upon
* request. * 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: * GsweTimestamp:gregorian-year:
* *
* The Gregorian year of the timestamp * 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: * GsweTimestamp:gregorian-month:
* *
* The Gregorian month of the timestamp * 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: * GsweTimestamp:gregorian-day:
* *
* The Gregorian day of the timestamp * 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: * GsweTimestamp:gregorian-hour:
* *
* The Gregorian hour of the timestamp * 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: * GsweTimestamp:gregorian-minute:
* *
* The Gregorian minute of the timestamp * 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: * GsweTimestamp:gregorian-second:
* *
* The Gregorian second of the timestamp * 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: * GsweTimestamp:gregorian-microsecond:
* *
* The Gregorian microsecond of the timestamp * 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: * GsweTimestamp:gregorian-timezone-offset:
@ -205,7 +325,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* currently considered as valid, thus, no recalculation is needed. * currently considered as valid, thus, no recalculation is needed.
* Otherwise, the Julian day components will be recalculated upon request. * 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); g_date_time_unref(local_time);
} }
@ -235,7 +365,11 @@ gswe_timestamp_finalize(GObject *gobject)
} }
static void 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); GsweTimestamp *timestamp = GSWE_TIMESTAMP(object);
@ -246,42 +380,74 @@ gswe_timestamp_set_property(GObject *object, guint prop_id, const GValue *value,
break; break;
case PROP_GREGORIAN_YEAR: 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; break;
case PROP_GREGORIAN_MONTH: 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; break;
case PROP_GREGORIAN_DAY: 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; break;
case PROP_GREGORIAN_HOUR: 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; break;
case PROP_GREGORIAN_MINUTE: 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; break;
case PROP_GREGORIAN_SECOND: 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; break;
case PROP_GREGORIAN_MICROSECOND: 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; break;
case PROP_GREGORIAN_TIMEZONE_OFFSET: 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; break;
@ -293,7 +459,11 @@ gswe_timestamp_set_property(GObject *object, guint prop_id, const GValue *value,
} }
static void 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); GsweTimestamp *timestamp = GSWE_TIMESTAMP(object);
@ -304,7 +474,11 @@ gswe_timestamp_get_property(GObject *object, guint prop_id, GValue *value, GPara
break; break;
case PROP_GREGORIAN_VALID: 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; break;
@ -351,12 +525,18 @@ gswe_timestamp_get_property(GObject *object, guint prop_id, GValue *value, GPara
break; break;
case PROP_GREGORIAN_TIMEZONE_OFFSET: 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; break;
case PROP_JULIAN_DAY_VALID: 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; break;
@ -395,11 +575,22 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err)
} }
if (timestamp->priv->valid_dates == 0) { 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; 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( swe_utc_time_zone(
utc_year, utc_month, utc_day, utc_year, utc_month, utc_day,
utc_hour, utc_minute, utc_second, utc_hour, utc_minute, utc_second,
@ -412,7 +603,9 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err)
&local_second &local_second
); );
timestamp->priv->gregorian_second = floor(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 * @instant_recalc: the new value
* @err: a #GError * @err: a #GError
* *
* Sets the value of the <link linkend="GsweTimestamp--instant-recalc">instant-recalc</link> property. For details, see the * Sets the value of the <link
* property's description. @err is populated with calculation errors if * linkend="GsweTimestamp--instant-recalc">instant-recalc</link> property. For
* @instant_recalc is TRUE and a calculation error happens. * details, see the property's description. @err is populated with calculation
* errors if @instant_recalc is TRUE and a calculation error happens.
*/ */
void 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; timestamp->priv->instant_recalc = instant_recalc;
@ -468,7 +665,12 @@ gswe_timestamp_get_instant_recalc(GsweTimestamp *timestamp)
* TRUE * TRUE
*/ */
void 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_year = year;
timestamp->priv->gregorian_month = month; timestamp->priv->gregorian_month = month;
@ -494,10 +696,15 @@ gswe_timestamp_set_gregorian_full(GsweTimestamp *timestamp, gint year, gint mont
* @err: a #GError * @err: a #GError
* *
* Sets the Gregorian year of @timestamp. @err is populated with calculation * Sets the Gregorian year of @timestamp. @err is populated with calculation
* errors if the <link linkend="GsweTimestamp--instant-recalc">instant-recalc</link> property is TRUE * errors if the <link
* linkend="GsweTimestamp--instant-recalc">instant-recalc</link> property is
* TRUE
*/ */
void 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->gregorian_year = gregorian_year;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -538,7 +745,10 @@ gswe_timestamp_get_gregorian_year(GsweTimestamp *timestamp, GError **err)
* TRUE * TRUE
*/ */
void 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->gregorian_month = gregorian_month;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -579,7 +789,10 @@ gswe_timestamp_get_gregorian_month(GsweTimestamp *timestamp, GError **err)
* TRUE * TRUE
*/ */
void 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->gregorian_day = gregorian_day;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -620,7 +833,10 @@ gswe_timestamp_get_gregorian_day(GsweTimestamp *timestamp, GError **err)
* TRUE * TRUE
*/ */
void 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->gregorian_hour = gregorian_hour;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -661,7 +877,10 @@ gswe_timestamp_get_gregorian_hour(GsweTimestamp *timestamp, GError **err)
* TRUE * TRUE
*/ */
void 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->gregorian_minute = gregorian_minute;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -702,7 +921,10 @@ gswe_timestamp_get_gregorian_minute(GsweTimestamp *timestamp, GError **err)
* TRUE. * TRUE.
*/ */
void 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->gregorian_second = gregorian_second;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -743,7 +965,10 @@ gswe_timestamp_get_gregorian_second(GsweTimestamp *timestamp, GError **err)
* TRUE * TRUE
*/ */
void 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->gregorian_microsecond = gregorian_microsecond;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = VALID_GREGORIAN;
@ -779,11 +1004,15 @@ gswe_timestamp_get_gregorian_microsecond(GsweTimestamp *timestamp, GError **err)
* @err: a #GError * @err: a #GError
* *
* Sets the time zone used in Gregorian date calculations. @err is populated * Sets the time zone used in Gregorian date calculations. @err is populated
* with calculation errors if the <link linkend="GsweTimestamp--instant-recalc">instant-recalc</link> property's value is TRUE and a * with calculation errors if the <link
* calculation error happens. * linkend="GsweTimestamp--instant-recalc">instant-recalc</link> property's
* value is TRUE and a calculation error happens.
*/ */
void 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; 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) { 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; return;
} }
@ -834,14 +1068,24 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err)
timestamp->priv->gregorian_day, timestamp->priv->gregorian_day,
timestamp->priv->gregorian_hour, timestamp->priv->gregorian_hour,
timestamp->priv->gregorian_minute, 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, timestamp->priv->gregorian_timezone_offset,
&utc_year, &utc_month, &utc_day, &utc_year, &utc_month, &utc_day,
&utc_hour, &utc_minute, &utc_second &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) { if (
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr); (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 { } else {
timestamp->priv->julian_day = dret[0]; timestamp->priv->julian_day = dret[0];
timestamp->priv->julian_day_ut = dret[1]; timestamp->priv->julian_day_ut = dret[1];
@ -891,7 +1135,10 @@ gswe_timestamp_get_julian_day(GsweTimestamp *timestamp, GError **err)
* Since: 2.1 * Since: 2.1
*/ */
void 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; GError *err_local = NULL;
@ -960,7 +1207,10 @@ gswe_timestamp_get_julian_day_et(GsweTimestamp *timestamp, GError **err)
* with the error details. * with the error details.
*/ */
void 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; GError *err_local = NULL;
@ -1074,12 +1324,16 @@ gswe_timestamp_new(void)
* @microsecond: the microsecond * @microsecond: the microsecond
* @time_zone_offset: the time zone offset in hours * @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. * Returns: a new GsweTimestamp object.
*/ */
GsweTimestamp * 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; GsweTimestamp *timestamp;

View File

@ -22,11 +22,23 @@
#include <glib-object.h> #include <glib-object.h>
#define GSWE_TYPE_TIMESTAMP (gswe_timestamp_get_type()) #define GSWE_TYPE_TIMESTAMP (gswe_timestamp_get_type())
#define GSWE_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_TIMESTAMP, GsweTimestamp)) #define GSWE_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_CAST( \
#define GSWE_IS_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_TIMESTAMP)) (obj), \
#define GSWE_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_TIMESTAMP, GsweTimestampClass)) GSWE_TYPE_TIMESTAMP, \
#define GSWE_IS_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_TIMESTAMP)) GsweTimestamp))
#define GSWE_TIMESTAMP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_TIMESTAMP, GsweTimestampClass)) #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 _GsweTimestamp GsweTimestamp;
typedef struct _GsweTimestampClass GsweTimestampClass; typedef struct _GsweTimestampClass GsweTimestampClass;
@ -85,41 +97,123 @@ GType gswe_timestamp_get_type(void);
/* Method definitions */ /* Method definitions */
GsweTimestamp *gswe_timestamp_new(void); GsweTimestamp *gswe_timestamp_new(void);
GsweTimestamp *gswe_timestamp_new_from_julian_day(gdouble julian_day); 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); GsweTimestamp * gswe_timestamp_new_from_gregorian_full(
void gswe_timestamp_set_instant_recalc(GsweTimestamp *timestamp, gboolean instant_recalc, GError **err); 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); 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); 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); 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); 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); 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_minute(
void gswe_timestamp_set_gregorian_second(GsweTimestamp *timestamp, gint gregorian_second, GError **err); GsweTimestamp *timestamp,
gint gswe_timestamp_get_gregorian_second(GsweTimestamp *timestamp, GError **err); gint gregorian_minute,
void gswe_timestamp_set_gregorian_microsecond(GsweTimestamp *timestamp, gint gregorian_microsecond, GError **err); 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); 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); gdouble gswe_timestamp_get_gregorian_timezone(GsweTimestamp *timestamp);
#ifndef GSWE_DISABLE_DEPRECATED #ifndef GSWE_DISABLE_DEPRECATED
G_DEPRECATED_FOR(gswe_timestamp_set_julian_day_et) 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) 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 #endif
void gswe_timestamp_set_julian_day_et(GsweTimestamp *timestamp, gdouble julian_day, GError **err); void gswe_timestamp_set_julian_day_et(
gdouble gswe_timestamp_get_julian_day_et(GsweTimestamp *timestamp, GError **err); GsweTimestamp *timestamp,
void gswe_timestamp_set_julian_day_ut(GsweTimestamp *timestamp, gdouble julian_day, GError **err); gdouble julian_day,
gdouble gswe_timestamp_get_julian_day_ut(GsweTimestamp *timestamp, GError **err); GError **err);
gdouble gswe_timestamp_get_sidereal_time(GsweTimestamp *timestamp, 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__ */ #endif /* __SWE_GLIB_GSWE_TIMESTAMP_H__ */

View File

@ -37,5 +37,9 @@ gswe_coordinates_copy(GsweCoordinates *coordinates)
return ret; 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);

View File

@ -71,7 +71,10 @@
* Returns: TRUE if the required version is satisfied; FALSE otherwise. * Returns: TRUE if the required version is satisfied; FALSE otherwise.
*/ */
gboolean 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)); return (GSWE_CHECK_VERSION(required_major, required_minor, required_micro));
} }

View File

@ -22,7 +22,10 @@
#define GSWE_MINOR_VERSION @SWE_GLIB_MINOR_VERSION@ #define GSWE_MINOR_VERSION @SWE_GLIB_MINOR_VERSION@
#define GSWE_MICRO_VERSION @SWE_GLIB_MICRO_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) \ #define GSWE_CHECK_VERSION(major,minor,micro) \
(GSWE_MAJOR_VERSION > (major) || \ (GSWE_MAJOR_VERSION > (major) || \

View File

@ -139,89 +139,508 @@ void gswe_init_with_dir(gchar *directory)
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 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,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MC, -1, FALSE, _("Midheaven"), 5.0, 1); GSWE_PLANET_ASCENDANT,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VERTEX, -1, FALSE, _("Vertex"), 2.0, 0); -1,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_NODE, SE_MEAN_NODE, TRUE, _("Ascending Moon Node"), 2.0, 1); FALSE,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_APOGEE, SE_MEAN_APOG, TRUE, _("Dark Moon"), 2.0, 0); _("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,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON, SE_MOON, TRUE, _("Moon"), 9.0, 2); GSWE_PLANET_SUN,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MERCURY, SE_MERCURY, TRUE, _("Mercury"), 7.0, 2); SE_SUN,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VENUS, SE_VENUS, TRUE, _("Venus"), 7.0, 1); TRUE,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MARS, SE_MARS, TRUE, _("Mars"), 7.0, 1); _("Sun"),
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUPITER, SE_JUPITER, TRUE, _("Jupiter"), 9.0, 1); 13.0,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SATURN, SE_SATURN, TRUE, _("Saturn"), 7.0, 1); 2
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,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PLUTO, SE_PLUTO, TRUE, _("Pluto"), 3.0, 1); 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,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CERES, SE_CERES, TRUE, _("Ceres"), 2.0, 0); GSWE_PLANET_CHIRON,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PALLAS, SE_PALLAS, TRUE, _("Pallas"), 2.0, 0); SE_CHIRON,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUNO, SE_JUNO, TRUE, _("Juno"), 2.0, 0); TRUE,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VESTA, SE_VESTA, TRUE, _("Vesta"), 2.0, 0); _("Chiron"),
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PHOLUS, SE_PHOLUS, TRUE, _("Pholus"), 2.0, 0); 2.0,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_NESSUS, SE_AST_OFFSET + 7066, TRUE, _("Nessus"), 2.0, 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,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ERIS, SE_AST_OFFSET + 136199, TRUE, _("Eris"), 2.0, 0); GSWE_PLANET_CERES,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_DEJANIRA, SE_AST_OFFSET + 157, TRUE, _("Dejanira"), 2.0, 0); SE_CERES,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CIRCE, SE_AST_OFFSET + 34, TRUE, _("Circe"), 2.0, 0); TRUE,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ORCUS, SE_AST_OFFSET + 90482, TRUE, _("Orcus"), 2.0, 0); _("Ceres"),
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ASBOLUS, SE_AST_OFFSET + 8405, TRUE, _("Asbolus"), 2.0, 0); 2.0,
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_HYGIEA, SE_AST_OFFSET + 10, TRUE, _("Hygiea"), 2.0, 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,
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_TAURUS, _("Taurus"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_FIX); GSWE_SIGN_ARIES,
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_GEMINI, _("Gemini"), GSWE_ELEMENT_AIR, GSWE_QUALITY_MUTABLE); _("Aries"),
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_CANCER, _("Cancer"), GSWE_ELEMENT_WATER, GSWE_QUALITY_CARDINAL); GSWE_ELEMENT_FIRE,
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_LEO, _("Leo"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_FIX); GSWE_QUALITY_CARDINAL
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,
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_SCORPIO, _("Scorpio"), GSWE_ELEMENT_WATER, GSWE_QUALITY_FIX); GSWE_SIGN_TAURUS,
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_SAGITTARIUS, _("Sagittarius"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_MUTABLE); _("Taurus"),
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_CAPRICORN, _("Capricorn"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_CARDINAL); GSWE_ELEMENT_EARTH,
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_AQUARIUS, _("Aquarius"), GSWE_ELEMENT_AIR, GSWE_QUALITY_FIX); 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_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,
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_PLACIDUS, 'P', _("Placidus")); GSWE_HOUSE_SYSTEM_NONE,
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_KOCH, 'K', _("Koch")); 0,
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_EQUAL, 'E', _("Equal")); _("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 // Note that because all aspects must be <= 180°, GSWE_ASPECT_NONE can
// never really exist. It is provided for name fetching purposes only. // 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,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_CONJUCTION, _("Conjuction"), 0, 0, TRUE, TRUE); GSWE_ASPECT_NONE,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_OPPOSITION, _("Opposition"), 180, 0, TRUE, TRUE); _("None"),
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_TRINE, _("Trine"), 120, 0, TRUE, TRUE); 360,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SQUARE, _("Square"), 90, 0, FALSE, TRUE); 4,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEXTILE, _("Sextile"), 60, 1, TRUE, TRUE); FALSE,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINCUNX, _("Quincunx"), 150, 2, FALSE, 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,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SESQUISQUARE, _("Sesqui-square"), 135, 2, FALSE, FALSE); GSWE_ASPECT_CONJUCTION,
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINTILE, _("Quintile"), 72, 3, TRUE, FALSE); _("Conjuction"),
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_BIQUINTILE, _("Bi-quintile"), 144, 3, TRUE, FALSE); 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,
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); gswe_sign_info_table, sign_info,
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); GSWE_ANTISCION_AXIS_NONE,
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); _("None"),
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_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); gswe_ephe_path = g_strdup(directory);
swe_set_ephe_path(directory); swe_set_ephe_path(directory);
@ -250,10 +669,17 @@ gswe_init(void)
GswePlanetInfo * GswePlanetInfo *
gswe_find_planet_info_by_id(GswePlanet planet, GError **err) 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) { 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; return ret;
@ -269,10 +695,17 @@ gswe_find_planet_info_by_id(GswePlanet planet, GError **err)
GsweSignInfo * GsweSignInfo *
gswe_find_sign_info_by_id(GsweZodiac sign, GError **err) 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) { 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; return ret;
@ -288,10 +721,17 @@ gswe_find_sign_info_by_id(GsweZodiac sign, GError **err)
GsweHouseSystemInfo * GsweHouseSystemInfo *
gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err) 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) { 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; return ret;
@ -307,10 +747,17 @@ gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err)
GsweAspectInfo * GsweAspectInfo *
gswe_find_aspect_info_by_id(GsweAspect aspect, GError **err) 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) { 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; 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 * @antiscion_axis: an antiscion axis ID registered with SWE-GLib
* @err: a GError * @err: a GError
* *
* Find the #GsweAntiscionAxisInfo record registered with the id @antiscion_axis. * Find the #GsweAntiscionAxisInfo record registered with the id
* @antiscion_axis.
*/ */
GsweAntiscionAxisInfo * 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) { 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; return ret;

View File

@ -76,11 +76,20 @@ typedef enum {
GQuark gswe_error_quark(void); GQuark gswe_error_quark(void);
void gswe_init(); void gswe_init();
GswePlanetInfo *gswe_find_planet_info_by_id(GswePlanet planet, GError **err); GswePlanetInfo *gswe_find_planet_info_by_id(GswePlanet planet, GError **err);
GsweSignInfo *gswe_find_sign_info_by_id(GsweZodiac sign, 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); 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__ */ #endif /* __SWE_GLIB_H__ */