goffice r2152 - in trunk: . goffice/graph plugins/plot_barcol



Author: jody
Date: Mon Jul 14 10:53:03 2008
New Revision: 2152
URL: http://svn.gnome.org/viewvc/goffice?rev=2152&view=rev

Log:
2008-07-14  Jody Goldberg <jody gnome org>

	* goffice/graph/gog-plot.c (gog_plot_enum_in_reverse) : new.
	(gog_plot_foreach_elem) : Legends are the only things that use this,
	  add a hook to allow a plot to decide what order to walk the list of
	  series. [#540719]

	* plugins/plot_barcol/gog-1.5d.c (gog_1_5d_enum_in_reverse) : stacked
	  and percentage plots prefer to list the series in reverse order.


Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/goffice/graph/gog-plot-impl.h
   trunk/goffice/graph/gog-plot.c
   trunk/plugins/plot_barcol/gog-1.5d.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Mon Jul 14 10:53:03 2008
@@ -3,6 +3,9 @@
 Jean:
 	* Fix plot engines memory leaks. [#542506]
 
+Jody:
+	* Reverse legend ordering for stacked 1.5d plots.
+
 Morten:
 	* Work around valgrind bug.
 

Modified: trunk/goffice/graph/gog-plot-impl.h
==============================================================================
--- trunk/goffice/graph/gog-plot-impl.h	(original)
+++ trunk/goffice/graph/gog-plot-impl.h	Mon Jul 14 10:53:03 2008
@@ -73,6 +73,10 @@
 
 	gboolean   (*supports_vary_style_by_element) (GogPlot const *plot);
 
+	/* %TRUE if the plot prefers to display series in reverse order for
+	 * legends (e.g. stacked plots want top element to be the last series) */
+	gboolean   (*enum_in_reverse) (GogPlot const *plot);
+
 	void       (*foreach_elem)    	(GogPlot *plot, gboolean only_visible,
 					 GogEnumFunc handler, gpointer data);
 

Modified: trunk/goffice/graph/gog-plot.c
==============================================================================
--- trunk/goffice/graph/gog-plot.c	(original)
+++ trunk/goffice/graph/gog-plot.c	Mon Jul 14 10:53:03 2008
@@ -710,6 +710,13 @@
 		*visible = plot->visible_cardinality;
 }
 
+static gboolean
+gog_plot_enum_in_reverse (GogPlot const *plot)
+{
+	GogPlotClass *klass = GOG_PLOT_GET_CLASS (plot);
+	return klass != NULL && klass->enum_in_reverse && (klass->enum_in_reverse) (plot);
+}
+
 void
 gog_plot_foreach_elem (GogPlot *plot, gboolean only_visible,
 		       GogEnumFunc func, gpointer data)
@@ -738,13 +745,22 @@
 		return;
 
 	if (!plot->vary_style_by_element) {
+		GSList *tmp = NULL;
+
 		unsigned i = plot->index_num;
+
+		if (gog_plot_enum_in_reverse (plot))
+			ptr = tmp = g_slist_reverse (g_slist_copy (ptr));
+
 		for (; ptr != NULL ; ptr = ptr->next)
 			if (!only_visible || gog_series_has_legend (ptr->data)) {
 				func (i, gog_styled_object_get_style (ptr->data),
 				      gog_object_get_name (ptr->data), data);
 				i++;
 			}
+
+		g_slist_free (tmp);
+
 		return;
 	}
 

Modified: trunk/plugins/plot_barcol/gog-1.5d.c
==============================================================================
--- trunk/plugins/plot_barcol/gog-1.5d.c	(original)
+++ trunk/plugins/plot_barcol/gog-1.5d.c	Mon Jul 14 10:53:03 2008
@@ -310,6 +310,12 @@
 	GogPlot1_5d *gog_1_5d = GOG_PLOT1_5D (plot);
 	return gog_1_5d->type == GOG_1_5D_NORMAL;
 }
+static gboolean
+gog_1_5d_enum_in_reverse (GogPlot const *plot)
+{
+	GogPlot1_5d *gog_1_5d = GOG_PLOT1_5D (plot);
+	return gog_1_5d->type != GOG_1_5D_NORMAL; /* stacked or percentage */
+}
 
 static void
 gog_plot1_5d_class_init (GogPlotClass *plot_klass)
@@ -358,6 +364,7 @@
 	plot_klass->axis_get_bounds   	= gog_plot1_5d_axis_get_bounds;
 	plot_klass->axis_set	      	= GOG_AXIS_SET_XY;
 	plot_klass->supports_vary_style_by_element = gog_1_5d_supports_vary_style_by_element;
+	plot_klass->enum_in_reverse	= gog_1_5d_enum_in_reverse;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]