aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
Diffstat (limited to 'e-util')
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-table-memory-callbacks.c234
-rw-r--r--e-util/e-table-memory-callbacks.h148
-rw-r--r--e-util/e-table-memory-store.h26
-rw-r--r--e-util/e-util.h1
5 files changed, 25 insertions, 386 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 3990c8858b..0ebbc8a17a 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -267,7 +267,6 @@ evolution_util_include_HEADERS = \
e-table-header-utils.h \
e-table-header.h \
e-table-item.h \
- e-table-memory-callbacks.h \
e-table-memory-store.h \
e-table-memory.h \
e-table-model.h \
@@ -511,7 +510,6 @@ libevolution_util_la_SOURCES = \
e-table-header-utils.c \
e-table-header.c \
e-table-item.c \
- e-table-memory-callbacks.c \
e-table-memory-store.c \
e-table-memory.c \
e-table-model.c \
diff --git a/e-util/e-table-memory-callbacks.c b/e-util/e-table-memory-callbacks.c
deleted file mode 100644
index a3f919b981..0000000000
--- a/e-util/e-table-memory-callbacks.c
+++ /dev/null
@@ -1,234 +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 "e-table-memory-callbacks.h"
-
-G_DEFINE_TYPE (ETableMemoryCallbacks, e_table_memory_callbacks, E_TYPE_TABLE_MEMORY)
-
-static gint
-etmc_column_count (ETableModel *etm)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->col_count)
- return etmc->col_count (etm, etmc->data);
- else
- return 0;
-}
-
-static gpointer
-etmc_value_at (ETableModel *etm,
- gint col,
- gint row)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->value_at)
- return etmc->value_at (etm, col, row, etmc->data);
- else
- return NULL;
-}
-
-static void
-etmc_set_value_at (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer val)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->set_value_at)
- etmc->set_value_at (etm, col, row, val, etmc->data);
-}
-
-static gboolean
-etmc_is_cell_editable (ETableModel *etm,
- gint col,
- gint row)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->is_cell_editable)
- return etmc->is_cell_editable (etm, col, row, etmc->data);
- else
- return FALSE;
-}
-
-/* The default for etmc_duplicate_value is to return the raw value. */
-static gpointer
-etmc_duplicate_value (ETableModel *etm,
- gint col,
- gconstpointer value)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->duplicate_value)
- return etmc->duplicate_value (etm, col, value, etmc->data);
- else
- return (gpointer) value;
-}
-
-static void
-etmc_free_value (ETableModel *etm,
- gint col,
- gpointer value)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->free_value)
- etmc->free_value (etm, col, value, etmc->data);
-}
-
-static gpointer
-etmc_initialize_value (ETableModel *etm,
- gint col)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->initialize_value)
- return etmc->initialize_value (etm, col, etmc->data);
- else
- return NULL;
-}
-
-static gboolean
-etmc_value_is_empty (ETableModel *etm,
- gint col,
- gconstpointer value)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->value_is_empty)
- return etmc->value_is_empty (etm, col, value, etmc->data);
- else
- return FALSE;
-}
-
-static gchar *
-etmc_value_to_string (ETableModel *etm,
- gint col,
- gconstpointer value)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->value_to_string)
- return etmc->value_to_string (etm, col, value, etmc->data);
- else
- return g_strdup ("");
-}
-
-static void
-etmc_append_row (ETableModel *etm,
- ETableModel *source,
- gint row)
-{
- ETableMemoryCallbacks *etmc = E_TABLE_MEMORY_CALLBACKS (etm);
-
- if (etmc->append_row)
- etmc->append_row (etm, source, row, etmc->data);
-}
-
-static void
-e_table_memory_callbacks_class_init (ETableMemoryCallbacksClass *class)
-{
- ETableModelClass *model_class = E_TABLE_MODEL_CLASS (class);
-
- model_class->column_count = etmc_column_count;
- model_class->value_at = etmc_value_at;
- model_class->set_value_at = etmc_set_value_at;
- model_class->is_cell_editable = etmc_is_cell_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;
- model_class->append_row = etmc_append_row;
-
-}
-
-static void
-e_table_memory_callbacks_init (ETableMemoryCallbacks *etmc)
-{
- /* nothing to do */
-}
-
-/**
- * e_table_memory_callbacks_new:
- * @col_count:
- * @value_at:
- * @set_value_at:
- * @is_cell_editable:
- * @duplicate_value:
- * @free_value:
- * @initialize_value:
- * @value_is_empty:
- * @value_to_string:
- * @data: closure pointer.
- *
- * This initializes a new ETableMemoryCallbacksModel object.
- * ETableMemoryCallbacksModel is an implementaiton of the abstract class
- * ETableModel. The ETableMemoryCallbacksModel is designed to allow people
- * to easily create ETableModels without having to create a new GType
- * derived from ETableModel every time they need one.
- *
- * Instead, ETableMemoryCallbacksModel uses a setup based in callback
- * functions, every callback function signature mimics the signature of
- * each ETableModel method and passes the extra @data pointer to each one
- * of the method to provide them with any context they might want to use.
- *
- * Returns: An ETableMemoryCallbacksModel object (which is also an ETableModel
- * object).
- */
-ETableModel *
-e_table_memory_callbacks_new (ETableMemoryCallbacksColumnCountFn col_count,
- ETableMemoryCallbacksValueAtFn value_at,
- ETableMemoryCallbacksSetValueAtFn set_value_at,
- ETableMemoryCallbacksIsCellEditableFn is_cell_editable,
- ETableMemoryCallbacksDuplicateValueFn duplicate_value,
- ETableMemoryCallbacksFreeValueFn free_value,
- ETableMemoryCallbacksInitializeValueFn initialize_value,
- ETableMemoryCallbacksValueIsEmptyFn value_is_empty,
- ETableMemoryCallbacksValueToStringFn value_to_string,
- gpointer data)
-{
- ETableMemoryCallbacks *et;
-
- et = g_object_new (E_TYPE_TABLE_MEMORY_CALLBACKS, NULL);
-
- et->col_count = col_count;
- et->value_at = value_at;
- et->set_value_at = set_value_at;
- et->is_cell_editable = is_cell_editable;
- et->duplicate_value = duplicate_value;
- et->free_value = free_value;
- et->initialize_value = initialize_value;
- et->value_is_empty = value_is_empty;
- et->value_to_string = value_to_string;
- et->data = data;
-
- return (ETableModel *) et;
- }
diff --git a/e-util/e-table-memory-callbacks.h b/e-util/e-table-memory-callbacks.h
deleted file mode 100644
index 08c346f604..0000000000
--- a/e-util/e-table-memory-callbacks.h
+++ /dev/null
@@ -1,148 +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_TABLE_MEMORY_CALLBACKS_H_
-#define _E_TABLE_MEMORY_CALLBACKS_H_
-
-#include <e-util/e-table-memory.h>
-
-/* Standard GObject macros */
-#define E_TYPE_TABLE_MEMORY_CALLBACKS \
- (e_table_memory_callbacks_get_type ())
-#define E_TABLE_MEMORY_CALLBACKS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_TABLE_MEMORY_CALLBACKS, ETableMemoryCallbacks))
-#define E_TABLE_MEMORY_CALLBACKS_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_TABLE_MEMORY_CALLBACKS, ETableMemoryCallbacksClass))
-#define E_IS_TABLE_MEMORY_CALLBACKS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_TABLE_MEMORY_CALLBACKS))
-#define E_IS_TABLE_MEMORY_CALLBACKS_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_TABLE_MEMORY_CALLBACKS))
-#define E_TABLE_MEMORY_CALLBACKS_GET_CLASS(cls) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((cls), E_TYPE_TABLE_MEMORY_CALLBACKS, ETableMemoryCallbacksClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ETableMemoryCallbacks ETableMemoryCallbacks;
-typedef struct _ETableMemoryCallbacksClass ETableMemoryCallbacksClass;
-
-typedef gint (*ETableMemoryCallbacksColumnCountFn)
- (ETableModel *etm,
- gpointer data);
-typedef void (*ETableMemoryCallbacksAppendRowFn)
- (ETableModel *etm,
- ETableModel *model,
- gint row,
- gpointer data);
-
-typedef gpointer (*ETableMemoryCallbacksValueAtFn)
- (ETableModel *etm,
- gint col,
- gint row,
- gpointer data);
-typedef void (*ETableMemoryCallbacksSetValueAtFn)
- (ETableModel *etm,
- gint col,
- gint row,
- gconstpointer val,
- gpointer data);
-typedef gboolean (*ETableMemoryCallbacksIsCellEditableFn)
- (ETableModel *etm,
- gint col,
- gint row,
- gpointer data);
-
-typedef gpointer (*ETableMemoryCallbacksDuplicateValueFn)
- (ETableModel *etm,
- gint col,
- gconstpointer val,
- gpointer data);
-typedef void (*ETableMemoryCallbacksFreeValueFn)
- (ETableModel *etm,
- gint col,
- gpointer val,
- gpointer data);
-typedef gpointer (*ETableMemoryCallbacksInitializeValueFn)
- (ETableModel *etm,
- gint col,
- gpointer data);
-typedef gboolean (*ETableMemoryCallbacksValueIsEmptyFn)
- (ETableModel *etm,
- gint col,
- gconstpointer val,
- gpointer data);
-typedef gchar * (*ETableMemoryCallbacksValueToStringFn)
- (ETableModel *etm,
- gint col,
- gconstpointer val,
- gpointer data);
-
-struct _ETableMemoryCallbacks {
- ETableMemory parent;
-
- ETableMemoryCallbacksColumnCountFn col_count;
- ETableMemoryCallbacksAppendRowFn append_row;
-
- ETableMemoryCallbacksValueAtFn value_at;
- ETableMemoryCallbacksSetValueAtFn set_value_at;
- ETableMemoryCallbacksIsCellEditableFn is_cell_editable;
-
- ETableMemoryCallbacksDuplicateValueFn duplicate_value;
- ETableMemoryCallbacksFreeValueFn free_value;
- ETableMemoryCallbacksInitializeValueFn initialize_value;
- ETableMemoryCallbacksValueIsEmptyFn value_is_empty;
- ETableMemoryCallbacksValueToStringFn value_to_string;
- gpointer data;
-};
-
-struct _ETableMemoryCallbacksClass {
- ETableMemoryClass parent_class;
-};
-
-GType e_table_memory_callbacks_get_type
- (void) G_GNUC_CONST;
-ETableModel * e_table_memory_callbacks_new
- (ETableMemoryCallbacksColumnCountFn col_count,
-
- ETableMemoryCallbacksValueAtFn value_at,
- ETableMemoryCallbacksSetValueAtFn set_value_at,
- ETableMemoryCallbacksIsCellEditableFn is_cell_editable,
-
- ETableMemoryCallbacksDuplicateValueFn duplicate_value,
- ETableMemoryCallbacksFreeValueFn free_value,
- ETableMemoryCallbacksInitializeValueFn initialize_value,
- ETableMemoryCallbacksValueIsEmptyFn value_is_empty,
- ETableMemoryCallbacksValueToStringFn value_to_string,
- gpointer data);
-
-G_END_DECLS
-
-#endif /* _E_TABLE_MEMORY_CALLBACKS_H_ */
-
diff --git a/e-util/e-table-memory-store.h b/e-util/e-table-memory-store.h
index 2af2b60360..1d3b995873 100644
--- a/e-util/e-table-memory-store.h
+++ b/e-util/e-table-memory-store.h
@@ -29,7 +29,6 @@
#define _E_TABLE_MEMORY_STORE_H_
#include <e-util/e-table-memory.h>
-#include <e-util/e-table-memory-callbacks.h>
/* Standard GObject macros */
#define E_TYPE_TABLE_MEMORY_STORE \
@@ -59,6 +58,31 @@ typedef enum {
E_TABLE_MEMORY_STORE_COLUMN_TYPE_PIXBUF
} ETableMemoryStoreColumnType;
+typedef gpointer (*ETableMemoryCallbacksDuplicateValueFn)
+ (ETableModel *etm,
+ gint col,
+ gconstpointer val,
+ gpointer data);
+typedef void (*ETableMemoryCallbacksFreeValueFn)
+ (ETableModel *etm,
+ gint col,
+ gpointer val,
+ gpointer data);
+typedef gpointer (*ETableMemoryCallbacksInitializeValueFn)
+ (ETableModel *etm,
+ gint col,
+ gpointer data);
+typedef gboolean (*ETableMemoryCallbacksValueIsEmptyFn)
+ (ETableModel *etm,
+ gint col,
+ gconstpointer val,
+ gpointer data);
+typedef gchar * (*ETableMemoryCallbacksValueToStringFn)
+ (ETableModel *etm,
+ gint col,
+ gconstpointer val,
+ gpointer data);
+
typedef struct {
ETableMemoryStoreColumnType type;
guint editable : 1;
diff --git a/e-util/e-util.h b/e-util/e-util.h
index c21add21dd..012c91d790 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -183,7 +183,6 @@
#include <e-util/e-table-header-utils.h>
#include <e-util/e-table-header.h>
#include <e-util/e-table-item.h>
-#include <e-util/e-table-memory-callbacks.h>
#include <e-util/e-table-memory-store.h>
#include <e-util/e-table-memory.h>
#include <e-util/e-table-model.h>