Code beautification

Wrap long lines in all files
This commit is contained in:
Gergely Polonkai 2014-07-11 10:33:04 +02:00
parent 110e7f3c25
commit 9342ea63de
10 changed files with 731 additions and 155 deletions

View File

@ -8,11 +8,17 @@
G_BEGIN_DECLS
#define AG_TYPE_APP (ag_app_get_type())
#define AG_APP(o) (G_TYPE_CHECK_INSTANCE_CAST((o), AG_TYPE_APP, AgApp))
#define AG_APP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), AG_TYPE_APP, AgAppClass))
#define AG_APP(o) (G_TYPE_CHECK_INSTANCE_CAST((o), \
AG_TYPE_APP, \
AgApp))
#define AG_APP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
AG_TYPE_APP, \
AgAppClass))
#define AG_IS_APP(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), AG_TYPE_APP))
#define AG_IS_APP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), AG_TYPE_APP))
#define AG_APP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), AG_TYPE_APP, AgAppClass))
#define AG_APP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), \
AG_TYPE_APP, \
AgAppClass))
typedef struct _AgApp AgApp;
typedef struct _AgAppClass AgAppClass;
@ -48,4 +54,3 @@ void ag_app_message_dialog(GtkWidget *window,
G_END_DECLS
#endif /* __AG_APP_H__ */

View File

@ -61,9 +61,39 @@ ag_chart_class_init(AgChartClass *klass)
gobject_class->get_property = ag_chart_get_property;
gobject_class->finalize = ag_chart_finalize;
g_object_class_install_property(gobject_class, PROP_NAME, g_param_spec_string("name", "Chart name", "Name of the person on this chart", NULL, G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_COUNTRY, g_param_spec_string("country", "Country name", "Name of the country of birth", NULL, G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_CITY, g_param_spec_string("city", "City name", "Name of the city of birth", NULL, G_PARAM_READWRITE));
g_object_class_install_property(
gobject_class,
PROP_NAME,
g_param_spec_string(
"name",
"Chart name",
"Name of the person on this chart",
NULL,
G_PARAM_READWRITE
)
);
g_object_class_install_property(
gobject_class,
PROP_COUNTRY,
g_param_spec_string(
"country",
"Country name",
"Name of the country of birth",
NULL,
G_PARAM_READWRITE
)
);
g_object_class_install_property(
gobject_class,
PROP_CITY,
g_param_spec_string(
"city",
"City name",
"Name of the city of birth",
NULL,
G_PARAM_READWRITE
)
);
}
static void
@ -78,7 +108,10 @@ ag_chart_init(AgChart *chart)
}
static void
ag_chart_set_property(GObject *gobject, guint prop_id, const GValue *value, GParamSpec *param_spec)
ag_chart_set_property(GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *param_spec)
{
switch (prop_id) {
case PROP_NAME:
@ -99,7 +132,10 @@ ag_chart_set_property(GObject *gobject, guint prop_id, const GValue *value, GPar
}
static void
ag_chart_get_property(GObject *gobject, guint prop_id, GValue *value, GParamSpec *param_spec)
ag_chart_get_property(GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *param_spec)
{
switch (prop_id) {
case PROP_NAME:
@ -146,77 +182,150 @@ void
ag_chart_add_planets(AgChart *chart)
{
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CHARIKLO, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_CHARIKLO));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_CHARIKLO)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VESTA, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_VESTA));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_VESTA)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_JUNO, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_JUNO));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_JUNO)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PALLAS, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_PALLAS));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_PALLAS)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CERES, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_CERES));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_CERES)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_NESSUS, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_NESSUS));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_NESSUS)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PHOLUS, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_PHOLUS));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_PHOLUS)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_CHIRON, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_CHIRON));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_CHIRON)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON_APOGEE, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_MOON_APOGEE));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MOON_APOGEE)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON_NODE, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_MOON_NODE));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MOON_NODE)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_PLUTO, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_PLUTO));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_PLUTO)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_NEPTUNE, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_NEPTUNE));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_NEPTUNE)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_URANUS, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_URANUS));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_URANUS)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_SATURN, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_SATURN));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_SATURN)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_JUPITER, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_JUPITER));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_JUPITER)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MARS, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_MARS));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MARS)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VENUS, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_VENUS));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_VENUS)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MERCURY, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_MERCURY));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MERCURY)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MOON, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_MOON));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MOON)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_SUN, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_SUN));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_SUN)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_VERTEX, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_VERTEX));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_VERTEX)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_ASCENDANT, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_ASCENDANT));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_ASCENDANT)
);
gswe_moment_add_planet(GSWE_MOMENT(chart), GSWE_PLANET_MC, NULL);
chart->priv->planet_list = g_list_prepend(chart->priv->planet_list, GINT_TO_POINTER(GSWE_PLANET_MC));
chart->priv->planet_list = g_list_prepend(
chart->priv->planet_list,
GINT_TO_POINTER(GSWE_PLANET_MC)
);
}
AgChart *
ag_chart_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system)
ag_chart_new_full(GsweTimestamp *timestamp,
gdouble longitude,
gdouble latitude,
gdouble altitude,
GsweHouseSystem house_system)
{
AgChart *chart;
GsweCoordinates *coords = g_new0(GsweCoordinates, 1);
@ -289,9 +398,12 @@ ag_chart_get_city(AgChart *chart)
/**
* get_by_xpath:
* @xpath_context: an XPath context
* @uri: the name of the file currently being processed. Used in error messages only
* @uri: the name of the file currently being processed. Used in error messages
* only
* @xpath: an XPath expression
* @value_required: marks the value as required. Although the XML tags must be present, some values (like country or city name) may be omitted
* @value_required: marks the value as required. Although the XML tags must be
* present, some values (like country or city name) may be
* omitted
* @type: the type of the variable to return
* @err: a GError
*
@ -300,7 +412,12 @@ ag_chart_get_city(AgChart *chart)
* Returns: (transfer container): a GVariant with the requested value
*/
static GVariant *
get_by_xpath(xmlXPathContextPtr xpath_context, const gchar *uri, const gchar *xpath, gboolean value_required, XmlConvertType type, GError **err)
get_by_xpath(xmlXPathContextPtr xpath_context,
const gchar *uri,
const gchar *xpath,
gboolean value_required,
XmlConvertType type,
GError **err)
{
xmlXPathObjectPtr xpathObj;
const gchar *text;
@ -309,15 +426,28 @@ get_by_xpath(xmlXPathContextPtr xpath_context, const gchar *uri, const gchar *xp
gdouble d;
gint i;
if ((xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath, xpath_context)) == NULL) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_LIBXML, "File '%s' could not be parsed due to internal XML error.", uri);
if ((xpathObj = xmlXPathEvalExpression(
(const xmlChar *)xpath,
xpath_context
)) == NULL) {
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_LIBXML,
"File '%s' could not be parsed due to internal XML error.",
uri
);
return NULL;
}
if (xpathObj->nodesetval == NULL) {
g_debug("No such node '%s'", xpath);
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' doesn't look like a valid saved chart.", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' doesn't look like a valid saved chart.",
uri
);
xmlXPathFreeObject(xpathObj);
return NULL;
@ -325,7 +455,12 @@ get_by_xpath(xmlXPathContextPtr xpath_context, const gchar *uri, const gchar *xp
if (xpathObj->nodesetval->nodeNr > 1) {
g_debug("Too many '%s' nodes", xpath);
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' doesn't look like a valid saved chart.", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' doesn't look like a valid saved chart.",
uri
);
xmlXPathFreeObject(xpathObj);
return NULL;
@ -334,7 +469,12 @@ get_by_xpath(xmlXPathContextPtr xpath_context, const gchar *uri, const gchar *xp
if (xpathObj->nodesetval->nodeNr == 0) {
if (value_required) {
g_debug("Too many '%s' nodes", xpath);
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' doesn't look like a valid saved chart.", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' doesn't look like a valid saved chart.",
uri
);
xmlXPathFreeObject(xpathObj);
return NULL;
@ -374,7 +514,12 @@ get_by_xpath(xmlXPathContextPtr xpath_context, const gchar *uri, const gchar *xp
d = g_ascii_strtod(text, &endptr);
if ((*endptr != 0) || (errno != 0)) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' doesn't look like a valid saved chart.", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' doesn't look like a valid saved chart.",
uri
);
ret = NULL;
} else {
ret = g_variant_new_double(d);
@ -386,7 +531,12 @@ get_by_xpath(xmlXPathContextPtr xpath_context, const gchar *uri, const gchar *xp
i = strtol(text, &endptr, 10);
if ((*endptr != 0) || (errno != 0)) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' doesn't look like a valid saved chart.", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' doesn't look like a valid saved chart.",
uri
);
ret = NULL;
} else {
ret = g_variant_new_int32(i);
@ -439,7 +589,13 @@ ag_chart_load_from_file(GFile *file, GError **err)
}
if ((doc = xmlReadMemory(xml, length, "chart.xml", NULL, 0)) == NULL) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' can not be read. Maybe it is corrupt, or not a save file at all", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' can not be read. " \
"Maybe it is corrupt, or not a save file at all",
uri
);
g_free(xml);
g_free(uri);
@ -447,7 +603,12 @@ ag_chart_load_from_file(GFile *file, GError **err)
}
if ((xpath_context = xmlXPathNewContext(doc)) == NULL) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_LIBXML, "File '%s' could not be loaded due to internal LibXML error", uri);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_LIBXML,
"File '%s' could not be loaded due to internal LibXML error",
uri
);
xmlFreeDoc(doc);
g_free(xml);
g_free(uri);
@ -455,59 +616,157 @@ ag_chart_load_from_file(GFile *file, GError **err)
return NULL;
}
if ((chart_name = get_by_xpath(xpath_context, uri, "/chartinfo/data/name/text()", TRUE, XML_CONVERT_STRING, err)) == NULL) {
if ((chart_name = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/name/text()",
TRUE,
XML_CONVERT_STRING,
err
)) == NULL) {
found_error = TRUE;
}
if ((country = get_by_xpath(xpath_context, uri, "/chartinfo/data/place/country/text()", FALSE, XML_CONVERT_STRING, err)) == NULL) {
if ((country = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/place/country/text()",
FALSE,
XML_CONVERT_STRING,
err
)) == NULL) {
found_error = TRUE;
}
if ((city = get_by_xpath(xpath_context, uri, "/chartinfo/data/place/city/text()", FALSE, XML_CONVERT_STRING, err)) == NULL) {
if ((city = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/place/city/text()",
FALSE,
XML_CONVERT_STRING,
err
)) == NULL) {
found_error = TRUE;
}
if ((longitude = get_by_xpath(xpath_context, uri, "/chartinfo/data/place/longitude/text()", TRUE, XML_CONVERT_DOUBLE, err)) == NULL) {
if ((longitude = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/place/longitude/text()",
TRUE,
XML_CONVERT_DOUBLE,
err
)) == NULL) {
found_error = TRUE;
}
if ((latitude = get_by_xpath(xpath_context, uri, "/chartinfo/data/place/latitude/text()", TRUE, XML_CONVERT_DOUBLE, err)) == NULL) {
if ((latitude = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/place/latitude/text()",
TRUE,
XML_CONVERT_DOUBLE,
err
)) == NULL) {
found_error = TRUE;
}
if ((altitude = get_by_xpath(xpath_context, uri, "/chartinfo/data/place/altitude/text()", TRUE, XML_CONVERT_DOUBLE, err)) == NULL) {
if ((altitude = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/place/altitude/text()",
TRUE,
XML_CONVERT_DOUBLE,
err
)) == NULL) {
found_error = TRUE;
}
if ((year = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/year/text()", TRUE, XML_CONVERT_INT, err)) == NULL) {
if ((year = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/year/text()",
TRUE,
XML_CONVERT_INT,
err
)) == NULL) {
found_error = TRUE;
}
if ((month = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/month/text()", TRUE, XML_CONVERT_INT, err)) == NULL) {
if ((month = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/month/text()",
TRUE,
XML_CONVERT_INT,
err
)) == NULL) {
found_error = TRUE;
}
if ((day = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/day/text()", TRUE, XML_CONVERT_INT, err)) == NULL) {
if ((day = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/day/text()",
TRUE,
XML_CONVERT_INT,
err
)) == NULL) {
found_error = TRUE;
}
if ((hour = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/hour/text()", TRUE, XML_CONVERT_INT, err)) == NULL) {
if ((hour = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/hour/text()",
TRUE,
XML_CONVERT_INT,
err
)) == NULL) {
found_error = TRUE;
}
if ((minute = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/minute/text()", TRUE, XML_CONVERT_INT, err)) == NULL) {
if ((minute = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/minute/text()",
TRUE,
XML_CONVERT_INT,
err
)) == NULL) {
found_error = TRUE;
}
if ((second = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/second/text()", TRUE, XML_CONVERT_INT, err)) == NULL) {
if ((second = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/second/text()",
TRUE,
XML_CONVERT_INT,
err
)) == NULL) {
found_error = TRUE;
}
if ((timezone = get_by_xpath(xpath_context, uri, "/chartinfo/data/time/timezone/text()", TRUE, XML_CONVERT_DOUBLE, err)) == NULL) {
if ((timezone = get_by_xpath(
xpath_context,
uri,
"/chartinfo/data/time/timezone/text()",
TRUE,
XML_CONVERT_DOUBLE,
err
)) == NULL) {
found_error = TRUE;
}
note = get_by_xpath(xpath_context, uri, "/chartinfo/note/text()", FALSE, XML_CONVERT_STRING, err);
note = get_by_xpath(
xpath_context,
uri,
"/chartinfo/note/text()",
FALSE,
XML_CONVERT_STRING,
err
);
if (found_error) {
ag_g_variant_unref(note);
@ -550,7 +809,13 @@ ag_chart_load_from_file(GFile *file, GError **err)
g_variant_unref(timezone);
// TODO: Make house system configurable (and saveable)
chart = ag_chart_new_full(timestamp, g_variant_get_double(longitude), g_variant_get_double(latitude), g_variant_get_double(altitude), GSWE_HOUSE_SYSTEM_PLACIDUS);
chart = ag_chart_new_full(
timestamp,
g_variant_get_double(longitude),
g_variant_get_double(latitude),
g_variant_get_double(altitude),
GSWE_HOUSE_SYSTEM_PLACIDUS
);
g_variant_unref(longitude);
g_variant_unref(latitude);
g_variant_unref(altitude);
@ -645,12 +910,18 @@ create_save_doc(AgChart *chart)
timestamp = gswe_moment_get_timestamp(GSWE_MOMENT(chart));
value = g_malloc0(10);
g_ascii_dtostr(value, 10, gswe_timestamp_get_gregorian_year(timestamp, NULL));
g_ascii_dtostr(
value, 10,
gswe_timestamp_get_gregorian_year(timestamp, NULL)
);
xmlNewChild(time_node, NULL, BAD_CAST "year", BAD_CAST value);
g_free(value);
value = g_malloc0(3);
g_ascii_dtostr(value, 3, gswe_timestamp_get_gregorian_month(timestamp, NULL));
g_ascii_dtostr(
value, 3,
gswe_timestamp_get_gregorian_month(timestamp, NULL)
);
xmlNewChild(time_node, NULL, BAD_CAST "month", BAD_CAST value);
g_free(value);
@ -660,17 +931,26 @@ create_save_doc(AgChart *chart)
g_free(value);
value = g_malloc0(3);
g_ascii_dtostr(value, 3, gswe_timestamp_get_gregorian_hour(timestamp, NULL));
g_ascii_dtostr(
value, 3,
gswe_timestamp_get_gregorian_hour(timestamp, NULL)
);
xmlNewChild(time_node, NULL, BAD_CAST "hour", BAD_CAST value);
g_free(value);
value = g_malloc0(3);
g_ascii_dtostr(value, 3, gswe_timestamp_get_gregorian_minute(timestamp, NULL));
g_ascii_dtostr(
value, 3,
gswe_timestamp_get_gregorian_minute(timestamp, NULL)
);
xmlNewChild(time_node, NULL, BAD_CAST "minute", BAD_CAST value);
g_free(value);
value = g_malloc0(3);
g_ascii_dtostr(value, 3, gswe_timestamp_get_gregorian_second(timestamp, NULL));
g_ascii_dtostr(
value, 3,
gswe_timestamp_get_gregorian_second(timestamp, NULL)
);
xmlNewChild(time_node, NULL, BAD_CAST "second", BAD_CAST value);
g_free(value);
@ -680,7 +960,12 @@ create_save_doc(AgChart *chart)
g_free(value);
if (ag_chart_get_note(chart)) {
xmlNewChild(root_node, NULL, BAD_CAST "note", BAD_CAST ag_chart_get_note(chart));
xmlNewChild(
root_node,
NULL,
BAD_CAST "note",
BAD_CAST ag_chart_get_note(chart)
);
}
return doc;
@ -695,7 +980,17 @@ ag_chart_save_to_file(AgChart *chart, GFile *file, GError **err)
xmlDocDumpFormatMemoryEnc(save_doc, &content, &length, "UTF-8", 1);
g_file_replace_contents(file, (const gchar *)content, length, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, err);
g_file_replace_contents(
file,
(const gchar *)content,
length,
NULL,
FALSE,
G_FILE_CREATE_NONE,
NULL,
NULL,
err
);
xmlFreeDoc(save_doc);
}
@ -737,7 +1032,8 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
root_node = xmlDocGetRootElement(doc);
// gswe_moment_get_house_cusps() also calculates ascmcs data, so call it this early
// gswe_moment_get_house_cusps() also calculates ascmcs data, so call it
// this early
houses = gswe_moment_get_house_cusps(GSWE_MOMENT(chart), NULL);
// Begin <ascmcs> node
@ -746,7 +1042,11 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
node = xmlNewChild(ascmcs_node, NULL, BAD_CAST "ascendant", NULL);
planet_data = gswe_moment_get_planet(GSWE_MOMENT(chart), GSWE_PLANET_ASCENDANT, NULL);
planet_data = gswe_moment_get_planet(
GSWE_MOMENT(chart),
GSWE_PLANET_ASCENDANT,
NULL
);
value = g_malloc0(12);
g_ascii_dtostr(value, 12, gswe_planet_data_get_position(planet_data));
xmlNewProp(node, BAD_CAST "degree_ut", BAD_CAST value);
@ -754,7 +1054,11 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
node = xmlNewChild(ascmcs_node, NULL, BAD_CAST "mc", NULL);
planet_data = gswe_moment_get_planet(GSWE_MOMENT(chart), GSWE_PLANET_MC, NULL);
planet_data = gswe_moment_get_planet(
GSWE_MOMENT(chart),
GSWE_PLANET_MC,
NULL
);
value = g_malloc0(12);
g_ascii_dtostr(value, 12, gswe_planet_data_get_position(planet_data));
xmlNewProp(node, BAD_CAST "degree_ut", BAD_CAST value);
@ -762,7 +1066,11 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
node = xmlNewChild(ascmcs_node, NULL, BAD_CAST "vertex", NULL);
planet_data = gswe_moment_get_planet(GSWE_MOMENT(chart), GSWE_PLANET_VERTEX, NULL);
planet_data = gswe_moment_get_planet(
GSWE_MOMENT(chart),
GSWE_PLANET_VERTEX,
NULL
);
value = g_malloc0(12);
g_ascii_dtostr(value, 12, gswe_planet_data_get_position(planet_data));
xmlNewProp(node, BAD_CAST "degree_ut", BAD_CAST value);
@ -783,7 +1091,10 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
g_free(value);
value = g_malloc0(12);
g_ascii_dtostr(value, 12, gswe_house_data_get_cusp_position(house_data));
g_ascii_dtostr(
value, 12,
gswe_house_data_get_cusp_position(house_data)
);
xmlNewProp(node, BAD_CAST "degree", BAD_CAST value);
g_free(value);
}
@ -794,21 +1105,28 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
planets_class = g_type_class_ref(GSWE_TYPE_PLANET);
for (planet = gswe_moment_get_all_planets(GSWE_MOMENT(chart)); planet; planet = g_list_next(planet)) {
for (
planet = gswe_moment_get_all_planets(GSWE_MOMENT(chart));
planet;
planet = g_list_next(planet)
) {
planet_data = planet->data;
GEnumValue *enum_value;
if (
(gswe_planet_data_get_planet(planet_data) == GSWE_PLANET_ASCENDANT) ||
(gswe_planet_data_get_planet(planet_data) == GSWE_PLANET_MC) ||
(gswe_planet_data_get_planet(planet_data) == GSWE_PLANET_VERTEX)
(gswe_planet_data_get_planet(planet_data) == GSWE_PLANET_ASCENDANT)
|| (gswe_planet_data_get_planet(planet_data) == GSWE_PLANET_MC)
|| (gswe_planet_data_get_planet(planet_data) == GSWE_PLANET_VERTEX)
) {
continue;
}
node = xmlNewChild(bodies_node, NULL, BAD_CAST "body", NULL);
enum_value = g_enum_get_value(G_ENUM_CLASS(planets_class), gswe_planet_data_get_planet(planet_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(planets_class),
gswe_planet_data_get_planet(planet_data)
);
xmlNewProp(node, BAD_CAST "name", BAD_CAST enum_value->value_name);
value = g_malloc0(12);
@ -823,7 +1141,11 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
aspects_class = g_type_class_ref(GSWE_TYPE_ASPECT);
for (aspect = gswe_moment_get_all_aspects(GSWE_MOMENT(chart)); aspect; aspect = g_list_next(aspect)) {
for (
aspect = gswe_moment_get_all_aspects(GSWE_MOMENT(chart));
aspect;
aspect = g_list_next(aspect)
) {
GswePlanetData *planet_data;
GEnumValue *enum_value;
@ -836,14 +1158,23 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
node = xmlNewChild(aspects_node, NULL, BAD_CAST "aspect", NULL);
planet_data = gswe_aspect_data_get_planet1(aspect_data);
enum_value = g_enum_get_value(G_ENUM_CLASS(planets_class), gswe_planet_data_get_planet(planet_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(planets_class),
gswe_planet_data_get_planet(planet_data)
);
xmlNewProp(node, BAD_CAST "body1", BAD_CAST enum_value->value_name);
planet_data = gswe_aspect_data_get_planet2(aspect_data);
enum_value = g_enum_get_value(G_ENUM_CLASS(planets_class), gswe_planet_data_get_planet(planet_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(planets_class),
gswe_planet_data_get_planet(planet_data)
);
xmlNewProp(node, BAD_CAST "body2", BAD_CAST enum_value->value_name);
enum_value = g_enum_get_value(G_ENUM_CLASS(aspects_class), gswe_aspect_data_get_aspect(aspect_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(aspects_class),
gswe_aspect_data_get_aspect(aspect_data)
);
xmlNewProp(node, BAD_CAST "type", BAD_CAST enum_value->value_name);
}
@ -854,26 +1185,41 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
antiscia_node = xmlNewChild(root_node, NULL, BAD_CAST "antiscia", NULL);
antiscia_class = g_type_class_ref(GSWE_TYPE_ANTISCION_AXIS);
for (antiscion = gswe_moment_get_all_antiscia(GSWE_MOMENT(chart)); antiscion; antiscion = g_list_next(antiscion)) {
for (
antiscion = gswe_moment_get_all_antiscia(GSWE_MOMENT(chart));
antiscion;
antiscion = g_list_next(antiscion)
) {
GswePlanetData *planet_data;
GsweAntiscionData *antiscion_data = antiscion->data;
GEnumValue *enum_value;
if (gswe_antiscion_data_get_axis(antiscion_data) == GSWE_ANTISCION_AXIS_NONE) {
if (gswe_antiscion_data_get_axis(
antiscion_data) == GSWE_ANTISCION_AXIS_NONE
) {
continue;
}
node = xmlNewChild(antiscia_node, NULL, BAD_CAST "antiscia", NULL);
planet_data = gswe_antiscion_data_get_planet1(antiscion_data);
enum_value = g_enum_get_value(G_ENUM_CLASS(planets_class), gswe_planet_data_get_planet(planet_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(planets_class),
gswe_planet_data_get_planet(planet_data)
);
xmlNewProp(node, BAD_CAST "body1", BAD_CAST enum_value->value_name);
planet_data = gswe_antiscion_data_get_planet2(antiscion_data);
enum_value = g_enum_get_value(G_ENUM_CLASS(planets_class), gswe_planet_data_get_planet(planet_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(planets_class),
gswe_planet_data_get_planet(planet_data)
);
xmlNewProp(node, BAD_CAST "body2", BAD_CAST enum_value->value_name);
enum_value = g_enum_get_value(G_ENUM_CLASS(antiscia_class), gswe_antiscion_data_get_axis(antiscion_data));
enum_value = g_enum_get_value(
G_ENUM_CLASS(antiscia_class),
gswe_antiscion_data_get_axis(antiscion_data)
);
xmlNewProp(node, BAD_CAST "axis", BAD_CAST enum_value->value_name);
}
@ -889,7 +1235,12 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
stylesheet_path = g_strdup_printf("%s/%s", PKGDATADIR, "chart.xsl");
g_debug("Opening %s as a stylesheet", stylesheet_path);
if ((xslt_doc = xmlReadFile(stylesheet_path, "UTF-8", 0)) == NULL) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' can not be parsed as a stylesheet file.", stylesheet_path);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' can not be parsed as a stylesheet file.",
stylesheet_path
);
g_free(stylesheet_path);
g_free(css_path);
g_free(css_uri);
@ -906,7 +1257,12 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
#endif
if ((xslt_proc = xsltParseStylesheetDoc(xslt_doc)) == NULL) {
g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, "File '%s' can not be parsed as a stylesheet file.", stylesheet_path);
g_set_error(
err,
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
"File '%s' can not be parsed as a stylesheet file.",
stylesheet_path
);
g_free(stylesheet_path);
g_free(css_path);
g_free(css_uri);
@ -938,7 +1294,13 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
// Now, svg_doc contains the generated SVG file
xmlDocDumpFormatMemoryEnc(svg_doc, (xmlChar **)&save_content, &save_length, "UTF-8", 1);
xmlDocDumpFormatMemoryEnc(
svg_doc,
(xmlChar **)&save_content,
&save_length,
"UTF-8",
1
);
xmlFreeDoc(svg_doc);
if (length != NULL) {
@ -964,7 +1326,17 @@ ag_chart_export_svg_to_file(AgChart *chart, GFile *file, GError **err)
return;
}
g_file_replace_contents(file, (const gchar *)svg, length, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, err);
g_file_replace_contents(
file,
(const gchar *)svg,
length,
NULL,
FALSE,
G_FILE_CREATE_NONE,
NULL,
NULL,
err
);
}
void

View File

@ -12,11 +12,17 @@ typedef enum {
} AgChartError;
#define AG_TYPE_CHART (ag_chart_get_type())
#define AG_CHART(o) (G_TYPE_CHECK_INSTANCE_CAST((o), AG_TYPE_CHART, AgChart))
#define AG_CHART_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), AG_TYPE_CHART, AgChartClass))
#define AG_CHART(o) (G_TYPE_CHECK_INSTANCE_CAST((o), \
AG_TYPE_CHART, \
AgChart))
#define AG_CHART_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
AG_TYPE_CHART, \
AgChartClass))
#define AG_IS_CHART(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), AG_TYPE_CHART))
#define AG_IS_CHART_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), AG_TYPE_CHART))
#define AG_CHART_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), AG_TYPE_CHART, AgChartClass))
#define AG_CHART_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), \
AG_TYPE_CHART, \
AgChartClass))
typedef struct _AgChart AgChart;
typedef struct _AgChartClass AgChartClass;

View File

@ -43,10 +43,25 @@ ag_preferences_class_init(AgPreferencesClass *klass)
object_class->finalize = ag_preferences_finalize;
dialog_class->response = ag_preferences_response;
gtk_widget_class_set_template_from_resource(widget_class, "/eu/polonkai/gergely/Astrognome/ui/ag-preferences.ui");
gtk_widget_class_bind_template_child_private(widget_class, AgPreferences, maximized);
gtk_widget_class_bind_template_child_private(widget_class, AgPreferences, planet_chars);
gtk_widget_class_bind_template_child_private(widget_class, AgPreferences, aspect_chars);
gtk_widget_class_set_template_from_resource(
widget_class,
"/eu/polonkai/gergely/Astrognome/ui/ag-preferences.ui"
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgPreferences,
maximized
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgPreferences,
planet_chars
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgPreferences,
aspect_chars
);
}
static void
@ -62,11 +77,29 @@ ag_preferences_init(AgPreferences *prefs)
priv->settings = ag_settings_get();
settings_window = ag_settings_peek_window_settings(priv->settings);
g_settings_bind(settings_window, "maximized", priv->maximized, "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind(
settings_window,
"maximized",
priv->maximized,
"active",
G_SETTINGS_BIND_DEFAULT
);
settings_main = ag_settings_peek_main_settings(priv->settings);
g_settings_bind(settings_main, "planets-char", priv->planet_chars, "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind(settings_main, "aspects-char", priv->aspect_chars, "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind(
settings_main,
"planets-char",
priv->planet_chars,
"active",
G_SETTINGS_BIND_DEFAULT
);
g_settings_bind(
settings_main,
"aspects-char",
priv->aspect_chars,
"active",
G_SETTINGS_BIND_DEFAULT
);
}
void
@ -76,7 +109,12 @@ ag_preferences_show_dialog(GtkWindow *parent)
if (prefs_dialog == NULL) {
prefs_dialog = GTK_WIDGET(g_object_new(AG_TYPE_PREFERENCES, NULL));
g_signal_connect(prefs_dialog, "destroy", G_CALLBACK(gtk_widget_destroyed), &prefs_dialog);
g_signal_connect(
prefs_dialog,
"destroy",
G_CALLBACK(gtk_widget_destroyed),
&prefs_dialog
);
}
if (parent != gtk_window_get_transient_for(GTK_WINDOW(prefs_dialog))) {

View File

@ -6,11 +6,19 @@
G_BEGIN_DECLS
#define AG_TYPE_PREFERENCES (ag_preferences_get_type())
#define AG_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_CAST((o), AG_TYPE_PREFERENCES, AgPreferences))
#define AG_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), AG_TYPE_PREFERENCES, AgPreferencesClass))
#define AG_IS_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), AG_TYPE_PREFERENCES))
#define AG_IS_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), AG_TYPE_PREFERENCES))
#define AG_PREFERENCES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), AG_TYPE_PREFERENCES, AgPreferencesClass))
#define AG_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_CAST((o), \
AG_TYPE_PREFERENCES, \
AgPreferences))
#define AG_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
AG_TYPE_PREFERENCES, \
AgPreferencesClass))
#define AG_IS_PREFERENCES(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), \
AG_TYPE_PREFERENCES))
#define AG_IS_PREFERENCES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), \
AG_TYPE_PREFERENCES))
#define AG_PREFERENCES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), \
AG_TYPE_PREFERENCES, \
AgPreferencesClass))
typedef struct _AgPreferences AgPreferences;
typedef struct _AgPreferencesClass AgPreferencesClass;

