Merge pull request #63 from gergelypolonkai/bug-61

Show chart name in header bar upon loading
This commit is contained in:
Gergely Polonkai 2014-08-26 13:21:14 +02:00
commit 8351445868
3 changed files with 20 additions and 25 deletions

View File

@ -403,12 +403,12 @@ ag_chart_set_name(AgChart *chart, const gchar *name)
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_NAME]);
}
gchar *
const gchar *
ag_chart_get_name(AgChart *chart)
{
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return g_strdup(priv->name);
return priv->name;
}
void
@ -425,12 +425,12 @@ ag_chart_set_country(AgChart *chart, const gchar *country)
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_COUNTRY]);
}
gchar *
const gchar *
ag_chart_get_country(AgChart *chart)
{
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return g_strdup(priv->country);
return priv->country;
}
void
@ -447,12 +447,12 @@ ag_chart_set_city(AgChart *chart, const gchar *city)
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_CITY]);
}
gchar *
const gchar *
ag_chart_get_city(AgChart *chart)
{
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
return g_strdup(priv->city);
return priv->city;
}
/**
@ -1353,6 +1353,7 @@ create_save_doc(AgChart *chart)
GsweTimestamp *timestamp;
GEnumClass *house_system_class;
GEnumValue *enum_value;
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
doc = xmlNewDoc(BAD_CAST "1.0");
root_node = xmlNewNode(NULL, BAD_CAST "chartinfo");
@ -1361,20 +1362,14 @@ create_save_doc(AgChart *chart)
// Begin <data> node
data_node = xmlNewChild(root_node, NULL, BAD_CAST "data", NULL);
value = ag_chart_get_name(chart);
xmlNewChild(data_node, NULL, BAD_CAST "name", BAD_CAST value);
g_free(value);
xmlNewChild(data_node, NULL, BAD_CAST "name", BAD_CAST priv->name);
// Begin <place> node
place_node = xmlNewChild(data_node, NULL, BAD_CAST "place", NULL);
value = ag_chart_get_country(chart);
xmlNewChild(place_node, NULL, BAD_CAST "country", BAD_CAST value);
g_free(value);
xmlNewChild(place_node, NULL, BAD_CAST "country", BAD_CAST priv->country);
value = ag_chart_get_city(chart);
xmlNewChild(place_node, NULL, BAD_CAST "city", BAD_CAST value);
g_free(value);
xmlNewChild(place_node, NULL, BAD_CAST "city", BAD_CAST priv->city);
coordinates = gswe_moment_get_coordinates(GSWE_MOMENT(chart));
@ -1895,7 +1890,8 @@ ag_chart_set_note(AgChart *chart, const gchar *note)
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_NOTE]);
}
const gchar *ag_chart_get_note(AgChart *chart)
const gchar *
ag_chart_get_note(AgChart *chart)
{
AgChartPrivate *priv = ag_chart_get_instance_private(chart);

View File

@ -70,17 +70,17 @@ void ag_chart_export_svg_to_file(AgChart *chart,
void ag_chart_set_name(AgChart *chart,
const gchar *name);
gchar *ag_chart_get_name(AgChart *chart);
const gchar *ag_chart_get_name(AgChart *chart);
void ag_chart_set_country(AgChart *chart,
const gchar *country);
gchar *ag_chart_get_country(AgChart *chart);
const gchar *ag_chart_get_country(AgChart *chart);
void ag_chart_set_city(AgChart *chart,
const gchar *city);
gchar *ag_chart_get_city(AgChart *chart);
const gchar *ag_chart_get_city(AgChart *chart);
gchar *ag_chart_create_svg(AgChart *chart,
gsize *length,

View File

@ -532,6 +532,11 @@ ag_window_update_from_chart(AgWindow *window)
);
}
gtk_header_bar_set_subtitle(
GTK_HEADER_BAR(priv->header_bar),
ag_chart_get_name(priv->chart)
);
g_free(coordinates);
ag_window_redraw_chart(window);
@ -736,8 +741,6 @@ ag_window_export_svg(AgWindow *window, GError **err)
name = ag_chart_get_name(priv->chart);
if ((name == NULL) || (*name == 0)) {
g_free(name);
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_MESSAGE_ERROR,
@ -753,7 +756,6 @@ ag_window_export_svg(AgWindow *window, GError **err)
}
file_name = g_strdup_printf("%s.svg", name);
g_free(name);
fs = gtk_file_chooser_dialog_new(_("Export Chart as SVG"),
GTK_WINDOW(window),
@ -829,8 +831,6 @@ ag_window_export(AgWindow *window, GError **err)
name = ag_chart_get_name(priv->chart);
if ((name == NULL) || (*name == 0)) {
g_free(name);
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_MESSAGE_ERROR,
@ -846,7 +846,6 @@ ag_window_export(AgWindow *window, GError **err)
}
file_name = g_strdup_printf("%s.agc", name);
g_free(name);
fs = gtk_file_chooser_dialog_new(_("Export Chart"),
GTK_WINDOW(window),