aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-table-group-container.c36
-rw-r--r--widgets/table/e-table-group-leaf.c22
-rw-r--r--widgets/table/e-table-group.c267
-rw-r--r--widgets/table/e-table-group.h123
-rw-r--r--widgets/table/e-table-item.c81
-rw-r--r--widgets/table/e-table-item.h2
-rw-r--r--widgets/table/e-table-selection-model.c33
-rw-r--r--widgets/table/e-table-selection-model.h1
-rw-r--r--widgets/table/e-table.c24
-rw-r--r--widgets/table/e-table.h1
10 files changed, 461 insertions, 129 deletions
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index 4327c2f94e..b92498657e 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -109,6 +109,18 @@ etgc_destroy (GtkObject *object)
GTK_OBJECT_CLASS (etgc_parent_class)->destroy (object);
}
+/**
+ * e_table_group_container_construct
+ * @parent: The %GnomeCanvasGroup to create a child of.
+ * @etgc: The %ETableGroupContainer.
+ * @full_header: The full header of the %ETable.
+ * @header: The current header of the %ETable.
+ * @model: The %ETableModel of the %ETable.
+ * @sort_info: The %ETableSortInfo of the %ETable.
+ * @n: Which grouping level this is (Starts at 0 and sends n + 1 to any child %ETableGroups.
+ *
+ * This routine constructs the new %ETableGroupContainer.
+ */
void
e_table_group_container_construct (GnomeCanvasGroup *parent, ETableGroupContainer *etgc,
ETableHeader *full_header,
@@ -140,6 +152,21 @@ e_table_group_container_construct (GnomeCanvasGroup *parent, ETableGroupContaine
etgc->open = TRUE;
}
+/**
+ * e_table_group_container_new
+ * @parent: The %GnomeCanvasGroup to create a child of.
+ * @full_header: The full header of the %ETable.
+ * @header: The current header of the %ETable.
+ * @model: The %ETableModel of the %ETable.
+ * @sort_info: The %ETableSortInfo of the %ETable.
+ * @n: Which grouping level this is (Starts at 0 and sends n + 1 to any child %ETableGroups.
+ *
+ * %ETableGroupContainer is an %ETableGroup which groups by the nth
+ * grouping of the %ETableSortInfo. It creates %ETableGroups as
+ * children.
+ *
+ * Returns: The new %ETableGroupContainer.
+ */
ETableGroup *
e_table_group_container_new (GnomeCanvasGroup *parent, ETableHeader *full_header,
ETableHeader *header,
@@ -326,6 +353,13 @@ child_cursor_change (ETableGroup *etg, int row,
}
static void
+child_cursor_activated (ETableGroup *etg, int row,
+ ETableGroupContainer *etgc)
+{
+ e_table_group_cursor_activated (E_TABLE_GROUP (etgc), row);
+}
+
+static void
child_double_click (ETableGroup *etg, int row, int col, GdkEvent *event,
ETableGroupContainer *etgc)
{
@@ -406,6 +440,8 @@ etgc_add (ETableGroup *etg, gint row)
gtk_signal_connect (GTK_OBJECT (child), "cursor_change",
GTK_SIGNAL_FUNC (child_cursor_change), etgc);
+ gtk_signal_connect (GTK_OBJECT (child), "cursor_activated",
+ GTK_SIGNAL_FUNC (child_cursor_activated), etgc);
gtk_signal_connect (GTK_OBJECT (child), "double_click",
GTK_SIGNAL_FUNC (child_double_click), etgc);
gtk_signal_connect (GTK_OBJECT (child), "right_click",
diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c
index 070bce2838..86703304b4 100644
--- a/widgets/table/e-table-group-leaf.c
+++ b/widgets/table/e-table-group-leaf.c
@@ -65,6 +65,19 @@ e_table_group_leaf_construct (GnomeCanvasGroup *parent,
e_table_group_construct (parent, E_TABLE_GROUP (etgl), full_header, header, model);
}
+/**
+ * e_table_group_leaf_new
+ * @parent: The %GnomeCanvasGroup to create a child of.
+ * @full_header: The full header of the %ETable.
+ * @header: The current header of the %ETable.
+ * @model: The %ETableModel of the %ETable.
+ * @sort_info: The %ETableSortInfo of the %ETable.
+ *
+ * %ETableGroupLeaf is an %ETableGroup which simply contains an
+ * %ETableItem.
+ *
+ * Returns: The new %ETableGroupLeaf.
+ */
ETableGroup *
e_table_group_leaf_new (GnomeCanvasGroup *parent,
ETableHeader *full_header,
@@ -91,6 +104,13 @@ etgl_cursor_change (GtkObject *object, gint row, ETableGroupLeaf *etgl)
}
static void
+etgl_cursor_activated (GtkObject *object, gint row, ETableGroupLeaf *etgl)
+{
+ if (row < E_TABLE_SUBSET(etgl->subset)->n_map)
+ e_table_group_cursor_activated (E_TABLE_GROUP(etgl), E_TABLE_SUBSET(etgl->subset)->map_table[row]);
+}
+
+static void
etgl_double_click (GtkObject *object, gint row, gint col, GdkEvent *event, ETableGroupLeaf *etgl)
{
if (row < E_TABLE_SUBSET(etgl->subset)->n_map)
@@ -159,6 +179,8 @@ etgl_realize (GnomeCanvasItem *item)
gtk_signal_connect (GTK_OBJECT(etgl->item), "cursor_change",
GTK_SIGNAL_FUNC(etgl_cursor_change), etgl);
+ gtk_signal_connect (GTK_OBJECT(etgl->item), "cursor_activated",
+ GTK_SIGNAL_FUNC(etgl_cursor_activated), etgl);
gtk_signal_connect (GTK_OBJECT(etgl->item), "double_click",
GTK_SIGNAL_FUNC(etgl_double_click), etgl);
gtk_signal_connect (GTK_OBJECT(etgl->item), "right_click",
diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c
index 1568184563..d87546db0d 100644
--- a/widgets/table/e-table-group.c
+++ b/widgets/table/e-table-group.c
@@ -26,6 +26,7 @@ static GnomeCanvasGroupClass *etg_parent_class;
enum {
CURSOR_CHANGE,
+ CURSOR_ACTIVATED,
DOUBLE_CLICK,
RIGHT_CLICK,
CLICK,
@@ -52,6 +53,24 @@ etg_destroy (GtkObject *object)
GTK_OBJECT_CLASS (etg_parent_class)->destroy (object);
}
+/**
+ * e_table_group_new
+ * @parent: The %GnomeCanvasGroup to create a child of.
+ * @full_header: The full header of the %ETable.
+ * @header: The current header of the %ETable.
+ * @model: The %ETableModel of the %ETable.
+ * @sort_info: The %ETableSortInfo of the %ETable.
+ * @n: The grouping information object to group by.
+ *
+ * %ETableGroup is a collection of rows of an %ETable. It's a
+ * %GnomeCanvasItem. There are two different forms. If n < the
+ * number of groupings in the given %ETableSortInfo, then the
+ * %ETableGroup will need to contain other %ETableGroups, thus it
+ * creates an %ETableGroupContainer. Otherwise, it will just contain
+ * an %ETableItem, and thus it creates an %ETableGroupLeaf.
+ *
+ * Returns: The new %ETableGroup.
+ */
ETableGroup *
e_table_group_new (GnomeCanvasGroup *parent,
ETableHeader *full_header,
@@ -70,6 +89,16 @@ e_table_group_new (GnomeCanvasGroup *parent,
return NULL;
}
+/**
+ * e_table_group_construct
+ * @parent: The %GnomeCanvasGroup to create a child of.
+ * @etg: The %ETableGroup to construct.
+ * @full_header: The full header of the %ETable.
+ * @header: The current header of the %ETable.
+ * @model: The %ETableModel of the %ETable.
+ *
+ * This routine does the base construction of the %ETableGroup.
+ */
void
e_table_group_construct (GnomeCanvasGroup *parent,
ETableGroup *etg,
@@ -86,6 +115,14 @@ e_table_group_construct (GnomeCanvasGroup *parent,
gnome_canvas_item_constructv (GNOME_CANVAS_ITEM (etg), parent, 0, NULL);
}
+/**
+ * e_table_group_add
+ * @etg: The %ETableGroup to add a row to
+ * @row: The row to add.
+ *
+ * This routine adds the given row from the %ETableModel to this set
+ * of rows.
+ */
void
e_table_group_add (ETableGroup *etg,
gint row)
@@ -97,6 +134,13 @@ e_table_group_add (ETableGroup *etg,
ETG_CLASS (etg)->add (etg, row);
}
+/**
+ * e_table_group_add_all
+ * @etg: The %ETableGroup to add to
+ *
+ * This routine adds all the rows from the %ETableModel to this set
+ * of rows.
+ */
void
e_table_group_add_all (ETableGroup *etg)
{
@@ -107,6 +151,17 @@ e_table_group_add_all (ETableGroup *etg)
ETG_CLASS (etg)->add_all (etg);
}
+/**
+ * e_table_group_remove
+ * @etg: The %ETableGroup to remove a row from
+ * @row: The row to remove.
+ *
+ * This routine removes the given row from the %ETableModel from this
+ * set of rows.
+ *
+ * Returns: TRUE if the row was deleted and FALSE if the row was not
+ * found.
+ */
gboolean
e_table_group_remove (ETableGroup *etg,
gint row)
@@ -120,30 +175,16 @@ e_table_group_remove (ETableGroup *etg,
return FALSE;
}
-gint
-e_table_group_get_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)->get_count)
- return ETG_CLASS (etg)->get_count (etg);
- else
- 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;
-}
-
+/**
+ * e_table_group_increment
+ * @etg: The %ETableGroup to increment
+ * @position: The position to increment from
+ * @amount: The amount to increment.
+ *
+ * This routine adds amount to all rows greater than or equal to
+ * position. This is to handle when a row gets inserted into the
+ * model.
+ */
void
e_table_group_increment (ETableGroup *etg,
gint position,
@@ -156,6 +197,16 @@ e_table_group_increment (ETableGroup *etg,
ETG_CLASS (etg)->increment (etg, position, amount);
}
+/**
+ * e_table_group_increment
+ * @etg: The %ETableGroup to decrement
+ * @position: The position to decrement from
+ * @amount: The amount to decrement
+ *
+ * This routine removes amount from all rows greater than or equal to
+ * position. This is to handle when a row gets deleted from the
+ * model.
+ */
void
e_table_group_decrement (ETableGroup *etg,
gint position,
@@ -168,18 +219,55 @@ e_table_group_decrement (ETableGroup *etg,
ETG_CLASS (etg)->decrement (etg, position, amount);
}
+/**
+ * e_table_group_increment
+ * @etg: The %ETableGroup to count
+ *
+ * This routine calculates the number of rows shown in this group.
+ *
+ * Returns: The number of rows.
+ */
+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;
+}
+
+/**
+ * e_table_group_set_focus
+ * @etg: The %ETableGroup to set
+ * @direction: The direction the focus is coming from.
+ * @view_col: The column to set the focus in.
+ *
+ * Sets the focus to this widget. Places the focus in the view column
+ * coming from direction direction.
+ */
void
e_table_group_set_focus (ETableGroup *etg,
EFocus direction,
- gint row)
+ gint view_col)
{
g_return_if_fail (etg != NULL);
g_return_if_fail (E_IS_TABLE_GROUP (etg));
if (ETG_CLASS (etg)->set_focus)
- ETG_CLASS (etg)->set_focus (etg, direction, row);
+ ETG_CLASS (etg)->set_focus (etg, direction, view_col);
}
+/**
+ * e_table_group_get_focus
+ * @etg: The %ETableGroup to check
+ *
+ * Calculates if this group has the focus.
+ *
+ * Returns: TRUE if this group has the focus.
+ */
gboolean
e_table_group_get_focus (ETableGroup *etg)
{
@@ -192,7 +280,15 @@ e_table_group_get_focus (ETableGroup *etg)
return FALSE;
}
-gboolean
+/**
+ * e_table_group_get_focus_column
+ * @etg: The %ETableGroup to check
+ *
+ * Calculates which column in this group has the focus.
+ *
+ * Returns: The column index (view column).
+ */
+gint
e_table_group_get_focus_column (ETableGroup *etg)
{
g_return_val_if_fail (etg != NULL, FALSE);
@@ -201,21 +297,18 @@ e_table_group_get_focus_column (ETableGroup *etg)
if (ETG_CLASS (etg)->get_focus_column)
return ETG_CLASS (etg)->get_focus_column (etg);
else
- return FALSE;
-}
-
-ETableCol *
-e_table_group_get_ecol (ETableGroup *etg)
-{
- g_return_val_if_fail (etg != NULL, NULL);
- g_return_val_if_fail (E_IS_TABLE_GROUP (etg), NULL);
-
- if (ETG_CLASS (etg)->get_ecol)
- return ETG_CLASS (etg)->get_ecol (etg);
- else
- return NULL;
+ return -1;
}
+/**
+ * e_table_group_get_printable
+ * @etg: %ETableGroup which will be printed
+ *
+ * This routine creates and returns an %EPrintable that can be used to
+ * print the given %ETableGroup.
+ *
+ * Returns: The %EPrintable.
+ */
EPrintable *
e_table_group_get_printable (ETableGroup *etg)
{
@@ -228,6 +321,20 @@ e_table_group_get_printable (ETableGroup *etg)
return NULL;
}
+/**
+ * e_table_group_compute_location
+ * @eti: %ETableGroup to look in.
+ * @x: A pointer to the x location to find in the %ETableGroup.
+ * @y: A pointer to the y location to find in the %ETableGroup.
+ * @row: A pointer to the location to store the found row in.
+ * @col: A pointer to the location to store the found col in.
+ *
+ * This routine locates the pixel location (*x, *y) in the
+ * %ETableGroup. If that location is in the %ETableGroup, *row and
+ * *col are set to the view row and column where it was found. If
+ * that location is not in the %ETableGroup, the height of the
+ * %ETableGroup is removed from the value y points to.
+ */
void
e_table_group_compute_location (ETableGroup *etg, int *x, int *y, int *row, int *col)
{
@@ -238,6 +345,13 @@ e_table_group_compute_location (ETableGroup *etg, int *x, int *y, int *row, int
ETG_CLASS (etg)->compute_location (etg, x, y, row, col);
}
+/**
+ * e_table_group_cursor_change
+ * @eti: %ETableGroup to emit the signal on
+ * @row: The new cursor row (model row)
+ *
+ * This routine emits the "cursor_change" signal.
+ */
void
e_table_group_cursor_change (ETableGroup *e_table_group, gint row)
{
@@ -249,6 +363,33 @@ e_table_group_cursor_change (ETableGroup *e_table_group, gint row)
row);
}
+/**
+ * e_table_group_cursor_activated
+ * @eti: %ETableGroup to emit the signal on
+ * @row: The cursor row (model row)
+ *
+ * This routine emits the "cursor_activated" signal.
+ */
+void
+e_table_group_cursor_activated (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_ACTIVATED],
+ row);
+}
+
+/**
+ * e_table_group_double_click
+ * @eti: %ETableGroup to emit the signal on
+ * @row: The row clicked on (model row)
+ * @col: The col clicked on (model col)
+ * @event: The event that caused this signal
+ *
+ * This routine emits the "double_click" signal.
+ */
void
e_table_group_double_click (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event)
{
@@ -260,6 +401,15 @@ e_table_group_double_click (ETableGroup *e_table_group, gint row, gint col, GdkE
row, col, event);
}
+/**
+ * e_table_group_right_click
+ * @eti: %ETableGroup to emit the signal on
+ * @row: The row clicked on (model row)
+ * @col: The col clicked on (model col)
+ * @event: The event that caused this signal
+ *
+ * This routine emits the "right_click" signal.
+ */
gint
e_table_group_right_click (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event)
{
@@ -275,6 +425,15 @@ e_table_group_right_click (ETableGroup *e_table_group, gint row, gint col, GdkEv
return return_val;
}
+/**
+ * e_table_group_click
+ * @eti: %ETableGroup to emit the signal on
+ * @row: The row clicked on (model row)
+ * @col: The col clicked on (model col)
+ * @event: The event that caused this signal
+ *
+ * This routine emits the "click" signal.
+ */
gint
e_table_group_click (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event)
{
@@ -290,6 +449,15 @@ e_table_group_click (ETableGroup *e_table_group, gint row, gint col, GdkEvent *e
return return_val;
}
+/**
+ * e_table_group_key_press
+ * @eti: %ETableGroup to emit the signal on
+ * @row: The cursor row (model row)
+ * @col: The cursor col (model col)
+ * @event: The event that caused this signal
+ *
+ * This routine emits the "key_press" signal.
+ */
gint
e_table_group_key_press (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event)
{
@@ -305,6 +473,14 @@ e_table_group_key_press (ETableGroup *e_table_group, gint row, gint col, GdkEven
return return_val;
}
+/**
+ * e_table_group_get_header
+ * @eti: %ETableGroup to check
+ *
+ * This routine returns the %ETableGroup's header.
+ *
+ * Returns: The %ETableHeader.
+ */
ETableHeader *
e_table_group_get_header (ETableGroup *etg)
{
@@ -354,6 +530,7 @@ etg_class_init (GtkObjectClass *object_class)
item_class->event = etg_event;
klass->cursor_change = NULL;
+ klass->cursor_activated = NULL;
klass->double_click = NULL;
klass->right_click = NULL;
klass->click = NULL;
@@ -362,13 +539,11 @@ etg_class_init (GtkObjectClass *object_class)
klass->add = NULL;
klass->add_all = NULL;
klass->remove = NULL;
- klass->get_count = NULL;
klass->row_count = NULL;
klass->increment = NULL;
klass->decrement = NULL;
klass->set_focus = NULL;
klass->get_focus = etg_get_focus;
- klass->get_ecol = NULL;
klass->get_printable = NULL;
klass->compute_location = NULL;
@@ -382,6 +557,14 @@ etg_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+ etg_signals [CURSOR_ACTIVATED] =
+ gtk_signal_new ("cursor_activated",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableGroupClass, cursor_activated),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
etg_signals [DOUBLE_CLICK] =
gtk_signal_new ("double_click",
GTK_RUN_LAST,
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
index 06775c9b2d..41a6c60d95 100644
--- a/widgets/table/e-table-group.h
+++ b/widgets/table/e-table-group.h
@@ -46,6 +46,7 @@ typedef struct {
/* Signals */
void (*cursor_change) (ETableGroup *etg, int row);
+ void (*cursor_activated) (ETableGroup *etg, int row);
void (*double_click) (ETableGroup *etg, int row, int col, GdkEvent *event);
gint (*right_click) (ETableGroup *etg, int row, int col, GdkEvent *event);
gint (*click) (ETableGroup *etg, int row, int col, GdkEvent *event);
@@ -55,83 +56,81 @@ typedef struct {
void (*add) (ETableGroup *etg, gint row);
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 (*decrement) (ETableGroup *etg, gint position, gint amount);
void (*set_focus) (ETableGroup *etg, EFocus direction, gint view_col);
gboolean (*get_focus) (ETableGroup *etg);
gint (*get_focus_column) (ETableGroup *etg);
- ETableCol *(*get_ecol) (ETableGroup *etg);
EPrintable *(*get_printable) (ETableGroup *etg);
void (*compute_location) (ETableGroup *etg, int *x, int *y, int *row, int *col);
} ETableGroupClass;
/* Virtual functions */
-void e_table_group_add (ETableGroup *etg,
- gint row);
-void e_table_group_add_all (ETableGroup *etg);
-gboolean e_table_group_remove (ETableGroup *etg,
- gint row);
-gint e_table_group_get_count (ETableGroup *etg);
-void e_table_group_increment (ETableGroup *etg,
- gint position,
- gint amount);
-void e_table_group_decrement (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);
-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);
-ETableCol *e_table_group_get_ecol (ETableGroup *etg);
-EPrintable *e_table_group_get_printable (ETableGroup *etg);
-void e_table_group_compute_location (ETableGroup *etg,
- int *x,
- int *y,
- int *row,
- int *col);
-
-ETableGroup *e_table_group_new (GnomeCanvasGroup *parent,
- ETableHeader *full_header,
- ETableHeader *header,
- ETableModel *model,
- ETableSortInfo *sort_info,
- int n);
-void e_table_group_construct (GnomeCanvasGroup *parent,
- ETableGroup *etg,
- ETableHeader *full_header,
- ETableHeader *header,
- ETableModel *model);
+void e_table_group_add (ETableGroup *etg,
+ gint row);
+void e_table_group_add_all (ETableGroup *etg);
+gboolean e_table_group_remove (ETableGroup *etg,
+ gint row);
+void e_table_group_increment (ETableGroup *etg,
+ gint position,
+ gint amount);
+void e_table_group_decrement (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);
+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);
+EPrintable *e_table_group_get_printable (ETableGroup *etg);
+void e_table_group_compute_location (ETableGroup *etg,
+ int *x,
+ int *y,
+ int *row,
+ int *col);
+
+ETableGroup *e_table_group_new (GnomeCanvasGroup *parent,
+ ETableHeader *full_header,
+ ETableHeader *header,
+ ETableModel *model,
+ ETableSortInfo *sort_info,
+ int n);
+void e_table_group_construct (GnomeCanvasGroup *parent,
+ ETableGroup *etg,
+ ETableHeader *full_header,
+ ETableHeader *header,
+ ETableModel *model);
/* For emitting the signals */
-void e_table_group_cursor_change (ETableGroup *etg,
- gint row);
-void e_table_group_double_click (ETableGroup *etg,
- gint row,
- gint col,
- GdkEvent *event);
-gint e_table_group_right_click (ETableGroup *etg,
- gint row,
- gint col,
- GdkEvent *event);
-gint e_table_group_click (ETableGroup *etg,
- gint row,
- gint col,
- GdkEvent *event);
-gint e_table_group_key_press (ETableGroup *etg,
- gint row,
- gint col,
- GdkEvent *event);
-
-GtkType e_table_group_get_type (void);
+void e_table_group_cursor_change (ETableGroup *etg,
+ gint row);
+void e_table_group_cursor_activated (ETableGroup *etg,
+ gint row);
+void e_table_group_double_click (ETableGroup *etg,
+ gint row,
+ gint col,
+ GdkEvent *event);
+gint e_table_group_right_click (ETableGroup *etg,
+ gint row,
+ gint col,
+ GdkEvent *event);
+gint e_table_group_click (ETableGroup *etg,
+ gint row,
+ gint col,
+ GdkEvent *event);
+gint e_table_group_key_press (ETableGroup *etg,
+ gint row,
+ gint col,
+ GdkEvent *event);
+GtkType e_table_group_get_type (void);
typedef void (*ETableGroupLeafFn) (void *e_table_item, void *closure);
-void e_table_group_apply_to_leafs (ETableGroup *etg,
- ETableGroupLeafFn fn, void *closure);
+void e_table_group_apply_to_leafs (ETableGroup *etg,
+ ETableGroupLeafFn fn,
+ void *closure);
#endif /* _E_TABLE_GROUP_H_ */
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 756a5d785b..a455775458 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -31,6 +31,7 @@ static GnomeCanvasItemClass *eti_parent_class;
enum {
CURSOR_CHANGE,
+ CURSOR_ACTIVATED,
DOUBLE_CLICK,
RIGHT_CLICK,
CLICK,
@@ -61,6 +62,7 @@ static int eti_get_minimum_width (ETableItem *eti);
static int eti_row_height (ETableItem *eti, int row);
static void e_table_item_focus (ETableItem *eti, int col, int row, GdkModifierType state);
static void eti_cursor_change (ETableSelectionModel *selection, int row, int col, ETableItem *eti);
+static void eti_cursor_activated (ETableSelectionModel *selection, int row, int col, ETableItem *eti);
static void eti_selection_change (ETableSelectionModel *selection, ETableItem *eti);
#if 0
static void eti_request_region_show (ETableItem *eti,
@@ -345,10 +347,12 @@ eti_remove_table_selection_model (ETableItem *eti)
eti->selection_change_id);
gtk_signal_disconnect (GTK_OBJECT (eti->selection),
eti->cursor_change_id);
+ gtk_signal_disconnect (GTK_OBJECT (eti->selection),
+ eti->cursor_activated_id);
gtk_object_unref (GTK_OBJECT (eti->selection));
eti->selection_change_id = 0;
- eti->cursor_change_id = 0;
+ eti->cursor_activated_id = 0;
eti->selection = NULL;
}
@@ -827,6 +831,10 @@ eti_add_table_selection_model (ETableItem *eti, ETableSelectionModel *selection)
GTK_OBJECT (selection), "cursor_changed",
GTK_SIGNAL_FUNC (eti_cursor_change), eti);
+ eti->cursor_activated_id = gtk_signal_connect (
+ GTK_OBJECT (selection), "cursor_activated",
+ GTK_SIGNAL_FUNC (eti_cursor_activated), eti);
+
eti_selection_change(selection, eti);
}
@@ -1048,6 +1056,7 @@ eti_init (GnomeCanvasItem *item)
eti->selection_change_id = 0;
eti->cursor_change_id = 0;
+ eti->cursor_activated_id = 0;
eti->selection = NULL;
eti->needs_redraw = 0;
@@ -1966,32 +1975,33 @@ static void
eti_class_init (GtkObjectClass *object_class)
{
GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) object_class;
- ETableItemClass *eti_class = (ETableItemClass *) object_class;
+ ETableItemClass *eti_class = (ETableItemClass *) object_class;
- eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE);
+ eti_parent_class = gtk_type_class (PARENT_OBJECT_TYPE);
- object_class->destroy = eti_destroy;
- object_class->set_arg = eti_set_arg;
- object_class->get_arg = eti_get_arg;
-
- item_class->update = eti_update;
- item_class->realize = eti_realize;
- item_class->unrealize = eti_unrealize;
- item_class->draw = eti_draw;
- item_class->point = eti_point;
- item_class->event = eti_event;
+ object_class->destroy = eti_destroy;
+ object_class->set_arg = eti_set_arg;
+ object_class->get_arg = eti_get_arg;
+
+ item_class->update = eti_update;
+ item_class->realize = eti_realize;
+ item_class->unrealize = eti_unrealize;
+ item_class->draw = eti_draw;
+ item_class->point = eti_point;
+ item_class->event = eti_event;
- eti_class->cursor_change = NULL;
- eti_class->double_click = NULL;
- eti_class->right_click = NULL;
- eti_class->click = NULL;
- eti_class->key_press = NULL;
-
- gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_OBJECT,
+ eti_class->cursor_change = NULL;
+ eti_class->cursor_activated = NULL;
+ eti_class->double_click = NULL;
+ eti_class->right_click = NULL;
+ eti_class->click = NULL;
+ eti_class->key_press = NULL;
+
+ gtk_object_add_arg_type ("ETableItem::ETableHeader", E_TABLE_HEADER_TYPE,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
- gtk_object_add_arg_type ("ETableItem::ETableModel", GTK_TYPE_OBJECT,
+ gtk_object_add_arg_type ("ETableItem::ETableModel", E_TABLE_MODEL_TYPE,
GTK_ARG_WRITABLE, ARG_TABLE_MODEL);
- gtk_object_add_arg_type ("ETableItem::table_selection_model", GTK_TYPE_OBJECT,
+ gtk_object_add_arg_type ("ETableItem::table_selection_model", E_TABLE_SELECTION_MODEL_TYPE,
GTK_ARG_WRITABLE, ARG_TABLE_SELECTION_MODEL);
gtk_object_add_arg_type ("ETableItem::drawgrid", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
@@ -2019,6 +2029,14 @@ eti_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+ eti_signals [CURSOR_ACTIVATED] =
+ gtk_signal_new ("cursor_activated",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableItemClass, cursor_activated),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
eti_signals [DOUBLE_CLICK] =
gtk_signal_new ("double_click",
GTK_RUN_LAST,
@@ -2158,6 +2176,23 @@ eti_cursor_change (ETableSelectionModel *selection, int row, int col, ETableItem
}
static void
+eti_cursor_activated (ETableSelectionModel *selection, int row, int col, ETableItem *eti)
+{
+ int view_row = model_to_view_row(eti, row);
+ int view_col = model_to_view_col(eti, col);
+
+ if (view_row == -1 || view_col == -1) {
+ e_table_item_leave_edit (eti);
+ return;
+ }
+
+ if (eti_editing(eti))
+ e_table_item_leave_edit (eti);
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [CURSOR_ACTIVATED],
+ view_row);
+}
+
+static void
eti_selection_change (ETableSelectionModel *selection, ETableItem *eti)
{
eti->needs_redraw = TRUE;
@@ -2221,7 +2256,7 @@ e_table_item_leave_edit (ETableItem *eti)
}
/**
- * e_table_item_enter_edit
+ * e_table_item_compute_location
* @eti: %ETableItem to look in.
* @x: A pointer to the x location to find in the %ETableItem.
* @y: A pointer to the y location to find in the %ETableItem.
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
index be53f0657f..fda0caa6a8 100644
--- a/widgets/table/e-table-item.h
+++ b/widgets/table/e-table-item.h
@@ -44,6 +44,7 @@ typedef struct {
int selection_change_id;
int cursor_change_id;
+ int cursor_activated_id;
GdkGC *fill_gc;
GdkGC *grid_gc;
@@ -99,6 +100,7 @@ typedef struct {
GnomeCanvasItemClass parent_class;
void (*cursor_change) (ETableItem *eti, int row);
+ void (*cursor_activated) (ETableItem *eti, int row);
void (*double_click) (ETableItem *eti, int row);
gint (*right_click) (ETableItem *eti, int row, int col, GdkEvent *event);
gint (*click) (ETableItem *eti, int row, int col, GdkEvent *event);
diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c
index 85a22fd638..57869602a4 100644
--- a/widgets/table/e-table-selection-model.c
+++ b/widgets/table/e-table-selection-model.c
@@ -31,6 +31,7 @@ static void etsm_select_single_row (ETableSelectionModel *selection, int row);
enum {
CURSOR_CHANGED,
+ CURSOR_ACTIVATED,
SELECTION_CHANGED,
LAST_SIGNAL
};
@@ -290,6 +291,14 @@ e_table_selection_model_class_init (ETableSelectionModelClass *klass)
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+ e_table_selection_model_signals [CURSOR_ACTIVATED] =
+ gtk_signal_new ("cursor_activated",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableSelectionModelClass, cursor_activated),
+ gtk_marshal_NONE__INT_INT,
+ GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+
e_table_selection_model_signals [SELECTION_CHANGED] =
gtk_signal_new ("selection_changed",
GTK_RUN_LAST,
@@ -298,7 +307,8 @@ e_table_selection_model_class_init (ETableSelectionModelClass *klass)
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
- klass->cursor_changed = NULL;
+ klass->cursor_changed = NULL;
+ klass->cursor_activated = NULL;
klass->selection_changed = NULL;
gtk_object_class_add_signals (object_class, e_table_selection_model_signals, LAST_SIGNAL);
@@ -545,6 +555,8 @@ e_table_selection_model_do_something (ETableSelectionModel *selection,
selection->cursor_col = col;
gtk_signal_emit(GTK_OBJECT(selection),
e_table_selection_model_signals[CURSOR_CHANGED], row, col);
+ gtk_signal_emit(GTK_OBJECT(selection),
+ e_table_selection_model_signals[CURSOR_ACTIVATED], row, col);
}
}
}
@@ -583,6 +595,7 @@ move_selection (ETableSelectionModel *selection,
{
int row = selection->cursor_row;
int col = selection->cursor_col;
+ int cursor_activated = TRUE;
gint shift_p = state & GDK_SHIFT_MASK;
gint ctrl_p = state & GDK_CONTROL_MASK;
@@ -602,7 +615,8 @@ move_selection (ETableSelectionModel *selection,
etsm_set_selection_end (selection, row);
} else if (!ctrl_p) {
etsm_select_single_row (selection, row);
- }
+ } else
+ cursor_activated = FALSE;
break;
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_MULTIPLE:
@@ -614,6 +628,9 @@ move_selection (ETableSelectionModel *selection,
selection->cursor_row = row;
gtk_signal_emit(GTK_OBJECT(selection),
e_table_selection_model_signals[CURSOR_CHANGED], row, col);
+ if (cursor_activated)
+ gtk_signal_emit(GTK_OBJECT(selection),
+ e_table_selection_model_signals[CURSOR_ACTIVATED], row, col);
}
return TRUE;
}
@@ -640,8 +657,20 @@ e_table_selection_model_key_press (ETableSelectionModel *selection,
return move_selection(selection, FALSE, key->state);
break;
case GDK_space:
+ case GDK_KP_Space:
if (selection->mode != GTK_SELECTION_SINGLE) {
etsm_toggle_single_row (selection, selection->cursor_row);
+ gtk_signal_emit(GTK_OBJECT(selection),
+ e_table_selection_model_signals[CURSOR_ACTIVATED], selection->cursor_row, selection->cursor_col);
+ return TRUE;
+ }
+ break;
+ case GDK_Return:
+ case GDK_KP_Enter:
+ if (selection->mode != GTK_SELECTION_SINGLE) {
+ etsm_select_single_row (selection, selection->cursor_row);
+ gtk_signal_emit(GTK_OBJECT(selection),
+ e_table_selection_model_signals[CURSOR_ACTIVATED], selection->cursor_row, selection->cursor_col);
return TRUE;
}
break;
diff --git a/widgets/table/e-table-selection-model.h b/widgets/table/e-table-selection-model.h
index f1d1d0cf45..2761301747 100644
--- a/widgets/table/e-table-selection-model.h
+++ b/widgets/table/e-table-selection-model.h
@@ -44,6 +44,7 @@ typedef struct {
*/
void (*cursor_changed) (ETableSelectionModel *selection, int row, int col);
+ void (*cursor_activated) (ETableSelectionModel *selection, int row, int col);
void (*selection_changed) (ETableSelectionModel *selection);
} ETableSelectionModelClass;
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index ba9b65a42c..39e388b79f 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -43,6 +43,7 @@ static GtkObjectClass *e_table_parent_class;
enum {
CURSOR_CHANGE,
+ CURSOR_ACTIVATED,
SELECTION_CHANGE,
DOUBLE_CLICK,
RIGHT_CLICK,
@@ -338,6 +339,14 @@ group_cursor_change (ETableGroup *etg, int row, ETable *et)
}
static void
+group_cursor_activated (ETableGroup *etg, int row, ETable *et)
+{
+ gtk_signal_emit (GTK_OBJECT (et),
+ et_signals [CURSOR_ACTIVATED],
+ row);
+}
+
+static void
group_double_click (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et)
{
gtk_signal_emit (GTK_OBJECT (et),
@@ -441,6 +450,8 @@ changed_idle (gpointer data)
NULL);
gtk_signal_connect (GTK_OBJECT (et->group), "cursor_change",
GTK_SIGNAL_FUNC (group_cursor_change), et);
+ gtk_signal_connect (GTK_OBJECT (et->group), "cursor_activated",
+ GTK_SIGNAL_FUNC (group_cursor_activated), et);
gtk_signal_connect (GTK_OBJECT (et->group), "double_click",
GTK_SIGNAL_FUNC (group_double_click), et);
gtk_signal_connect (GTK_OBJECT (et->group), "right_click",
@@ -618,6 +629,8 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
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), "cursor_activated",
+ GTK_SIGNAL_FUNC(group_cursor_activated), e_table);
gtk_signal_connect (GTK_OBJECT (e_table->group), "double_click",
GTK_SIGNAL_FUNC(group_double_click), e_table);
gtk_signal_connect (GTK_OBJECT (e_table->group), "right_click",
@@ -1722,6 +1735,8 @@ e_table_compute_location (ETable *table, GtkWidget *widget,
{
if (!(row || col))
return;
+ x += GTK_LAYOUT(table->table_canvas)->hadjustment->value;
+ y += GTK_LAYOUT(table->table_canvas)->vadjustment->value;
e_table_group_compute_location(table->group, &x, &y, row, col);
}
@@ -2005,6 +2020,7 @@ e_table_class_init (GtkObjectClass *object_class)
object_class->get_arg = et_get_arg;
klass->cursor_change = NULL;
+ klass->cursor_activated = NULL;
klass->selection_change = NULL;
klass->double_click = NULL;
klass->right_click = NULL;
@@ -2029,6 +2045,14 @@ e_table_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+ et_signals [CURSOR_ACTIVATED] =
+ gtk_signal_new ("cursor_activated",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableClass, cursor_activated),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
et_signals [SELECTION_CHANGE] =
gtk_signal_new ("selection_change",
GTK_RUN_LAST,
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index d52333ada9..7aea980c13 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -101,6 +101,7 @@ typedef struct {
GtkTableClass parent_class;
void (*cursor_change) (ETable *et, int row);
+ void (*cursor_activated) (ETable *et, int row);
void (*selection_change) (ETable *et);
void (*double_click) (ETable *et, int row, int col, GdkEvent *event);
gint (*right_click) (ETable *et, int row, int col, GdkEvent *event);