View File

@ -27,7 +27,9 @@ ag_settings_init(AgSettings *settings)
static void
ag_settings_dispose(GObject *object)
{
AgSettingsPrivate *priv = ag_settings_get_instance_private(AG_SETTINGS(object));
AgSettingsPrivate *priv = ag_settings_get_instance_private(
AG_SETTINGS(object)
);
g_clear_object(&priv->settings_window);
g_clear_object(&priv->settings_chart);

View File

@ -7,11 +7,19 @@
G_BEGIN_DECLS
#define AG_TYPE_SETTINGS (ag_settings_get_type())
#define AG_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_CAST((o), AG_TYPE_SETTINGS, AgSettings))
#define AG_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), AG_TYPE_SETTINGS, AgSettingsClass))
#define AG_IS_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), AG_TYPE_SETTINGS))
#define AG_IS_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), AG_TYPE_SETTINGS))
#define AG_SETTINGS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), AG_TYPE_SETTINGS, AgSettingsClass))
#define AG_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_CAST((o), \
AG_TYPE_SETTINGS, \
AgSettings))
#define AG_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
AG_TYPE_SETTINGS, \
AgSettingsClass))
#define AG_IS_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), \
AG_TYPE_SETTINGS))
#define AG_IS_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), \
AG_TYPE_SETTINGS))
#define AG_SETTINGS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), \
AG_TYPE_SETTINGS, \
AgSettingsClass))
typedef struct _AgSettings AgSettings;
typedef struct _AgSettingsClass AgSettingsClass;

