aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-30 21:19:32 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-30 21:19:32 +0800
commita076f5b58f51b45bf5308f7b077d6314dc893f29 (patch)
treea9a9c17a8db8028145847823e3e04f747882684c /widgets/e-table
parentbdf6f37a8afa9988de108ac207b48de01fee6141 (diff)
downloadgsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.tar
gsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.tar.gz
gsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.tar.bz2
gsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.tar.lz
gsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.tar.xz
gsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.tar.zst
gsoc2013-evolution-a076f5b58f51b45bf5308f7b077d6314dc893f29.zip
Fixed a bunch of selection bugs. Removed "spreadsheet" argument (for now.)
2000-05-30 Christopher James Lahey <clahey@helixcode.com> * e-table-group-container.c, e-table-group-container.h, e-table-group-leaf.c, e-table-group-leaf.h, e-table-group.c, e-table-group.h, e-table-item.c, e-table-item.h, e-table.c, e-table.h, test-check.c, test-cols.c, test-table.c: Fixed a bunch of selection bugs. Removed "spreadsheet" argument (for now.) Added "cursor_mode" argument. Added "cursor_change" signal. Temporarily removed "selection_mode" argument. svn path=/trunk/; revision=3277
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog10
-rw-r--r--widgets/e-table/e-table-group-container.c92
-rw-r--r--widgets/e-table/e-table-group-container.h3
-rw-r--r--widgets/e-table/e-table-group-leaf.c53
-rw-r--r--widgets/e-table/e-table-group-leaf.h2
-rw-r--r--widgets/e-table/e-table-group.c58
-rw-r--r--widgets/e-table/e-table-group.h10
-rw-r--r--widgets/e-table/e-table-item.c203
-rw-r--r--widgets/e-table/e-table-item.h29
-rw-r--r--widgets/e-table/e-table.c42
-rw-r--r--widgets/e-table/e-table.h5
-rw-r--r--widgets/e-table/test-check.c3
-rw-r--r--widgets/e-table/test-cols.c6
-rw-r--r--widgets/e-table/test-table.c2
14 files changed, 409 insertions, 109 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 3cff3fcf39..5ab457a5e0 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-30 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table-group-container.c, e-table-group-container.h,
+ e-table-group-leaf.c, e-table-group-leaf.h, e-table-group.c,
+ e-table-group.h, e-table-item.c, e-table-item.h, e-table.c,
+ e-table.h, test-check.c, test-cols.c, test-table.c: Fixed a bunch
+ of selection bugs. Removed "spreadsheet" argument (for now.)
+ Added "cursor_mode" argument. Added "cursor_change" signal.
+ Temporarily removed "selection_mode" argument.
+
2000-05-28 Christopher James Lahey <clahey@helixcode.com>
* e-table-group-container.c: Fixed setting of arguments.
diff --git a/widgets/e-table/e-table-group-container.c b/widgets/e-table/e-table-group-container.c
index 39547cd837..900edb023f 100644
--- a/widgets/e-table/e-table-group-container.c
+++ b/widgets/e-table/e-table-group-container.c
@@ -36,7 +36,7 @@ enum {
ARG_FROZEN,
ARG_TABLE_DRAW_GRID,
ARG_TABLE_DRAW_FOCUS,
- ARG_MODE_SPREADSHEET,
+ ARG_CURSOR_MODE,
ARG_LENGTH_THRESHOLD,
};
@@ -211,7 +211,8 @@ etgc_event (GnomeCanvasItem *item, GdkEvent *event)
old_col = 0;
if (start_col == -1)
start_col = e_table_header_count (e_table_group_get_header (child)) - 1;
-
+
+ e_table_group_unfocus(child);
if (direction == E_FOCUS_END)
list = list->prev;
else
@@ -230,6 +231,23 @@ etgc_event (GnomeCanvasItem *item, GdkEvent *event)
}
}
}
+ if (direction == E_FOCUS_END)
+ list = g_list_last(etgc->children);
+ else
+ list = etgc->children;
+ if (list) {
+ ETableGroupContainerChildNode *child_node;
+ ETableGroup *child;
+
+ child_node = (ETableGroupContainerChildNode *)list->data;
+ child = child_node->child;
+
+ if (start_col == -1)
+ start_col = e_table_header_count (e_table_group_get_header (child)) - 1;
+
+ e_table_group_set_focus (child, direction, start_col);
+ return 1;
+ }
}
return_val = FALSE;
default:
@@ -292,6 +310,13 @@ child_row_selection (ETableGroup *etg, int row, gboolean selected,
}
static void
+child_cursor_change (ETableGroup *etg, int row,
+ ETableGroupContainer *etgc)
+{
+ e_table_group_cursor_change (E_TABLE_GROUP (etgc), row);
+}
+
+static void
child_double_click (ETableGroup *etg, int row,
ETableGroupContainer *etgc)
{
@@ -344,11 +369,13 @@ etgc_add (ETableGroup *etg, gint row)
gnome_canvas_item_set(GNOME_CANVAS_ITEM(child),
"drawgrid", etgc->draw_grid,
"drawfocus", etgc->draw_focus,
- "spreadsheet", etgc->mode_spreadsheet,
+ "cursor_mode", etgc->cursor_mode,
"length_threshold", etgc->length_threshold,
NULL);
gtk_signal_connect (GTK_OBJECT (child), "row_selection",
GTK_SIGNAL_FUNC (child_row_selection), etgc);
+ gtk_signal_connect (GTK_OBJECT (child), "cursor_change",
+ GTK_SIGNAL_FUNC (child_cursor_change), etgc);
gtk_signal_connect (GTK_OBJECT (child), "double_click",
GTK_SIGNAL_FUNC (child_double_click), etgc);
child_node->child = child;
@@ -401,6 +428,20 @@ etgc_remove (ETableGroup *etg, gint row)
return FALSE;
}
+static int
+etgc_row_count (ETableGroup *etg)
+{
+ ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
+ GList *list;
+ gint count = 0;
+ for (list = etgc->children; list; list = g_list_next(list)) {
+ ETableGroup *group = ((ETableGroupContainerChildNode *)list->data)->child;
+ gint this_count = e_table_group_row_count(group);
+ count += this_count;
+ }
+ return count;
+}
+
static void
etgc_increment (ETableGroup *etg, gint position, gint amount)
{
@@ -413,6 +454,22 @@ etgc_increment (ETableGroup *etg, gint position, gint amount)
}
static void
+etgc_select_row (ETableGroup *etg, gint row)
+{
+ ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
+ GList *list;
+ for (list = etgc->children; list; list = g_list_next(list)) {
+ ETableGroup *group = ((ETableGroupContainerChildNode *)list->data)->child;
+ gint this_count = e_table_group_row_count(group);
+ if (row < this_count) {
+ e_table_group_select_row(group, row);
+ return;
+ }
+ row -= this_count;
+ }
+}
+
+static void
etgc_set_focus (ETableGroup *etg, EFocus direction, gint view_col)
{
ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
@@ -426,6 +483,16 @@ etgc_set_focus (ETableGroup *etg, EFocus direction, gint view_col)
}
}
+static void
+etgc_unfocus (ETableGroup *etg)
+{
+ ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
+ GList *list;
+ for (list = etgc->children; list; list = g_list_next(list)) {
+ e_table_group_unfocus (((ETableGroupContainerChildNode *)list->data)->child);
+ }
+}
+
static gint
etgc_get_focus_column (ETableGroup *etg)
{
@@ -504,12 +571,12 @@ etgc_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
break;
- case ARG_MODE_SPREADSHEET:
- etgc->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ case ARG_CURSOR_MODE:
+ etgc->cursor_mode = GTK_VALUE_INT (*arg);
for (list = etgc->children; list; list = g_list_next (list)) {
ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
gtk_object_set (GTK_OBJECT(child_node->child),
- "spreadsheet", GTK_VALUE_BOOL (*arg),
+ "cursor_mode", GTK_VALUE_INT (*arg),
NULL);
}
break;
@@ -562,16 +629,19 @@ etgc_class_init (GtkObjectClass *object_class)
e_group_class->add = etgc_add;
e_group_class->add_all = etgc_add_all;
e_group_class->remove = etgc_remove;
- e_group_class->increment = etgc_increment;
- e_group_class->set_focus = etgc_set_focus;
+ e_group_class->increment = etgc_increment;
+ e_group_class->row_count = etgc_row_count;
+ e_group_class->set_focus = etgc_set_focus;
+ e_group_class->select_row = etgc_select_row;
+ e_group_class->unfocus = etgc_unfocus;
e_group_class->get_focus_column = etgc_get_focus_column;
gtk_object_add_arg_type ("ETableGroupContainer::drawgrid", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETableGroupContainer::drawfocus", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
- gtk_object_add_arg_type ("ETableGroupContainer::spreadsheet", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableGroupContainer::cursor_mode", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_CURSOR_MODE);
gtk_object_add_arg_type ("ETableGroupContainer::length_threshold", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
@@ -676,7 +746,7 @@ etgc_init (GtkObject *object)
container->draw_grid = 1;
container->draw_focus = 1;
- container->mode_spreadsheet = 1;
+ container->cursor_mode = E_TABLE_CURSOR_SIMPLE;
container->length_threshold = -1;
}
diff --git a/widgets/e-table/e-table-group-container.h b/widgets/e-table/e-table-group-container.h
index cfeeb7bbc9..1157768ea4 100644
--- a/widgets/e-table/e-table-group-container.h
+++ b/widgets/e-table/e-table-group-container.h
@@ -6,6 +6,7 @@
#include "e-table-model.h"
#include "e-table-header.h"
#include "e-table-group.h"
+#include "e-table-item.h"
#define E_TABLE_GROUP_CONTAINER_TYPE (e_table_group_container_get_type ())
#define E_TABLE_GROUP_CONTAINER(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_CONTAINER_TYPE, ETableGroupContainer))
@@ -42,7 +43,7 @@ typedef struct {
guint draw_grid : 1;
guint draw_focus : 1;
- guint mode_spreadsheet : 1;
+ ETableCursorMode cursor_mode;
/*
* State: the ETableGroup is open or closed
diff --git a/widgets/e-table/e-table-group-leaf.c b/widgets/e-table/e-table-group-leaf.c
index 674a70608a..50241f9990 100644
--- a/widgets/e-table/e-table-group-leaf.c
+++ b/widgets/e-table/e-table-group-leaf.c
@@ -32,7 +32,7 @@ enum {
ARG_FROZEN,
ARG_TABLE_DRAW_GRID,
ARG_TABLE_DRAW_FOCUS,
- ARG_MODE_SPREADSHEET,
+ ARG_CURSOR_MODE,
ARG_LENGTH_THRESHOLD,
};
@@ -91,6 +91,13 @@ etgl_row_selection (GtkObject *object, gint row, gboolean selected, ETableGroupL
}
static void
+etgl_cursor_change (GtkObject *object, gint row, ETableGroupLeaf *etgl)
+{
+ if (row < E_TABLE_SUBSET(etgl->subset)->n_map)
+ e_table_group_cursor_change (E_TABLE_GROUP(etgl), E_TABLE_SUBSET(etgl->subset)->map_table[row]);
+}
+
+static void
etgl_double_click (GtkObject *object, gint row, ETableGroupLeaf *etgl)
{
if (row < E_TABLE_SUBSET(etgl->subset)->n_map)
@@ -124,13 +131,15 @@ etgl_realize (GnomeCanvasItem *item)
"ETableModel", etgl->subset,
"drawgrid", etgl->draw_grid,
"drawfocus", etgl->draw_focus,
- "spreadsheet", etgl->mode_spreadsheet,
+ "cursor_mode", etgl->cursor_mode,
"minimum_width", etgl->minimum_width,
"length_threshold", etgl->length_threshold,
NULL));
gtk_signal_connect (GTK_OBJECT(etgl->item), "row_selection",
GTK_SIGNAL_FUNC(etgl_row_selection), etgl);
+ gtk_signal_connect (GTK_OBJECT(etgl->item), "cursor_change",
+ GTK_SIGNAL_FUNC(etgl_cursor_change), etgl);
gtk_signal_connect (GTK_OBJECT(etgl->item), "double_click",
GTK_SIGNAL_FUNC(etgl_double_click), etgl);
e_canvas_item_request_reflow(item);
@@ -164,6 +173,13 @@ etgl_increment (ETableGroup *etg, gint position, gint amount)
e_table_subset_variable_increment (etgl->subset, position, amount);
}
+static int
+etgl_row_count (ETableGroup *etg)
+{
+ ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
+ return e_table_model_row_count(E_TABLE_MODEL(etgl->subset));
+}
+
static void
etgl_set_focus (ETableGroup *etg, EFocus direction, gint view_col)
{
@@ -175,6 +191,20 @@ etgl_set_focus (ETableGroup *etg, EFocus direction, gint view_col)
}
}
+static void
+etgl_select_row (ETableGroup *etg, gint row)
+{
+ ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
+ e_table_item_focus(etgl->item, 0, row);
+}
+
+static void
+etgl_unfocus (ETableGroup *etg)
+{
+ ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
+ e_table_item_unfocus (etgl->item);
+}
+
static gint
etgl_get_focus_column (ETableGroup *etg)
{
@@ -231,11 +261,11 @@ etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
break;
- case ARG_MODE_SPREADSHEET:
- etgl->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ case ARG_CURSOR_MODE:
+ etgl->cursor_mode = GTK_VALUE_INT (*arg);
if (etgl->item) {
gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
- "spreadsheet", GTK_VALUE_BOOL (*arg),
+ "cursor_mode", GTK_VALUE_INT (*arg),
NULL);
}
break;
@@ -286,16 +316,19 @@ etgl_class_init (GtkObjectClass *object_class)
e_group_class->add = etgl_add;
e_group_class->add_all = etgl_add_all;
e_group_class->remove = etgl_remove;
- e_group_class->increment = etgl_increment;
- e_group_class->set_focus = etgl_set_focus;
+ e_group_class->increment = etgl_increment;
+ e_group_class->row_count = etgl_row_count;
+ e_group_class->set_focus = etgl_set_focus;
+ e_group_class->select_row = etgl_select_row;
+ e_group_class->unfocus = etgl_unfocus;
e_group_class->get_focus_column = etgl_get_focus_column;
gtk_object_add_arg_type ("ETableGroupLeaf::drawgrid", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETableGroupLeaf::drawfocus", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
- gtk_object_add_arg_type ("ETableGroupLeaf::spreadsheet", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableGroupLeaf::cursor_mode", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_CURSOR_MODE);
gtk_object_add_arg_type ("ETableGroupLeaf::length_threshold", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
@@ -323,7 +356,7 @@ etgl_init (GtkObject *object)
etgl->draw_grid = 1;
etgl->draw_focus = 1;
- etgl->mode_spreadsheet = 1;
+ etgl->cursor_mode = E_TABLE_CURSOR_SIMPLE;
etgl->length_threshold = -1;
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgl_reflow);
diff --git a/widgets/e-table/e-table-group-leaf.h b/widgets/e-table/e-table-group-leaf.h
index 3789e16402..365f268307 100644
--- a/widgets/e-table/e-table-group-leaf.h
+++ b/widgets/e-table/e-table-group-leaf.h
@@ -31,7 +31,7 @@ typedef struct {
guint draw_grid : 1;
guint draw_focus : 1;
- guint mode_spreadsheet : 1;
+ ETableCursorMode cursor_mode;
} ETableGroupLeaf;
typedef struct {
diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c
index 90893cfee2..4258640a97 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,
+ CURSOR_CHANGE,
DOUBLE_CLICK,
LAST_SIGNAL
};
@@ -132,6 +133,18 @@ e_table_group_get_count (ETableGroup *etg)
return 0;
}
+gint
+e_table_group_row_count (ETableGroup *etg)
+{
+ g_return_val_if_fail (etg != NULL, 0);
+ g_return_val_if_fail (E_IS_TABLE_GROUP (etg), 0);
+
+ if (ETG_CLASS (etg)->row_count)
+ return ETG_CLASS (etg)->row_count (etg);
+ else
+ return 0;
+}
+
void
e_table_group_increment (ETableGroup *etg,
gint position,
@@ -156,6 +169,27 @@ e_table_group_set_focus (ETableGroup *etg,
ETG_CLASS (etg)->set_focus (etg, direction, row);
}
+void
+e_table_group_select_row (ETableGroup *etg,
+ gint row)
+{
+ g_return_if_fail (etg != NULL);
+ g_return_if_fail (E_IS_TABLE_GROUP (etg));
+
+ if (ETG_CLASS (etg)->select_row)
+ ETG_CLASS (etg)->select_row (etg, row);
+}
+
+void
+e_table_group_unfocus (ETableGroup *etg)
+{
+ g_return_if_fail (etg != NULL);
+ g_return_if_fail (E_IS_TABLE_GROUP (etg));
+
+ if (ETG_CLASS (etg)->unfocus)
+ ETG_CLASS (etg)->unfocus (etg);
+}
+
gboolean
e_table_group_get_focus (ETableGroup *etg)
{
@@ -204,6 +238,17 @@ e_table_group_row_selection (ETableGroup *e_table_group, gint row, gboolean sele
}
void
+e_table_group_cursor_change (ETableGroup *e_table_group, gint row)
+{
+ 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 [CURSOR_CHANGE],
+ row);
+}
+
+void
e_table_group_double_click (ETableGroup *e_table_group, gint row)
{
g_return_if_fail (e_table_group != NULL);
@@ -263,14 +308,18 @@ etg_class_init (GtkObjectClass *object_class)
item_class->event = etg_event;
klass->row_selection = NULL;
+ klass->cursor_change = NULL;
klass->double_click = NULL;
klass->add = NULL;
klass->add_all = NULL;
klass->remove = NULL;
klass->get_count = NULL;
+ klass->row_count = NULL;
klass->increment = NULL;
klass->set_focus = NULL;
+ klass->select_row = NULL;
+ klass->unfocus = NULL;
klass->get_focus = etg_get_focus;
klass->get_ecol = NULL;
@@ -284,6 +333,14 @@ etg_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+ etg_signals [CURSOR_CHANGE] =
+ gtk_signal_new ("cursor_change",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableGroupClass, cursor_change),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
etg_signals [DOUBLE_CLICK] =
gtk_signal_new ("double_click",
GTK_RUN_LAST,
@@ -296,4 +353,3 @@ etg_class_init (GtkObjectClass *object_class)
}
E_MAKE_TYPE (e_table_group, "ETableGroup", ETableGroup, etg_class_init, NULL, PARENT_TYPE);
-
diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h
index 8226ad055c..3389cee984 100644
--- a/widgets/e-table/e-table-group.h
+++ b/widgets/e-table/e-table-group.h
@@ -44,6 +44,7 @@ typedef struct {
/* Signals */
void (*row_selection) (ETableGroup *etg, int row, gboolean selected);
+ void (*cursor_change) (ETableGroup *etg, int row);
void (*double_click) (ETableGroup *etg, int row);
/* Virtual functions. */
@@ -51,8 +52,11 @@ typedef struct {
void (*add_all) (ETableGroup *etg);
gboolean (*remove) (ETableGroup *etg, gint row);
gint (*get_count) (ETableGroup *etg);
+ gint (*row_count) (ETableGroup *etg);
void (*increment) (ETableGroup *etg, gint position, gint amount);
void (*set_focus) (ETableGroup *etg, EFocus direction, gint view_col);
+ void (*select_row) (ETableGroup *etg, gint row);
+ void (*unfocus) (ETableGroup *etg);
gboolean (*get_focus) (ETableGroup *etg);
gint (*get_focus_column) (ETableGroup *etg);
ETableCol *(*get_ecol) (ETableGroup *etg);
@@ -68,9 +72,13 @@ gint e_table_group_get_count (ETableGroup *etg);
void e_table_group_increment (ETableGroup *etg,
gint position,
gint amount);
+gint e_table_group_row_count (ETableGroup *etg);
void e_table_group_set_focus (ETableGroup *etg,
EFocus direction,
gint view_col);
+void e_table_group_select_row (ETableGroup *etg,
+ gint row);
+void e_table_group_unfocus (ETableGroup *etg);
gboolean e_table_group_get_focus (ETableGroup *etg);
gint e_table_group_get_focus_column (ETableGroup *etg);
ETableHeader *e_table_group_get_header (ETableGroup *etg);
@@ -92,6 +100,8 @@ void e_table_group_construct (GnomeCanvasGroup *parent,
void e_table_group_row_selection (ETableGroup *etg,
gint row,
gboolean selected);
+void e_table_group_cursor_change (ETableGroup *etg,
+ gint row);
void e_table_group_double_click (ETableGroup *etg,
gint row);
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
index ad645a8c39..854693a3d7 100644
--- a/widgets/e-table/e-table-item.c
+++ b/widgets/e-table/e-table-item.c
@@ -28,6 +28,7 @@ static GnomeCanvasItemClass *eti_parent_class;
enum {
ROW_SELECTION,
+ CURSOR_CHANGE,
DOUBLE_CLICK,
LAST_SIGNAL
};
@@ -40,13 +41,13 @@ enum {
ARG_TABLE_MODEL,
ARG_TABLE_DRAW_GRID,
ARG_TABLE_DRAW_FOCUS,
- ARG_MODE_SPREADSHEET,
+ ARG_CURSOR_MODE,
ARG_LENGTH_THRESHOLD,
+ ARG_HAS_CURSOR,
ARG_MINIMUM_WIDTH,
ARG_WIDTH,
ARG_HEIGHT,
- ARG_HAS_FOCUS,
};
static int eti_get_height (ETableItem *eti);
@@ -476,8 +477,10 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti)
{
eti->rows = e_table_model_row_count (eti->table_model);
- if (eti->focused_row > eti->rows - 1)
- eti->focused_row = eti->rows - 1;
+ /* FIXME: cursor */
+ if (eti->cursor_row > eti->rows - 1)
+ eti->cursor_row = eti->rows - 1;
+
free_height_cache(eti);
@@ -524,11 +527,11 @@ eti_request_region_redraw (ETableItem *eti,
y1 = eti_row_diff (eti, 0, start_row);
width = e_table_header_col_diff (eti->header, start_col, end_col + 1);
height = eti_row_diff (eti, start_row, end_row + 1);
-
+
eti_item_region_redraw (eti, eti->x1 + x1 - border,
- eti->y1 + y1 - border,
- eti->x1 + x1 + width + 1 + border,
- eti->y1 + y1 + height + 1 + border);
+ eti->y1 + y1 - border,
+ eti->x1 + x1 + width + 1 + border,
+ eti->y1 + y1 + height + 1 + border);
}
static void
@@ -550,7 +553,7 @@ eti_table_model_cell_changed (ETableModel *table_model, int col, int row, ETable
return;
}
- eti_request_region_redraw (eti, 0, row, eti->cols, row, 0);
+ eti_request_region_redraw (eti, 0, row, eti->cols -1, row, 0);
}
static void
@@ -575,10 +578,10 @@ e_table_item_redraw_range (ETableItem *eti,
g_return_if_fail (eti != NULL);
g_return_if_fail (E_IS_TABLE_ITEM (eti));
- if ((start_col == eti->focused_col) ||
- (end_col == eti->focused_col) ||
- (start_row == eti->focused_row) ||
- (end_row == eti->focused_row))
+ if ((start_col == eti->cursor_col) ||
+ (end_col == eti->cursor_col) ||
+ (start_row == eti->cursor_row) ||
+ (end_row == eti->cursor_row))
border = 2;
else
border = 0;
@@ -685,7 +688,9 @@ eti_destroy (GtkObject *object)
eti_remove_header_model (eti);
eti_remove_table_model (eti);
+#if 0
g_slist_free (eti->selection);
+#endif
if (eti->height_cache_idle_id)
g_source_remove(eti->height_cache_idle_id);
@@ -728,9 +733,10 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
eti->draw_focus = GTK_VALUE_BOOL (*arg);
break;
- case ARG_MODE_SPREADSHEET:
- eti->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ case ARG_CURSOR_MODE:
+ eti->cursor_mode = GTK_VALUE_INT (*arg);
break;
+
case ARG_MINIMUM_WIDTH:
if (eti->minimum_width == eti->width && GTK_VALUE_DOUBLE (*arg) > eti->width)
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
@@ -762,6 +768,9 @@ eti_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_MINIMUM_WIDTH:
GTK_VALUE_DOUBLE (*arg) = eti->minimum_width;
break;
+ case ARG_HAS_CURSOR:
+ GTK_VALUE_BOOL (*arg) = (eti->cursor_row != -1);
+ break;
default:
arg->type = GTK_TYPE_INVALID;
}
@@ -772,8 +781,10 @@ eti_init (GnomeCanvasItem *item)
{
ETableItem *eti = E_TABLE_ITEM (item);
- eti->focused_col = -1;
- eti->focused_row = -1;
+ eti->cursor_row = -1;
+ eti->cursor_col = 0;
+ eti->cursor_mode = E_TABLE_CURSOR_SIMPLE;
+
eti->editing_col = -1;
eti->editing_row = -1;
eti->height = 0;
@@ -787,7 +798,9 @@ eti_init (GnomeCanvasItem *item)
eti->length_threshold = -1;
eti->renderers_can_change_size = 1;
+#if 0
eti->selection_mode = GTK_SELECTION_SINGLE;
+#endif
eti->needs_redraw = 0;
eti->needs_compute_height = 0;
@@ -975,16 +988,29 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
xd = x_offset;
/* printf ("paint: %d %d\n", yd, yd + height); */
+#if 0
selected = g_slist_find (eti->selection, GINT_TO_POINTER (row)) != NULL;
+#endif
+ selected = (row == eti->cursor_row);
for (col = first_col; col < last_col; col++){
ETableCol *ecol = e_table_header_get_column (eti->header, col);
ECellView *ecell_view = eti->cell_views [col];
+ gboolean col_selected = selected;
+ switch (eti->cursor_mode) {
+ case E_TABLE_CURSOR_SIMPLE:
+ if (eti->cursor_col == col && eti->cursor_row == row)
+ col_selected = !col_selected;
+ break;
+ case E_TABLE_CURSOR_LINE:
+ /* Nothing */
+ break;
+ }
- e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, selected,
+ e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, col_selected,
xd, yd, xd + ecol->width, yd + height);
- if (col == eti->focused_col && row == eti->focused_row){
+ if (col == eti->cursor_col && row == eti->cursor_row){
f_x1 = xd;
f_x2 = xd + ecol->width;
f_y1 = yd;
@@ -1097,27 +1123,28 @@ eti_cursor_move (ETableItem *eti, gint row, gint column)
static void
eti_cursor_move_left (ETableItem *eti)
{
- eti_cursor_move (eti, eti->focused_row, eti->focused_col - 1);
+ eti_cursor_move (eti, eti->cursor_row, eti->cursor_col - 1);
}
static void
eti_cursor_move_right (ETableItem *eti)
{
- eti_cursor_move (eti, eti->focused_row, eti->focused_col + 1);
+ eti_cursor_move (eti, eti->cursor_row, eti->cursor_col + 1);
}
static void
eti_cursor_move_up (ETableItem *eti)
{
- eti_cursor_move (eti, eti->focused_row - 1, eti->focused_col);
+ eti_cursor_move (eti, eti->cursor_row - 1, eti->cursor_col);
}
static void
eti_cursor_move_down (ETableItem *eti)
{
- eti_cursor_move (eti, eti->focused_row + 1, eti->focused_col);
+ eti_cursor_move (eti, eti->cursor_row + 1, eti->cursor_col);
}
+/* FIXME: cursor */
static int
eti_event (GnomeCanvasItem *item, GdkEvent *e)
{
@@ -1141,7 +1168,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
return TRUE;
- if (eti->focused_row == row && eti->focused_col == col){
+ if (eti->cursor_row == row && eti->cursor_col == col){
ecol = e_table_header_get_column (eti->header, col);
ecell_view = eti->cell_views [col];
@@ -1159,7 +1186,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
*/
e_table_item_leave_edit (eti);
e_table_item_focus (eti, col, row);
- e_table_item_select_row (eti, row);
}
break;
}
@@ -1178,7 +1204,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
return TRUE;
gtk_signal_emit (GTK_OBJECT (eti), eti_signals [DOUBLE_CLICK],
- GPOINTER_TO_INT (eti->selection->data));
+ row);
break;
}
case GDK_MOTION_NOTIFY: {
@@ -1190,7 +1216,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
if (!find_cell (eti, e->motion.x, e->motion.y, &col, &row, &x1, &y1))
return TRUE;
- if (eti->focused_row == row && eti->focused_col == col){
+ if (eti->cursor_row == row && eti->cursor_col == col){
ecol = e_table_header_get_column (eti->header, col);
ecell_view = eti->cell_views [col];
@@ -1206,35 +1232,39 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
}
case GDK_KEY_PRESS:
- if (eti->focused_col == -1)
+ if (eti->cursor_col == -1)
return FALSE;
switch (e->key.keyval){
case GDK_Left:
+#if 0
if (!eti->mode_spreadsheet && eti_editing (eti))
break;
+#endif
- if (eti->focused_col > 0)
+ if (eti->cursor_col > 0)
eti_cursor_move_left (eti);
break;
case GDK_Right:
+#if 0
if (!eti->mode_spreadsheet && eti_editing (eti))
break;
+#endif
- if (eti->focused_col < eti->cols - 1)
+ if (eti->cursor_col < eti->cols - 1)
eti_cursor_move_right (eti);
break;
case GDK_Up:
- if (eti->focused_row > 0)
+ if (eti->cursor_row > 0)
eti_cursor_move_up (eti);
else
return_val = FALSE;
break;
case GDK_Down:
- if ((eti->focused_row + 1) < eti->rows)
+ if ((eti->cursor_row + 1) < eti->rows)
eti_cursor_move_down (eti);
else
return_val = FALSE;
@@ -1245,17 +1275,17 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
case GDK_ISO_Left_Tab:
if ((e->key.state & GDK_SHIFT_MASK) != 0){
/* shift tab */
- if (eti->focused_col > 0)
+ if (eti->cursor_col > 0)
eti_cursor_move_left (eti);
- else if (eti->focused_row > 0)
- eti_cursor_move (eti, eti->focused_row - 1, eti->cols - 1);
+ else if (eti->cursor_row > 0)
+ eti_cursor_move (eti, eti->cursor_row - 1, eti->cols - 1);
else
return_val = FALSE;
} else {
- if (eti->focused_col < eti->cols - 1)
+ if (eti->cursor_col < eti->cols - 1)
eti_cursor_move_right (eti);
- else if (eti->focused_row < eti->rows - 1)
- eti_cursor_move (eti, eti->focused_row + 1, 0);
+ else if (eti->cursor_row < eti->rows - 1)
+ eti_cursor_move (eti, eti->cursor_row + 1, 0);
else
return_val = FALSE;
}
@@ -1270,14 +1300,14 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
return_val = FALSE;
}
- ecol = e_table_header_get_column (eti->header, eti->focused_col);
- ecell_view = eti->cell_views [eti->focused_col];
- e_cell_event (ecell_view, e, ecol->col_idx, eti->focused_col, eti->focused_row);
+ ecol = e_table_header_get_column (eti->header, eti->cursor_col);
+ ecell_view = eti->cell_views [eti->cursor_col];
+ e_cell_event (ecell_view, e, ecol->col_idx, eti->cursor_col, eti->cursor_row);
}
break;
case GDK_KEY_RELEASE:
- if (eti->focused_col == -1)
+ if (eti->cursor_col == -1)
return FALSE;
if (eti_editing (eti)){
@@ -1287,13 +1317,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
}
break;
- case GDK_FOCUS_CHANGE:
- if (e->focus_change.in) {
- } else {
- e_table_item_leave_edit (eti);
- e_table_item_unfocus (eti);
- }
-
default:
return_val = FALSE;
}
@@ -1306,12 +1329,14 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
static void
eti_row_selection (ETableItem *eti, int row, gboolean selected)
{
+#if 0
eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0);
if (selected)
eti->selection = g_slist_prepend (eti->selection, GINT_TO_POINTER (row));
else
eti->selection = g_slist_remove (eti->selection, GINT_TO_POINTER (row));
+#endif
}
@@ -1334,8 +1359,9 @@ eti_class_init (GtkObjectClass *object_class)
item_class->point = eti_point;
item_class->event = eti_event;
- eti_class->row_selection = eti_row_selection;
- eti_class->double_click = NULL;
+ eti_class->row_selection = eti_row_selection;
+ eti_class->cursor_change = NULL;
+ eti_class->double_click = NULL;
gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_OBJECT,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
@@ -1345,8 +1371,8 @@ eti_class_init (GtkObjectClass *object_class)
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETableItem::drawfocus", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
- gtk_object_add_arg_type ("ETableItem::spreadsheet", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableItem::cursor_mode", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_CURSOR_MODE);
gtk_object_add_arg_type ("ETableItem::length_threshold", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
@@ -1356,8 +1382,8 @@ eti_class_init (GtkObjectClass *object_class)
GTK_ARG_READWRITE, ARG_WIDTH);
gtk_object_add_arg_type ("ETableItem::height", GTK_TYPE_DOUBLE,
GTK_ARG_READABLE, ARG_HEIGHT);
- gtk_object_add_arg_type ("ETableItem::has_focus", GTK_TYPE_BOOL,
- GTK_ARG_READWRITE, ARG_HAS_FOCUS);
+ gtk_object_add_arg_type ("ETableItem::has_cursor", GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_HAS_CURSOR);
eti_signals [ROW_SELECTION] =
gtk_signal_new ("row_selection",
@@ -1367,6 +1393,14 @@ eti_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+ eti_signals [CURSOR_CHANGE] =
+ gtk_signal_new ("cursor_change",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableItemClass, cursor_change),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
eti_signals [DOUBLE_CLICK] =
gtk_signal_new ("double_click",
GTK_RUN_LAST,
@@ -1413,13 +1447,34 @@ e_table_item_focus (ETableItem *eti, int col, int row)
*/
gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (eti));
- if (eti->focused_col != -1)
- e_table_item_unfocus (eti);
+ e_table_item_unfocus (eti);
+
+ if (row == -1) {
+ row = eti->rows - 1;
+ }
+
+ if (col == -1) {
+ col = eti->cursor_col;
+ row = -1;
+ }
- eti->focused_col = col;
- eti->focused_row = row;
+ eti->cursor_col = col;
+ eti->cursor_row = row;
- eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [CURSOR_CHANGE],
+ row);
+ if (row != -1) {
+#if 0
+ if (eti->cursor_mode == E_TABLE_CURSOR_SPREADSHEET)
+ eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
+ else
+#endif
+ /* FIXME: remove once selection stuff is done. */
+ eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, FOCUSED_BORDER);
+#if 0
+ e_table_item_select_row (eti, row);
+#endif
+ }
}
void
@@ -1428,20 +1483,32 @@ e_table_item_unfocus (ETableItem *eti)
g_return_if_fail (eti != NULL);
g_return_if_fail (E_IS_TABLE_ITEM (eti));
- if (eti->focused_row == -1)
+ if (eti->cursor_row == -1)
return;
{
- const int col = eti->focused_col;
- const int row = eti->focused_row;
+#if 0
+ const int col = eti->cursor_col;
+#endif
+ const int row = eti->cursor_row;
- eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
+#if 0
+ if (eti->cursor_mode == E_TABLE_CURSOR_SPREADSHEET)
+ eti_request_region_redraw (eti, col, row, col, row, FOCUSED_BORDER);
+ else
+#endif
+ /* FIXME: remove once selection stuff is done. */
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
+ row, 0);
+ eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, FOCUSED_BORDER);
+#if 0
while (eti->selection){
e_table_item_unselect_row (eti, GPOINTER_TO_INT(eti->selection->data));
}
+#endif
}
- eti->focused_col = -1;
- eti->focused_row = -1;
+ eti->cursor_col = -1;
+ eti->cursor_row = -1;
}
gint
@@ -1450,10 +1517,11 @@ e_table_item_get_focused_column (ETableItem *eti)
g_return_val_if_fail (eti != NULL, -1);
g_return_val_if_fail (E_IS_TABLE_ITEM (eti), -1);
- return eti->focused_col;
+ return eti->cursor_col;
}
+#if 0
const GSList *
e_table_item_get_selection (ETableItem *eti)
{
@@ -1544,6 +1612,7 @@ e_table_item_select_row (ETableItem *eti, int row)
}
}
+#endif
void
e_table_item_enter_edit (ETableItem *eti, int col, int row)
diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h
index 1e9b6a46d6..b466824bd7 100644
--- a/widgets/e-table/e-table-item.h
+++ b/widgets/e-table/e-table-item.h
@@ -12,6 +12,13 @@
#define E_IS_TABLE_ITEM(o) (GTK_CHECK_TYPE ((o), E_TABLE_ITEM_TYPE))
#define E_IS_TABLE_ITEM_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_ITEM_TYPE))
+/* list selection modes */
+typedef enum
+{
+ E_TABLE_CURSOR_LINE,
+ E_TABLE_CURSOR_SIMPLE,
+} ETableCursorMode;
+
typedef struct {
GnomeCanvasItem parent;
ETableModel *table_model;
@@ -40,12 +47,12 @@ typedef struct {
unsigned int draw_grid:1;
unsigned int draw_focus:1;
- unsigned int mode_spreadsheet:1;
unsigned int renderers_can_change_size:1;
unsigned int cell_views_realized:1;
- int focused_col, focused_row;
-
+ guint needs_redraw : 1;
+ guint needs_compute_height : 1;
+ guint needs_compute_width : 1;
/*
* Realized views, per column
*/
@@ -61,30 +68,36 @@ typedef struct {
* the size
*/
int length_threshold;
+
+ gint cursor_row;
+ gint cursor_col;
+ ETableCursorMode cursor_mode;
+#if 0
GSList *selection;
- GtkSelectionMode selection_mode;
+ gint selection_count;
+ GtkSelectionMode selection_mode;
+#endif
/*
* During edition
*/
int editing_col, editing_row;
void *edit_ctx;
- guint needs_redraw : 1;
- guint needs_compute_height : 1;
- guint needs_compute_width : 1;
} ETableItem;
typedef struct {
GnomeCanvasItemClass parent_class;
void (*row_selection) (ETableItem *eti, int row, gboolean selected);
+ void (*cursor_change) (ETableItem *eti, int row);
void (*double_click) (ETableItem *eti, int row);
} ETableItemClass;
GtkType e_table_item_get_type (void);
+
/*
* Focus
*/
@@ -93,6 +106,7 @@ void e_table_item_unfocus (ETableItem *eti);
gint e_table_item_get_focused_column (ETableItem *eti);
+#if 0
/*
* Selection
*/
@@ -109,6 +123,7 @@ void e_table_item_set_selection_mode (ETableItem *e_table_Item,
GtkSelectionMode selection_mode);
gboolean e_table_item_is_row_selected (ETableItem *e_table_Item,
int row);
+#endif
void e_table_item_leave_edit (ETableItem *eti);
void e_table_item_enter_edit (ETableItem *eti, int col, int row);
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index f5abd29d5a..25095db72d 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -40,6 +40,7 @@ static GtkObjectClass *e_table_parent_class;
enum {
ROW_SELECTION,
+ CURSOR_CHANGE,
DOUBLE_CLICK,
LAST_SIGNAL
};
@@ -48,7 +49,7 @@ enum {
ARG_0,
ARG_TABLE_DRAW_GRID,
ARG_TABLE_DRAW_FOCUS,
- ARG_MODE_SPREADSHEET,
+ ARG_CURSOR_MODE,
ARG_LENGTH_THRESHOLD,
};
@@ -105,7 +106,7 @@ e_table_init (GtkObject *object)
e_table->draw_grid = 1;
e_table->draw_focus = 1;
- e_table->spreadsheet = 1;
+ e_table->cursor_mode = E_TABLE_CURSOR_SIMPLE;
e_table->length_threshold = 200;
e_table->need_rebuild = 0;
@@ -190,6 +191,14 @@ group_row_selection (ETableGroup *etg, int row, gboolean selected, ETable *et)
}
static void
+group_cursor_change (ETableGroup *etg, int row, ETable *et)
+{
+ gtk_signal_emit (GTK_OBJECT (et),
+ et_signals [CURSOR_CHANGE],
+ row);
+}
+
+static void
group_double_click (ETableGroup *etg, int row, ETable *et)
{
gtk_signal_emit (GTK_OBJECT (et),
@@ -213,11 +222,13 @@ changed_idle (gpointer data)
gnome_canvas_item_set(GNOME_CANVAS_ITEM(et->group),
"drawgrid", et->draw_grid,
"drawfocus", et->draw_focus,
- "spreadsheet", et->spreadsheet,
+ "cursor_mode", et->cursor_mode,
"length_threshold", et->length_threshold,
NULL);
gtk_signal_connect (GTK_OBJECT (et->group), "row_selection",
GTK_SIGNAL_FUNC (group_row_selection), et);
+ gtk_signal_connect (GTK_OBJECT (et->group), "cursor_change",
+ GTK_SIGNAL_FUNC (group_cursor_change), et);
gtk_signal_connect (GTK_OBJECT (et->group), "double_click",
GTK_SIGNAL_FUNC (group_double_click), et);
e_table_fill_table (et, et->model);
@@ -294,12 +305,14 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_table->group),
"drawgrid", e_table->draw_grid,
"drawfocus", e_table->draw_focus,
- "spreadsheet", e_table->spreadsheet,
+ "cursor_mode", e_table->cursor_mode,
"length_threshold", e_table->length_threshold,
NULL);
gtk_signal_connect (GTK_OBJECT (e_table->group), "row_selection",
GTK_SIGNAL_FUNC(group_row_selection), e_table);
+ gtk_signal_connect (GTK_OBJECT (e_table->group), "cursor_change",
+ GTK_SIGNAL_FUNC(group_cursor_change), e_table);
gtk_signal_connect (GTK_OBJECT (e_table->group), "double_click",
GTK_SIGNAL_FUNC(group_double_click), e_table);
@@ -629,7 +642,7 @@ e_table_save_specification (ETable *e_table, gchar *filename)
void
e_table_select_row (ETable *e_table, int row)
{
-
+ e_table_group_select_row(e_table->group, row);
}
static void
@@ -686,11 +699,11 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
}
break;
- case ARG_MODE_SPREADSHEET:
- etable->spreadsheet = GTK_VALUE_BOOL (*arg);
+ case ARG_CURSOR_MODE:
+ etable->cursor_mode = GTK_VALUE_INT (*arg);
if (etable->group) {
gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
- "spreadsheet", GTK_VALUE_BOOL (*arg),
+ "cursor_mode", GTK_VALUE_INT (*arg),
NULL);
}
break;
@@ -708,6 +721,7 @@ e_table_class_init (GtkObjectClass *object_class)
object_class->get_arg = et_get_arg;
klass->row_selection = NULL;
+ klass->cursor_change = NULL;
klass->double_click = NULL;
et_signals [ROW_SELECTION] =
@@ -718,6 +732,14 @@ e_table_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+ et_signals [CURSOR_CHANGE] =
+ gtk_signal_new ("cursor_change",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableClass, cursor_change),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
et_signals [DOUBLE_CLICK] =
gtk_signal_new ("double_click",
GTK_RUN_LAST,
@@ -732,8 +754,8 @@ e_table_class_init (GtkObjectClass *object_class)
GTK_ARG_READWRITE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETable::drawfocus", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_TABLE_DRAW_FOCUS);
- gtk_object_add_arg_type ("ETable::spreadsheet", GTK_TYPE_BOOL,
- GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETable::cursor_mode", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_CURSOR_MODE);
gtk_object_add_arg_type ("ETable::length_threshold", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h
index 25467843f3..52ba005dc2 100644
--- a/widgets/e-table/e-table.h
+++ b/widgets/e-table/e-table.h
@@ -9,6 +9,7 @@
#include "e-table-header.h"
#include "e-table-group.h"
#include "e-table-sort-info.h"
+#include "e-table-item.h"
BEGIN_GNOME_DECLS
@@ -51,13 +52,15 @@ typedef struct {
*/
guint draw_grid : 1;
guint draw_focus : 1;
- guint spreadsheet : 1;
+
+ ETableCursorMode cursor_mode;
} ETable;
typedef struct {
GtkTableClass parent_class;
void (*row_selection) (ETable *et, int row, gboolean selected);
+ void (*cursor_change) (ETable *et, int row);
void (*double_click) (ETable *et, int row);
} ETableClass;
diff --git a/widgets/e-table/test-check.c b/widgets/e-table/test-check.c
index 300ebf7a7e..9d95a91d91 100644
--- a/widgets/e-table/test-check.c
+++ b/widgets/e-table/test-check.c
@@ -194,7 +194,10 @@ check_test (void)
"ETableModel", e_table_model,
"drawgrid", TRUE,
"drawfocus", TRUE,
+#if 0
"spreadsheet", TRUE,
+#endif
+ "cursor_mode", E_TABLE_CURSOR_SIMPLE,
NULL);
e_canvas_item_move_absolute (item, 0, 30);
}
diff --git a/widgets/e-table/test-cols.c b/widgets/e-table/test-cols.c
index e34e477dae..5de5d3399a 100644
--- a/widgets/e-table/test-cols.c
+++ b/widgets/e-table/test-cols.c
@@ -214,7 +214,10 @@ multi_cols_test (void)
"ETableModel", e_table_model,
"drawgrid", TRUE,
"drawfocus", TRUE,
+ "cursor_mode", E_TABLE_CURSOR_SIMPLE,
+#if 0
"spreadsheet", TRUE,
+#endif
NULL);
e_canvas_item_move_absolute (item, 0, 30);
@@ -233,7 +236,10 @@ multi_cols_test (void)
"ETableModel", e_table_model,
"drawgrid", TRUE,
"drawfocus", TRUE,
+#if 0
"spreadsheet", TRUE,
+#endif
+ "cursor_mode", E_TABLE_CURSOR_SIMPLE,
NULL);
e_canvas_item_move_absolute (item, 300, 30);
}
diff --git a/widgets/e-table/test-table.c b/widgets/e-table/test-table.c
index 724090d904..59126abdab 100644
--- a/widgets/e-table/test-table.c
+++ b/widgets/e-table/test-table.c
@@ -284,7 +284,9 @@ table_browser_test (void)
"ETableModel", e_table_model,
"drawgrid", TRUE,
"drawfocus", TRUE,
+#if 0
"spreadsheet", TRUE,
+#endif
NULL);
}