[goffice] Add a name to regression curves for display in legends. [#605040]
- From: Jean Bréfort <jbrefort src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] Add a name to regression curves for display in legends. [#605040]
- Date: Mon, 21 Dec 2009 09:28:40 +0000 (UTC)
commit 436c7ece7ff27d780be999590abcc8e91d1b1f45
Author: Jean Brefort <jean brefort normalesup org>
Date: Mon Dec 21 10:29:33 2009 +0100
Add a name to regression curves for display in legends. [#605040]
ChangeLog | 10 ++++++++++
NEWS | 3 +++
goffice/graph/gog-reg-curve-prefs.ui | 27 ++++++++++++++++++++++-----
goffice/graph/gog-reg-curve.c | 24 +++++++++++++++++-------
goffice/graph/gog-reg-curve.h | 2 +-
5 files changed, 53 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dd69996..f0728f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-21 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/gog-reg-curve-prefs.ui: add a name to regression curves
+ for display in legends. [#605040]
+ * goffice/graph/gog-reg-curve.c (gog_reg_curve_populate_editor),
+ (gog_reg_curve_finalize), (gog_reg_curve_init),
+ (gog_reg_curve_dataset_dims), (gog_reg_curve_dataset_get_elem),
+ (gog_reg_curve_dataset_dim_changed):
+ * goffice/graph/gog-reg-curve.h: ditto.
+
2009-12-19 Jean Brefort <jean brefort normalesup org>
* plugins/plot_barcol/gog-barcol.c
diff --git a/NEWS b/NEWS
index b0be139..b86303b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.7.18:
+Jean:
+ * Add a name to regression curves for display in legends. [#605040]
+
--------------------------------------------------------------------------
goffice 0.7.17:
diff --git a/goffice/graph/gog-reg-curve-prefs.ui b/goffice/graph/gog-reg-curve-prefs.ui
index 2aca211..c8c26b5 100644
--- a/goffice/graph/gog-reg-curve-prefs.ui
+++ b/goffice/graph/gog-reg-curve-prefs.ui
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<interface>
+ <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkTable" id="reg-curve-prefs">
<property name="visible">True</property>
<property name="border_width">12</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -16,6 +17,8 @@
<property name="label" translatable="yes">Low bound:</property>
</object>
<packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -28,8 +31,8 @@
<property name="label" translatable="yes">High bound:</property>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -45,13 +48,27 @@
</object>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
+ <object class="GtkLabel" id="name-label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">(_Name):</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
diff --git a/goffice/graph/gog-reg-curve.c b/goffice/graph/gog-reg-curve.c
index 16b22a6..9102d75 100644
--- a/goffice/graph/gog-reg-curve.c
+++ b/goffice/graph/gog-reg-curve.c
@@ -71,12 +71,15 @@ gog_reg_curve_populate_editor (GogObject *gobj,
_("Details"));
table = GTK_TABLE (gtk_builder_get_object (gui, "reg-curve-prefs"));
- w = GTK_WIDGET (gog_data_allocator_editor (dalloc, set, 0, GOG_DATA_SCALAR));
+ w = GTK_WIDGET (gog_data_allocator_editor (dalloc, set, -1, GOG_DATA_SCALAR));
gtk_widget_show (w);
gtk_table_attach (table, w, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- w = GTK_WIDGET (gog_data_allocator_editor (dalloc, set, 1, GOG_DATA_SCALAR));
+ w = GTK_WIDGET (gog_data_allocator_editor (dalloc, set, 0, GOG_DATA_SCALAR));
gtk_widget_show (w);
gtk_table_attach (table, w, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ w = GTK_WIDGET (gog_data_allocator_editor (dalloc, set, 1, GOG_DATA_SCALAR));
+ gtk_widget_show (w);
+ gtk_table_attach (table, w, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
w = go_gtk_builder_get_widget (gui, "skip-invalid");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
(GOG_REG_CURVE (gobj))->skip_invalid);
@@ -128,7 +131,7 @@ gog_reg_curve_finalize (GObject *obj)
GogRegCurve *rc = GOG_REG_CURVE (obj);
if (rc->bounds != NULL) {
gog_dataset_finalize (GOG_DATASET (obj));
- g_free (rc->bounds);
+ g_free (rc->bounds - 1); /* aliased pointer */
rc->bounds = NULL;
}
g_free (rc->a);
@@ -186,13 +189,13 @@ static void
gog_reg_curve_init (GogRegCurve *reg_curve)
{
reg_curve->ninterp = 100;
- reg_curve->bounds = g_new0 (GogDatasetElement, 2);
+ reg_curve->bounds = g_new0 (GogDatasetElement,3) + 1;
}
static void
gog_reg_curve_dataset_dims (GogDataset const *set, int *first, int *last)
{
- *first = 0;
+ *first = -1;
*last = 1;
}
@@ -201,14 +204,21 @@ gog_reg_curve_dataset_get_elem (GogDataset const *set, int dim_i)
{
GogRegCurve const *rc = GOG_REG_CURVE (set);
g_return_val_if_fail (2 > dim_i, NULL);
- g_return_val_if_fail (dim_i >= 0, NULL);
+ g_return_val_if_fail (dim_i >= -1, NULL);
return rc->bounds + dim_i;
}
static void
gog_reg_curve_dataset_dim_changed (GogDataset *set, int dim_i)
{
- gog_object_request_update (GOG_OBJECT (set));
+ if (dim_i == -1) {
+ GogRegCurve const *rc = GOG_REG_CURVE (set);
+ GOData *name_src = rc->bounds[-1].data;
+ char *name = (name_src != NULL)
+ ? go_data_get_scalar_string (name_src) : NULL;
+ gog_object_set_name (GOG_OBJECT (set), name, NULL);
+ } else
+ gog_object_request_update (GOG_OBJECT (set));
}
static void
diff --git a/goffice/graph/gog-reg-curve.h b/goffice/graph/gog-reg-curve.h
index 87b9f2e..7e3061c 100644
--- a/goffice/graph/gog-reg-curve.h
+++ b/goffice/graph/gog-reg-curve.h
@@ -32,7 +32,7 @@ struct _GogRegCurve {
GogSeries *series;
gboolean weighted;
GODataVector *weights;
- GogDatasetElement *bounds;
+ GogDatasetElement *bounds; /* aliased to include the name as -1 */
gboolean skip_invalid; /* do not take into account invalid data */
int ninterp; /* how many points to use for display the curve as a vpath */
double *a; /* calculated coefficients, must be allocated by derived class */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]