aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnu.org>1999-12-02 02:18:35 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-12-02 02:18:35 +0800
commit9c0f9f1264f8083d177a01bf01e75e8787d587ed (patch)
tree5a966e5e5a992eb4ab01c20ddf7b203db454c97d /widgets
parent5dd5e9ffe2ba0c27c22281ebe62f9a565d184c38 (diff)
downloadgsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.tar
gsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.tar.gz
gsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.tar.bz2
gsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.tar.lz
gsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.tar.xz
gsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.tar.zst
gsoc2013-evolution-9c0f9f1264f8083d177a01bf01e75e8787d587ed.zip
Removed change cursor from here.
1999-12-01 Miguel de Icaza <miguel@gnu.org> * e-table-header-item.c (ethi_unrealize): Removed change cursor from here. * e-cell-text.c (ect_draw): Memory leak fix. * table-test.c (main): Enhance the demo to load sample.table automatically, to get memprof working. * e-table-header.c (eth_do_remove): Take an argument: do -remove. * e-table-header.c (e_table_header_add_column): Sink ETableCol to own the object. * e-table-col.h: Made ETableCol a GtkObject to make reference counting the lifecycle method for these objects. * e-table-col.c (e_table_col_destroy): New API call. * e-table-subset.c (e_table_subset_get_toplevel): New API call. svn path=/trunk/; revision=1450
Diffstat (limited to 'widgets')
-rw-r--r--widgets/ChangeLog22
-rw-r--r--widgets/e-cell-text.c1
-rw-r--r--widgets/e-table-col.c32
-rw-r--r--widgets/e-table-col.h37
-rw-r--r--widgets/e-table-header-item.c3
-rw-r--r--widgets/e-table-header.c20
-rw-r--r--widgets/e-table-subset.c11
-rw-r--r--widgets/e-table-subset.h2
-rw-r--r--widgets/e-table/ChangeLog22
-rw-r--r--widgets/e-table/e-cell-text.c1
-rw-r--r--widgets/e-table/e-table-col.c32
-rw-r--r--widgets/e-table/e-table-col.h37
-rw-r--r--widgets/e-table/e-table-header-item.c3
-rw-r--r--widgets/e-table/e-table-header.c20
-rw-r--r--widgets/e-table/e-table-subset.c11
-rw-r--r--widgets/e-table/e-table-subset.h2
-rw-r--r--widgets/e-table/table-test.c12
-rw-r--r--widgets/e-table/test-check.c4
-rw-r--r--widgets/e-table/test-cols.c7
-rw-r--r--widgets/e-table/test-table.c3
-rw-r--r--widgets/table-test.c12
-rw-r--r--widgets/table/e-cell-text.c1
-rw-r--r--widgets/table/e-table-col.c32
-rw-r--r--widgets/table/e-table-col.h37
-rw-r--r--widgets/table/e-table-header-item.c3
-rw-r--r--widgets/table/e-table-header.c20
-rw-r--r--widgets/table/e-table-subset.c11
-rw-r--r--widgets/table/e-table-subset.h2
-rw-r--r--widgets/table/table-test.c12
-rw-r--r--widgets/table/test-check.c4
-rw-r--r--widgets/table/test-cols.c7
-rw-r--r--widgets/table/test-table.c3
-rw-r--r--widgets/test-check.c4
-rw-r--r--widgets/test-cols.c7
-rw-r--r--widgets/test-table.c3
35 files changed, 353 insertions, 87 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog
index d1a58f7022..1317034e74 100644
--- a/widgets/ChangeLog
+++ b/widgets/ChangeLog
@@ -1,3 +1,25 @@
+1999-12-01 Miguel de Icaza <miguel@gnu.org>
+
+ * e-table-header-item.c (ethi_unrealize): Removed change cursor
+ from here.
+
+ * e-cell-text.c (ect_draw): Memory leak fix.
+
+ * table-test.c (main): Enhance the demo to load sample.table
+ automatically, to get memprof working.
+
+ * e-table-header.c (eth_do_remove): Take an argument: do -remove.
+
+ * e-table-header.c (e_table_header_add_column): Sink ETableCol to
+ own the object.
+
+ * e-table-col.h: Made ETableCol a GtkObject to make reference
+ counting the lifecycle method for these objects.
+
+ * e-table-col.c (e_table_col_destroy): New API call.
+
+ * e-table-subset.c (e_table_subset_get_toplevel): New API call.
+
1999-11-30 Miguel de Icaza <miguel@gnu.org>
* e-cell-checkbox.c (e_cell_checkbox_new): This one derives from
diff --git a/widgets/e-cell-text.c b/widgets/e-cell-text.c
index b18c179ca5..78ba01e2ed 100644
--- a/widgets/e-cell-text.c
+++ b/widgets/e-cell-text.c
@@ -241,6 +241,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
px, y + font->descent - 1);
}
}
+ g_free (text_wc);
} else {
/*
* Regular cell
diff --git a/widgets/e-table-col.c b/widgets/e-table-col.c
index 3d940fce04..cca7bd13d6 100644
--- a/widgets/e-table-col.c
+++ b/widgets/e-table-col.c
@@ -10,9 +10,35 @@
#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include "e-table-col.h"
+#include "e-util.h"
+
+#define PARENT_TYPE (gtk_object_get_type ())
+
+static GtkObjectClass *parent_class;
+
+static void
+etc_destroy (GtkObject *object)
+{
+ ETableCol *etc = E_TABLE_COL (object);
+
+ printf ("Destroying columns: %s %s\n", etc->id, etc->text);
+ g_free (etc->id);
+ g_free (etc->text);
+
+ (*parent_class->destroy)(object);
+}
+
+static void
+e_table_col_class_init (GtkObjectClass *object_class)
+{
+ parent_class = gtk_type_class (PARENT_TYPE);
+ object_class->destroy = etc_destroy;
+}
+
+E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE);
ETableCol *
-e_table_col_new (const char *id, int width, int min_width,
+e_table_col_new (const char *id, const char *text, int width, int min_width,
ECell *ecell, GCompareFunc compare, gboolean resizable)
{
ETableCol *etc;
@@ -23,9 +49,10 @@ e_table_col_new (const char *id, int width, int min_width,
g_return_val_if_fail (width >= min_width, NULL);
g_return_val_if_fail (compare != NULL, NULL);
- etc = g_new (ETableCol, 1);
+ etc = gtk_type_new (E_TABLE_COL_TYPE);
etc->id = g_strdup (id);
+ etc->text = g_strdup (text);
etc->width = width;
etc->min_width = min_width;
etc->ecell = ecell;
@@ -38,4 +65,3 @@ e_table_col_new (const char *id, int width, int min_width,
}
-
diff --git a/widgets/e-table-col.h b/widgets/e-table-col.h
index 582c4eb383..c8fa6dd581 100644
--- a/widgets/e-table-col.h
+++ b/widgets/e-table-col.h
@@ -3,27 +3,42 @@
#include "e-cell.h"
+#define E_TABLE_COL_TYPE (e_table_col_get_type ())
+#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol))
+#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass))
+#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE))
+#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
+
typedef struct _ETableCol ETableCol;
/*
* Information about a single column
*/
struct _ETableCol {
- char *id;
- short width;
- short min_width;
- short x;
- GCompareFunc compare;
- unsigned int selected:1;
- unsigned int resizeable:1;
+ GtkObject base;
+ char *id, *text;
+ short width;
+ short min_width;
+ short x;
+ GCompareFunc compare;
+ unsigned int selected:1;
+ unsigned int resizeable:1;
+
ECell *ecell;
};
-ETableCol *e_table_col_new (const char *id, int width, int min_width,
- ECell *ecell, GCompareFunc compare,
- gboolean resizable);
-
+typedef struct {
+ GtkObjectClass parent_class;
+} ETableColClass;
+
+GtkType e_table_col_get_type (void);
+ETableCol *e_table_col_new (const char *id, const char *text,
+ int width, int min_width,
+ ECell *ecell, GCompareFunc compare,
+ gboolean resizable);
+void e_table_col_destroy (ETableCol *etc);
+
#endif /* _E_TABLE_COL_H_ */
diff --git a/widgets/e-table-header-item.c b/widgets/e-table-header-item.c
index 52e01abef6..378bdf4447 100644
--- a/widgets/e-table-header-item.c
+++ b/widgets/e-table-header-item.c
@@ -181,9 +181,6 @@ ethi_unrealize (GnomeCanvasItem *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;
diff --git a/widgets/e-table-header.c b/widgets/e-table-header.c
index 5900c5ca4f..e91113bbb9 100644
--- a/widgets/e-table-header.c
+++ b/widgets/e-table-header.c
@@ -31,8 +31,9 @@ e_table_header_destroy (GtkObject *object)
/*
* Destroy columns
*/
- for (i = 0; i < cols; i++)
+ 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);
@@ -124,11 +125,19 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
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 (E_IS_TABLE_COL (tc));
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));
+
+ /*
+ * We are the primary owners of the column
+ */
+ gtk_object_ref (GTK_OBJECT (tc));
+ gtk_object_sink (GTK_OBJECT (tc));
+
eth_do_insert (eth, pos, tc);
eth->col_count++;
eth_update_offsets (eth);
@@ -255,8 +264,11 @@ e_table_header_total_width (ETableHeader *eth)
}
static void
-eth_do_remove (ETableHeader *eth, int idx)
+eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref)
{
+ if (do_unref)
+ gtk_object_unref (GTK_OBJECT (eth->columns [idx]));
+
memcpy (&eth->columns [idx], &eth->columns [idx+1],
sizeof (ETableCol *) * eth->col_count - idx);
eth->col_count--;
@@ -275,7 +287,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
g_return_if_fail (target_index < eth->col_count);
old = eth->columns [source_index];
- eth_do_remove (eth, source_index);
+ eth_do_remove (eth, source_index, FALSE);
eth_do_insert (eth, target_index, old);
eth_update_offsets (eth);
@@ -290,7 +302,7 @@ e_table_header_remove (ETableHeader *eth, int idx)
g_return_if_fail (idx >= 0);
g_return_if_fail (idx < eth->col_count);
- eth_do_remove (eth, idx);
+ eth_do_remove (eth, idx, TRUE);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
}
diff --git a/widgets/e-table-subset.c b/widgets/e-table-subset.c
index afa1b862b4..41763d309b 100644
--- a/widgets/e-table-subset.c
+++ b/widgets/e-table-subset.c
@@ -138,3 +138,14 @@ e_table_subset_new (ETableModel *source, const int nvals)
return (ETableModel *) etss;
}
+ETableModel *
+e_table_subset_get_toplevel (ETableSubset *table)
+{
+ g_return_val_if_fail (table != NULL, NULL);
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL);
+
+ if (E_IS_TABLE_SUBSET (table->source))
+ return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source));
+ else
+ return table->subset;
+}
diff --git a/widgets/e-table-subset.h b/widgets/e-table-subset.h
index 5576c55f1d..66d11e9658 100644
--- a/widgets/e-table-subset.h
+++ b/widgets/e-table-subset.h
@@ -26,4 +26,6 @@ GtkType e_table_subset_get_type (void);
ETableModel *e_table_subset_new (ETableModel *etm, int n_vals);
ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals);
+ETableModel *e_table_subset_get_toplevel (ETableModel *table_model);
+
#endif /* _E_TABLE_SUBSET_H_ */
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index d1a58f7022..1317034e74 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,25 @@
+1999-12-01 Miguel de Icaza <miguel@gnu.org>
+
+ * e-table-header-item.c (ethi_unrealize): Removed change cursor
+ from here.
+
+ * e-cell-text.c (ect_draw): Memory leak fix.
+
+ * table-test.c (main): Enhance the demo to load sample.table
+ automatically, to get memprof working.
+
+ * e-table-header.c (eth_do_remove): Take an argument: do -remove.
+
+ * e-table-header.c (e_table_header_add_column): Sink ETableCol to
+ own the object.
+
+ * e-table-col.h: Made ETableCol a GtkObject to make reference
+ counting the lifecycle method for these objects.
+
+ * e-table-col.c (e_table_col_destroy): New API call.
+
+ * e-table-subset.c (e_table_subset_get_toplevel): New API call.
+
1999-11-30 Miguel de Icaza <miguel@gnu.org>
* e-cell-checkbox.c (e_cell_checkbox_new): This one derives from
diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c
index b18c179ca5..78ba01e2ed 100644
--- a/widgets/e-table/e-cell-text.c
+++ b/widgets/e-table/e-cell-text.c
@@ -241,6 +241,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
px, y + font->descent - 1);
}
}
+ g_free (text_wc);
} else {
/*
* Regular cell
diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c
index 3d940fce04..cca7bd13d6 100644
--- a/widgets/e-table/e-table-col.c
+++ b/widgets/e-table/e-table-col.c
@@ -10,9 +10,35 @@
#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include "e-table-col.h"
+#include "e-util.h"
+
+#define PARENT_TYPE (gtk_object_get_type ())
+
+static GtkObjectClass *parent_class;
+
+static void
+etc_destroy (GtkObject *object)
+{
+ ETableCol *etc = E_TABLE_COL (object);
+
+ printf ("Destroying columns: %s %s\n", etc->id, etc->text);
+ g_free (etc->id);
+ g_free (etc->text);
+
+ (*parent_class->destroy)(object);
+}
+
+static void
+e_table_col_class_init (GtkObjectClass *object_class)
+{
+ parent_class = gtk_type_class (PARENT_TYPE);
+ object_class->destroy = etc_destroy;
+}
+
+E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE);
ETableCol *
-e_table_col_new (const char *id, int width, int min_width,
+e_table_col_new (const char *id, const char *text, int width, int min_width,
ECell *ecell, GCompareFunc compare, gboolean resizable)
{
ETableCol *etc;
@@ -23,9 +49,10 @@ e_table_col_new (const char *id, int width, int min_width,
g_return_val_if_fail (width >= min_width, NULL);
g_return_val_if_fail (compare != NULL, NULL);
- etc = g_new (ETableCol, 1);
+ etc = gtk_type_new (E_TABLE_COL_TYPE);
etc->id = g_strdup (id);
+ etc->text = g_strdup (text);
etc->width = width;
etc->min_width = min_width;
etc->ecell = ecell;
@@ -38,4 +65,3 @@ e_table_col_new (const char *id, int width, int min_width,
}
-
diff --git a/widgets/e-table/e-table-col.h b/widgets/e-table/e-table-col.h
index 582c4eb383..c8fa6dd581 100644
--- a/widgets/e-table/e-table-col.h
+++ b/widgets/e-table/e-table-col.h
@@ -3,27 +3,42 @@
#include "e-cell.h"
+#define E_TABLE_COL_TYPE (e_table_col_get_type ())
+#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol))
+#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass))
+#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE))
+#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
+
typedef struct _ETableCol ETableCol;
/*
* Information about a single column
*/
struct _ETableCol {
- char *id;
- short width;
- short min_width;
- short x;
- GCompareFunc compare;
- unsigned int selected:1;
- unsigned int resizeable:1;
+ GtkObject base;
+ char *id, *text;
+ short width;
+ short min_width;
+ short x;
+ GCompareFunc compare;
+ unsigned int selected:1;
+ unsigned int resizeable:1;
+
ECell *ecell;
};
-ETableCol *e_table_col_new (const char *id, int width, int min_width,
- ECell *ecell, GCompareFunc compare,
- gboolean resizable);
-
+typedef struct {
+ GtkObjectClass parent_class;
+} ETableColClass;
+
+GtkType e_table_col_get_type (void);
+ETableCol *e_table_col_new (const char *id, const char *text,
+ int width, int min_width,
+ ECell *ecell, GCompareFunc compare,
+ gboolean resizable);
+void e_table_col_destroy (ETableCol *etc);
+
#endif /* _E_TABLE_COL_H_ */
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index 52e01abef6..378bdf4447 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -181,9 +181,6 @@ ethi_unrealize (GnomeCanvasItem *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;
diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c
index 5900c5ca4f..e91113bbb9 100644
--- a/widgets/e-table/e-table-header.c
+++ b/widgets/e-table/e-table-header.c
@@ -31,8 +31,9 @@ e_table_header_destroy (GtkObject *object)
/*
* Destroy columns
*/
- for (i = 0; i < cols; i++)
+ 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);
@@ -124,11 +125,19 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
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 (E_IS_TABLE_COL (tc));
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));
+
+ /*
+ * We are the primary owners of the column
+ */
+ gtk_object_ref (GTK_OBJECT (tc));
+ gtk_object_sink (GTK_OBJECT (tc));
+
eth_do_insert (eth, pos, tc);
eth->col_count++;
eth_update_offsets (eth);
@@ -255,8 +264,11 @@ e_table_header_total_width (ETableHeader *eth)
}
static void
-eth_do_remove (ETableHeader *eth, int idx)
+eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref)
{
+ if (do_unref)
+ gtk_object_unref (GTK_OBJECT (eth->columns [idx]));
+
memcpy (&eth->columns [idx], &eth->columns [idx+1],
sizeof (ETableCol *) * eth->col_count - idx);
eth->col_count--;
@@ -275,7 +287,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
g_return_if_fail (target_index < eth->col_count);
old = eth->columns [source_index];
- eth_do_remove (eth, source_index);
+ eth_do_remove (eth, source_index, FALSE);
eth_do_insert (eth, target_index, old);
eth_update_offsets (eth);
@@ -290,7 +302,7 @@ e_table_header_remove (ETableHeader *eth, int idx)
g_return_if_fail (idx >= 0);
g_return_if_fail (idx < eth->col_count);
- eth_do_remove (eth, idx);
+ eth_do_remove (eth, idx, TRUE);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
}
diff --git a/widgets/e-table/e-table-subset.c b/widgets/e-table/e-table-subset.c
index afa1b862b4..41763d309b 100644
--- a/widgets/e-table/e-table-subset.c
+++ b/widgets/e-table/e-table-subset.c
@@ -138,3 +138,14 @@ e_table_subset_new (ETableModel *source, const int nvals)
return (ETableModel *) etss;
}
+ETableModel *
+e_table_subset_get_toplevel (ETableSubset *table)
+{
+ g_return_val_if_fail (table != NULL, NULL);
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL);
+
+ if (E_IS_TABLE_SUBSET (table->source))
+ return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source));
+ else
+ return table->subset;
+}
diff --git a/widgets/e-table/e-table-subset.h b/widgets/e-table/e-table-subset.h
index 5576c55f1d..66d11e9658 100644
--- a/widgets/e-table/e-table-subset.h
+++ b/widgets/e-table/e-table-subset.h
@@ -26,4 +26,6 @@ GtkType e_table_subset_get_type (void);
ETableModel *e_table_subset_new (ETableModel *etm, int n_vals);
ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals);
+ETableModel *e_table_subset_get_toplevel (ETableModel *table_model);
+
#endif /* _E_TABLE_SUBSET_H_ */
diff --git a/widgets/e-table/table-test.c b/widgets/e-table/table-test.c
index 706dec437c..32d726dd06 100644
--- a/widgets/e-table/table-test.c
+++ b/widgets/e-table/table-test.c
@@ -7,6 +7,7 @@
#include <config.h>
#include <stdio.h>
#include <string.h>
+#include <fcntl.h>
#include <gnome.h>
int
@@ -14,8 +15,15 @@ main (int argc, char *argv [])
{
if (isatty (0)){
- printf ("you have to provide data on standard input\n");
- exit (1);
+ int fd;
+
+ close (0);
+ fd = open ("sample.table", O_RDONLY);
+ if (fd == -1){
+ fprintf (stderr, "Could not find sample.table, try feeding a table on stdin");
+ exit (1);
+ }
+ dup2 (fd, 0);
}
gnome_init ("TableTest", "TableTest", argc, argv);
diff --git a/widgets/e-table/test-check.c b/widgets/e-table/test-check.c
index 49c7f44f70..4573580562 100644
--- a/widgets/e-table/test-check.c
+++ b/widgets/e-table/test-check.c
@@ -118,10 +118,10 @@ check_test (void)
cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
cell_image_check = e_cell_checkbox_new (e_table_model);
- col_0 = e_table_col_new ("", 18, 18, cell_image_check, g_int_equal, TRUE);
+ col_0 = e_table_col_new ("id", "", 18, 18, cell_image_check, g_int_equal, TRUE);
e_table_header_add_column (e_table_header, col_0, 0);
- col_1 = e_table_col_new ("Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
+ col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
/*
diff --git a/widgets/e-table/test-cols.c b/widgets/e-table/test-cols.c
index f8fb01081f..c4ce0e1b75 100644
--- a/widgets/e-table/test-cols.c
+++ b/widgets/e-table/test-cols.c
@@ -133,12 +133,13 @@ multi_cols_test (void)
g_free (images);
}
- col_0 = e_table_col_new ("A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
+ col_0 = e_table_col_new ("id", "A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
e_table_header_add_column (e_table_header, col_0, 0);
-
- col_1 = e_table_col_new ("Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
+
+ col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
+
/*
* GUI
*/
diff --git a/widgets/e-table/test-table.c b/widgets/e-table/test-table.c
index 56cdd0f208..be1a1059db 100644
--- a/widgets/e-table/test-table.c
+++ b/widgets/e-table/test-table.c
@@ -200,7 +200,8 @@ table_browser_test (void)
for (i = 0; i < cols; i++){
ETableCol *ecol = e_table_col_new (
- column_labels [i], 80, 20, cell_left_just,
+ column_labels [i], column_labels [i],
+ 80, 20, cell_left_just,
g_str_equal, TRUE);
e_table_header_add_column (e_table_header, ecol, i);
diff --git a/widgets/table-test.c b/widgets/table-test.c
index 706dec437c..32d726dd06 100644
--- a/widgets/table-test.c
+++ b/widgets/table-test.c
@@ -7,6 +7,7 @@
#include <config.h>
#include <stdio.h>
#include <string.h>
+#include <fcntl.h>
#include <gnome.h>
int
@@ -14,8 +15,15 @@ main (int argc, char *argv [])
{
if (isatty (0)){
- printf ("you have to provide data on standard input\n");
- exit (1);
+ int fd;
+
+ close (0);
+ fd = open ("sample.table", O_RDONLY);
+ if (fd == -1){
+ fprintf (stderr, "Could not find sample.table, try feeding a table on stdin");
+ exit (1);
+ }
+ dup2 (fd, 0);
}
gnome_init ("TableTest", "TableTest", argc, argv);
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index b18c179ca5..78ba01e2ed 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -241,6 +241,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
px, y + font->descent - 1);
}
}
+ g_free (text_wc);
} else {
/*
* Regular cell
diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c
index 3d940fce04..cca7bd13d6 100644
--- a/widgets/table/e-table-col.c
+++ b/widgets/table/e-table-col.c
@@ -10,9 +10,35 @@
#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include "e-table-col.h"
+#include "e-util.h"
+
+#define PARENT_TYPE (gtk_object_get_type ())
+
+static GtkObjectClass *parent_class;
+
+static void
+etc_destroy (GtkObject *object)
+{
+ ETableCol *etc = E_TABLE_COL (object);
+
+ printf ("Destroying columns: %s %s\n", etc->id, etc->text);
+ g_free (etc->id);
+ g_free (etc->text);
+
+ (*parent_class->destroy)(object);
+}
+
+static void
+e_table_col_class_init (GtkObjectClass *object_class)
+{
+ parent_class = gtk_type_class (PARENT_TYPE);
+ object_class->destroy = etc_destroy;
+}
+
+E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, NULL, PARENT_TYPE);
ETableCol *
-e_table_col_new (const char *id, int width, int min_width,
+e_table_col_new (const char *id, const char *text, int width, int min_width,
ECell *ecell, GCompareFunc compare, gboolean resizable)
{
ETableCol *etc;
@@ -23,9 +49,10 @@ e_table_col_new (const char *id, int width, int min_width,
g_return_val_if_fail (width >= min_width, NULL);
g_return_val_if_fail (compare != NULL, NULL);
- etc = g_new (ETableCol, 1);
+ etc = gtk_type_new (E_TABLE_COL_TYPE);
etc->id = g_strdup (id);
+ etc->text = g_strdup (text);
etc->width = width;
etc->min_width = min_width;
etc->ecell = ecell;
@@ -38,4 +65,3 @@ e_table_col_new (const char *id, int width, int min_width,
}
-
diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h
index 582c4eb383..c8fa6dd581 100644
--- a/widgets/table/e-table-col.h
+++ b/widgets/table/e-table-col.h
@@ -3,27 +3,42 @@
#include "e-cell.h"
+#define E_TABLE_COL_TYPE (e_table_col_get_type ())
+#define E_TABLE_COL(o) (GTK_CHECK_CAST ((o), E_TABLE_COL_TYPE, ETableCol))
+#define E_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_COL_TYPE, ETableColClass))
+#define E_IS_TABLE_COL(o) (GTK_CHECK_TYPE ((o), E_TABLE_COL_TYPE))
+#define E_IS_TABLE_COL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_COL_TYPE))
+
typedef struct _ETableCol ETableCol;
/*
* Information about a single column
*/
struct _ETableCol {
- char *id;
- short width;
- short min_width;
- short x;
- GCompareFunc compare;
- unsigned int selected:1;
- unsigned int resizeable:1;
+ GtkObject base;
+ char *id, *text;
+ short width;
+ short min_width;
+ short x;
+ GCompareFunc compare;
+ unsigned int selected:1;
+ unsigned int resizeable:1;
+
ECell *ecell;
};
-ETableCol *e_table_col_new (const char *id, int width, int min_width,
- ECell *ecell, GCompareFunc compare,
- gboolean resizable);
-
+typedef struct {
+ GtkObjectClass parent_class;
+} ETableColClass;
+
+GtkType e_table_col_get_type (void);
+ETableCol *e_table_col_new (const char *id, const char *text,
+ int width, int min_width,
+ ECell *ecell, GCompareFunc compare,
+ gboolean resizable);
+void e_table_col_destroy (ETableCol *etc);
+
#endif /* _E_TABLE_COL_H_ */
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index 52e01abef6..378bdf4447 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -181,9 +181,6 @@ ethi_unrealize (GnomeCanvasItem *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;
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index 5900c5ca4f..e91113bbb9 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -31,8 +31,9 @@ e_table_header_destroy (GtkObject *object)
/*
* Destroy columns
*/
- for (i = 0; i < cols; i++)
+ 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);
@@ -124,11 +125,19 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
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 (E_IS_TABLE_COL (tc));
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));
+
+ /*
+ * We are the primary owners of the column
+ */
+ gtk_object_ref (GTK_OBJECT (tc));
+ gtk_object_sink (GTK_OBJECT (tc));
+
eth_do_insert (eth, pos, tc);
eth->col_count++;
eth_update_offsets (eth);
@@ -255,8 +264,11 @@ e_table_header_total_width (ETableHeader *eth)
}
static void
-eth_do_remove (ETableHeader *eth, int idx)
+eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref)
{
+ if (do_unref)
+ gtk_object_unref (GTK_OBJECT (eth->columns [idx]));
+
memcpy (&eth->columns [idx], &eth->columns [idx+1],
sizeof (ETableCol *) * eth->col_count - idx);
eth->col_count--;
@@ -275,7 +287,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
g_return_if_fail (target_index < eth->col_count);
old = eth->columns [source_index];
- eth_do_remove (eth, source_index);
+ eth_do_remove (eth, source_index, FALSE);
eth_do_insert (eth, target_index, old);
eth_update_offsets (eth);
@@ -290,7 +302,7 @@ e_table_header_remove (ETableHeader *eth, int idx)
g_return_if_fail (idx >= 0);
g_return_if_fail (idx < eth->col_count);
- eth_do_remove (eth, idx);
+ eth_do_remove (eth, idx, TRUE);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
}
diff --git a/widgets/table/e-table-subset.c b/widgets/table/e-table-subset.c
index afa1b862b4..41763d309b 100644
--- a/widgets/table/e-table-subset.c
+++ b/widgets/table/e-table-subset.c
@@ -138,3 +138,14 @@ e_table_subset_new (ETableModel *source, const int nvals)
return (ETableModel *) etss;
}
+ETableModel *
+e_table_subset_get_toplevel (ETableSubset *table)
+{
+ g_return_val_if_fail (table != NULL, NULL);
+ g_return_val_if_fail (E_IS_TABLE_SUBSET (table), NULL);
+
+ if (E_IS_TABLE_SUBSET (table->source))
+ return e_table_subset_get_toplevel (E_TABLE_SUBSET (table->source));
+ else
+ return table->subset;
+}
diff --git a/widgets/table/e-table-subset.h b/widgets/table/e-table-subset.h
index 5576c55f1d..66d11e9658 100644
--- a/widgets/table/e-table-subset.h
+++ b/widgets/table/e-table-subset.h
@@ -26,4 +26,6 @@ GtkType e_table_subset_get_type (void);
ETableModel *e_table_subset_new (ETableModel *etm, int n_vals);
ETableModel *e_table_subset_construct (ETableSubset *ets, ETableModel *source, int nvals);
+ETableModel *e_table_subset_get_toplevel (ETableModel *table_model);
+
#endif /* _E_TABLE_SUBSET_H_ */
diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c
index 706dec437c..32d726dd06 100644
--- a/widgets/table/table-test.c
+++ b/widgets/table/table-test.c
@@ -7,6 +7,7 @@
#include <config.h>
#include <stdio.h>
#include <string.h>
+#include <fcntl.h>
#include <gnome.h>
int
@@ -14,8 +15,15 @@ main (int argc, char *argv [])
{
if (isatty (0)){
- printf ("you have to provide data on standard input\n");
- exit (1);
+ int fd;
+
+ close (0);
+ fd = open ("sample.table", O_RDONLY);
+ if (fd == -1){
+ fprintf (stderr, "Could not find sample.table, try feeding a table on stdin");
+ exit (1);
+ }
+ dup2 (fd, 0);
}
gnome_init ("TableTest", "TableTest", argc, argv);
diff --git a/widgets/table/test-check.c b/widgets/table/test-check.c
index 49c7f44f70..4573580562 100644
--- a/widgets/table/test-check.c
+++ b/widgets/table/test-check.c
@@ -118,10 +118,10 @@ check_test (void)
cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
cell_image_check = e_cell_checkbox_new (e_table_model);
- col_0 = e_table_col_new ("", 18, 18, cell_image_check, g_int_equal, TRUE);
+ col_0 = e_table_col_new ("id", "", 18, 18, cell_image_check, g_int_equal, TRUE);
e_table_header_add_column (e_table_header, col_0, 0);
- col_1 = e_table_col_new ("Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
+ col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
/*
diff --git a/widgets/table/test-cols.c b/widgets/table/test-cols.c
index f8fb01081f..c4ce0e1b75 100644
--- a/widgets/table/test-cols.c
+++ b/widgets/table/test-cols.c
@@ -133,12 +133,13 @@ multi_cols_test (void)
g_free (images);
}
- col_0 = e_table_col_new ("A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
+ col_0 = e_table_col_new ("id", "A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
e_table_header_add_column (e_table_header, col_0, 0);
-
- col_1 = e_table_col_new ("Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
+
+ col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
+
/*
* GUI
*/
diff --git a/widgets/table/test-table.c b/widgets/table/test-table.c
index 56cdd0f208..be1a1059db 100644
--- a/widgets/table/test-table.c
+++ b/widgets/table/test-table.c
@@ -200,7 +200,8 @@ table_browser_test (void)
for (i = 0; i < cols; i++){
ETableCol *ecol = e_table_col_new (
- column_labels [i], 80, 20, cell_left_just,
+ column_labels [i], column_labels [i],
+ 80, 20, cell_left_just,
g_str_equal, TRUE);
e_table_header_add_column (e_table_header, ecol, i);
diff --git a/widgets/test-check.c b/widgets/test-check.c
index 49c7f44f70..4573580562 100644
--- a/widgets/test-check.c
+++ b/widgets/test-check.c
@@ -118,10 +118,10 @@ check_test (void)
cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT);
cell_image_check = e_cell_checkbox_new (e_table_model);
- col_0 = e_table_col_new ("", 18, 18, cell_image_check, g_int_equal, TRUE);
+ col_0 = e_table_col_new ("id", "", 18, 18, cell_image_check, g_int_equal, TRUE);
e_table_header_add_column (e_table_header, col_0, 0);
- col_1 = e_table_col_new ("Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
+ col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
/*
diff --git a/widgets/test-cols.c b/widgets/test-cols.c
index f8fb01081f..c4ce0e1b75 100644
--- a/widgets/test-cols.c
+++ b/widgets/test-cols.c
@@ -133,12 +133,13 @@ multi_cols_test (void)
g_free (images);
}
- col_0 = e_table_col_new ("A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
+ col_0 = e_table_col_new ("id", "A", 48, 48, cell_image_toggle, g_int_equal, TRUE);
e_table_header_add_column (e_table_header, col_0, 0);
-
- col_1 = e_table_col_new ("Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
+
+ col_1 = e_table_col_new ("item", "Item Name", 180, 20, cell_left_just, g_str_equal, TRUE);
e_table_header_add_column (e_table_header, col_1, 1);
+
/*
* GUI
*/
diff --git a/widgets/test-table.c b/widgets/test-table.c
index 56cdd0f208..be1a1059db 100644
--- a/widgets/test-table.c
+++ b/widgets/test-table.c
@@ -200,7 +200,8 @@ table_browser_test (void)
for (i = 0; i < cols; i++){
ETableCol *ecol = e_table_col_new (
- column_labels [i], 80, 20, cell_left_just,
+ column_labels [i], column_labels [i],
+ 80, 20, cell_left_just,
g_str_equal, TRUE);
e_table_header_add_column (e_table_header, ecol, i);