From 67dda14da027239109554a1e77e02a2608bdf4d2 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 14 Sep 2013 01:25:46 +0200 Subject: [PATCH 1/3] Started implementing load/save functionality --- data/examples/saved-chart.xml | 20 ++++++++++++++++++ src/Makefile.am | 9 ++++++++- src/ag-chart.c | 28 ++++++++++++++++++++++++++ src/ag-chart.h | 38 +++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 data/examples/saved-chart.xml create mode 100644 src/ag-chart.c create mode 100644 src/ag-chart.h diff --git a/data/examples/saved-chart.xml b/data/examples/saved-chart.xml new file mode 100644 index 0000000..2e612ea --- /dev/null +++ b/data/examples/saved-chart.xml @@ -0,0 +1,20 @@ + + + + Gergely Polonkai + + Hungary + Budapest + 47.49801 + 19.03991 + + + + diff --git a/src/Makefile.am b/src/Makefile.am index d19f7b2..94a30dc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,13 @@ BUILT_SOURCES = \ ag-resources.c \ $(NULL) +astrognome_source_files = \ + ag-app.c \ + ag-window.c \ + ag-chart.c \ + astrognome.c \ + $(NULL) + EXTRA_DIST = \ $(resource_files) \ ag.gresource.xml \ @@ -19,7 +26,7 @@ EXTRA_DIST = \ AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Astrognome\" -DLOCALEDIR=\"$(localedir)\" -DPKGDATADIR=\"$(pkgdatadir)\" bin_PROGRAMS = astrognome -astrognome_SOURCES = ag-app.c ag-window.c astrognome.c $(BUILT_SOURCES) +astrognome_SOURCES = $(astrognome_source_files) $(BUILT_SOURCES) astrognome_LDADD = $(SWE_GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/libgd/libgd.la astrognome_LDFLAGS = -rdynamic astrognome_CFLAGS = $(SWE_GLIB_CFLAGS) $(CFLAGS) $(GTK_CFLAGS) -Wall -I$(top_srcdir)/libgd diff --git a/src/ag-chart.c b/src/ag-chart.c new file mode 100644 index 0000000..9a42b44 --- /dev/null +++ b/src/ag-chart.c @@ -0,0 +1,28 @@ +#include "ag-chart.h" + +struct _AgChartPrivate { + gchar *save_buffer; +}; + +G_DEFINE_TYPE(AgChart, ag_chart, GSWE_TYPE_MOMENT); + +#define GET_PRIVATE(instance) (G_TYPE_INSTANCE_GET_PRIVATE((instance), AG_TYPE_CHART, AgChartPrivate)) + +static void +ag_chart_class_init(AgChartClass *klass) +{ + g_type_class_add_private(klass, sizeof(AgChartPrivate)); +} + +static void +ag_chart_init(AgChart *chart) +{ + chart->priv = GET_PRIVATE(chart); +} + +AgChart * +ag_chart_new(void) +{ + return NULL; +} + diff --git a/src/ag-chart.h b/src/ag-chart.h new file mode 100644 index 0000000..4e4e38b --- /dev/null +++ b/src/ag-chart.h @@ -0,0 +1,38 @@ +#ifndef __AG_CHART_H__ +#define __AG_CHART_H__ + +#include +#include + +G_BEGIN_DECLS + +#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_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)) + +typedef struct _AgChart AgChart; +typedef struct _AgChartClass AgChartClass; +typedef struct _AgChartPrivate AgChartPrivate; + +struct _AgChart { + GsweMoment parent_instance; + AgChartPrivate *priv; +}; + +struct _AgChartClass { + GsweMomentClass parent_class; +}; + +GType ag_chart_get_type(void) G_GNUC_CONST; +AgChart *ag_chart_new(void); + +void ag_chart_load_from_file(const gchar *path, GError **err); +void ag_chart_save_to_file(const gchar *path, GError **err); + +G_END_DECLS + +#endif /* __AG_CHART_H__ */ + From 6a2da690ea97a4941aa718d09b96f5d664a419e6 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 14 Sep 2013 17:37:33 +0200 Subject: [PATCH 2/3] Created ag_chart_new_full() instead of ag_chart_new() --- src/ag-chart.c | 19 +++++++++++++++++-- src/ag-chart.h | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ag-chart.c b/src/ag-chart.c index 9a42b44..092c0ab 100644 --- a/src/ag-chart.c +++ b/src/ag-chart.c @@ -21,8 +21,23 @@ ag_chart_init(AgChart *chart) } AgChart * -ag_chart_new(void) +ag_chart_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system) { - return NULL; + AgChart *ret; + GsweCoordinates *coords = g_new0(GsweCoordinates, 1); + + coords->longitude = longitude; + coords->latitude = latitude; + coords->altitude = altitude; + + ret = AG_CHART(g_object_new(AG_TYPE_CHART, + "timestamp", timestamp, + "coordinates", coords, + "house-system", house_system, + NULL)); + + g_free(coords); + + return ret; } diff --git a/src/ag-chart.h b/src/ag-chart.h index 4e4e38b..d41de89 100644 --- a/src/ag-chart.h +++ b/src/ag-chart.h @@ -27,7 +27,7 @@ struct _AgChartClass { }; GType ag_chart_get_type(void) G_GNUC_CONST; -AgChart *ag_chart_new(void); +AgChart *ag_chart_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system); void ag_chart_load_from_file(const gchar *path, GError **err); void ag_chart_save_to_file(const gchar *path, GError **err); From b6eca0c99f43e890df4cd3de79c8e40322df9f5a Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 14 Sep 2013 17:44:18 +0200 Subject: [PATCH 3/3] Changed AgWindow's moment to an AgChart for later saving functionality. --- src/ag-window.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ag-window.c b/src/ag-window.c index 4ab59d8..dce7d2f 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -6,6 +6,7 @@ #include "ag-app.h" #include "ag-window.h" +#include "ag-chart.h" struct _AgWindowPrivate { GtkWidget *grid; @@ -34,7 +35,7 @@ struct _AgWindowPrivate { GtkWidget *current_tab; GsweTimestamp *timestamp; - GsweMoment *moment; + AgChart *chart; }; G_DEFINE_TYPE(AgWindow, ag_window, GTK_TYPE_APPLICATION_WINDOW); @@ -62,9 +63,9 @@ close_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) } static void -moment_changed(GsweMoment *moment, gpointer user_data) +chart_changed(AgChart *chart, gpointer user_data) { - g_warning("Moment changed!"); + g_warning("Chart changed!"); } static void @@ -97,11 +98,11 @@ recalculate_chart(AgWindow *window) gswe_timestamp_set_gregorian_full(priv->timestamp, year, month, day, hour, minute, second, 0, 1.0, NULL); } - if (priv->moment == NULL) { + if (priv->chart == NULL) { // TODO: moke house system configurable - priv->moment = gswe_moment_new_full(priv->timestamp, longitude, latitude, 380.0, GSWE_HOUSE_SYSTEM_PLACIDUS); - g_signal_connect(priv->moment, "changed", G_CALLBACK(moment_changed), NULL); - moment_changed(priv->moment, NULL); + priv->chart = ag_chart_new_full(priv->timestamp, longitude, latitude, 380.0, GSWE_HOUSE_SYSTEM_PLACIDUS); + g_signal_connect(priv->chart, "changed", G_CALLBACK(chart_changed), NULL); + chart_changed(priv->chart, NULL); } } @@ -140,7 +141,7 @@ ag_window_init(AgWindow *window) window->priv = priv = GET_PRIVATE(window); priv->timestamp = NULL; - priv->moment = NULL; + priv->chart = NULL; gtk_window_set_hide_titlebar_when_maximized(GTK_WINDOW(window), TRUE);