diff options
Diffstat (limited to 'widgets/table')
27 files changed, 0 insertions, 2432 deletions
diff --git a/widgets/table/.cvsignore b/widgets/table/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/widgets/table/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c deleted file mode 100644 index 8a2bfe90cf..0000000000 --- a/widgets/table/e-table-col.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * E-table-col.c: ETableCol implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 International GNOME Support - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-col.h" - -ETableCol * -e_table_col_new (const char *id, int width, int min_width, - ETableColRenderFn render, void *render_data, - GCompareFunc compare, gboolean resizable) -{ - ETableCol *etc; - - g_return_if_fail (id != NULL); - g_return_if_fail (width >= 0); - g_return_if_fail (min_width >= 0); - g_return_if_fail (width >= min_width); - g_return_if_fail (render != NULL); - g_return_if_fail (compare != NULL); - - etc = g_new (ETableCol, 1); - - etc->id = g_strdup (id); - etc->width = width; - etc->min_width = min_width; - etc->render = render; - etc->render_data = render_data; - etc->compare = compare; - - etc->selected = 0; - etc->resizeable = 0; - - return etc; -} - - - diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h deleted file mode 100644 index 215df07797..0000000000 --- a/widgets/table/e-table-col.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _E_TABLE_COL_H_ -#define _E_TABLE_COL_H_ - -typedef struct _ETableCol ETableCol; - -/* - * Rendering function for the column header - */ -typedef struct ERenderContext ERenderContext; - -typedef void (*ETableColRenderFn)(ERenderContext *ctxt); - -/* - * Information about a single column - */ -struct _ETableCol { - char *id; - short width; - short min_width; - short x; - ETableColRenderFn render; - GCompareFunc compare; - void *render_data; - unsigned int selected:1; - unsigned int resizeable:1; -}; - -ETableCol *e_table_col_new (const char *id, int width, int min_width, - ETableColRenderFn render, void *render_data, - GCompareFunc compare, gboolean resizable); - - -#endif /* _E_TABLE_COL_H_ */ diff --git a/widgets/table/e-table-column-item.c b/widgets/table/e-table-column-item.c deleted file mode 100644 index dc0da16c11..0000000000 --- a/widgets/table/e-table-column-item.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * E-table-column-view.c: A canvas view of the TableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, International GNOME Support. - */ -#include <config.h> -#include "e-table-column.h" -#include "e-table-column-view.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *etci_parent_class; - -enum { - ARG_0, - ARG_TABLE_COLUMN -}; - -static void -etci_destroy (GtkObject *object) -{ - ETableColumnItem *etcv = E_TABLE_COLUMN_VIEW (object); - - gtk_object_unref (GTK_OBJECT (etcv)); - - if (GTK_OBJECT_CLASS (etcv_parent_class)->destroy) - (*GTK_OBJECT_CLASS (etcv_parent_class)->destroy) (object); -} - -static void -etci_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS(item_bar_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -etci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableColumnItem *etci; - int v; - - item = GNOME_CANVAS_ITEM (o); - etci = E_TABLE_COLUMN_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_COLUMN: - etci->etci = GTK_VALUE_POINTER (*arg); - break; - } - etci_update (item, NULL, NULL, 0); -} - -static void -etci_realize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - etci->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (etci->gc, &c); - - etci->normal_cursor = gdk_cursor_new (GDK_ARROW); -} - -static void -etci_unrealize (GnomeCanvasItem *item) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - - gdk_gc_unref (etci->gc); - etci->gc = NULL; - - gdk_cursor_destroy (etci->change_cursor); - etci->change_cursor = NULL; - - gdk_cursor_destroy (etci->normal_cursor); - etci->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (etci_parent_class)->unrealize)(item); -} - -static void -etci_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableColumnItem *etci = E_TABLE_COLUMN_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_column_count (etci->etc); - int x2 = x1 + width; - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *col = e_table_column_get_column (etci->etc, col); - const int col_width = col->width; - - if (x1 > total + col_width) - continue; - - if (x2 < total) - return; - - gc = canvas->style->bg_gc [GTK_STATE_ACTIVE]; - gdk_draw_rectangle (drawble, gc, TRUE, - gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x, y, width, height - } -} - -static double -etci_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = *item; - return 0.0; -} - -static void -etci_event (GnomeCanvasItem *item, GdkEvent *e) -{ - switch (e->type){ - default: - return FALSE; - } - return TRUE; -} - -static void -etci_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - object_class->destroy = etci_destroy; - object_class->set_arg = etci_set_arg; - - item_class->update = etci_update; - item_class->realize = etci_realize; - item_class->unrealize = etci_unrealize; - item_class->draw = etci_draw; - item_class->point = etci_point; - item_class->event = etci_event; - - gtk_object_add_arg_type ("ETableColumnItem::ETableColumn", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_COLUMN); -} - -static void -etci_init (GnomeCanvasItem *item) -{ - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_column_view_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumnItem", - sizeof (ETableColumnItem), - sizeof (ETableColumnItemClass), - (GtkClassInitFunc) etci_class_init, - (GtkObjectInitFunc) etci_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - - - diff --git a/widgets/table/e-table-column-item.h b/widgets/table/e-table-column-item.h deleted file mode 100644 index fd38681a73..0000000000 --- a/widgets/table/e-table-column-item.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _E_TABLE_COLUMN_VIEW_H -#defein _E_TABLE_COLUMN_VIEW_H - -#include "e-table-column.h" - -typedef struct { - GnomeCanvasItem parent; - ETableColumn *etc; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; -} ETableColumnView; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableColumnViewClass; - -GtkType e_table_column_item_get_type (void); - -#endif /* _E_TABLE_COLUMN_VIEW_H */ diff --git a/widgets/table/e-table-column-model.h b/widgets/table/e-table-column-model.h deleted file mode 100644 index 043dd783ca..0000000000 --- a/widgets/table/e-table-column-model.h +++ /dev/null @@ -1,5 +0,0 @@ - -class ETableColumnModel { - virtual void add_column (ETableCol *et) = 0; - virtual ETableCol *get_column (int column); - virtual diff --git a/widgets/table/e-table-column.c b/widgets/table/e-table-column.c deleted file mode 100644 index 851ebc4532..0000000000 --- a/widgets/table/e-table-column.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * e-table-column.c: TableColumn implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 International GNOME Support - */ -#include <config.h> -#include "e-table-column.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint etc_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_column_parent_class; - -static void -e_table_column_destroy (GtkObject *object) -{ - ETableColumn *etc = E_TABLE_COLUMN (object); - const int cols = etc->col_count; - - /* - * Destroy listeners - */ - for (l = etc->listeners; l; l = l->next) - g_free (l->data); - g_slist_free (etc->listeners); - etc->listeners = NULL; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++) - e_table_column_remove (etc, i); - - if (e_table_column_parent_class->destroy) - e_table_column_parent_class->destroy (object); -} - -static void -e_table_column_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_column_destroy; - - e_table_column_parent_class = (gtk_type_class (gtk_object_get_type ())); - - etc_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - etc_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableColumn, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, etc_signals, LAST_SIGNAL); -} - -GtkType -e_table_column_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableColumn", - sizeof (ETableColumn), - sizeof (ETableColumnClass), - (GtkClassInitFunc) e_table_column_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -static void -etc_do_insert (ETableColumn *etc, int pos, ETableCol *val) -{ - memcpy (&etc->columns [pos+1], &etc->columns [pos], - sizeof (ETableCol *) * (etc->col_count - pos)); - etc->columns [pos] = val; -} - -void -e_table_column_add_column (ETableColumn *etc, ETableCol *tc, int pos) -{ - ETableCol **new_ptr; - - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (tc != NULL); - g_return_if_fail (pos >= 0 && pos < etc->col_count); - - if (pos == -1) - pos = etc->col_count; - etc->columns = g_realloc (etc->columns, sizeof (ETableCol *) * (etc->col_count + 1)); - etc_do_insert (etc, pos, tc); - etc->col_count++; - - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_column_get_column (ETableColumn *etc, int column) -{ - g_return_val_if_fail (etc != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), NULL); - - if (column < 0) - return NULL; - - if (column >= etc->col_count) - return NULL; - - return etc->columns [column]; -} - -int -e_table_column_count (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - return etc->col_count; -} - -int -e_table_column_index (ETableColumn *etc, const char *identifier) -{ - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < etc->col_count; i++){ - ETableCol *tc = etc->columns [i]; - - if (strcmp (i->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_column_get_index_at (ETableColumn *etc, int x_offset) -{ - int i, total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - g_return_val_if_fail (identifier != NULL, 0); - - total = 0; - for (i = 0; i < etc->col_count; i++){ - total += etc->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_column_get_columns (ETableColumn *etc) -{ - ETableCol **ret; - int i; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - ret = g_new (ETableCol *, etc->col_count + 1); - memcpy (ret, etc->columns, sizeof (ETableCol *) * etc->col_count); - ret [etc->col_count] = NULL; - - return ret; -} - -gboolean -e_table_column_selection_ok (ETableColumn *etc) -{ - g_return_val_if_fail (etc != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), FALSE); - - return etc->selectable; -} - -int -ve_table_column_get_selected (ETableColumn *etc) -{ - int i; - int selected = 0; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - for (i = 0; i < etc->col_count; i++){ - if (etc->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_column_total_width (ETableColumn *etc) -{ - int total; - - g_return_val_if_fail (etc != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_COLUMN (etc), 0); - - total = 0; - for (i = 0; i < etc->col_count; i++) - total += etc->columns [i].width; - - return total; -} - -static void -etc_do_remove (ETableColumn *etc, int idx) -{ - memcpy (&etc->columns [idx], &etc->columns [idx+1], - sizeof (ETableCol *) * etc->col_count - idx); - etc->col_count--; -} - -void -e_table_column_move (ETableColumn *etc, int source_index, int target_index) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < etc->col_count); - g_return_if_fail (target_index < etc->col_count); - - old = etc->columns [source_index]; - etc_do_remove (etc, source_index); - etc_do_insert (etc, target_index, old); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_remove (ETableColumn *etc, int idx) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - - etc_do_remove (etc, idx); - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [STRUCTURE_CHANGE]); -} - -void -e_table_column_set_selection (ETableColumn *etc, gboolean allow_selection); -{ -} - -void -e_table_column_set_size (ETableColumn *etc, int idx, int size) -{ - g_return_if_fail (etc != NULL); - g_return_if_fail (E_IS_TABLE_COLUMN (etc)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < etc->col_count); - g_return_if_fail (size > 0); - - etc->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (etc), etc_signals [SIZE_CHANGE], idx); -} diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c deleted file mode 100644 index 07a3fb60f2..0000000000 --- a/widgets/table/e-table-group.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * E-Table-Group.c: Implements the grouping objects for elements on a table - * - * Author: - * Miguel de Icaza (miguel@gnu.org() - * - * Copyright 1999, International GNOME Support. - */ - -#include <config.h> -#include "e-table-group.h" - -void -e_table_group_destroy (ETableGroup *etg) -{ - g_return_if_fail (etg != NULL); - - g_free (etg->title); - - if (etg->is_leaf == 0){ - GSList *l; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - e_table_group_destroy (child); - } - g_slist_free (etg->u.children); - etg->u.children = NULL; - } - g_free (etg); -} - -ETableGroup * -e_table_group_new_leaf (const char *title, ETableModel *table) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - g_return_val_if_fail (table != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 1; - etg->u.table = table; - etg->title = g_strdup (title); - - return etg; -} - -ETableGroup * -e_table_group_new (const char *title) -{ - ETableGroup *etg; - - g_return_val_if_fail (title != NULL, NULL); - - etg = g_new (ETableGroup, 1); - - etg->expanded = 0; - etg->is_leaf = 0; - etg->u.children = NULL; - etg->title = g_strdup (title); - - return etg; -} - -void -e_table_group_append_child (ETableGroup *etg, ETableGroup *child) -{ - g_return_if_fail (etg != NULL); - g_return_if_fail (child != NULL); - g_return_if_fail (etg->is_leaf != 0); - - etg->u.children = g_slist_append (etg->u.children, child); -} - -int -e_table_group_size (ETableGroup *etg) -{ - g_return_if_fail (etg != NULL); - - if (etg->is_leaf) - return e_table_model_height (etg->u.table); - else { - GSList *l; - int size = 0; - - for (l = etg->u.children; l; l = l->next){ - ETableGroup *child = l->data; - - size += e_table_group_size (child); - } - return size; - } -} - diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h deleted file mode 100644 index d673aebd11..0000000000 --- a/widgets/table/e-table-group.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -#include "e-table-model.h" - -typedef struct { - char *title; - - union { - ETableModel *table; - GSList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title); -ETableGroup *e_table_group_new_leaf (const char *title, ETableModel *table); -void e_table_group_destroy (ETableGroup *etg); - -int e_table_group_size (ETableGroup *egroup); -void e_table_group_append_child (ETableGroup *etg, ETableGroup *child); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c deleted file mode 100644 index 50b0b6a677..0000000000 --- a/widgets/table/e-table-header-item.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * E-table-column-view.c: A canvas item based view of the ETableColumn. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, Helix Code, Inc. - */ -#include <config.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-cursors.h" - -/* Padding above and below of the string in the header display */ -#define PADDING 4 - -/* Defines the tolerance for proximity of the column division to the cursor position */ -#define TOLERANCE 2 - -#define ETHI_RESIZING(x) ((x)->resize_col != -1) - -#define PARENT_OBJECT_TYPE gnome_canvas_item_get_type () - -static GnomeCanvasItemClass *ethi_parent_class; - -enum { - ARG_0, - ARG_TABLE_HEADER, - ARG_TABLE_X, - ARG_TABLE_Y, - ARG_TABLE_FONTSET -}; - -static void -ethi_destroy (GtkObject *object) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object); - - gtk_object_unref (GTK_OBJECT (ethi)); - - if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy) - (*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object); -} - -static void -ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags); - - item->x1 = ethi->x1; - item->y1 = ethi->y1; - item->x2 = INT_MAX; - item->y2 = ethi->x1 + ethi->height; - - gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item); -} - -static void -ethi_font_load (ETableHeaderItem *ethi, char *font) -{ - if (ethi->font) - gdk_font_unref (ethi->font); - - ethi->font = gdk_fontset_load (font); - if (ethi->font == NULL) - ethi->font = gdk_font_load ("fixed"); - - ethi->height = ethi->font->ascent + ethi->font->descent + PADDING; -} - -static void -ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ETableHeaderItem *ethi; - int v; - - item = GNOME_CANVAS_ITEM (o); - ethi = E_TABLE_HEADER_ITEM (o); - - switch (arg_id){ - case ARG_TABLE_HEADER: - ethi->eth = GTK_VALUE_POINTER (*arg); - break; - - case ARG_TABLE_X: - ethi->x1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_Y: - ethi->y1 = GTK_VALUE_INT (*arg); - break; - - case ARG_TABLE_FONTSET: - ethi_font_load (ethi, GTK_VALUE_STRING (*arg)); - break; - - } - ethi_update (item, NULL, NULL, 0); -} - -static void -ethi_realize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GdkWindow *window; - GdkColor c; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)-> realize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->realize)(item); - - window = GTK_WIDGET (item->canvas)->window; - - ethi->gc = gdk_gc_new (window); - gnome_canvas_get_color (item->canvas, "black", &c); - gdk_gc_set_foreground (ethi->gc, &c); - - ethi->normal_cursor = gdk_cursor_new (GDK_ARROW); - - if (!ethi->font) - ethi_font_load (ethi, "fixed"); -} - -static void -ethi_unrealize (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - gdk_gc_unref (ethi->gc); - ethi->gc = NULL; - - gdk_cursor_destroy (ethi->change_cursor); - ethi->change_cursor = NULL; - - gdk_cursor_destroy (ethi->normal_cursor); - ethi->normal_cursor = NULL; - - if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize) - (*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->unrealize)(item); -} - -static void -draw_button (ETableHeaderItem *ethi, ETableCol *col, - GdkDrawable *drawable, GdkGC *gc, GtkStyle *style, - int x, int y, int width, int height) -{ - GdkRectangle clip; - int xtra; - - gdk_draw_rectangle ( - drawable, gc, TRUE, - x + 1, y + 1, width - 2, height -2); - - gtk_draw_shadow ( - style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x , y, width, height); - - clip.x = x + 2; - clip.y = y + 2; - clip.width = width - 4; - clip.height = ethi->height; - - gdk_gc_set_clip_rectangle (ethi->gc, &clip); - - /* Center the thing */ - xtra = (clip.width - gdk_string_measure (ethi->font, col->id))/2; - - if (xtra < 0) - xtra = 0; - - /* Skip over border */ - x += xtra + 2; - - gdk_draw_text ( - drawable, ethi->font, - ethi->gc, x, y + ethi->height - PADDING, - col->id, strlen (col->id)); -} - -static void -ethi_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x1, int y1, int width, int height) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - GdkGC *gc; - const int cols = e_table_header_count (ethi->eth); - int x2 = x1 + width; - int col, total; - int x; - - total = 0; - x = -x1; - - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - int col_width; - - if (col == ethi->resize_col) - col_width = ethi->resize_width; - else - col_width = ecol->width; - - if (x1 > total + col_width){ - x += col_width; - continue; - } - - if (x2 < total) - return; - - gc = GTK_WIDGET (canvas)->style->bg_gc [GTK_STATE_ACTIVE]; - - draw_button (ethi, ecol, drawable, gc, - GTK_WIDGET (canvas)->style, - x, -y1, col_width, ethi->height); - - x += col_width; - } -} - -static double -ethi_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - -/* - * is_pointer_on_division: - * - * Returns whether @pos is a column header division; If @the_total is not NULL, - * then the actual position is returned here. If @return_ecol is not NULL, - * then the ETableCol that actually contains this point is returned here - */ -static gboolean -is_pointer_on_division (ETableHeaderItem *ethi, int pos, int *the_total, int *return_col) -{ - const int cols = e_table_header_count (ethi->eth); - int col, total; - - total = 0; - for (col = 0; col < cols; col++){ - ETableCol *ecol = e_table_header_get_column (ethi->eth, col); - - total += ecol->width; - - if ((total - TOLERANCE < pos ) && (pos < total + TOLERANCE)){ - if (return_col) - *return_col = col; - if (the_total) - *the_total = total; - - return TRUE; - } - - if (total > pos + TOLERANCE) - return FALSE; - } - - return FALSE; -} - -#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y) - -static void -set_cursor (ETableHeaderItem *ethi, int pos) -{ - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ethi)->canvas); - - /* We might be invoked before we are realized */ - if (!canvas->window) - return; - - if (is_pointer_on_division (ethi, pos, NULL, NULL)) - e_cursor_set (canvas->window, E_CURSOR_SIZE_X); - else - e_cursor_set (canvas->window, E_CURSOR_ARROW); -} - -static void -ethi_request_redraw (ETableHeaderItem *ethi) -{ - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (ethi)->canvas; - - /* - * request a redraw - */ - gnome_canvas_request_redraw ( - canvas, ethi->x1, ethi->y1, INT_MAX, ethi->x1 + ethi->height); -} - -static void -ethi_end_resize (ETableHeaderItem *ethi, int new_size) -{ - e_table_header_set_size (ethi->eth, ethi->resize_col, new_size); - - if (ethi->resize_guide){ -#warning Fix this - /* gtk_object_destroy (ethi->resize_guide);*/ - ethi->resize_guide = NULL; - } - ethi->resize_col = -1; - ethi_request_redraw (ethi); -} - -/* - * Handles the events on the ETableHeaderItem, particularly it handles resizing - */ -static int -ethi_event (GnomeCanvasItem *item, GdkEvent *e) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - GnomeCanvas *canvas = item->canvas; - const gboolean resizing = ETHI_RESIZING (ethi); - int x, y, start, col; - - switch (e->type){ - case GDK_ENTER_NOTIFY: - convert (canvas, e->crossing.x, e->crossing.y, &x, &y); - set_cursor (ethi, x); - break; - - case GDK_MOTION_NOTIFY: - convert (canvas, e->motion.x, e->motion.y, &x, &y); - if (resizing){ - if (ethi->resize_guide == NULL){ - /* Quick hack until I actually bind the views */ - ethi->resize_guide = GINT_TO_POINTER (1); - gnome_canvas_item_grab (item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - e_cursor_get (E_CURSOR_SIZE_X), - e->button.time); - } - - if (x - ethi->resize_start_pos <= 0) - break; - - ethi->resize_width = x - ethi->resize_start_pos; - - ethi_request_redraw (ethi); - } else - set_cursor (ethi, x); - break; - - case GDK_BUTTON_PRESS: - convert (canvas, e->button.x, e->button.y, &x, &y); - - if (is_pointer_on_division (ethi, x, &start, &col)){ - ETableCol *ecol; - - /* - * Record the important bits. - * - * By setting resize_pos to a non -1 value, - * we know that we are being resized (used in the - * other event handlers). - */ - ecol = e_table_header_get_column (ethi->eth, col); - ethi->resize_col = col; - ethi->resize_width = ecol->width; - ethi->resize_start_pos = start - ecol->width; - } - break; - - case GDK_2BUTTON_PRESS: - if (!resizing) - break; - - if (e->button.button != 1) - break; - - printf ("Resize this guy\n"); - break; - - case GDK_BUTTON_RELEASE: { - gboolean needs_ungrab = FALSE; - - if (ethi->resize_col != -1){ - needs_ungrab = (ethi->resize_guide != NULL); - ethi_end_resize (ethi, ethi->resize_width); - } - if (needs_ungrab) - gnome_canvas_item_ungrab (item, e->button.time); - - break; - } - - default: - return FALSE; - } - return TRUE; -} - -static void -ethi_class_init (GtkObjectClass *object_class) -{ - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class; - - ethi_parent_class = gtk_type_class (PARENT_OBJECT_TYPE); - - object_class->destroy = ethi_destroy; - object_class->set_arg = ethi_set_arg; - - item_class->update = ethi_update; - item_class->realize = ethi_realize; - item_class->unrealize = ethi_unrealize; - item_class->draw = ethi_draw; - item_class->point = ethi_point; - item_class->event = ethi_event; - - gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_POINTER, - GTK_ARG_WRITABLE, ARG_TABLE_HEADER); - gtk_object_add_arg_type ("ETableHeaderItem::x", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_X); - gtk_object_add_arg_type ("ETableHeaderItem::y", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_TABLE_Y); - gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING, - GTK_ARG_WRITABLE, ARG_TABLE_FONTSET); -} - -static void -ethi_init (GnomeCanvasItem *item) -{ - ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item); - - ethi->resize_col = -1; - - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; -} - -GtkType -e_table_header_item_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeaderItem", - sizeof (ETableHeaderItem), - sizeof (ETableHeaderItemClass), - (GtkClassInitFunc) ethi_class_init, - (GtkObjectInitFunc) ethi_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} - diff --git a/widgets/table/e-table-header-item.h b/widgets/table/e-table-header-item.h deleted file mode 100644 index 45e8f8851d..0000000000 --- a/widgets/table/e-table-header-item.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _E_TABLE_HEADER_ITEM_H_ -#define _E_TABLE_HEADER_ITEM_H_ - -#include <libgnomeui/gnome-canvas.h> -#include "e-table-header.h" - -#define E_TABLE_HEADER_ITEM_TYPE (e_table_header_item_get_type ()) -#define E_TABLE_HEADER_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItem)) -#define E_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_ITEM_TYPE, ETableHeaderItemClass)) -#define E_IS_TABLE_HEADER_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_ITEM_TYPE)) -#define E_IS_TABLE_HEADER_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_ITEM_TYPE)) - -typedef struct { - GnomeCanvasItem parent; - ETableHeader *eth; - - GdkGC *gc; - GdkCursor *change_cursor, *normal_cursor; - - short x1, y1, height; - GdkFont *font; - - /* - * Used during resizing - */ - int resize_col; - int resize_width; - int resize_start_pos; - GtkObject *resize_guide; -} ETableHeaderItem; - -typedef struct { - GnomeCanvasItemClass parent_class; -} ETableHeaderItemClass; - -GtkType e_table_header_item_get_type (void); - -#endif /* _E_TABLE_HEADER_ITEM_H_ */ diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c deleted file mode 100644 index 3edc57a527..0000000000 --- a/widgets/table/e-table-header.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * E-table-col-head.c: TableColHead implementation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 International GNOME Support - */ -#include <config.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include "e-table-header.h" - -enum { - STRUCTURE_CHANGE, - DIMENSION_CHANGE, - LAST_SIGNAL -}; - -static guint eth_signals [LAST_SIGNAL] = { 0, }; - -static GtkObjectClass *e_table_header_parent_class; - -static void -e_table_header_destroy (GtkObject *object) -{ - ETableHeader *eth = E_TABLE_HEADER (object); - const int cols = eth->col_count; - int i; - - /* - * Destroy columns - */ - for (i = 0; i < cols; i++) - e_table_header_remove (eth, i); - - if (e_table_header_parent_class->destroy) - e_table_header_parent_class->destroy (object); -} - -static void -e_table_header_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = e_table_header_destroy; - - e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ())); - - eth_signals [STRUCTURE_CHANGE] = - gtk_signal_new ("structure_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, structure_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - eth_signals [DIMENSION_CHANGE] = - gtk_signal_new ("dimension_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eth_signals, LAST_SIGNAL); -} - -GtkType -e_table_header_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableHeader", - sizeof (ETableHeader), - sizeof (ETableHeaderClass), - (GtkClassInitFunc) e_table_header_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -ETableHeader * -e_table_header_new (void) -{ - ETableHeader *eth; - - eth = gtk_type_new (e_table_header_get_type ()); - - return eth; -} - -static void -eth_do_insert (ETableHeader *eth, int pos, ETableCol *val) -{ - memcpy (ð->columns [pos+1], ð->columns [pos], - sizeof (ETableCol *) * (eth->col_count - pos)); - eth->columns [pos] = val; -} - -static void -eth_update_offsets (ETableHeader *eth) -{ - int i; - int x = 0; - - for (i = 0; i < eth->col_count; i++){ - ETableCol *etc = eth->columns [i]; - - etc->x = x; - x += etc->width; - } -} - -void -e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos) -{ - ETableCol **new_ptr; - - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (tc != NULL); - g_return_if_fail (pos >= 0 && pos <= eth->col_count); - - if (pos == -1) - pos = eth->col_count; - eth->columns = g_realloc (eth->columns, sizeof (ETableCol *) * (eth->col_count + 1)); - eth_do_insert (eth, pos, tc); - eth->col_count++; - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -ETableCol * -e_table_header_get_column (ETableHeader *eth, int column) -{ - g_return_val_if_fail (eth != NULL, NULL); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL); - - if (column < 0) - return NULL; - - if (column >= eth->col_count) - return NULL; - - return eth->columns [column]; -} - -int -e_table_header_count (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - return eth->col_count; -} - -int -e_table_header_index (ETableHeader *eth, const char *identifier) -{ - int i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - g_return_val_if_fail (identifier != NULL, 0); - - for (i = 0; i < eth->col_count; i++){ - ETableCol *tc = eth->columns [i]; - - if (strcmp (tc->id, identifier) == 0) - return i; - } - - return -1; -} - -int -e_table_header_get_index_at (ETableHeader *eth, int x_offset) -{ - int i, total; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++){ - total += eth->columns [i]->width; - - if (x_offset < total) - return i; - } - - return -1; -} - -ETableCol ** -e_table_header_get_columns (ETableHeader *eth) -{ - ETableCol **ret; - int i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - ret = g_new (ETableCol *, eth->col_count + 1); - memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); - ret [eth->col_count] = NULL; - - return ret; -} - -gboolean -e_table_header_selection_ok (ETableHeader *eth) -{ - g_return_val_if_fail (eth != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), FALSE); - - return eth->selectable; -} - -int -ve_table_header_get_selected (ETableHeader *eth) -{ - int i; - int selected = 0; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - for (i = 0; i < eth->col_count; i++){ - if (eth->columns [i]->selected) - selected++; - } - - return selected; -} - -int -e_table_header_total_width (ETableHeader *eth) -{ - int total, i; - - g_return_val_if_fail (eth != NULL, 0); - g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - - total = 0; - for (i = 0; i < eth->col_count; i++) - total += eth->columns [i]->width; - - return total; -} - -static void -eth_do_remove (ETableHeader *eth, int idx) -{ - memcpy (ð->columns [idx], ð->columns [idx+1], - sizeof (ETableCol *) * eth->col_count - idx); - eth->col_count--; -} - -void -e_table_header_move (ETableHeader *eth, int source_index, int target_index) -{ - ETableCol *old; - - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (source_index >= 0); - g_return_if_fail (target_index >= 0); - g_return_if_fail (source_index < eth->col_count); - g_return_if_fail (target_index < eth->col_count); - - old = eth->columns [source_index]; - eth_do_remove (eth, source_index); - eth_do_insert (eth, target_index, old); - eth_update_offsets (eth); - - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_remove (ETableHeader *eth, int idx) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - - eth_do_remove (eth, idx); - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); -} - -void -e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) -{ -} - -void -e_table_header_set_size (ETableHeader *eth, int idx, int size) -{ - g_return_if_fail (eth != NULL); - g_return_if_fail (E_IS_TABLE_HEADER (eth)); - g_return_if_fail (idx >= 0); - g_return_if_fail (idx < eth->col_count); - g_return_if_fail (size > 0); - - eth->columns [idx]->width = size; - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE], idx); -} diff --git a/widgets/table/e-table-header.h b/widgets/table/e-table-header.h deleted file mode 100644 index c263c36ad3..0000000000 --- a/widgets/table/e-table-header.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _E_TABLE_COLUMN_H_ -#define _E_TABLE_COLUMN_H_ - -#include <gtk/gtkobject.h> -#include <gdk/gdk.h> -#include "e-table-col.h" - -typedef struct _ETableHeader ETableHeader; - -#define E_TABLE_HEADER_TYPE (e_table_header_get_type ()) -#define E_TABLE_HEADER(o) (GTK_CHECK_CAST ((o), E_TABLE_HEADER_TYPE, ETableHeader)) -#define E_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_HEADER_TYPE, ETableHeaderClass)) -#define E_IS_TABLE_HEADER(o) (GTK_CHECK_TYPE ((o), E_TABLE_HEADER_TYPE)) -#define E_IS_TABLE_HEADER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_HEADER_TYPE)) - -/* - * A Columnar header. - */ -struct _ETableHeader { - GtkObject base; - - int col_count; - ETableCol **columns; - gboolean selectable; -}; - -typedef struct { - GtkObjectClass parent_class; - - void (*structure_change) (ETableHeader *eth); - void (*dimension_change) (ETableHeader *eth, int col); -} ETableHeaderClass; - -GtkType e_table_header_get_type (void); -ETableHeader *e_table_header_new (void); - -void e_table_header_add_column (ETableHeader *eth, - ETableCol *tc, int pos); -ETableCol * e_table_header_get_column (ETableHeader *eth, - int column); -int e_table_header_count (ETableHeader *eth); -int e_table_header_index (ETableHeader *eth, - const char *identifier); -int e_table_header_get_index_at (ETableHeader *eth, - int x_offset); -ETableCol **e_table_header_get_columns (ETableHeader *eth); -gboolean e_table_header_selection_ok (ETableHeader *eth); -int e_table_header_get_selected (ETableHeader *eth); -int e_table_header_total_width (ETableHeader *eth); -void e_table_header_move (ETableHeader *eth, - int source_index, - int target_index); -void e_table_header_remove (ETableHeader *eth, int idx); -void e_table_header_set_size (ETableHeader *eth, int idx, int size); -void e_table_header_set_selection (ETableHeader *eth, - gboolean allow_selection); - -GList *e_table_header_get_selected_indexes(ETableHeader *eth); - - -#endif /* _E_TABLE_HEADER_H_ */ - diff --git a/widgets/table/e-table-model.c b/widgets/table/e-table-model.c deleted file mode 100644 index c3b6674130..0000000000 --- a/widgets/table/e-table-model.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * e-table-model.c: a Table Model - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 International GNOME Support. - */ -#include <config.h> -#include "e-table-model.h" - -#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass) - -static GtkObjectClass *e_table_model_parent_class; - -int -e_table_model_column_count (ETableModel *etable) -{ - return ETM_CLASS (etable)->column_count (etable); -} - -const char * -e_table_model_column_name (ETableModel *etable, int col) -{ - return ETM_CLASS (etable)->column_name (etable, col); -} - -int -e_table_model_row_count (ETableModel *etable) -{ - return ETM_CLASS (etable)->row_count (etable); -} - -void * -e_table_model_value_at (ETableModel *etable, int col, int row) -{ - return ETM_CLASS (etable)->value_at (etable, col, row); -} - -void -e_table_model_set_value_at (ETableModel *etable, int col, int row, void *data) -{ - return ETM_CLASS (etable)->set_value_at (etable, col, row, data); -} - -gboolean -e_table_model_is_cell_editable (ETableModel *etable, int col, int row) -{ - return ETM_CLASS (etable)->is_cell_editable (etable, col, row); -} - -int -e_table_model_row_height (ETableModel *etable, int row) -{ - return ETM_CLASS (etable)->row_height (etable, row); -} - -static void -e_table_model_destroy (GtkObject *object) -{ - GSList *l; - - ETableModel *etable = (ETableModel *) object; - - if (e_table_model_parent_class->destroy) - (*e_table_model_parent_class->destroy)(object); -} - -static void -e_table_model_class_init (GtkObjectClass *class) -{ - e_table_model_parent_class = gtk_type_class (gtk_object_get_type ()); - - class->destroy = e_table_model_destroy; -} - -GtkType -e_table_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableModel", - sizeof (ETableModel), - sizeof (ETableModelClass), - (GtkClassInitFunc) e_table_model_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -int -e_table_model_height (ETableModel *etable) -{ - int rows, size, i; - - g_return_val_if_fail (etable != NULL, 0); - - rows = e_table_model_row_count (etable); - size = 0; - - for (i = 0; i < rows; i++) - size += e_table_model_row_height (etable, i); - - return size; -} - -#if 0 -int -e_table_model_max_col_width (ETableModel *etm, int col) -{ - const int nvals = e_table_model_row_count (etm); - int max = 0; - int row; - - for (row = 0; row < nvals; row++){ - int w; - - w = e_table_model_cell_width (etm, col, i); - - if (w > max) - max = w; - } - - return max; -} -#endif diff --git a/widgets/table/e-table-model.h b/widgets/table/e-table-model.h deleted file mode 100644 index ce57f73e7a..0000000000 --- a/widgets/table/e-table-model.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _E_TABLE_MODEL_H_ -#define _E_TABLE_MODEL_H_ - -#include <gtk/gtkobject.h> - -#define E_TABLE_MODEL_TYPE (e_table_model_get_type ()) -#define E_TABLE_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_MODEL_TYPE, ETableModel)) -#define E_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_MODEL_TYPE, ETableModelClass)) -#define E_IS_TABLE_MODEL(o) (GTK_CHECK_TYPE ((o), E_TABLE_MODEL_TYPE)) -#define E_IS_TABLE_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_MODEL_TYPE)) - -typedef struct { - GtkObject base; -} ETableModel; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Virtual methods - */ - int (*column_count) (ETableModel *etm); - const char *(*column_name) (ETableModel *etm, int col); - int (*row_count) (ETableModel *etm); - void *(*value_at) (ETableModel *etm, int col, int row); - void (*set_value_at) (ETableModel *etm, int col, int row, void *value); - gboolean (*is_cell_editable) (ETableModel *etm, int col, int row); - int (*row_height) (ETableModel *etm, int row); -} ETableModelClass; - -GtkType e_table_model_get_type (void); - -int e_table_model_column_count (ETableModel *e_table_model); -const char *e_table_model_column_name (ETableModel *e_table_model, int col); -int e_table_model_row_count (ETableModel *e_table_model); -int e_table_model_row_height (ETableModel *e_table_model, int row); -int e_table_model_height (ETableModel *e_table_model); -void *e_table_model_value_at (ETableModel *e_table_model, int col, int row); -void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, void *data); -gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row); - -/* - * Routines for emitting signals on the e_table - */ - -#endif /* _E_TABLE_MODEL_H_ */ - diff --git a/widgets/table/e-table-render.c b/widgets/table/e-table-render.c deleted file mode 100644 index 8e9f1bf285..0000000000 --- a/widgets/table/e-table-render.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * E-table-render.c: Various renderers - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, International GNOME Support. - */ -#include <config.h> -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-col.h" -#include "e-table-render.h" - -void -e_table_render_string (ERenderContext *ctxt) -{ - printf ("Rendering string: %s\n", ctxt->render_data); -} - diff --git a/widgets/table/e-table-render.h b/widgets/table/e-table-render.h deleted file mode 100644 index ebc65968f0..0000000000 --- a/widgets/table/e-table-render.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef E_TABLE_RENDER_H -#define E_TABLE_RENDER_H - -#include <libgnomeui/gnome-canvas.h> - -struct ERenderContext { - ETableCol *etc; - int row; - int base_x, base_y; - GnomeCanvasItem *gnome_canvas_item; - GdkDrawable *drawable; - int drawable_width; - int drawable_height; - void *render_data; - void *closure; -}; - -void e_table_render_string (ERenderContext *ctxt); - - -#endif diff --git a/widgets/table/e-table-simple.c b/widgets/table/e-table-simple.c deleted file mode 100644 index 6532d6e542..0000000000 --- a/widgets/table/e-table-simple.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * e-table-model.c: a simple 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 International GNOME Support. - */ - -#include <config.h> -#include "e-table-simple.h" - -static int -simple_column_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_count (etm, simple->data); -} - -static const char * -simple_column_name (ETableModel *etm, int col) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->col_name (etm, col, simple->data); -} - -static int -simple_row_count (ETableModel *etm) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->row_count (etm, simple->data); -} - -static void * -simple_value_at (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->value_at (etm, col, row, simple->data); -} - -static void -simple_set_value_at (ETableModel *etm, int col, int row, void *val) -{ - ETableSimple *simple = (ETableSimple *)etm; - - simple->set_value_at (etm, col, row, val, simple->data); -} - -static gboolean -simple_is_cell_editable (ETableModel *etm, int col, int row) -{ - ETableSimple *simple = (ETableSimple *)etm; - - return simple->is_cell_editable (etm, col, row, simple->data); -} - -static void -e_table_simple_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - model_class->column_count = simple_column_count; - model_class->column_name = simple_column_name; - model_class->row_count = simple_row_count; - model_class->value_at = simple_value_at; - model_class->set_value_at = simple_set_value_at; - model_class->is_cell_editable = simple_is_cell_editable; -} - -GtkType -e_table_simple_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETableSimple", - sizeof (ETableSimple), - sizeof (ETableSimpleClass), - (GtkClassInitFunc) e_table_simple_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (e_table_model_get_type (), &info); - } - - return type; -} - -ETableModel * -e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data) -{ - ETableSimple *et; - - et = gtk_type_new (e_table_simple_get_type ()); - - et->col_count = col_count; - et->col_name = col_name; - et->row_count = row_count; - et->value_at = value_at; - et->set_value_at = set_value_at; - et->is_cell_editable = is_cell_editable; - - return (ETableModel *) et; -} diff --git a/widgets/table/e-table-simple.h b/widgets/table/e-table-simple.h deleted file mode 100644 index d47a1cbe0b..0000000000 --- a/widgets/table/e-table-simple.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _E_TABLE_SIMPLE_H_ -#define _E_TABLE_SIMPLE_H_ - -#include "e-table-model.h" - -typedef int (*ETableSimpleColumnCountFn) (ETableModel *etm, void *data); -typedef const char *(*ETableSimpleColumnNameFn) (ETableModel *etm, int col, void *data); -typedef int (*ETableSimpleRowCountFn) (ETableModel *etm, void *data); -typedef void *(*ETableSimpleValueAtFn) (ETableModel *etm, int col, int row, void *data); -typedef void (*ETableSimpleSetValueAtFn) (ETableModel *etm, int col, int row, void *val, void *data); -typedef gboolean (*ETableSimpleIsCellEditableFn) (ETableModel *etm, int col, int row, void *data); -typedef int (*ETableSimpleRowHeightFn) (ETableModel *etm, int row, void *data); - -typedef struct { - ETableModel parent; - - ETableSimpleColumnCountFn col_count; - ETableSimpleColumnNameFn col_name; - ETableSimpleRowCountFn row_count; - ETableSimpleValueAtFn value_at; - ETableSimpleSetValueAtFn set_value_at; - ETableSimpleIsCellEditableFn is_cell_editable; - ETableSimpleRowHeightFn row_height; - void *data; -} ETableSimple; - -typedef struct { - ETableModelClass parent_class; -} ETableSimpleClass; - -GtkType e_table_simple_get_type (void); - -ETableModel *e_table_simple_new (ETableSimpleColumnCountFn col_count, - ETableSimpleColumnNameFn col_name, - ETableSimpleRowCountFn row_count, - ETableSimpleValueAtFn value_at, - ETableSimpleSetValueAtFn set_value_at, - ETableSimpleIsCellEditableFn is_cell_editable, - void *data); - -#endif /* _E_TABLE_SIMPLE_H_ */ - diff --git a/widgets/table/e-table-sorted.c b/widgets/table/e-table-sorted.c deleted file mode 100644 index d8c5273800..0000000000 --- a/widgets/table/e-table-sorted.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * E-table-sorted.c: Implements a table that sorts another table - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ -#include <config.h> -#include <stdlib.h> -#include "e-util.h" -#include "e-table-sorted.h" - -#define PARENT_TYPE E_TABLE_MODEL_TYPE - -static ETableModelClass *ets_parent_class; - -static void -ets_destroy (GtkObject *object) -{ - ETableSorted *ets = E_TABLE_SORTED (object); - - gtk_object_unref (GTK_OBJECT (ets->source)); - gtk_object_unref (GTK_OBJECT (ets->header)); - free (ets->map_table); - - GTK_OBJECT_CLASS (ets_parent_class)->destroy (object); -} - -static void -ets_class_init (GtkObjectClass *klass) -{ - ets_parent_class = gtk_type_class (PARENT_TYPE); - klass->destroy = ets_destroy; -} - -E_MAKE_TYPE(e_table_sorted, "ETableSorted", ETableSorted, ets_class_init, NULL, PARENT_TYPE); - -static ETableSorted *sort_ets; - -static int -my_sort (const void *a, const void *b) -{ - GCompareFunc comp; - const int *ia = (const int *) a; - const int *ib = (const int *) b; - void *va, *vb; - - va = e_table_model_value_at (sort_ets->source, sort_ets->sort_idx, *ia); - vb = e_table_model_value_at (sort_ets->source, sort_ets->sort_idx, *ib); - - comp = sort_ets->sort_col->compare; - - return (*comp) (va, vb); -} - -ETableModel * -e_table_sorted_new (ETableModel *source, ETableHeader *header, short sort_field) -{ - ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE); - const int nvals = e_table_model_row_count (source); - unsigned int *buffer; - int i; - - buffer = malloc (sizeof (unsigned int *) * nvals); - if (buffer = NULL) - return NULL; - ets->map_table = buffer; - ets->n_map = nvals; - ets->source = source; - ets->header = header; - ets->sort_col = e_table_header_get_column (header, sort_field); - ets->sort_idx = sort_field; - gtk_object_ref (GTK_OBJECT (source)); - gtk_object_ref (GTK_OBJECT (header)); - - /* Init */ - for (i = 0; i < nvals; i++) - ets->map_table [i] = i; - - /* Sort */ - g_assert (sort_ets == NULL); - sort_ets = ets; - qsort (ets->map_table, nvals, sizeof (unsigned int), my_sort); - sort_ets = NULL; - - return (ETableModel *) ets; -} - - diff --git a/widgets/table/e-table-sorted.h b/widgets/table/e-table-sorted.h deleted file mode 100644 index 65578b7b83..0000000000 --- a/widgets/table/e-table-sorted.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _E_TABLE_SORTED_H_ -#define _E_TABLE_SORTED_H_ - -#include <gtk/gtkobject.h> -#include "e-table-model.h" -#include "e-table-header.h" - -#define E_TABLE_SORTED_TYPE (e_table_sorted_get_type ()) -#define E_TABLE_SORTED(o) (GTK_CHECK_CAST ((o), E_TABLE_SORTED_TYPE, ETableSorted)) -#define E_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SORTED_TYPE, ETableSortedClass)) -#define E_IS_TABLE_SORTED(o) (GTK_CHECK_TYPE ((o), E_TABLE_SORTED_TYPE)) -#define E_IS_TABLE_SORTED_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SORTED_TYPE)) - -typedef struct { - ETableModel base; - - ETableModel *source; - ETableHeader *header; - ETableCol *sort_col; - short sort_idx; - - int n_map; - unsigned int *map_table; -} ETableSorted; - -typedef struct { - ETableModelClass parent_class; -} ETableSortedClass; - -GtkType e_table_sorted_get_type (void); -ETableModel *e_table_sorted_new (ETableModel *etm, ETableHeader *header, - short sort_field); - -#endif /* _E_TABLE_SORTED_H_ */ diff --git a/widgets/table/e-table-tree.h b/widgets/table/e-table-tree.h deleted file mode 100644 index e7e125a6af..0000000000 --- a/widgets/table/e-table-tree.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _E_TABLE_TREE_H_ -#define _E_TABLE_TREE_H_ - -typedef struct { - char *title; - - union { - ETableModel *table; - GList *children; - } u; - - guint expanded :1; - guint is_leaf :1; -} ETableGroup; - -ETableGroup *e_table_group_new (const char *title, ETableModel *table); -ETableGroup *e_table_group_new_leaf (const char *title); - -#endif /* _E_TABLE_TREE_H_ */ diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c deleted file mode 100644 index 427f527185..0000000000 --- a/widgets/table/e-table.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * E-table-view.c: A graphical view of a Table. - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * Copyright 1999, International GNOME Support - */ -#include <config.h> -#include <libgnomeui/gnome-canvas.h> -#include "e-table.h" - -#define PARENT_OBJECT_TYPE gnome_canvas_get_type () - -GtkType -e_table_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETable", - sizeof (ETable), - sizeof (ETableClass), - (GtkClassInitFunc) e_table_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_OBJECT_TYPE, &info); - } - - return type; -} diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h deleted file mode 100644 index 0847ddde6c..0000000000 --- a/widgets/table/e-table.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _E_TABLE_H_ -#define _E_TABLE_H_ - -GtkType e_table_get_type (void); -ETable * -#endif /* _E_TABLE_H_ */ diff --git a/widgets/table/sample.table b/widgets/table/sample.table deleted file mode 100644 index 2cb09d7f1f..0000000000 --- a/widgets/table/sample.table +++ /dev/null @@ -1,8 +0,0 @@ -Col1 Col2 Address Title Dorks -c1.a c2.a a.a tit-1 DorkA -c1.b c2.b a.b tit-2 DDork -c1.c c2.c a.c tit-1 DorkB -c1.d c2.d a.d tit-2 ADork -c1.e c2.e a.e tit-1 DorkC -c1.f c2.f a.f tit-2 UDork - diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c deleted file mode 100644 index d67a211094..0000000000 --- a/widgets/table/table-test.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Test code for the ETable package - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - */ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <gnome.h> -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-render.h" - -char buffer [1024]; -char **column_labels; -char ***table_data; -int cols = 0; -int lines = 0; -int lines_alloc = 0; - -static void -parse_headers () -{ - char *p, *s; - int in_value = 0, i; - - fgets (buffer, sizeof (buffer)-1, stdin); - - for (p = buffer; *p; p++){ - if (*p == ' ' || *p == '\t'){ - if (in_value){ - cols++; - in_value = 0; - } - } else - in_value = 1; - } - if (in_value) - cols++; - - if (!cols){ - fprintf (stderr, "No columns in first row\n"); - exit (1); - } - - column_labels = g_new0 (char *, cols); - - p = buffer; - for (i = 0; (s = strtok (p, " \t")) != NULL; i++){ - column_labels [i] = g_strdup (s); - p = NULL; - } - - printf ("%d headers:\n", cols); - for (i = 0; i < cols; i++){ - printf ("header %d: %s\n", i, column_labels [i]); - } -} - -static char ** -load_line (char *buffer, int cols) -{ - char **line = g_new0 (char *, cols); - char *p; - int i; - - for (i = 0; i < cols; i++){ - p = strtok (buffer, " \t\n"); - if (p == NULL){ - for (; i < cols; i++) - line [i] = g_strdup (""); - return line; - } else - line [i] = g_strdup (p); - buffer = NULL; - } - return line; -} - -static void -append_line (char **line) -{ - if (lines <= lines_alloc){ - lines_alloc = lines + 50; - table_data = g_renew (char **, table_data, lines_alloc); - } - table_data [lines] = line; - lines++; -} - -static void -load_data () -{ - int i; - - parse_headers (); - - while (fgets (buffer, sizeof (buffer)-1, stdin) != NULL){ - char **line; - - if (buffer [0] == '\n') - continue; - line = load_line (buffer, cols); - append_line (line); - } - - for (i = 0; i < lines; i++){ - int j; - - printf ("Line %d: ", i); - for (j = 0; j < cols; j++) - printf ("[%s] ", table_data [i][j]); - printf ("\n"); - } -} - -/* - * ETableSimple callbacks - */ -static int -col_count (ETableModel *etc, void *data) -{ - return cols; -} - -static const char * -col_name (ETableModel *etc, int col, void *data) -{ - g_assert (col < cols); - - return column_labels [col]; -} - -static int -row_count (ETableModel *etc, void *data) -{ - return lines; -} - -static void * -value_at (ETableModel *etc, int col, int row, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - return (void *) &table_data [row][col]; -} - -static void -set_value_at (ETableModel *etc, int col, int row, void *val, void *data) -{ - g_assert (col < cols); - g_assert (row < lines); - - g_free (table_data [row][col]); - table_data [row][col] = g_strdup (val); - - printf ("Value at %d,%d set to %s\n", col, row, val); -} - -static gboolean -is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -static void -set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) -{ - gnome_canvas_set_scroll_region (canvas, 0, 0, alloc->width, alloc->height); -} - -int -main (int argc, char *argv []) -{ - GtkWidget *canvas, *window; - ETableModel *e_table_model; - ETableHeader *e_table_header; - int i; - - gnome_init ("TableTest", "TableTest", argc, argv); - e_cursors_init (); - - load_data (); - - /* - * Data model - */ - e_table_model = e_table_simple_new ( - col_count, col_name, row_count, value_at, - set_value_at, is_cell_editable, NULL); - - /* - * Header - */ - e_table_header = e_table_header_new (); - for (i = 0; i < cols; i++){ - ETableCol *ecol = e_table_col_new ( - column_labels [i], 80, 20, e_table_render_string, - NULL, g_str_equal, TRUE); - - e_table_header_add_column (e_table_header, ecol, i); - } - - /* - * Setup GUI - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - canvas = gnome_canvas_new (); - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - GTK_SIGNAL_FUNC (set_canvas_size), NULL); - - gtk_container_add (GTK_CONTAINER (window), canvas); - gtk_widget_show_all (window); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - e_table_header_item_get_type (), - "ETableHeader", e_table_header, - NULL); - gnome_canvas_item_new ( - gnome_canvas_root (GNOME_CANVAS (canvas)), - gnome_canvas_rect_get_type (), - "x1", 0.0, - "y1", 0.0, - "x2", 10.0, - "y2", 10.0, - "fill_color", "red", - NULL); - gtk_main (); - - e_cursors_shutdown (); - return 0; -} diff --git a/widgets/table/test.c b/widgets/table/test.c deleted file mode 100644 index 0eece34467..0000000000 --- a/widgets/table/test.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <config.h> -#include "e-table-simple.h" - -struct { - char *str; - int val; -} data [] = { - { "Miguel", 10 }, - { "Nat", 20 }, - { NULL, 0 }, -}; - -main () -{ - -} - |