aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog11
-rw-r--r--widgets/e-table/e-table-group-container.c8
-rw-r--r--widgets/e-table/e-table-group-leaf.c10
-rw-r--r--widgets/e-table/e-table-group.c21
-rw-r--r--widgets/e-table/e-table-group.h6
-rw-r--r--widgets/e-table/e-table.c32
-rw-r--r--widgets/e-table/e-table.h2
-rw-r--r--widgets/e-table/test-table.c11
8 files changed, 100 insertions, 1 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 9a074a3e8b..705432b19e 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,14 @@
+2000-03-06 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table.c, e-table.h: Add a "row_selection" signal.
+
+ * test-table.c: Test the new "row_selection" signal.
+
+ * e-table-group-container.c, e-table-group-leaf.c: Implement the
+ "row_selection" property properly.
+
+ * e-table-group.c, e-table-group.h: Add a "row_selection" signal.
+
2000-03-05 Christopher James Lahey <clahey@helixcode.com>
* e-table.c, e-table.h: Added support for the sorting info. The
diff --git a/widgets/e-table/e-table-group-container.c b/widgets/e-table/e-table-group-container.c
index 1ae73b6c3b..589b59c976 100644
--- a/widgets/e-table/e-table-group-container.c
+++ b/widgets/e-table/e-table-group-container.c
@@ -526,6 +526,12 @@ compute_text (ETableGroupContainer *etgc, ETableGroupContainerChildNode *child_n
g_free(text);
}
+static void
+child_row_selection (ETableGroup *etg, int row, gboolean selected, ETableGroupContainer *etgc)
+{
+ e_table_group_row_selection(E_TABLE_GROUP(etgc), row, selected);
+}
+
static void etgc_add (ETableGroup *etg, gint row)
{
ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
@@ -565,6 +571,8 @@ static void etgc_add (ETableGroup *etg, gint row)
"fill_color", "black",
NULL);
child = e_table_group_new(GNOME_CANVAS_GROUP(etgc), etg->full_header, etg->header, etg->model, etgc->child_rules);
+ gtk_signal_connect(GTK_OBJECT(child), "row_selection",
+ GTK_SIGNAL_FUNC(child_row_selection), etgc);
child_node->child = child;
child_node->key = e_table_model_duplicate_value(etg->model, etgc->ecol->col_idx, val);
diff --git a/widgets/e-table/e-table-group-leaf.c b/widgets/e-table/e-table-group-leaf.c
index a56fb3db6b..9d5f858c16 100644
--- a/widgets/e-table/e-table-group-leaf.c
+++ b/widgets/e-table/e-table-group-leaf.c
@@ -82,6 +82,13 @@ etgl_resize (GtkObject *object, gpointer data)
}
static void
+etgl_row_selection (GtkObject *object, gint row, gboolean selected, ETableGroupLeaf *etgl)
+{
+ if ( row < E_TABLE_SUBSET(etgl->subset)->n_map )
+ e_table_group_row_selection (E_TABLE_GROUP(etgl), E_TABLE_SUBSET(etgl->subset)->map_table[row], selected);
+}
+
+static void
etgl_realize (GnomeCanvasItem *item)
{
ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF(item);
@@ -99,6 +106,9 @@ etgl_realize (GnomeCanvasItem *item)
"spreadsheet", TRUE,
"width", etgl->width,
NULL));
+
+ gtk_signal_connect(GTK_OBJECT(etgl->item), "row_selection",
+ GTK_SIGNAL_FUNC(etgl_row_selection), etgl);
gtk_signal_connect(GTK_OBJECT(etgl->item),
"resize", etgl_resize, etgl);
gtk_object_get(GTK_OBJECT(etgl->item),
diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c
index ef89efd9bd..ce7f1945f6 100644
--- a/widgets/e-table/e-table-group.c
+++ b/widgets/e-table/e-table-group.c
@@ -29,6 +29,7 @@
static GnomeCanvasGroupClass *etg_parent_class;
enum {
+ ROW_SELECTION,
RESIZE,
LAST_SIGNAL
};
@@ -228,6 +229,17 @@ e_table_group_resize (ETableGroup *e_table_group)
etg_signals [RESIZE]);
}
+void
+e_table_group_row_selection (ETableGroup *e_table_group, gint row, gboolean selected)
+{
+ g_return_if_fail (e_table_group != NULL);
+ g_return_if_fail (E_IS_TABLE_GROUP (e_table_group));
+
+ gtk_signal_emit (GTK_OBJECT (e_table_group),
+ etg_signals [ROW_SELECTION],
+ row, selected);
+}
+
ETableHeader *
e_table_group_get_header (ETableGroup *etg)
{
@@ -339,6 +351,7 @@ etg_class_init (GtkObjectClass *object_class)
item_class->event = etg_event;
klass->resize = NULL;
+ klass->row_selection = NULL;
klass->add = NULL;
klass->remove = NULL;
@@ -355,6 +368,14 @@ etg_class_init (GtkObjectClass *object_class)
etg_parent_class = gtk_type_class (PARENT_TYPE);
+ etg_signals [ROW_SELECTION] =
+ gtk_signal_new ("row_selection",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableGroupClass, row_selection),
+ gtk_marshal_NONE__INT_INT,
+ GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+
etg_signals [RESIZE] =
gtk_signal_new ("resize",
GTK_RUN_LAST,
diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h
index 0dd62eb125..820c17007e 100644
--- a/widgets/e-table/e-table-group.h
+++ b/widgets/e-table/e-table-group.h
@@ -42,6 +42,7 @@ typedef struct {
typedef struct {
GnomeCanvasGroupClass parent_class;
void (*resize) (ETableGroup *etg);
+ void (*row_selection) (ETableGroup *etg, int row, gboolean selected);
void (*add) (ETableGroup *etg, gint row);
gboolean (*remove) (ETableGroup *etg, gint row);
@@ -85,8 +86,11 @@ void e_table_group_construct (GnomeCanvasGroup *parent,
ETableHeader *header,
ETableModel *model);
-/* For emitting the signal */
+/* For emitting the signals */
void e_table_group_resize (ETableGroup *etg);
+void e_table_group_row_selection (ETableGroup *etg,
+ gint row,
+ gboolean selected);
GtkType e_table_group_get_type (void);
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index b1c14b958a..d75937d5ed 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -34,6 +34,13 @@
static GtkObjectClass *e_table_parent_class;
+enum {
+ ROW_SELECTION,
+ LAST_SIGNAL
+};
+
+static gint et_signals [LAST_SIGNAL] = { 0, };
+
static void e_table_fill_table (ETable *e_table, ETableModel *model);
static gboolean changed_idle (gpointer data);
@@ -598,6 +605,14 @@ change_row (gpointer key, gpointer value, gpointer data)
}
}
+static void
+group_row_selection (ETableGroup *etg, int row, gboolean selected, ETable *et)
+{
+ gtk_signal_emit (GTK_OBJECT(et),
+ et_signals [ROW_SELECTION],
+ row, selected);
+}
+
static gboolean
changed_idle (gpointer data)
{
@@ -609,6 +624,8 @@ changed_idle (gpointer data)
et->header,
et->model,
e_xml_get_child_by_name(xmlDocGetRootElement(et->specification), "grouping")->childs);
+ gtk_signal_connect(GTK_OBJECT(et->group), "row_selection",
+ GTK_SIGNAL_FUNC(group_row_selection), et);
e_table_fill_table(et, et->model);
} else if (et->need_row_changes) {
g_hash_table_foreach(et->row_changes_list, change_row, et);
@@ -672,6 +689,8 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
header,
model,
xml_grouping->childs);
+ gtk_signal_connect(GTK_OBJECT(e_table->group), "row_selection",
+ GTK_SIGNAL_FUNC(group_row_selection), e_table);
e_table->table_model_change_id = gtk_signal_connect (
GTK_OBJECT (model), "model_changed",
@@ -865,9 +884,22 @@ e_table_save_specification (ETable *e_table, gchar *filename)
static void
e_table_class_init (GtkObjectClass *object_class)
{
+ ETableClass *klass = E_TABLE_CLASS(object_class);
e_table_parent_class = gtk_type_class (PARENT_TYPE);
object_class->destroy = et_destroy;
+
+ klass->row_selection = NULL;
+
+ et_signals [ROW_SELECTION] =
+ gtk_signal_new ("row_selection",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableClass, row_selection),
+ gtk_marshal_NONE__INT_INT,
+ GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+
+ gtk_object_class_add_signals (object_class, et_signals, LAST_SIGNAL);
}
E_MAKE_TYPE(e_table, "ETable", ETable, e_table_class_init, e_table_init, PARENT_TYPE);
diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h
index 9c5bb9b8a0..8f31a1df70 100644
--- a/widgets/e-table/e-table.h
+++ b/widgets/e-table/e-table.h
@@ -54,6 +54,8 @@ typedef struct {
typedef struct {
GtkTableClass parent_class;
+
+ void (*row_selection) (ETable *et, int row, gboolean selected);
} ETableClass;
GtkType e_table_get_type (void);
diff --git a/widgets/e-table/test-table.c b/widgets/e-table/test-table.c
index 7bb54b668a..341013e92c 100644
--- a/widgets/e-table/test-table.c
+++ b/widgets/e-table/test-table.c
@@ -279,6 +279,15 @@ save_spec (GtkWidget *button, ETable *e_table)
}
static void
+row_selection_test (ETable *table, int row, gboolean selected)
+{
+ if ( selected )
+ g_print ("Row %d selected\n", row);
+ else
+ g_print ("Row %d unselected\n", row);
+}
+
+static void
do_e_table_demo (const char *spec)
{
GtkWidget *e_table, *window, *frame, *vbox, *button;
@@ -314,6 +323,8 @@ do_e_table_demo (const char *spec)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
frame = gtk_frame_new (NULL);
e_table = e_table_new (full_header, e_table_model, spec);
+ gtk_signal_connect(GTK_OBJECT(e_table), "row_selection",
+ GTK_SIGNAL_FUNC(row_selection_test), NULL);
button = gtk_button_new_with_label("Save spec");
gtk_signal_connect (GTK_OBJECT (button), "clicked",