Files
evolution/widgets/table/e-table-one.c
Christopher James Lahey e4de45da5f Calculate height including if clip_height is set to -1.
2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* widgets/e-text/e-text.c: Calculate height including if
	clip_height is set to -1.

From addressbook/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* contact-editor/e-contact-editor-categories.c,
	addressbook/gui/component/e-cardlist-model.c: Added
	value_to_string handlers.

	* demo/addressbook-widget.c, demo/demo.c: Removed usage of "x" and
	"y" arguments.

	* addressbook/gui/component/addressbook.c: Activated Click To Add
	and set the click to add message.

	* addressbook/gui/component/e-addressbook-model.c: Added
	value_to_string and append_row handlers.

	* addressbook/gui/component/e-select-names.c: Added a column.

From calendar/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* gui/calendar-model.c: Added an #ifdefed value_to_string handler
	assignment.

From camel/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* providers/mbox/camel-mbox-summary.c: Added debugging
	information.

From composer/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* Makefile.am: Added e-msg-composer-select-file.h for make
	distcheck.

From e-util/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* Makefile.am: Added e-canvas-vbox.c and e-canvas-vbox.h.

	* e-canvas-vbox.c, e-canvas-vbox.h: New canvas object to act like
	a vbox using the reflow system.

From mail/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* message-list.c: Added a value_to_string handler.

From shell/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* glade/Makefile.am: Added EXTRA_DIST for make distcheck.

From widgets/e-table/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* Makefile.am: Added e-table-click-to-add.c,
	e-table-click-to-add.h, e-table-one.c, and e-table-one.h.

	* e-table-click-to-add.c, e-table-click-to-add.h: A new canvas
	item that represents a single row that sometimes exists.  It's for
	adding new rows to your table.

	* e-table-example-1.c, e-table-example-2.c, e-table-size-test.c,
	test-check.c, test-cols.c, test-table.c: Added value_to_string handlers.

	* e-table-group-container.c: Use value_to_string to make grouping
	not crash for non string columns.  Made some changes to work
	properly in an ECanvasVbox.

	* e-table-group-leaf.c, e-table-item.c: Made some changes to work
	properly in an ECanvasVbox.

	* e-table-model.c, e-table-model.h: Added append_row and
	value_to_string methods.

	* e-table-one.c, e-table-one.h: Given a source ETableModel, this
	provides a single row model that uses the initialize_value,
	duplicate_value, free_value, and value_is_empty methods of the
	original source to implement set_value and value_at (and proxies
	most of the other methods.)  This is used for ETableClickToAdd.

	* e-table-simple.c, e-table-simple.h: Added append_row and
	value_to_string handlers.  append_row uses a GtkArg instead of a
	parameter to e_table_simple_new.

	* e-table-subset.c: Added append_row and value_to_string handlers.

	* e-table.c, e-table.h: Use a vbox containing an ETableClickToAdd
	and an ETableItem instead of an ETableItem directly.  Only show
	the ETableClickToAdd if the top level of the xml SPEC has the
	attribute click-to-add set to some non-zero integer.
	(click-to-add="1").  Add a "click_to_add_message" argument.

	* e-tree-model.c: Add a commented out value_to_string handler.

From widgets/meeting-time-sel/ChangeLog:

2000-06-26  Christopher James Lahey  <clahey@helixcode.com>

	* Makefile.am: Added the include path to top_srcdir.

svn path=/trunk/; revision=3744
2000-06-27 00:51:06 +00:00

