From 6854c8a64389ea75b2f513680c9ab591cdddafc5 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 16 Jan 2011 14:33:52 +0100
Subject: Revert the order of LdDiagram objects.
Now they go from oldest to newest.
---
liblogdiag/ld-canvas.c | 6 +++---
liblogdiag/ld-diagram.c | 3 +--
2 files changed, 4 insertions(+), 5 deletions(-)
(limited to 'liblogdiag')
diff --git a/liblogdiag/ld-canvas.c b/liblogdiag/ld-canvas.c
index a4ac720..83ac918 100644
--- a/liblogdiag/ld-canvas.c
+++ b/liblogdiag/ld-canvas.c
@@ -890,7 +890,7 @@ get_object_at_coords (LdCanvas *self, gdouble x, gdouble y)
/* Iterate from the top object downwards. */
objects = (GList *) ld_diagram_get_objects (self->priv->diagram);
- for (iter = objects; iter; iter = g_list_next (iter))
+ for (iter = g_list_last (objects); iter; iter = g_list_previous (iter))
{
LdDiagramObject *object;
@@ -1182,7 +1182,7 @@ on_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
move_object_to_coords (self, data->object, event->x, event->y);
if (self->priv->diagram)
- ld_diagram_insert_object (self->priv->diagram, data->object, 0);
+ ld_diagram_insert_object (self->priv->diagram, data->object, -1);
/* XXX: "cancel" causes confusion. */
ld_canvas_real_cancel_operation (self);
@@ -1338,7 +1338,7 @@ draw_diagram (GtkWidget *widget, DrawData *data)
/* Draw objects from the diagram, from bottom to top. */
objects = (GList *) ld_diagram_get_objects (data->self->priv->diagram);
- for (iter = g_list_last (objects); iter; iter = g_list_previous (iter))
+ for (iter = objects; iter; iter = g_list_next (iter))
draw_object (LD_DIAGRAM_OBJECT (iter->data), data);
switch (data->self->priv->operation)
diff --git a/liblogdiag/ld-diagram.c b/liblogdiag/ld-diagram.c
index 3aae65d..0075850 100644
--- a/liblogdiag/ld-diagram.c
+++ b/liblogdiag/ld-diagram.c
@@ -461,8 +461,7 @@ serialize_diagram (LdDiagram *self)
json_node_take_object (root_node, root_object);
objects_array = json_array_new ();
- iter = g_list_last (self->priv->objects);
- for (; iter; iter = g_list_previous (iter))
+ for (iter = self->priv->objects; iter; iter = g_list_next (iter))
json_array_add_element (objects_array,
serialize_object (LD_DIAGRAM_OBJECT (iter->data)));
--
cgit v1.2.3-70-g09d2