aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-08 00:13:17 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-08 00:13:17 +0800
commitf0c10e106c6d47e4817f118ff94555a15dfbed00 (patch)
tree2019b77f6a141f93609ecbe3d79dabc609da89fa /e-util
parentd6fdf08d681d4db1687705e2d19e6c1db1acf5e4 (diff)
downloadgsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.tar
gsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.tar.gz
gsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.tar.bz2
gsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.tar.lz
gsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.tar.xz
gsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.tar.zst
gsoc2013-evolution-f0c10e106c6d47e4817f118ff94555a15dfbed00.zip
Added last and insert functions.
2000-07-07 Christopher James Lahey <clahey@helixcode.com> * e-iterator.c, e-iterator.h, e-list-iterator.c, e-list-iterator.h: Added last and insert functions. svn path=/trunk/; revision=3946
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog5
-rw-r--r--e-util/e-iterator.c17
-rw-r--r--e-util/e-iterator.h44
-rw-r--r--e-util/e-list-iterator.c78
4 files changed, 111 insertions, 33 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 17066f1fce..4a19bb7207 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,8 @@
+2000-07-07 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-iterator.c, e-iterator.h, e-list-iterator.c,
+ e-list-iterator.h: Added last and insert functions.
+
2000-07-06 Federico Mena Quintero <federico@helixcode.com>
* e-dialog-widgets.c: Added docstrings. This file did not have
diff --git a/e-util/e-iterator.c b/e-util/e-iterator.c
index cff6fec946..874d05ccea 100644
--- a/e-util/e-iterator.c
+++ b/e-util/e-iterator.c
@@ -82,9 +82,11 @@ e_iterator_class_init (EIteratorClass *klass)
klass->invalidate = NULL;
klass->get = NULL;
klass->reset = NULL;
+ klass->last = NULL;
klass->next = NULL;
klass->prev = NULL;
klass->delete = NULL;
+ klass->insert = NULL;
klass->set = NULL;
klass->is_valid = NULL;
}
@@ -116,6 +118,13 @@ e_iterator_reset (EIterator *iterator)
ECI_CLASS(iterator)->reset(iterator);
}
+void
+e_iterator_last (EIterator *iterator)
+{
+ if (ECI_CLASS(iterator)->last)
+ ECI_CLASS(iterator)->last(iterator);
+}
+
gboolean
e_iterator_next (EIterator *iterator)
{
@@ -141,6 +150,14 @@ e_iterator_delete (EIterator *iterator)
ECI_CLASS(iterator)->delete(iterator);
}
+void e_iterator_insert (EIterator *iterator,
+ const void *object,
+ gboolean before)
+{
+ if (ECI_CLASS(iterator)->insert)
+ ECI_CLASS(iterator)->insert(iterator, object, before);
+}
+
void
e_iterator_set (EIterator *iterator,
const void *object)
diff --git a/e-util/e-iterator.h b/e-util/e-iterator.h
index eb983e9da9..84a2db142b 100644
--- a/e-util/e-iterator.h
+++ b/e-util/e-iterator.h
@@ -31,29 +31,37 @@ struct _EIteratorClass {
GtkObjectClass parent_class;
/* Signals */
- void (*invalidate) (EIterator *iterator);
+ void (*invalidate) (EIterator *iterator);
/* Virtual functions */
- const void * (*get) (EIterator *iterator);
- void (*reset) (EIterator *iterator);
- gboolean (*next) (EIterator *iterator);
- gboolean (*prev) (EIterator *iterator);
- void (*delete) (EIterator *iterator);
- void (*set) (EIterator *iterator,
- const void *object);
- gboolean (*is_valid) (EIterator *iterator);
+ const void * (*get) (EIterator *iterator);
+ void (*reset) (EIterator *iterator);
+ void (*last) (EIterator *iterator);
+ gboolean (*next) (EIterator *iterator);
+ gboolean (*prev) (EIterator *iterator);
+ void (*delete) (EIterator *iterator);
+ void (*insert) (EIterator *iterator,
+ const void *object,
+ gboolean before);
+ void (*set) (EIterator *iterator,
+ const void *object);
+ gboolean (*is_valid) (EIterator *iterator);
};
-const void *e_iterator_get (EIterator *iterator);
-void e_iterator_reset (EIterator *iterator);
-gboolean e_iterator_next (EIterator *iterator);
-gboolean e_iterator_prev (EIterator *iterator);
-void e_iterator_delete (EIterator *iterator);
-void e_iterator_set (EIterator *iterator,
- const void *object);
-gboolean e_iterator_is_valid (EIterator *iterator);
+const void *e_iterator_get (EIterator *iterator);
+void e_iterator_reset (EIterator *iterator);
+void e_iterator_last (EIterator *iterator);
+gboolean e_iterator_next (EIterator *iterator);
+gboolean e_iterator_prev (EIterator *iterator);
+void e_iterator_delete (EIterator *iterator);
+void e_iterator_insert (EIterator *iterator,
+ const void *object,
+ gboolean before);
+void e_iterator_set (EIterator *iterator,
+ const void *object);
+gboolean e_iterator_is_valid (EIterator *iterator);
-void e_iterator_invalidate (EIterator *iterator);
+void e_iterator_invalidate (EIterator *iterator);
/* Standard Gtk function */
GtkType e_iterator_get_type (void);
diff --git a/e-util/e-list-iterator.c b/e-util/e-list-iterator.c
index 19ebbef681..51480447b4 100644
--- a/e-util/e-list-iterator.c
+++ b/e-util/e-list-iterator.c
@@ -13,19 +13,23 @@
#include "e-list-iterator.h"
#include "e-list.h"
-static void e_list_iterator_init (EListIterator *list);
-static void e_list_iterator_class_init (EListIteratorClass *klass);
-
-static void e_list_iterator_invalidate (EIterator *iterator);
-static gboolean e_list_iterator_is_valid (EIterator *iterator);
-static void e_list_iterator_set (EIterator *iterator,
- const void *object);
-static void e_list_iterator_delete (EIterator *iterator);
-static gboolean e_list_iterator_prev (EIterator *iterator);
-static gboolean e_list_iterator_next (EIterator *iterator);
-static void e_list_iterator_reset (EIterator *iterator);
-static const void *e_list_iterator_get (EIterator *iterator);
-static void e_list_iterator_destroy (GtkObject *object);
+static void e_list_iterator_init (EListIterator *list);
+static void e_list_iterator_class_init (EListIteratorClass *klass);
+
+static void e_list_iterator_invalidate (EIterator *iterator);
+static gboolean e_list_iterator_is_valid (EIterator *iterator);
+static void e_list_iterator_set (EIterator *iterator,
+ const void *object);
+static void e_list_iterator_delete (EIterator *iterator);
+static void e_list_iterator_insert (EIterator *iterator,
+ const void *object,
+ gboolean before);
+static gboolean e_list_iterator_prev (EIterator *iterator);
+static gboolean e_list_iterator_next (EIterator *iterator);
+static void e_list_iterator_reset (EIterator *iterator);
+static void e_list_iterator_last (EIterator *iterator);
+static const void *e_list_iterator_get (EIterator *iterator);
+static void e_list_iterator_destroy (GtkObject *object);
#define PARENT_TYPE (e_iterator_get_type ())
@@ -80,9 +84,11 @@ e_list_iterator_class_init (EListIteratorClass *klass)
iterator_class->invalidate = e_list_iterator_invalidate;
iterator_class->get = e_list_iterator_get;
iterator_class->reset = e_list_iterator_reset;
+ iterator_class->last = e_list_iterator_last;
iterator_class->next = e_list_iterator_next;
iterator_class->prev = e_list_iterator_prev;
iterator_class->delete = e_list_iterator_delete;
+ iterator_class->insert = e_list_iterator_insert;
iterator_class->set = e_list_iterator_set;
iterator_class->is_valid = e_list_iterator_is_valid;
}
@@ -137,6 +143,13 @@ e_list_iterator_reset (EIterator *_iterator)
iterator->iterator = iterator->list->list;
}
+static void
+e_list_iterator_last (EIterator *_iterator)
+{
+ EListIterator *iterator = E_LIST_ITERATOR(_iterator);
+ iterator->iterator = g_list_last(iterator->list->list);
+}
+
static gboolean
e_list_iterator_next (EIterator *_iterator)
{
@@ -156,6 +169,41 @@ e_list_iterator_prev (EIterator *_iterator)
}
static void
+e_list_iterator_insert (EIterator *_iterator,
+ const void *object,
+ gboolean before)
+{
+ EListIterator *iterator = E_LIST_ITERATOR(_iterator);
+ void *data;
+ if (iterator->list->copy)
+ data = iterator->list->copy(object, iterator->list->closure);
+ else
+ data = (void *) object;
+ if (iterator->iterator) {
+ if (before) {
+ iterator->list->list = g_list_first(g_list_prepend(iterator->iterator, data));
+ iterator->iterator = iterator->iterator->prev;
+ } else {
+ if (iterator->iterator->next)
+ g_list_prepend(iterator->iterator->next, data);
+ else
+ g_list_append(iterator->iterator, data);
+ iterator->iterator = iterator->iterator->next;
+ }
+ e_list_invalidate_iterators(iterator->list, E_ITERATOR(iterator));
+ } else {
+ if (before) {
+ iterator->list->list = g_list_append(iterator->list->list, data);
+ iterator->iterator = g_list_last(iterator->list->list);
+ } else {
+ iterator->list->list = g_list_prepend(iterator->list->list, data);
+ iterator->iterator = iterator->list->list;
+ }
+ e_list_invalidate_iterators(iterator->list, E_ITERATOR(iterator));
+ }
+}
+
+static void
e_list_iterator_delete (EIterator *_iterator)
{
EListIterator *iterator = E_LIST_ITERATOR(_iterator);
@@ -170,8 +218,8 @@ e_list_iterator_delete (EIterator *_iterator)
}
static void
-e_list_iterator_set (EIterator *_iterator,
- const void *object)
+e_list_iterator_set (EIterator *_iterator,
+ const void *object)
{
EListIterator *iterator = E_LIST_ITERATOR(_iterator);
if (iterator->iterator) {