245 lines
5.0 KiB
C

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* e-table-model.c: a one table model implementation that uses function
* pointers to simplify the creation of new, exotic and colorful tables in
* no time.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
* (C) 1999 Helix Code, Inc.
*/
#include <config.h>
#include "e-table-one.h"
#define PARENT_TYPE e_table_model_get_type ()
static int
one_column_count (ETableModel *etm)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
return e_table_model_column_count(one->source);
else
return 0;
}
static int
one_row_count (ETableModel *etm)
{
return 1;
}
static void *
one_value_at (ETableModel *etm, int col, int row)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->data)
return one->data[col];
else
return NULL;
}
static void
one_set_value_at (ETableModel *etm, int col, int row, const void *val)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->data && one->source) {
e_table_model_free_value(one->source, col, one->data[col]);
one->data[col] = e_table_model_duplicate_value(one->source, col, val);
}
}
static gboolean
one_is_cell_editable (ETableModel *etm, int col, int row)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
return e_table_model_is_cell_editable(one->source, 0, row);
else
return FALSE;
}
/* The default for one_duplicate_value is to return the raw value. */
static void *
one_duplicate_value (ETableModel *etm, int col, const void *value)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
return e_table_model_duplicate_value(one->source, col, value);
else
return (void *)value;
}
static void
one_free_value (ETableModel *etm, int col, void *value)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
e_table_model_free_value(one->source, col, value);
}
static void *
one_initialize_value (ETableModel *etm, int col)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
return e_table_model_initialize_value (one->source, col);
else
return NULL;
}
static gboolean
one_value_is_empty (ETableModel *etm, int col, const void *value)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
return e_table_model_value_is_empty (one->source, col, value);
else
return FALSE;
}
static char *
one_value_to_string (ETableModel *etm, int col, const void *value)
{
ETableOne *one = E_TABLE_ONE(etm);
if (one->source)
return e_table_model_value_to_string (one->source, col, value);
else
return g_strdup("");
}
static void
one_destroy (GtkObject *object)
{
ETableOne *one = E_TABLE_ONE(object);
if (one->source) {
int i;
int col_count;
col_count = e_table_model_column_count(one->source);
if (one->data) {
for (i = 0; i < col_count; i++) {
e_table_model_free_value(one->source, i, one->data[i]);
}
}
gtk_object_unref(GTK_OBJECT(one->source));
}
g_free(one->data);
}
static void
e_table_one_class_init (GtkObjectClass *object_class)
{
ETableModelClass *model_class = (ETableModelClass *) object_class;
model_class->column_count = one_column_count;
model_class->row_count = one_row_count;
model_class->value_at = one_value_at;
model_class->set_value_at = one_set_value_at;
model_class->is_cell_editable = one_is_cell_editable;
model_class->duplicate_value = one_duplicate_value;
model_class->free_value = one_free_value;
model_class->initialize_value = one_initialize_value;
model_class->value_is_empty = one_value_is_empty;
model_class->value_to_string = one_value_to_string;
object_class->destroy = one_destroy;
}
static void
e_table_one_init (GtkObject *object)
{
ETableOne *one = E_TABLE_ONE(object);
one->source = NULL;
one->data = NULL;
}
GtkType
e_table_one_get_type (void)
{
static GtkType type = 0;
if (!type){
GtkTypeInfo info = {
"ETableOne",
sizeof (ETableOne),
sizeof (ETableOneClass),
(GtkClassInitFunc) e_table_one_class_init,
(GtkObjectInitFunc) e_table_one_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
type = gtk_type_unique (PARENT_TYPE, &info);
}
return type;
}
ETableModel *
e_table_one_new (ETableModel *source)
{
ETableOne *eto;
int col_count;
int i;
eto = gtk_type_new (e_table_one_get_type ());
eto->source = source;
col_count = e_table_model_column_count(source);
eto->data = g_new(void *, col_count);
for (i = 0; i < col_count; i++) {
eto->data[i] = e_table_model_initialize_value(source, i);
}
if (source)
gtk_object_ref(GTK_OBJECT(source));
return (ETableModel *) eto;
}
gint
e_table_one_commit (ETableOne *one)
{
if (one->source) {
int empty = TRUE;
int col;
int cols = e_table_model_column_count(one->source);
for (col = 0; col < cols; col++) {
if (!e_table_model_value_is_empty(one->source, col, one->data[col])) {
empty = FALSE;
break;
}
}
if (!empty) {
int row = e_table_model_append_row(one->source);
if (row != -1) {
for (col = 0; col < cols; col++) {
e_table_model_set_value_at(one->source, col, row, one->data[col]);
}
}
return row;
}
}
return -1;
}