@@ -36,7 +37,6 @@ struct _AgWindowPrivate {
GtkWidget *tab_edit;
GtkWidget *current_tab;
- GsweTimestamp *timestamp;
AgChart *chart;
gchar *uri;
};
@@ -109,6 +109,17 @@ save_as_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
void
ag_window_redraw_chart(AgWindow *window)
{
+ GError *err = NULL;
+ gchar *svg_content;
+
+ svg_content = ag_chart_create_svg(window->priv->chart, &err);
+
+ if (svg_content == NULL) {
+ g_warning("%s", err->message);
+ } else {
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(window->priv->tab_chart), svg_content, "image/svg+xml", "UTF-8", "file://");
+ g_free(svg_content);
+ }
}
void
@@ -144,48 +155,57 @@ chart_changed(AgChart *chart, AgWindow *window)
static void
recalculate_chart(AgWindow *window)
{
- AgWindowPrivate *priv = window->priv;
- 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));
- gdouble 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,
+ month,
+ day,
+ hour,
+ minute,
+ second;
+ gdouble longitude,
+ latitude;
+ gboolean south,
+ west;
+ GsweTimestamp *timestamp;
- if (south) {
+ g_debug("Recalculating chart data");
+
+ year = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window->priv->year));
+ month = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window->priv->month));
+ day = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window->priv->day));
+ hour = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window->priv->hour));
+ minute = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window->priv->minute));
+ second = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(window->priv->second));
+ longitude = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->priv->longitude));
+ latitude = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->priv->latitude));
+
+ if ((south = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->priv->south_lat)))) {
latitude = 0 - latitude;
}
- if (west) {
+ if ((west = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->priv->west_long)))) {
longitude = 0 - longitude;
}
// TODO: Set timezone according to the city selected!
- if (priv->timestamp == NULL) {
- priv->timestamp = gswe_timestamp_new_from_gregorian_full(year, month, day, hour, minute, second, 0, 1.0);
+ if (window->priv->chart == NULL) {
+ timestamp = gswe_timestamp_new_from_gregorian_full(year, month, day, hour, minute, second, 0, 1.0);
+ // TODO: make house system configurable
+ window->priv->chart = ag_chart_new_full(timestamp, longitude, latitude, 380.0, GSWE_HOUSE_SYSTEM_PLACIDUS);
+ g_signal_connect(window->priv->chart, "changed", G_CALLBACK(chart_changed), window);
} else {
- gswe_timestamp_set_gregorian_full(priv->timestamp, year, month, day, hour, minute, second, 0, 1.0, NULL);
+ timestamp = gswe_moment_get_timestamp(GSWE_MOMENT(window->priv->chart));
+ gswe_timestamp_set_gregorian_full(timestamp, year, month, day, hour, minute, second, 0, 1.0, NULL);
}
- if (priv->chart == NULL) {
- // TODO: make house system configurable
- priv->chart = ag_chart_new_full(priv->timestamp, longitude, latitude, 380.0, GSWE_HOUSE_SYSTEM_PLACIDUS);
- ag_chart_set_name(priv->chart, gtk_entry_get_text(GTK_ENTRY(priv->name)));
- g_signal_connect(priv->chart, "changed", G_CALLBACK(chart_changed), window);
- ag_window_update_from_chart(window);
- } else {
- gswe_moment_set_timestamp(GSWE_MOMENT(priv->chart), priv->timestamp);
- }
+ ag_chart_set_name(window->priv->chart, gtk_entry_get_text(GTK_ENTRY(window->priv->name)));
+ ag_window_redraw_chart(window);
}
static void
tab_changed_cb(GdStack *stack, GParamSpec *pspec, AgWindow *window)
{
const gchar *active_tab_name = gd_stack_get_visible_child_name(stack);
+ GtkWidget *active_tab;
g_debug("Active tab changed: %s", active_tab_name);
@@ -193,13 +213,18 @@ tab_changed_cb(GdStack *stack, GParamSpec *pspec, AgWindow *window)
return;
}
+ active_tab = gd_stack_get_visible_child(stack);
+
+ if (strcmp("chart", active_tab_name) == 0) {
+ gtk_widget_set_size_request(active_tab, 600, 600);
+ }
+
// Note that priv->current_tab is actually the previously selected tab, not the real active one!
if (window->priv->current_tab == window->priv->tab_edit) {
- g_debug("Recalculating chart data");
recalculate_chart(window);
}
- window->priv->current_tab = gd_stack_get_visible_child(stack);
+ window->priv->current_tab = active_tab;
}
static GActionEntry win_entries[] = {
@@ -218,7 +243,6 @@ ag_window_init(AgWindow *window)
window->priv = priv = GET_PRIVATE(window);
- priv->timestamp = NULL;
priv->chart = NULL;
priv->uri = NULL;
@@ -347,7 +371,8 @@ static void
window_populate(AgWindow *window)
{
AgWindowPrivate *priv = window->priv;
- GtkWidget *menu_button;
+ GtkWidget *menu_button,
+ *scroll;
GObject *menu;
priv->header_bar = gd_header_bar_new();
@@ -372,8 +397,14 @@ window_populate(AgWindow *window)
priv->tab_edit = notebook_edit(window);
gd_stack_add_titled(GD_STACK(priv->stack), priv->tab_edit, "edit", _("Edit"));
- priv->tab_chart = gtk_label_new("PLACEHOLDER FOR THE CHART WEBKIT");
- gd_stack_add_titled(GD_STACK(priv->stack), priv->tab_chart, "chart", _("Chart"));
+ scroll = gtk_scrolled_window_new(NULL, NULL);
+ g_object_set(scroll, "shadow-type", GTK_SHADOW_IN, NULL);
+ gd_stack_add_titled(GD_STACK(priv->stack), scroll, "chart", _("Chart"));
+
+ priv->tab_chart = webkit_web_view_new();
+ gtk_container_add(GTK_CONTAINER(scroll), priv->tab_chart);
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(priv->tab_chart), "No ChartNo Chart
No chart is loaded. Create one on the edit view, or open one from the application menu!
", "text/html", "UTF-8", NULL);
+ gtk_widget_set_size_request(priv->tab_chart, 600, 600);
priv->tab_aspects = gtk_label_new("PLACEHOLDER FOR THE ASPECTS TABLE");
gd_stack_add_titled(GD_STACK(priv->stack), priv->tab_aspects, "aspects", _("Aspects"));
diff --git a/src/astrognome.c b/src/astrognome.c
index 67c8c50..6370856 100644
--- a/src/astrognome.c
+++ b/src/astrognome.c
@@ -3,6 +3,9 @@
#include
#include
#include
+#include
+#include
+#include
#include
@@ -88,6 +91,10 @@ main(int argc, char *argv[])
#endif
LIBXML_TEST_VERSION;
+ xmlSubstituteEntitiesDefault(1);
+ xmlLoadExtDtdDefaultValue = 1;
+ xsltInit();
+ exsltRegisterAll();
gswe_init();
option_version = FALSE,