aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-16 02:25:16 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-16 08:10:06 +0800
commit69de51a15ab85e4dca9fed93a1e03644b0e6a840 (patch)
tree6249ab1f556b98b79a5ea6f7679e703428107dc4 /e-util
parentb58e9944529a890c5b9672cf6e5eb4f930112b63 (diff)
downloadgsoc2013-evolution-69de51a15ab85e4dca9fed93a1e03644b0e6a840.tar.gz
gsoc2013-evolution-69de51a15ab85e4dca9fed93a1e03644b0e6a840.tar.zst
gsoc2013-evolution-69de51a15ab85e4dca9fed93a1e03644b0e6a840.zip
Convert ETreeModel to an interface.
This commit does a number of things which I could not subdivide into smaller commits. * Converts ETreeModel to an interface, implemented by MessageList. * Drops ETreeMemory and ETreeMemoryCallbacks, which were ETreeModel subclasses. Their functionality is subsumed by MessageList. * MessageList drops its public ETreeModel pointer, since MessageList now implements ETreeModel as an interface. * Adds message_list_set_expanded_default(), which takes over for e_tree_memory_set_expanded_default().
Diffstat (limited to 'e-util')
-rw-r--r--e-util/Makefile.am4
-rw-r--r--e-util/e-tree-memory-callbacks.c314
-rw-r--r--e-util/e-tree-memory-callbacks.h182
-rw-r--r--e-util/e-tree-memory.c356
-rw-r--r--e-util/e-tree-memory.h93
-rw-r--r--e-util/e-tree-model.c286
-rw-r--r--e-util/e-tree-model.h33
-rw-r--r--e-util/e-util.h2
8 files changed, 130 insertions, 1140 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index e0e4bf05a1..3990c8858b 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -293,8 +293,6 @@ evolution_util_include_HEADERS = \
e-text-model.h \
e-text.h \
e-timezone-dialog.h \
- e-tree-memory-callbacks.h \
- e-tree-memory.h \
e-tree-model-generator.h \
e-tree-model.h \
e-tree-selection-model.h \
@@ -538,8 +536,6 @@ libevolution_util_la_SOURCES = \
e-text-model.c \
e-text.c \
e-timezone-dialog.c \
- e-tree-memory-callbacks.c \
- e-tree-memory.c \
e-tree-model-generator.c \
e-tree-model.c \
e-tree-selection-model.c \
diff --git a/e-util/e-tree-memory-callbacks.c b/e-util/e-tree-memory-callbacks.c
deleted file mode 100644
index 9d2fda6e3e..0000000000
--- a/e-util/e-tree-memory-callbacks.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include "e-tree-memory-callbacks.h"
-
-G_DEFINE_TYPE (ETreeMemoryCallbacks, e_tree_memory_callbacks, E_TYPE_TREE_MEMORY)
-
-static GdkPixbuf *
-etmc_icon_at (ETreeModel *etm,
- ETreePath node)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- return etmc->icon_at (etm, node, etmc->model_data);
-}
-
-static gint
-etmc_column_count (ETreeModel *etm)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->column_count)
- return etmc->column_count (etm, etmc->model_data);
- else
- return 0;
-}
-
-static gboolean
-etmc_has_save_id (ETreeModel *etm)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->has_save_id)
- return etmc->has_save_id (etm, etmc->model_data);
- else
- return FALSE;
-}
-
-static gchar *
-etmc_get_save_id (ETreeModel *etm,
- ETreePath node)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->get_save_id)
- return etmc->get_save_id (etm, node, etmc->model_data);
- else
- return NULL;
-}
-
-static gboolean
-etmc_has_get_node_by_id (ETreeModel *etm)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->has_get_node_by_id)
- return etmc->has_get_node_by_id (etm, etmc->model_data);
- else
- return FALSE;
-}
-
-static ETreePath
-etmc_get_node_by_id (ETreeModel *etm,
- const gchar *save_id)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->get_node_by_id)
- return etmc->get_node_by_id (etm, save_id, etmc->model_data);
- else
- return NULL;
-}
-
-static gpointer
-etmc_sort_value_at (ETreeModel *etm,
- ETreePath node,
- gint col)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->sort_value_at)
- return etmc->sort_value_at (etm, node, col, etmc->model_data);
- else
- return etmc->value_at (etm, node, col, etmc->model_data);
-}
-
-static gpointer
-etmc_value_at (ETreeModel *etm,
- ETreePath node,
- gint col)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- return etmc->value_at (etm, node, col, etmc->model_data);
-}
-
-static void
-etmc_set_value_at (ETreeModel *etm,
- ETreePath node,
- gint col,
- gconstpointer val)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- etmc->set_value_at (etm, node, col, val, etmc->model_data);
-}
-
-static gboolean
-etmc_is_editable (ETreeModel *etm,
- ETreePath node,
- gint col)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- return etmc->is_editable (etm, node, col, etmc->model_data);
-}
-
-/* The default for etmc_duplicate_value is to return the raw value. */
-static gpointer
-etmc_duplicate_value (ETreeModel *etm,
- gint col,
- gconstpointer value)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->duplicate_value)
- return etmc->duplicate_value (etm, col, value, etmc->model_data);
- else
- return (gpointer) value;
-}
-
-static void
-etmc_free_value (ETreeModel *etm,
- gint col,
- gpointer value)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->free_value)
- etmc->free_value (etm, col, value, etmc->model_data);
-}
-
-static gpointer
-etmc_initialize_value (ETreeModel *etm,
- gint col)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->initialize_value)
- return etmc->initialize_value (etm, col, etmc->model_data);
- else
- return NULL;
-}
-
-static gboolean
-etmc_value_is_empty (ETreeModel *etm,
- gint col,
- gconstpointer value)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->value_is_empty)
- return etmc->value_is_empty (etm, col, value, etmc->model_data);
- else
- return FALSE;
-}
-
-static gchar *
-etmc_value_to_string (ETreeModel *etm,
- gint col,
- gconstpointer value)
-{
- ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS (etm);
-
- if (etmc->value_to_string)
- return etmc->value_to_string (etm, col, value, etmc->model_data);
- else
- return g_strdup ("");
-}
-
-static void
-e_tree_memory_callbacks_class_init (ETreeMemoryCallbacksClass *class)
-{
- ETreeModelClass *model_class = E_TREE_MODEL_CLASS (class);
-
- model_class->icon_at = etmc_icon_at;
-
- model_class->column_count = etmc_column_count;
-
- model_class->has_save_id = etmc_has_save_id;
- model_class->get_save_id = etmc_get_save_id;
-
- model_class->has_get_node_by_id = etmc_has_get_node_by_id;
- model_class->get_node_by_id = etmc_get_node_by_id;
-
- model_class->sort_value_at = etmc_sort_value_at;
- model_class->value_at = etmc_value_at;
- model_class->set_value_at = etmc_set_value_at;
- model_class->is_editable = etmc_is_editable;
-
- model_class->duplicate_value = etmc_duplicate_value;
- model_class->free_value = etmc_free_value;
- model_class->initialize_value = etmc_initialize_value;
- model_class->value_is_empty = etmc_value_is_empty;
- model_class->value_to_string = etmc_value_to_string;
-}
-
-static void
-e_tree_memory_callbacks_init (ETreeMemoryCallbacks *etmc)
-{
- /* nothing to do */
-}
-
-/**
- * e_tree_memory_callbacks_new:
- *
- * This initializes a new ETreeMemoryCallbacksModel object.
- * ETreeMemoryCallbacksModel is an implementaiton of the somewhat
- * abstract class ETreeMemory. The ETreeMemoryCallbacksModel is
- * designed to allow people to easily create ETreeMemorys without
- * having to create a new GType derived from ETreeMemory every time
- * they need one.
- *
- * Instead, ETreeMemoryCallbacksModel uses a setup based in callback functions, every
- * callback function signature mimics the signature of each ETreeModel method
- * and passes the extra @data pointer to each one of the method to provide them
- * with any context they might want to use.
- *
- * ETreeMemoryCallbacks is to ETreeMemory as ETableSimple is to ETableModel.
- *
- * Return value: An ETreeMemoryCallbacks object (which is also an
- * ETreeMemory and thus an ETreeModel object).
- *
- */
-ETreeModel *
-e_tree_memory_callbacks_new (ETreeMemoryCallbacksIconAtFn icon_at,
-
- ETreeMemoryCallbacksColumnCountFn column_count,
-
- ETreeMemoryCallbacksHasSaveIdFn has_save_id,
- ETreeMemoryCallbacksGetSaveIdFn get_save_id,
-
- ETreeMemoryCallbacksHasGetNodeByIdFn has_get_node_by_id,
- ETreeMemoryCallbacksGetNodeByIdFn get_node_by_id,
-
- ETreeMemoryCallbacksValueAtFn sort_value_at,
- ETreeMemoryCallbacksValueAtFn value_at,
- ETreeMemoryCallbacksSetValueAtFn set_value_at,
- ETreeMemoryCallbacksIsEditableFn is_editable,
-
- ETreeMemoryCallbacksDuplicateValueFn duplicate_value,
- ETreeMemoryCallbacksFreeValueFn free_value,
- ETreeMemoryCallbacksInitializeValueFn initialize_value,
- ETreeMemoryCallbacksValueIsEmptyFn value_is_empty,
- ETreeMemoryCallbacksValueToStringFn value_to_string,
-
- gpointer model_data)
-{
- ETreeMemoryCallbacks *etmc;
-
- etmc = g_object_new (E_TYPE_TREE_MEMORY_CALLBACKS, NULL);
-
- etmc->icon_at = icon_at;
-
- etmc->column_count = column_count;
-
- etmc->has_save_id = has_save_id;
- etmc->get_save_id = get_save_id;
-
- etmc->has_get_node_by_id = has_get_node_by_id;
- etmc->get_node_by_id = get_node_by_id;
-
- etmc->sort_value_at = sort_value_at;
- etmc->value_at = value_at;
- etmc->set_value_at = set_value_at;
- etmc->is_editable = is_editable;
-
- etmc->duplicate_value = duplicate_value;
- etmc->free_value = free_value;
- etmc->initialize_value = initialize_value;
- etmc->value_is_empty = value_is_empty;
- etmc->value_to_string = value_to_string;
-
- etmc->model_data = model_data;
-
- return (ETreeModel *) etmc;
-}
-
diff --git a/e-util/e-tree-memory-callbacks.h b/e-util/e-tree-memory-callbacks.h
deleted file mode 100644
index df47e9a491..0000000000
--- a/e-util/e-tree-memory-callbacks.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
-#error "Only <e-util/e-util.h> should be included directly."
-#endif
-
-#ifndef _E_TREE_MEMORY_CALLBACKS_H_
-#define _E_TREE_MEMORY_CALLBACKS_H_
-
-#include <e-util/e-tree-memory.h>
-
-/* Standard GObject macros */
-#define E_TYPE_TREE_MEMORY_CALLBACKS \
- (e_tree_memory_callbacks_get_type ())
-#define E_TREE_MEMORY_CALLBACKS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_TREE_MEMORY_CALLBACKS, ETreeMemoryCallbacks))
-#define E_TREE_MEMORY_CALLBACKS_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_TREE_MEMORY_CALLBACKS, ETreeMemoryCallbacksClass))
-#define E_IS_TREE_MEMORY_CALLBACKS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_TREE_MEMORY_CALLBACKS))
-#define E_IS_TREE_MEMORY_CALLBACKS_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_TREE_MEMORY_CALLBACKS))
-#define E_TREE_MEMORY_CALLBACKS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_TREE_MEMORY_CALLBACKS, ETreeMemoryCallbacksClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ETreeMemoryCallbacks ETreeMemoryCallbacks;
-typedef struct _ETreeMemoryCallbacksClass ETreeMemoryCallbacksClass;
-
-typedef GdkPixbuf * (*ETreeMemoryCallbacksIconAtFn)
- (ETreeModel *etree,
- ETreePath path,
- gpointer model_data);
-
-typedef gint (*ETreeMemoryCallbacksColumnCountFn)
- (ETreeModel *etree,
- gpointer model_data);
-
-typedef gboolean (*ETreeMemoryCallbacksHasSaveIdFn)
- (ETreeModel *etree,
- gpointer model_data);
-typedef gchar * (*ETreeMemoryCallbacksGetSaveIdFn)
- (ETreeModel *etree,
- ETreePath path,
- gpointer model_data);
-
-typedef gboolean (*ETreeMemoryCallbacksHasGetNodeByIdFn)
- (ETreeModel *etree,
- gpointer model_data);
-typedef ETreePath (*ETreeMemoryCallbacksGetNodeByIdFn)
- (ETreeModel *etree,
- const gchar *save_id,
- gpointer model_data);
-
-typedef gpointer (*ETreeMemoryCallbacksValueAtFn)
- (ETreeModel *etree,
- ETreePath path,
- gint col,
- gpointer model_data);
-typedef void (*ETreeMemoryCallbacksSetValueAtFn)
- (ETreeModel *etree,
- ETreePath path,
- gint col,
- gconstpointer val,
- gpointer model_data);
-typedef gboolean (*ETreeMemoryCallbacksIsEditableFn)
- (ETreeModel *etree,
- ETreePath path,
- gint col,
- gpointer model_data);
-
-typedef gpointer (*ETreeMemoryCallbacksDuplicateValueFn)
- (ETreeModel *etm,
- gint col,
- gconstpointer val,
- gpointer data);
-typedef void (*ETreeMemoryCallbacksFreeValueFn)
- (ETreeModel *etm,
- gint col,
- gpointer val,
- gpointer data);
-typedef gpointer (*ETreeMemoryCallbacksInitializeValueFn)
- (ETreeModel *etm,
- gint col,
- gpointer data);
-typedef gboolean (*ETreeMemoryCallbacksValueIsEmptyFn)
- (ETreeModel *etm,
- gint col,
- gconstpointer val,
- gpointer data);
-typedef gchar * (*ETreeMemoryCallbacksValueToStringFn)
- (ETreeModel *etm,
- gint col,
- gconstpointer val,
- gpointer data);
-
-struct _ETreeMemoryCallbacks {
- ETreeMemory parent;
-
- ETreeMemoryCallbacksIconAtFn icon_at;
-
- ETreeMemoryCallbacksColumnCountFn column_count;
-
- ETreeMemoryCallbacksHasSaveIdFn has_save_id;
- ETreeMemoryCallbacksGetSaveIdFn get_save_id;
-
- ETreeMemoryCallbacksHasGetNodeByIdFn has_get_node_by_id;
- ETreeMemoryCallbacksGetNodeByIdFn get_node_by_id;
-
- ETreeMemoryCallbacksValueAtFn sort_value_at;
- ETreeMemoryCallbacksValueAtFn value_at;
- ETreeMemoryCallbacksSetValueAtFn set_value_at;
- ETreeMemoryCallbacksIsEditableFn is_editable;
-
- ETreeMemoryCallbacksDuplicateValueFn duplicate_value;
- ETreeMemoryCallbacksFreeValueFn free_value;
- ETreeMemoryCallbacksInitializeValueFn initialize_value;
- ETreeMemoryCallbacksValueIsEmptyFn value_is_empty;
- ETreeMemoryCallbacksValueToStringFn value_to_string;
-
- gpointer model_data;
-};
-
-struct _ETreeMemoryCallbacksClass {
- ETreeMemoryClass parent_class;
-};
-
-GType e_tree_memory_callbacks_get_type
- (void) G_GNUC_CONST;
-ETreeModel * e_tree_memory_callbacks_new
- (ETreeMemoryCallbacksIconAtFn icon_at,
-
- ETreeMemoryCallbacksColumnCountFn column_count,
-
- ETreeMemoryCallbacksHasSaveIdFn has_save_id,
- ETreeMemoryCallbacksGetSaveIdFn get_save_id,
-
- ETreeMemoryCallbacksHasGetNodeByIdFn has_get_node_by_id,
- ETreeMemoryCallbacksGetNodeByIdFn get_node_by_id,
-
- ETreeMemoryCallbacksValueAtFn sort_value_at,
- ETreeMemoryCallbacksValueAtFn value_at,
- ETreeMemoryCallbacksSetValueAtFn set_value_at,
- ETreeMemoryCallbacksIsEditableFn is_editable,
-
- ETreeMemoryCallbacksDuplicateValueFn duplicate_value,
- ETreeMemoryCallbacksFreeValueFn free_value,
- ETreeMemoryCallbacksInitializeValueFn initialize_value,
- ETreeMemoryCallbacksValueIsEmptyFn value_is_empty,
- ETreeMemoryCallbacksValueToStringFn value_to_string,
-
- gpointer model_data);
-
-G_END_DECLS
-
-#endif /* _E_TREE_MEMORY_CALLBACKS_H_ */
diff --git a/e-util/e-tree-memory.c b/e-util/e-tree-memory.c
deleted file mode 100644
index 743aab010d..0000000000
--- a/e-util/e-tree-memory.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-tree-memory.h"
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-#include <libxml/parser.h>
-#include <libxml/xmlmemory.h>
-
-#include "e-xml-utils.h"
-
-#define E_TREE_MEMORY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_TREE_MEMORY, ETreeMemoryPrivate))
-
-G_DEFINE_TYPE (ETreeMemory, e_tree_memory, E_TYPE_TREE_MODEL)
-
-struct _ETreeMemoryPrivate {
- GNode *root;
-
- /* whether nodes are created expanded
- * or collapsed by default */
- gboolean expanded_default;
-
- gint frozen;
-};
-
-static void
-tree_memory_finalize (GObject *object)
-{
- ETreeMemoryPrivate *priv;
-
- priv = E_TREE_MEMORY_GET_PRIVATE (object);
-
- if (priv->root != NULL)
- g_node_destroy (priv->root);
-
- G_OBJECT_CLASS (e_tree_memory_parent_class)->finalize (object);
-}
-
-static ETreePath
-tree_memory_get_root (ETreeModel *etm)
-{
- ETreeMemory *tree_memory = E_TREE_MEMORY (etm);
-
- return tree_memory->priv->root;
-}
-
-static ETreePath
-tree_memory_get_parent (ETreeModel *etm,
- ETreePath path)
-{
- return ((GNode *) path)->parent;
-}
-
-static ETreePath
-tree_memory_get_first_child (ETreeModel *etm,
- ETreePath path)
-{
- return g_node_first_child ((GNode *) path);
-}
-
-static ETreePath
-tree_memory_get_next (ETreeModel *etm,
- ETreePath path)
-{
- return g_node_next_sibling ((GNode *) path);
-}
-
-static gboolean
-tree_memory_is_root (ETreeModel *etm,
- ETreePath path)
-{
- return G_NODE_IS_ROOT ((GNode *) path);
-}
-
-static gboolean
-tree_memory_is_expandable (ETreeModel *etm,
- ETreePath path)
-{
- return (g_node_first_child ((GNode *) path) != NULL);
-}
-
-static guint
-tree_memory_get_n_children (ETreeModel *etm,
- ETreePath path)
-{
- return g_node_n_children ((GNode *) path);
-}
-
-static guint
-tree_memory_depth (ETreeModel *etm,
- ETreePath path)
-{
- return g_node_depth ((GNode *) path);
-}
-
-static gboolean
-tree_memory_get_expanded_default (ETreeModel *etm)
-{
- ETreeMemory *tree_memory = E_TREE_MEMORY (etm);
-
- return tree_memory->priv->expanded_default;
-}
-
-static void
-e_tree_memory_class_init (ETreeMemoryClass *class)
-{
- GObjectClass *object_class;
- ETreeModelClass *tree_model_class;
-
- g_type_class_add_private (class, sizeof (ETreeMemoryPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = tree_memory_finalize;
-
- tree_model_class = E_TREE_MODEL_CLASS (class);
- tree_model_class->get_root = tree_memory_get_root;
- tree_model_class->get_next = tree_memory_get_next;
- tree_model_class->get_first_child = tree_memory_get_first_child;
- tree_model_class->get_parent = tree_memory_get_parent;
-
- tree_model_class->is_root = tree_memory_is_root;
- tree_model_class->is_expandable = tree_memory_is_expandable;
- tree_model_class->get_n_children = tree_memory_get_n_children;
- tree_model_class->depth = tree_memory_depth;
- tree_model_class->get_expanded_default = tree_memory_get_expanded_default;
-}
-
-static void
-e_tree_memory_init (ETreeMemory *tree_memory)
-{
- tree_memory->priv = E_TREE_MEMORY_GET_PRIVATE (tree_memory);
-}
-
-/**
- * e_tree_memory_node_insert:
- * @tree_memory:
- * @parent_node:
- * @position:
- * @data:
- *
- *
- *
- * Returns:
- **/
-ETreePath
-e_tree_memory_node_insert (ETreeMemory *tree_memory,
- ETreePath parent_node,
- gint position,
- gpointer data)
-{
- GNode *new_path;
- GNode *parent_path = parent_node;
-
- g_return_val_if_fail (E_IS_TREE_MEMORY (tree_memory), NULL);
-
- if (parent_path == NULL)
- g_return_val_if_fail (tree_memory->priv->root == NULL, NULL);
-
- if (!tree_memory->priv->frozen)
- e_tree_model_pre_change (E_TREE_MODEL (tree_memory));
-
- new_path = g_node_new (data);
-
- if (parent_path != NULL) {
- g_node_insert (parent_path, position, new_path);
- if (!tree_memory->priv->frozen)
- e_tree_model_node_inserted (
- E_TREE_MODEL (tree_memory),
- parent_path, new_path);
- } else {
- tree_memory->priv->root = new_path;
- if (!tree_memory->priv->frozen)
- e_tree_model_node_changed (
- E_TREE_MODEL (tree_memory), new_path);
- }
-
- return new_path;
-}
-
-/**
- * e_tree_memory_node_remove:
- * @tree_memory:
- * @node:
- *
- *
- *
- * Returns:
- **/
-gpointer
-e_tree_memory_node_remove (ETreeMemory *tree_memory,
- ETreePath node)
-{
- GNode *path = node;
- GNode *parent = path->parent;
- GNode *sibling;
- gpointer ret = path->data;
- gint old_position = 0;
-
- g_return_val_if_fail (E_IS_TREE_MEMORY (tree_memory), NULL);
-
- if (!tree_memory->priv->frozen) {
- e_tree_model_pre_change (E_TREE_MODEL (tree_memory));
- for (old_position = 0, sibling = path;
- sibling;
- old_position++, sibling = sibling->prev)
- /* Empty intentionally*/;
- old_position--;
- }
-
- /* unlink this node - we only have to unlink the root node being
- * removed, since the others are only references from this node */
- g_node_unlink (path);
-
- /*printf("removing %d nodes from position %d\n", visible, base);*/
- if (!tree_memory->priv->frozen)
- e_tree_model_node_removed (
- E_TREE_MODEL (tree_memory),
- parent, path, old_position);
-
- g_node_destroy (path);
-
- if (path == tree_memory->priv->root)
- tree_memory->priv->root = NULL;
-
- if (!tree_memory->priv->frozen)
- e_tree_model_node_deleted (E_TREE_MODEL (tree_memory), path);
-
- return ret;
-}
-
-/**
- * e_tree_memory_freeze:
- * @tree_memory: the ETreeModel to freeze.
- *
- * This function prepares an ETreeModel for a period of much change.
- * All signals regarding changes to the tree are deferred until we
- * thaw the tree.
- *
- **/
-void
-e_tree_memory_freeze (ETreeMemory *tree_memory)
-{
- g_return_if_fail (E_IS_TREE_MEMORY (tree_memory));
-
- if (tree_memory->priv->frozen == 0)
- e_tree_model_pre_change (E_TREE_MODEL (tree_memory));
-
- tree_memory->priv->frozen++;
-}
-
-/**
- * e_tree_memory_thaw:
- * @tree_memory: the ETreeMemory to thaw.
- *
- * This function thaws an ETreeMemory. All the defered signals can add
- * up to a lot, we don't know - so we just emit a model_changed
- * signal.
- *
- **/
-void
-e_tree_memory_thaw (ETreeMemory *tree_memory)
-{
- g_return_if_fail (E_IS_TREE_MEMORY (tree_memory));
-
- if (tree_memory->priv->frozen > 0)
- tree_memory->priv->frozen--;
-
- if (tree_memory->priv->frozen == 0)
- e_tree_model_node_changed (
- E_TREE_MODEL (tree_memory),
- tree_memory->priv->root);
-}
-
-/**
- * e_tree_memory_set_expanded_default
- *
- * Sets the state of nodes to be append to a thread.
- * They will either be expanded or collapsed, according to
- * the value of @expanded.
- */
-void
-e_tree_memory_set_expanded_default (ETreeMemory *tree_memory,
- gboolean expanded)
-{
- g_return_if_fail (E_IS_TREE_MEMORY (tree_memory));
-
- tree_memory->priv->expanded_default = expanded;
-}
-
-/**
- * e_tree_memory_node_get_data:
- * @tree_memory:
- * @path:
- *
- *
- *
- * Return value:
- **/
-gpointer
-e_tree_memory_node_get_data (ETreeMemory *tree_memory,
- ETreePath path)
-{
- g_return_val_if_fail (path != NULL, NULL);
-
- return ((GNode *) path)->data;
-}
-
-/**
- * e_tree_memory_node_set_data:
- * @tree_memory:
- * @path:
- * @data:
- *
- *
- **/
-void
-e_tree_memory_node_set_data (ETreeMemory *tree_memory,
- ETreePath path,
- gpointer data)
-{
- g_return_if_fail (path != NULL);
-
- ((GNode *) path)->data = data;
-}
-
diff --git a/e-util/e-tree-memory.h b/e-util/e-tree-memory.h
deleted file mode 100644
index f7a386ecf6..0000000000
--- a/e-util/e-tree-memory.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
-#error "Only <e-util/e-util.h> should be included directly."
-#endif
-
-#ifndef E_TREE_MEMORY_H
-#define E_TREE_MEMORY_H
-
-#include <e-util/e-tree-model.h>
-
-/* Standard GObject macros */
-#define E_TYPE_TREE_MEMORY \
- (e_tree_memory_get_type ())
-#define E_TREE_MEMORY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_TREE_MEMORY, ETreeMemory))
-#define E_TREE_MEMORY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_TREE_MEMORY, ETreeMemoryClass))
-#define E_IS_TREE_MEMORY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_TREE_MEMORY))
-#define E_IS_TREE_MEMORY_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_TREE_MEMORY))
-#define E_TREE_MEMORY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_TREE_MEMORY, ETreeMemoryClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ETreeMemory ETreeMemory;
-typedef struct _ETreeMemoryClass ETreeMemoryClass;
-typedef struct _ETreeMemoryPrivate ETreeMemoryPrivate;
-
-struct _ETreeMemory {
- ETreeModel parent;
- ETreeMemoryPrivate *priv;
-};
-
-struct _ETreeMemoryClass {
- ETreeModelClass parent_class;
-};
-
-GType e_tree_memory_get_type (void) G_GNUC_CONST;
-
-/* node operations */
-ETreePath e_tree_memory_node_insert (ETreeMemory *tree_memory,
- ETreePath parent_node,
- gint position,
- gpointer data);
-gpointer e_tree_memory_node_remove (ETreeMemory *tree_memory,
- ETreePath node);
-
-/* Freeze and thaw */
-void e_tree_memory_freeze (ETreeMemory *tree_memory);
-void e_tree_memory_thaw (ETreeMemory *tree_memory);
-void e_tree_memory_set_expanded_default
- (ETreeMemory *tree_memory,
- gboolean expanded);
-gpointer e_tree_memory_node_get_data (ETreeMemory *tree_memory,
- ETreePath path);
-void e_tree_memory_node_set_data (ETreeMemory *tree_memory,
- ETreePath path,
- gpointer data);
-
-G_END_DECLS
-
-#endif /* E_TREE_MEMORY_H */
-
diff --git a/e-util/e-tree-model.c b/e-util/e-tree-model.c
index d469d23da4..f9bf28a3a2 100644
--- a/e-util/e-tree-model.c
+++ b/e-util/e-tree-model.c
@@ -1,4 +1,6 @@
/*
+ * e-tree-model.c
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -12,37 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "e-tree-model.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <gtk/gtk.h>
-#include <libxml/parser.h>
-#include <libxml/xmlmemory.h>
-
-#include "e-marshal.h"
-#include "e-xml-utils.h"
-
-#define d(x)
-
-G_DEFINE_TYPE (ETreeModel, e_tree_model, G_TYPE_OBJECT)
-
enum {
PRE_CHANGE,
NODE_CHANGED,
@@ -54,69 +29,63 @@ enum {
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = {0, };
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_INTERFACE (ETreeModel, e_tree_model, G_TYPE_OBJECT)
static void
-e_tree_model_class_init (ETreeModelClass *class)
+e_tree_model_default_init (ETreeModelInterface *interface)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
signals[PRE_CHANGE] = g_signal_new (
"pre_change",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, pre_change),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ G_STRUCT_OFFSET (ETreeModelInterface, pre_change),
+ NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[REBUILT] = g_signal_new (
"rebuilt",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, rebuilt),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ G_STRUCT_OFFSET (ETreeModelInterface, rebuilt),
+ NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[NODE_CHANGED] = g_signal_new (
"node_changed",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, node_changed),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ G_STRUCT_OFFSET (ETreeModelInterface, node_changed),
+ NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[NODE_DATA_CHANGED] = g_signal_new (
"node_data_changed",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, node_data_changed),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ G_STRUCT_OFFSET (ETreeModelInterface, node_data_changed),
+ NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[NODE_INSERTED] = g_signal_new (
"node_inserted",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, node_inserted),
- (GSignalAccumulator) NULL, NULL,
- e_marshal_VOID__POINTER_POINTER,
+ G_STRUCT_OFFSET (ETreeModelInterface, node_inserted),
+ NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
signals[NODE_REMOVED] = g_signal_new (
"node_removed",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, node_removed),
- (GSignalAccumulator) NULL, NULL,
- e_marshal_VOID__POINTER_POINTER_INT,
+ G_STRUCT_OFFSET (ETreeModelInterface, node_removed),
+ NULL, NULL, NULL,
G_TYPE_NONE, 3,
G_TYPE_POINTER,
G_TYPE_POINTER,
@@ -124,23 +93,14 @@ e_tree_model_class_init (ETreeModelClass *class)
signals[NODE_DELETED] = g_signal_new (
"node_deleted",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ETreeModelClass, node_deleted),
- (GSignalAccumulator) NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ G_STRUCT_OFFSET (ETreeModelInterface, node_deleted),
+ NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
}
-static void
-e_tree_model_init (ETreeModel *tree_model)
-{
- /* nothing to do */
-}
-
-/* signals */
-
/**
* e_tree_model_pre_change:
* @tree_model:
@@ -272,14 +232,14 @@ e_tree_model_node_deleted (ETreeModel *tree_model,
ETreePath
e_tree_model_get_root (ETreeModel *tree_model)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_root != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_root != NULL, NULL);
- return class->get_root (tree_model);
+ return interface->get_root (tree_model);
}
/**
@@ -295,14 +255,14 @@ ETreePath
e_tree_model_node_get_parent (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_parent != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_parent != NULL, NULL);
- return class->get_parent (tree_model, path);
+ return interface->get_parent (tree_model, path);
}
/**
@@ -318,14 +278,14 @@ ETreePath
e_tree_model_node_get_first_child (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_first_child != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_first_child != NULL, NULL);
- return class->get_first_child (tree_model, path);
+ return interface->get_first_child (tree_model, path);
}
/**
@@ -341,14 +301,14 @@ ETreePath
e_tree_model_node_get_next (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_next != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_next != NULL, NULL);
- return class->get_next (tree_model, path);
+ return interface->get_next (tree_model, path);
}
/**
@@ -364,14 +324,14 @@ gboolean
e_tree_model_node_is_root (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), FALSE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->is_root != NULL, FALSE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->is_root != NULL, FALSE);
- return class->is_root (tree_model, path);
+ return interface->is_root (tree_model, path);
}
/**
@@ -387,29 +347,29 @@ gboolean
e_tree_model_node_is_expandable (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->is_expandable != NULL, FALSE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->is_expandable != NULL, FALSE);
- return class->is_expandable (tree_model, path);
+ return interface->is_expandable (tree_model, path);
}
guint
e_tree_model_node_get_n_children (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), 0);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_n_children != NULL, 0);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_n_children != NULL, 0);
- return class->get_n_children (tree_model, path);
+ return interface->get_n_children (tree_model, path);
}
/**
@@ -425,14 +385,14 @@ guint
e_tree_model_node_depth (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), 0);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->depth != NULL, 0);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->depth != NULL, 0);
- return class->depth (tree_model, path);
+ return interface->depth (tree_model, path);
}
/**
@@ -448,14 +408,14 @@ GdkPixbuf *
e_tree_model_icon_at (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->icon_at != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->icon_at != NULL, NULL);
- return class->icon_at (tree_model, path);
+ return interface->icon_at (tree_model, path);
}
/**
@@ -469,14 +429,14 @@ e_tree_model_icon_at (ETreeModel *tree_model,
gboolean
e_tree_model_get_expanded_default (ETreeModel *tree_model)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), FALSE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_expanded_default != NULL, FALSE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_expanded_default != NULL, FALSE);
- return class->get_expanded_default (tree_model);
+ return interface->get_expanded_default (tree_model);
}
/**
@@ -490,14 +450,14 @@ e_tree_model_get_expanded_default (ETreeModel *tree_model)
gint
e_tree_model_column_count (ETreeModel *tree_model)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), 0);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->column_count != NULL, 0);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->column_count != NULL, 0);
- return class->column_count (tree_model);
+ return interface->column_count (tree_model);
}
/**
@@ -511,14 +471,14 @@ e_tree_model_column_count (ETreeModel *tree_model)
gboolean
e_tree_model_has_save_id (ETreeModel *tree_model)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), FALSE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->has_save_id != NULL, FALSE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->has_save_id != NULL, FALSE);
- return class->has_save_id (tree_model);
+ return interface->has_save_id (tree_model);
}
/**
@@ -534,14 +494,14 @@ gchar *
e_tree_model_get_save_id (ETreeModel *tree_model,
ETreePath path)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_save_id != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_save_id != NULL, NULL);
- return class->get_save_id (tree_model, path);
+ return interface->get_save_id (tree_model, path);
}
/**
@@ -555,14 +515,14 @@ e_tree_model_get_save_id (ETreeModel *tree_model,
gboolean
e_tree_model_has_get_node_by_id (ETreeModel *tree_model)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), FALSE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->has_get_node_by_id != NULL, FALSE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->has_get_node_by_id != NULL, FALSE);
- return class->has_get_node_by_id (tree_model);
+ return interface->has_get_node_by_id (tree_model);
}
/**
@@ -581,14 +541,14 @@ ETreePath
e_tree_model_get_node_by_id (ETreeModel *tree_model,
const gchar *save_id)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->get_node_by_id != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->get_node_by_id != NULL, NULL);
- return class->get_node_by_id (tree_model, save_id);
+ return interface->get_node_by_id (tree_model, save_id);
}
/**
@@ -616,14 +576,14 @@ e_tree_model_sort_value_at (ETreeModel *tree_model,
ETreePath path,
gint col)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->sort_value_at != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->sort_value_at != NULL, NULL);
- return class->sort_value_at (tree_model, path, col);
+ return interface->sort_value_at (tree_model, path, col);
}
/**
@@ -650,14 +610,14 @@ e_tree_model_value_at (ETreeModel *tree_model,
ETreePath path,
gint col)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->value_at != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->value_at != NULL, NULL);
- return class->value_at (tree_model, path, col);
+ return interface->value_at (tree_model, path, col);
}
void
@@ -666,14 +626,14 @@ e_tree_model_set_value_at (ETreeModel *tree_model,
gint col,
gconstpointer val)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_if_fail (E_IS_TREE_MODEL (tree_model));
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_if_fail (class->set_value_at != NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_if_fail (interface->set_value_at != NULL);
- class->set_value_at (tree_model, path, col, val);
+ interface->set_value_at (tree_model, path, col, val);
}
/**
@@ -690,14 +650,14 @@ e_tree_model_node_is_editable (ETreeModel *tree_model,
ETreePath path,
gint col)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), FALSE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->is_editable != NULL, FALSE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->is_editable != NULL, FALSE);
- return class->is_editable (tree_model, path, col);
+ return interface->is_editable (tree_model, path, col);
}
/**
@@ -714,14 +674,14 @@ e_tree_model_duplicate_value (ETreeModel *tree_model,
gint col,
gconstpointer value)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->duplicate_value != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->duplicate_value != NULL, NULL);
- return class->duplicate_value (tree_model, col, value);
+ return interface->duplicate_value (tree_model, col, value);
}
/**
@@ -738,14 +698,14 @@ e_tree_model_free_value (ETreeModel *tree_model,
gint col,
gpointer value)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_if_fail (E_IS_TREE_MODEL (tree_model));
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_if_fail (class->free_value != NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_if_fail (interface->free_value != NULL);
- class->free_value (tree_model, col, value);
+ interface->free_value (tree_model, col, value);
}
/**
@@ -761,14 +721,14 @@ gpointer
e_tree_model_initialize_value (ETreeModel *tree_model,
gint col)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->initialize_value != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->initialize_value != NULL, NULL);
- return class->initialize_value (tree_model, col);
+ return interface->initialize_value (tree_model, col);
}
/**
@@ -785,14 +745,14 @@ e_tree_model_value_is_empty (ETreeModel *tree_model,
gint col,
gconstpointer value)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), TRUE);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->value_is_empty != NULL, TRUE);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->value_is_empty != NULL, TRUE);
- return class->value_is_empty (tree_model, col, value);
+ return interface->value_is_empty (tree_model, col, value);
}
/**
@@ -809,14 +769,14 @@ e_tree_model_value_to_string (ETreeModel *tree_model,
gint col,
gconstpointer value)
{
- ETreeModelClass *class;
+ ETreeModelInterface *interface;
g_return_val_if_fail (E_IS_TREE_MODEL (tree_model), NULL);
- class = E_TREE_MODEL_GET_CLASS (tree_model);
- g_return_val_if_fail (class->value_to_string != NULL, NULL);
+ interface = E_TREE_MODEL_GET_INTERFACE (tree_model);
+ g_return_val_if_fail (interface->value_to_string != NULL, NULL);
- return class->value_to_string (tree_model, col, value);
+ return interface->value_to_string (tree_model, col, value);
}
/**
diff --git a/e-util/e-tree-model.h b/e-util/e-tree-model.h
index 431f93e2a2..bdbf64ce1b 100644
--- a/e-util/e-tree-model.h
+++ b/e-util/e-tree-model.h
@@ -1,4 +1,5 @@
/*
+ * e-tree-model.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,13 +14,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- * Chris Toshok <toshok@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
@@ -37,40 +31,27 @@
#define E_TREE_MODEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), E_TYPE_TREE_MODEL, ETreeModel))
-#define E_TREE_MODEL_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_TREE_MODEL, ETreeModelClass))
#define E_IS_TREE_MODEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_TREE_MODEL))
-#define E_IS_TREE_MODEL_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_TREE_MODEL))
-#define E_TREE_MODEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_TREE_MODEL, ETreeModelClass))
+#define E_TREE_MODEL_GET_INTERFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE \
+ ((obj), E_TYPE_TREE_MODEL, ETreeModelInterface))
G_BEGIN_DECLS
typedef gpointer ETreePath;
typedef struct _ETreeModel ETreeModel;
-typedef struct _ETreeModelClass ETreeModelClass;
+typedef struct _ETreeModelInterface ETreeModelInterface;
typedef gboolean (*ETreePathFunc) (ETreeModel *tree_model,
ETreePath path,
gpointer data);
-struct _ETreeModel {
- GObject parent;
-};
+struct _ETreeModelInterface {
+ GTypeInterface parent_class;
-struct _ETreeModelClass {
- GObjectClass parent_class;
-
- /*
- * Virtual methods
- */
ETreePath (*get_root) (ETreeModel *tree_model);
ETreePath (*get_parent) (ETreeModel *tree_model,
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 40a0e14da3..c21add21dd 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -209,8 +209,6 @@
#include <e-util/e-text-model.h>
#include <e-util/e-text.h>
#include <e-util/e-timezone-dialog.h>
-#include <e-util/e-tree-memory-callbacks.h>
-#include <e-util/e-tree-memory.h>
#include <e-util/e-tree-model-generator.h>
#include <e-util/e-tree-model.h>
#include <e-util/e-tree-selection-model.h>