View File

@ -398,7 +398,8 @@ ag_window_create_planet_widget(GswePlanetInfo *planet_info)
switch (planet) {
case GSWE_PLANET_SUN:
return gtk_image_new_from_resource(
"/eu/polonkai/gergely/Astrognome/default-icons/planet-sun.svg"
"/eu/polonkai/gergely"
"/Astrognome/default-icons/planet-sun.svg"
);
default:
@ -482,7 +483,11 @@ ag_window_redraw_aspect_table(AgWindow *window)
GList *planet;
guint i;
for (planet = planet_list, i = 0; planet; planet = g_list_next(planet), i++) {
for (
planet = planet_list, i = 0;
planet;
planet = g_list_next(planet), i++
) {
GtkWidget *label_hor,
*label_ver,
*current_widget;
@ -491,56 +496,111 @@ ag_window_redraw_aspect_table(AgWindow *window)
GswePlanetInfo *planet_info;
planet_id = GPOINTER_TO_INT(planet->data);
planet_data = gswe_moment_get_planet(GSWE_MOMENT(priv->chart), planet_id, NULL);
planet_data = gswe_moment_get_planet(
GSWE_MOMENT(priv->chart),
planet_id,
NULL
);
planet_info = gswe_planet_data_get_planet_info(planet_data);
if ((current_widget = gtk_grid_get_child_at(GTK_GRID(priv->aspect_table), i + 1, i)) != NULL) {
gtk_container_remove(GTK_CONTAINER(priv->aspect_table), current_widget);
if ((current_widget = gtk_grid_get_child_at(
GTK_GRID(priv->aspect_table),
i + 1, i
)) != NULL) {
gtk_container_remove(
GTK_CONTAINER(priv->aspect_table),
current_widget
);
}
label_hor = ag_window_create_planet_widget(planet_info);
gtk_grid_attach(GTK_GRID(priv->aspect_table), label_hor, i + 1, i, 1, 1);
gtk_grid_attach(
GTK_GRID(priv->aspect_table),
label_hor,
i + 1, i,
1, 1
);
if (i > 0) {
if ((current_widget = gtk_grid_get_child_at(GTK_GRID(priv->aspect_table), 0, i)) != NULL) {
gtk_container_remove(GTK_CONTAINER(priv->aspect_table), current_widget);
if ((current_widget = gtk_grid_get_child_at(
GTK_GRID(priv->aspect_table),
0, i
)) != NULL) {
gtk_container_remove(
GTK_CONTAINER(priv->aspect_table),
current_widget
);
}
label_ver = ag_window_create_planet_widget(planet_info);
gtk_grid_attach(GTK_GRID(priv->aspect_table), label_ver, 0, i, 1, 1);
gtk_grid_attach(
GTK_GRID(priv->aspect_table),
label_ver,
0, i,
1, 1
);
}
}
priv->aspect_table_populated = TRUE;
}
for (planet1 = planet_list, i = 0; planet1; planet1 = g_list_next(planet1), i++) {
for (planet2 = planet_list, j = 0; planet2; planet2 = g_list_next(planet2), j++) {
for (
planet1 = planet_list, i = 0;
planet1;
planet1 = g_list_next(planet1), i++
) {
for (
planet2 = planet_list, j = 0;
planet2;
planet2 = g_list_next(planet2), j++
) {
GsweAspectData *aspect;
GtkWidget *aspect_widget;
GError *err = NULL;
if (GPOINTER_TO_INT(planet1->data) == GPOINTER_TO_INT(planet2->data)) {
if (GPOINTER_TO_INT(planet1->data)
== GPOINTER_TO_INT(planet2->data)
) {
break;
}
if ((aspect_widget = gtk_grid_get_child_at(GTK_GRID(priv->aspect_table), j + 1, i)) != NULL) {
gtk_container_remove(GTK_CONTAINER(priv->aspect_table), aspect_widget);
if ((aspect_widget = gtk_grid_get_child_at(
GTK_GRID(priv->aspect_table),
j + 1, i
)) != NULL) {
gtk_container_remove(
GTK_CONTAINER(priv->aspect_table),
aspect_widget
);
}
if ((aspect = gswe_moment_get_aspect_by_planets(GSWE_MOMENT(priv->chart), GPOINTER_TO_INT(planet1->data), GPOINTER_TO_INT(planet2->data), &err)) != NULL) {
if ((aspect = gswe_moment_get_aspect_by_planets(
GSWE_MOMENT(priv->chart),
GPOINTER_TO_INT(planet1->data),
GPOINTER_TO_INT(planet2->data),
&err
)) != NULL) {
GsweAspectInfo *aspect_info;
aspect_info = gswe_aspect_data_get_aspect_info(aspect);
if (gswe_aspect_data_get_aspect(aspect) != GSWE_ASPECT_NONE) {
aspect_widget = ag_window_create_aspect_widget(aspect_info);
gtk_grid_attach(GTK_GRID(priv->aspect_table), aspect_widget, j + 1, i, 1, 1);
gtk_grid_attach(
GTK_GRID(priv->aspect_table),
aspect_widget,
j + 1, i,
1, 1
);
}
} else if (err) {
g_warning("%s\n", err->message);
} else {
g_error("No aspect is returned between two planets. This is a bug in SWE-GLib!\n");
g_error(
"No aspect is returned between two planets. " \
"This is a bug in SWE-GLib!"
);
}
}
}
@ -659,16 +719,36 @@ recalculate_chart(AgWindow *window)
end_iter;
gchar *note;
AgWindowPrivate *priv = ag_window_get_instance_private(window);
gint year = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->year)),
month = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->month)),
day = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->day)),
hour = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->hour)),
minute = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->minute)),
second = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->second));
gdouble longitude = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->longitude)),
latitude = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->latitude));
gboolean south = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->south_lat)),
west = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->west_long));
gint year = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(priv->year)
),
month = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(priv->month)
),
day = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(priv->day)
),
hour = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(priv->hour)
),
minute = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(priv->minute)
),
second = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(priv->second)
);
gdouble longitude = gtk_spin_button_get_value(
GTK_SPIN_BUTTON(priv->longitude)
),
latitude = gtk_spin_button_get_value(
GTK_SPIN_BUTTON(priv->latitude)
);
gboolean south = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(priv->south_lat)
),
west = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(priv->west_long)
);
g_debug("Recalculating chart data");
@ -682,19 +762,42 @@ recalculate_chart(AgWindow *window)
// TODO: Set timezone according to the city selected!
if (priv->chart == NULL) {
timestamp = gswe_timestamp_new_from_gregorian_full(year, month, day, hour, minute, second, 0, 1.0);
timestamp = gswe_timestamp_new_from_gregorian_full(
year, month, day,
hour, minute, second, 0,
1.0
);
// TODO: make house system configurable
priv->chart = ag_chart_new_full(timestamp, longitude, latitude, 380.0, GSWE_HOUSE_SYSTEM_PLACIDUS);
g_signal_connect(priv->chart, "changed", G_CALLBACK(chart_changed), window);
priv->chart = ag_chart_new_full(
timestamp,
longitude, latitude, 380.0,
GSWE_HOUSE_SYSTEM_PLACIDUS
);
g_signal_connect(
priv->chart,
"changed",
G_CALLBACK(chart_changed),
window
);
ag_window_redraw_chart(window);
} else {
timestamp = gswe_moment_get_timestamp(GSWE_MOMENT(priv->chart));
gswe_timestamp_set_gregorian_full(timestamp, year, month, day, hour, minute, second, 0, 1.0, NULL);
gswe_timestamp_set_gregorian_full(
timestamp,
year, month, day,
hour, minute, second, 0,
1.0,
NULL
);
}
ag_chart_set_name(priv->chart, gtk_entry_get_text(GTK_ENTRY(priv->name)));
gtk_text_buffer_get_bounds(priv->note_buffer, &start_iter, &end_iter);
note = gtk_text_buffer_get_text(priv->note_buffer, &start_iter, &end_iter, TRUE);
note = gtk_text_buffer_get_text(
priv->note_buffer,
&start_iter, &end_iter,
TRUE
);
ag_chart_set_note(priv->chart, note);
g_free(note);
}
@ -732,7 +835,9 @@ ag_window_tab_changed_cb(GtkStack *stack, GParamSpec *pspec, AgWindow *window)
}
static void
ag_window_change_tab_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
ag_window_change_tab_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
AgWindow *window = AG_WINDOW(user_data);
const gchar *target_tab = g_variant_get_string(parameter, NULL);
@ -1072,7 +1177,10 @@ ag_window_settings_save(GtkWindow *window, GSettings *settings)
gboolean maximized;
state = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window)));
maximized = ((state & GDK_WINDOW_STATE_MAXIMIZED) == GDK_WINDOW_STATE_MAXIMIZED);
maximized = (
(state & GDK_WINDOW_STATE_MAXIMIZED)
== GDK_WINDOW_STATE_MAXIMIZED
);
g_settings_set_boolean(settings, "maximized", maximized);

