Merge pull request #30 from gergelypolonkai/chart-note
Add chart note support
This commit is contained in:
commit
a498c93c20
@ -17,6 +17,7 @@ struct _AgChartPrivate {
|
|||||||
gchar *city;
|
gchar *city;
|
||||||
gchar *save_buffer;
|
gchar *save_buffer;
|
||||||
GList *planet_list;
|
GList *planet_list;
|
||||||
|
gchar *note;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -425,6 +426,7 @@ ag_chart_load_from_file(GFile *file, GError **err)
|
|||||||
GVariant *minute;
|
GVariant *minute;
|
||||||
GVariant *second;
|
GVariant *second;
|
||||||
GVariant *timezone;
|
GVariant *timezone;
|
||||||
|
GVariant *note;
|
||||||
GsweTimestamp *timestamp;
|
GsweTimestamp *timestamp;
|
||||||
gboolean found_error = FALSE;
|
gboolean found_error = FALSE;
|
||||||
|
|
||||||
@ -505,7 +507,10 @@ ag_chart_load_from_file(GFile *file, GError **err)
|
|||||||
found_error = TRUE;
|
found_error = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
note = get_by_xpath(xpath_context, uri, "/chartinfo/note/text()", FALSE, XML_CONVERT_STRING, err);
|
||||||
|
|
||||||
if (found_error) {
|
if (found_error) {
|
||||||
|
ag_g_variant_unref(note);
|
||||||
ag_g_variant_unref(chart_name);
|
ag_g_variant_unref(chart_name);
|
||||||
ag_g_variant_unref(country);
|
ag_g_variant_unref(country);
|
||||||
ag_g_variant_unref(city);
|
ag_g_variant_unref(city);
|
||||||
@ -565,6 +570,14 @@ ag_chart_load_from_file(GFile *file, GError **err)
|
|||||||
ag_chart_set_city(chart, city_name);
|
ag_chart_set_city(chart, city_name);
|
||||||
g_free(city_name);
|
g_free(city_name);
|
||||||
|
|
||||||
|
if (note) {
|
||||||
|
gchar *note_text;
|
||||||
|
|
||||||
|
g_variant_get(note, "ms", ¬e_text);
|
||||||
|
g_variant_unref(note);
|
||||||
|
ag_chart_set_note(chart, note_text);
|
||||||
|
}
|
||||||
|
|
||||||
g_free(xml);
|
g_free(xml);
|
||||||
g_free(uri);
|
g_free(uri);
|
||||||
xmlXPathFreeContext(xpath_context);
|
xmlXPathFreeContext(xpath_context);
|
||||||
@ -666,6 +679,10 @@ create_save_doc(AgChart *chart)
|
|||||||
xmlNewChild(time_node, NULL, BAD_CAST "timezone", BAD_CAST value);
|
xmlNewChild(time_node, NULL, BAD_CAST "timezone", BAD_CAST value);
|
||||||
g_free(value);
|
g_free(value);
|
||||||
|
|
||||||
|
if (ag_chart_get_note(chart)) {
|
||||||
|
xmlNewChild(root_node, NULL, BAD_CAST "note", BAD_CAST ag_chart_get_note(chart));
|
||||||
|
}
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,3 +966,19 @@ ag_chart_export_svg_to_file(AgChart *chart, GFile *file, GError **err)
|
|||||||
|
|
||||||
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
|
||||||
|
ag_chart_set_note(AgChart *chart, const gchar *note)
|
||||||
|
{
|
||||||
|
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
|
||||||
|
|
||||||
|
priv->note = g_strdup(note);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *ag_chart_get_note(AgChart *chart)
|
||||||
|
{
|
||||||
|
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
|
||||||
|
|
||||||
|
return priv->note;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ gchar *ag_chart_create_svg(AgChart *chart,
|
|||||||
gsize *length,
|
gsize *length,
|
||||||
GError **err);
|
GError **err);
|
||||||
GList *ag_chart_get_planets(AgChart *chart);
|
GList *ag_chart_get_planets(AgChart *chart);
|
||||||
|
void ag_chart_set_note(AgChart *chart, const gchar *note);
|
||||||
|
const gchar *ag_chart_get_note(AgChart *chart);
|
||||||
|
|
||||||
#define AG_CHART_ERROR (ag_chart_error_quark())
|
#define AG_CHART_ERROR (ag_chart_error_quark())
|
||||||
GQuark ag_chart_error_quark(void);
|
GQuark ag_chart_error_quark(void);
|
||||||
|
@ -41,6 +41,7 @@ struct _AgWindowPrivate {
|
|||||||
AgChart *chart;
|
AgChart *chart;
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
gboolean aspect_table_populated;
|
gboolean aspect_table_populated;
|
||||||
|
GtkTextBuffer *note_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_QUARK(ag_window_error_quark, ag_window_error);
|
G_DEFINE_QUARK(ag_window_error_quark, ag_window_error);
|
||||||
@ -548,6 +549,11 @@ ag_window_update_from_chart(AgWindow *window)
|
|||||||
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(priv->name), ag_chart_get_name(priv->chart));
|
gtk_entry_set_text(GTK_ENTRY(priv->name), ag_chart_get_name(priv->chart));
|
||||||
|
|
||||||
|
if (ag_chart_get_note(priv->chart)) {
|
||||||
|
// TODO: maybe setting length to -1 here is not that good of an idea…
|
||||||
|
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(priv->note_buffer), ag_chart_get_note(priv->chart), -1);
|
||||||
|
}
|
||||||
|
|
||||||
g_free(coordinates);
|
g_free(coordinates);
|
||||||
|
|
||||||
ag_window_redraw_chart(window);
|
ag_window_redraw_chart(window);
|
||||||
@ -562,6 +568,10 @@ chart_changed(AgChart *chart, AgWindow *window)
|
|||||||
static void
|
static void
|
||||||
recalculate_chart(AgWindow *window)
|
recalculate_chart(AgWindow *window)
|
||||||
{
|
{
|
||||||
|
GsweTimestamp *timestamp;
|
||||||
|
GtkTextIter start_iter,
|
||||||
|
end_iter;
|
||||||
|
gchar *note;
|
||||||
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
||||||
gint year = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->year)),
|
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)),
|
month = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(priv->month)),
|
||||||
@ -573,7 +583,6 @@ recalculate_chart(AgWindow *window)
|
|||||||
latitude = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->latitude));
|
latitude = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->latitude));
|
||||||
gboolean south = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->south_lat)),
|
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));
|
west = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->west_long));
|
||||||
GsweTimestamp *timestamp;
|
|
||||||
|
|
||||||
g_debug("Recalculating chart data");
|
g_debug("Recalculating chart data");
|
||||||
|
|
||||||
@ -598,6 +607,10 @@ recalculate_chart(AgWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ag_chart_set_name(priv->chart, gtk_entry_get_text(GTK_ENTRY(priv->name)));
|
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);
|
||||||
|
ag_chart_set_note(priv->chart, note);
|
||||||
|
g_free(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -749,6 +762,7 @@ ag_window_class_init(AgWindowClass *klass)
|
|||||||
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, aspect_table);
|
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, aspect_table);
|
||||||
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, year_adjust);
|
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, year_adjust);
|
||||||
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, stack);
|
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, stack);
|
||||||
|
gtk_widget_class_bind_template_child_private(widget_class, AgWindow, note_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -105,6 +105,8 @@
|
|||||||
<property name="step_increment">1</property>
|
<property name="step_increment">1</property>
|
||||||
<property name="page_increment">10</property>
|
<property name="page_increment">10</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkTextBuffer" id="note_buffer">
|
||||||
|
</object>
|
||||||
<template class="AgWindow" parent="GtkApplicationWindow">
|
<template class="AgWindow" parent="GtkApplicationWindow">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="has_focus">False</property>
|
<property name="has_focus">False</property>
|
||||||
@ -219,6 +221,20 @@
|
|||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSearchEntry" id="country">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||||
|
<property name="primary_icon_activatable">False</property>
|
||||||
|
<property name="primary_icon_sensitive">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="width">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="city_label">
|
<object class="GtkLabel" id="city_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -230,6 +246,20 @@
|
|||||||
<property name="top_attach">2</property>
|
<property name="top_attach">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSearchEntry" id="city">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||||
|
<property name="primary_icon_activatable">False</property>
|
||||||
|
<property name="primary_icon_sensitive">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="width">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="latitude_label">
|
<object class="GtkLabel" id="latitude_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -375,17 +405,6 @@
|
|||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="day_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes" context="Chart edit, Day label">Day</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">6</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSpinButton" id="month">
|
<object class="GtkSpinButton" id="month">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -397,6 +416,17 @@
|
|||||||
<property name="top_attach">2</property>
|
<property name="top_attach">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="day_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes" context="Chart edit, Day label">Day</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">6</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSpinButton" id="day">
|
<object class="GtkSpinButton" id="day">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -419,39 +449,6 @@
|
|||||||
<property name="top_attach">3</property>
|
<property name="top_attach">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="minute_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes" context="Chart edit, Minute label">Minute</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">5</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="second_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes" context="Chart edit, Second label">Second</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">6</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="timezone_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes" context="Chart edit, Timezone label">Timezone</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">4</property>
|
|
||||||
<property name="top_attach">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSpinButton" id="hour">
|
<object class="GtkSpinButton" id="hour">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -463,6 +460,17 @@
|
|||||||
<property name="top_attach">4</property>
|
<property name="top_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="minute_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes" context="Chart edit, Minute label">Minute</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">5</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSpinButton" id="minute">
|
<object class="GtkSpinButton" id="minute">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -474,6 +482,17 @@
|
|||||||
<property name="top_attach">4</property>
|
<property name="top_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="second_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes" context="Chart edit, Second label">Second</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">6</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSpinButton" id="second">
|
<object class="GtkSpinButton" id="second">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -485,6 +504,17 @@
|
|||||||
<property name="top_attach">4</property>
|
<property name="top_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="timezone_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes" context="Chart edit, Timezone label">Timezone</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">4</property>
|
||||||
|
<property name="top_attach">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSpinButton" id="timezone">
|
<object class="GtkSpinButton" id="timezone">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -499,31 +529,36 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSearchEntry" id="city">
|
<object class="GtkLabel" id="note_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
<property name="xalign">0</property>
|
||||||
<property name="primary_icon_activatable">False</property>
|
<property name="label" translatable="yes" context="Chart edit, Note label">Note</property>
|
||||||
<property name="primary_icon_sensitive">False</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">6</property>
|
||||||
<property name="width">3</property>
|
<property name="width">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSearchEntry" id="country">
|
<object class="GtkScrolledWindow" id="note_scroll">
|
||||||
|
<property name="height_request">300</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
<property name="shadow_type">in</property>
|
||||||
<property name="primary_icon_activatable">False</property>
|
<child>
|
||||||
<property name="primary_icon_sensitive">False</property>
|
<object class="GtkTextView" id="note">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="buffer">note_buffer</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="top_attach">2</property>
|
<property name="top_attach">7</property>
|
||||||
<property name="width">3</property>
|
<property name="width">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
Loading…
Reference in New Issue
Block a user