View File

@ -15,11 +15,17 @@ typedef enum {
} AgWindowError;
#define AG_TYPE_WINDOW (ag_window_get_type())
#define AG_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), AG_TYPE_WINDOW, AgWindow))
#define AG_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), AG_TYPE_WINDOW, AgWindowClass))
#define AG_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), \
AG_TYPE_WINDOW, \
AgWindow))
#define AG_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
AG_TYPE_WINDOW, \
AgWindowClass))
#define AG_IS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), AG_TYPE_WINDOW))
#define AG_IS_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), AG_TYPE_WINDOW))
#define AG_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), AG_TYPE_WINDOW, AgWindowClass))
#define AG_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), \
AG_TYPE_WINDOW, \
AgWindowClass))
typedef struct _AgWindow AgWindow;
typedef struct _AgWindowClass AgWindowClass;

View File

@ -56,9 +56,27 @@ main(int argc, char *argv[])
AstrognomeOptions options;
GOptionEntry option_entries[] = {
{ "new-window", 'n', 0, G_OPTION_ARG_NONE, &(options.new_window), N_("Opens a new Astrognome window"), NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &(options.version), N_("Display version and exit"), NULL },
{ "quit", 'q', 0, G_OPTION_ARG_NONE, &(options.quit), N_("Quit any running Astrognome"), NULL },
{
"new-window", 'n',
0, G_OPTION_ARG_NONE,
&(options.new_window),
N_("Opens a new Astrognome window"),
NULL
},
{
"version", 'v',
0, G_OPTION_ARG_NONE,
&(options.version),
N_("Display version and exit"),
NULL
},
{
"quit", 'q',
0, G_OPTION_ARG_NONE,
&(options.quit),
N_("Quit any running Astrognome"),
NULL
},
{ NULL }
};
@ -78,7 +96,10 @@ main(int argc, char *argv[])
memset(&options, 0, sizeof(AstrognomeOptions));
if (!gtk_init_with_args(&argc, &argv, _("[FILE…]"), option_entries, GETTEXT_PACKAGE, &err)) {
if (!gtk_init_with_args(
&argc, &argv,
_("[FILE…]"
), option_entries, GETTEXT_PACKAGE, &err)) {
g_printerr("%s\n", err->message);
return EXIT_FAILURE;
@ -96,7 +117,10 @@ main(int argc, char *argv[])
g_application_set_default(G_APPLICATION(app));
if (!g_application_register(G_APPLICATION(app), NULL, &err)) {
g_printerr("Couldn't register Astrognome instance: '%s'\n", (err) ? err->message : "");
g_printerr(
"Couldn't register Astrognome instance: '%s'\n",
(err) ? err->message : ""
);
g_object_unref(app);
return EXIT_FAILURE;
@ -115,4 +139,3 @@ main(int argc, char *argv[])
return status;
}