diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-06-06 13:50:12 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-06-06 13:50:12 +0800 |
commit | 06978bc7368680efabec6a2cde14c74ca5201d04 (patch) | |
tree | 9b01fb6ea232dbb144e7ae5687a004c98bf1272b | |
parent | ce74cc7bb1d1a3f27d93dfa2842a9f13e461714f (diff) | |
download | gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.tar gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.tar.gz gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.tar.bz2 gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.tar.lz gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.tar.xz gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.tar.zst gsoc2013-evolution-06978bc7368680efabec6a2cde14c74ca5201d04.zip |
Added a right click signal.
2000-06-06 Christopher James Lahey <clahey@helixcode.com>
* e-table-group-container.c, e-table-group-leaf.c,
e-table-group.c, e-table-group.h, e-table-item.c, e-table-item.h,
e-table.c, e-table.h: Added a right click signal.
* e-table-sorted-variable.c: Fixed a buffer overrun.
svn path=/trunk/; revision=3437
-rw-r--r-- | widgets/e-table/ChangeLog | 8 | ||||
-rw-r--r-- | widgets/e-table/e-table-group-container.c | 9 | ||||
-rw-r--r-- | widgets/e-table/e-table-group-leaf.c | 11 | ||||
-rw-r--r-- | widgets/e-table/e-table-group.c | 25 | ||||
-rw-r--r-- | widgets/e-table/e-table-group.h | 5 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.c | 75 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.h | 1 | ||||
-rw-r--r-- | widgets/e-table/e-table-sorted-variable.c | 2 | ||||
-rw-r--r-- | widgets/e-table/e-table.c | 24 | ||||
-rw-r--r-- | widgets/e-table/e-table.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table-group-container.c | 9 | ||||
-rw-r--r-- | widgets/table/e-table-group-leaf.c | 11 | ||||
-rw-r--r-- | widgets/table/e-table-group.c | 25 | ||||
-rw-r--r-- | widgets/table/e-table-group.h | 5 | ||||
-rw-r--r-- | widgets/table/e-table-item.c | 75 | ||||
-rw-r--r-- | widgets/table/e-table-item.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table-sorted-variable.c | 2 | ||||
-rw-r--r-- | widgets/table/e-table.c | 24 | ||||
-rw-r--r-- | widgets/table/e-table.h | 1 |
19 files changed, 262 insertions, 52 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index ae4163f8ae..2d81cf5ac3 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,3 +1,11 @@ +2000-06-06 Christopher James Lahey <clahey@helixcode.com> + + * e-table-group-container.c, e-table-group-leaf.c, + e-table-group.c, e-table-group.h, e-table-item.c, e-table-item.h, + e-table.c, e-table.h: Added a right click signal. + + * e-table-sorted-variable.c: Fixed a buffer overrun. + 2000-06-02 Christopher James Lahey <clahey@helixcode.com> * e-table-sorted-variable.c: Fixed the multiple copies of rows in diff --git a/widgets/e-table/e-table-group-container.c b/widgets/e-table/e-table-group-container.c index 4aa7e2fe8a..a2e9575bcb 100644 --- a/widgets/e-table/e-table-group-container.c +++ b/widgets/e-table/e-table-group-container.c @@ -324,6 +324,13 @@ child_double_click (ETableGroup *etg, int row, } static gint +child_right_click (ETableGroup *etg, int row, int col, GdkEvent *event, + ETableGroupContainer *etgc) +{ + return e_table_group_right_click (E_TABLE_GROUP (etgc), row, col, event); +} + +static gint child_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETableGroupContainer *etgc) { @@ -385,6 +392,8 @@ etgc_add (ETableGroup *etg, gint row) GTK_SIGNAL_FUNC (child_cursor_change), etgc); gtk_signal_connect (GTK_OBJECT (child), "double_click", GTK_SIGNAL_FUNC (child_double_click), etgc); + gtk_signal_connect (GTK_OBJECT (child), "right_click", + GTK_SIGNAL_FUNC (child_right_click), etgc); gtk_signal_connect (GTK_OBJECT (child), "key_press", GTK_SIGNAL_FUNC (child_key_press), etgc); child_node->child = child; diff --git a/widgets/e-table/e-table-group-leaf.c b/widgets/e-table/e-table-group-leaf.c index dcf9c280c4..25819bb188 100644 --- a/widgets/e-table/e-table-group-leaf.c +++ b/widgets/e-table/e-table-group-leaf.c @@ -113,6 +113,15 @@ etgl_key_press (GtkObject *object, gint row, gint col, GdkEvent *event, ETableGr return 0; } +static gint +etgl_right_click (GtkObject *object, gint row, gint col, GdkEvent *event, ETableGroupLeaf *etgl) +{ + if (row < E_TABLE_SUBSET(etgl->subset)->n_map) + return e_table_group_right_click (E_TABLE_GROUP(etgl), E_TABLE_SUBSET(etgl->subset)->map_table[row], col, event); + else + return 0; +} + static void etgl_reflow (GnomeCanvasItem *item, gint flags) { @@ -151,6 +160,8 @@ etgl_realize (GnomeCanvasItem *item) GTK_SIGNAL_FUNC(etgl_cursor_change), 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", + GTK_SIGNAL_FUNC(etgl_right_click), etgl); gtk_signal_connect (GTK_OBJECT(etgl->item), "key_press", GTK_SIGNAL_FUNC(etgl_key_press), etgl); e_canvas_item_request_reflow(item); diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c index 9c873e63f9..987636ed6b 100644 --- a/widgets/e-table/e-table-group.c +++ b/widgets/e-table/e-table-group.c @@ -31,6 +31,7 @@ enum { ROW_SELECTION, CURSOR_CHANGE, DOUBLE_CLICK, + RIGHT_CLICK, KEY_PRESS, LAST_SIGNAL }; @@ -273,6 +274,21 @@ e_table_group_double_click (ETableGroup *e_table_group, gint row) } gint +e_table_group_right_click (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event) +{ + gint return_val = 0; + + g_return_val_if_fail (e_table_group != NULL, 0); + g_return_val_if_fail (E_IS_TABLE_GROUP (e_table_group), 0); + + gtk_signal_emit (GTK_OBJECT (e_table_group), + etg_signals [RIGHT_CLICK], + row, col, event, &return_val); + + return return_val; +} + +gint e_table_group_key_press (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event) { gint return_val = 0; @@ -338,6 +354,7 @@ etg_class_init (GtkObjectClass *object_class) klass->row_selection = NULL; klass->cursor_change = NULL; klass->double_click = NULL; + klass->right_click = NULL; klass->key_press = NULL; klass->add = NULL; @@ -379,6 +396,14 @@ etg_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + etg_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableGroupClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + etg_signals [KEY_PRESS] = gtk_signal_new ("key_press", GTK_RUN_LAST, diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h index 2260168cd4..8f9e047959 100644 --- a/widgets/e-table/e-table-group.h +++ b/widgets/e-table/e-table-group.h @@ -46,6 +46,7 @@ typedef struct { void (*row_selection) (ETableGroup *etg, int row, gboolean selected); void (*cursor_change) (ETableGroup *etg, int row); void (*double_click) (ETableGroup *etg, int row); + gint (*right_click) (ETableGroup *etg, int row, int col, GdkEvent *event); gint (*key_press) (ETableGroup *etg, int row, int col, GdkEvent *event); /* Virtual functions. */ @@ -107,6 +108,10 @@ void e_table_group_cursor_change (ETableGroup *etg, gint row); void e_table_group_double_click (ETableGroup *etg, gint row); +gint e_table_group_right_click (ETableGroup *etg, + gint row, + gint col, + GdkEvent *event); gint e_table_group_key_press (ETableGroup *etg, gint row, gint col, diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c index 8d96543eed..e494e5ed2b 100644 --- a/widgets/e-table/e-table-item.c +++ b/widgets/e-table/e-table-item.c @@ -32,6 +32,7 @@ enum { ROW_SELECTION, CURSOR_CHANGE, DOUBLE_CLICK, + RIGHT_CLICK, KEY_PRESS, LAST_SIGNAL }; @@ -1187,33 +1188,48 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) double x1, y1; int col, row; - if (e->button.button == 5 || - e->button.button == 4) - return FALSE; - - gnome_canvas_item_w2i (item, &e->button.x, &e->button.y); - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->cursor_row == row && eti->cursor_col == col){ + switch (e->button.button) { + case 1: /* Fall through. */ + case 2: + gnome_canvas_item_w2i (item, &e->button.x, &e->button.y); - ecol = e_table_header_get_column (eti->header, col); - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x = x1; - e->button.y = y1; - e_cell_event (ecell_view, e, ecol->col_idx, col, row); - } else { - /* - * Focus the cell, and select the row - */ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, col, row); + if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) + return TRUE; + + if (eti->cursor_row == row && eti->cursor_col == col){ + + ecol = e_table_header_get_column (eti->header, col); + ecell_view = eti->cell_views [col]; + + /* + * Adjust the event positions + */ + e->button.x = x1; + e->button.y = y1; + + e_cell_event (ecell_view, e, ecol->col_idx, col, row); + } else { + /* + * Focus the cell, and select the row + */ + e_table_item_leave_edit (eti); + e_table_item_focus (eti, col, row); + } + break; + case 3: + gnome_canvas_item_w2i (item, &e->button.x, &e->button.y); + if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) + return TRUE; + + gtk_signal_emit (GTK_OBJECT (eti), eti_signals [RIGHT_CLICK], + row, col, e, &return_val); + break; + case 4: + case 5: + return FALSE; + break; + } break; } @@ -1387,6 +1403,7 @@ eti_class_init (GtkObjectClass *object_class) eti_class->row_selection = eti_row_selection; eti_class->cursor_change = NULL; eti_class->double_click = NULL; + eti_class->right_click = NULL; eti_class->key_press = NULL; gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_OBJECT, @@ -1437,6 +1454,14 @@ eti_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + eti_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableItemClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + eti_signals [KEY_PRESS] = gtk_signal_new ("key_press", GTK_RUN_LAST, diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h index 54defe30e1..961103b665 100644 --- a/widgets/e-table/e-table-item.h +++ b/widgets/e-table/e-table-item.h @@ -93,6 +93,7 @@ typedef struct { void (*row_selection) (ETableItem *eti, int row, gboolean selected); void (*cursor_change) (ETableItem *eti, int row); void (*double_click) (ETableItem *eti, int row); + gint (*right_click) (ETableItem *eti, int row, int col, GdkEvent *event); gint (*key_press) (ETableItem *eti, int row, int col, GdkEvent *event); } ETableItemClass; diff --git a/widgets/e-table/e-table-sorted-variable.c b/widgets/e-table/e-table-sorted-variable.c index 8c7e49cbbd..f7719df3c1 100644 --- a/widgets/e-table/e-table-sorted-variable.c +++ b/widgets/e-table/e-table-sorted-variable.c @@ -153,7 +153,7 @@ etsv_add (ETableSubsetVariable *etssv, i = etss->n_map; if (etsv->sort_idle_id == 0) { i = 0; - while (etsv_compare(etsv, etss->map_table[i], row) < 0) + while (i < etss->n_map && etsv_compare(etsv, etss->map_table[i], row) < 0) i++; memmove(etss->map_table + i + 1, etss->map_table + i, (etss->n_map - i) * sizeof(int)); } diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c index f928e555ed..21a92f5ecb 100644 --- a/widgets/e-table/e-table.c +++ b/widgets/e-table/e-table.c @@ -42,6 +42,7 @@ enum { ROW_SELECTION, CURSOR_CHANGE, DOUBLE_CLICK, + RIGHT_CLICK, KEY_PRESS, LAST_SIGNAL }; @@ -208,6 +209,16 @@ group_double_click (ETableGroup *etg, int row, ETable *et) } static gint +group_right_click (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et) +{ + int return_val; + gtk_signal_emit (GTK_OBJECT (et), + et_signals [RIGHT_CLICK], + row, col, event, &return_val); + return return_val; +} + +static gint group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et) { int return_val; @@ -242,6 +253,8 @@ changed_idle (gpointer data) GTK_SIGNAL_FUNC (group_cursor_change), 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", + GTK_SIGNAL_FUNC (group_right_click), et); gtk_signal_connect (GTK_OBJECT (et->group), "key_press", GTK_SIGNAL_FUNC (group_key_press), et); e_table_fill_table (et, et->model); @@ -328,6 +341,8 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h 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); + gtk_signal_connect (GTK_OBJECT (e_table->group), "right_click", + GTK_SIGNAL_FUNC(group_right_click), e_table); gtk_signal_connect (GTK_OBJECT (e_table->group), "key_press", GTK_SIGNAL_FUNC(group_key_press), e_table); @@ -744,6 +759,7 @@ e_table_class_init (GtkObjectClass *object_class) klass->row_selection = NULL; klass->cursor_change = NULL; klass->double_click = NULL; + klass->right_click = NULL; klass->key_press = NULL; et_signals [ROW_SELECTION] = @@ -770,6 +786,14 @@ e_table_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + et_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + et_signals [KEY_PRESS] = gtk_signal_new ("key_press", GTK_RUN_LAST, diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h index df396cd529..ff15628dc5 100644 --- a/widgets/e-table/e-table.h +++ b/widgets/e-table/e-table.h @@ -62,6 +62,7 @@ typedef struct { void (*row_selection) (ETable *et, int row, gboolean selected); void (*cursor_change) (ETable *et, int row); void (*double_click) (ETable *et, int row); + gint (*right_click) (ETable *et, int row, int col, GdkEvent *event); gint (*key_press) (ETable *et, int row, int col, GdkEvent *event); } ETableClass; diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c index 4aa7e2fe8a..a2e9575bcb 100644 --- a/widgets/table/e-table-group-container.c +++ b/widgets/table/e-table-group-container.c @@ -324,6 +324,13 @@ child_double_click (ETableGroup *etg, int row, } static gint +child_right_click (ETableGroup *etg, int row, int col, GdkEvent *event, + ETableGroupContainer *etgc) +{ + return e_table_group_right_click (E_TABLE_GROUP (etgc), row, col, event); +} + +static gint child_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETableGroupContainer *etgc) { @@ -385,6 +392,8 @@ etgc_add (ETableGroup *etg, gint row) GTK_SIGNAL_FUNC (child_cursor_change), etgc); gtk_signal_connect (GTK_OBJECT (child), "double_click", GTK_SIGNAL_FUNC (child_double_click), etgc); + gtk_signal_connect (GTK_OBJECT (child), "right_click", + GTK_SIGNAL_FUNC (child_right_click), etgc); gtk_signal_connect (GTK_OBJECT (child), "key_press", GTK_SIGNAL_FUNC (child_key_press), etgc); child_node->child = child; diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c index dcf9c280c4..25819bb188 100644 --- a/widgets/table/e-table-group-leaf.c +++ b/widgets/table/e-table-group-leaf.c @@ -113,6 +113,15 @@ etgl_key_press (GtkObject *object, gint row, gint col, GdkEvent *event, ETableGr return 0; } +static gint +etgl_right_click (GtkObject *object, gint row, gint col, GdkEvent *event, ETableGroupLeaf *etgl) +{ + if (row < E_TABLE_SUBSET(etgl->subset)->n_map) + return e_table_group_right_click (E_TABLE_GROUP(etgl), E_TABLE_SUBSET(etgl->subset)->map_table[row], col, event); + else + return 0; +} + static void etgl_reflow (GnomeCanvasItem *item, gint flags) { @@ -151,6 +160,8 @@ etgl_realize (GnomeCanvasItem *item) GTK_SIGNAL_FUNC(etgl_cursor_change), 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", + GTK_SIGNAL_FUNC(etgl_right_click), etgl); gtk_signal_connect (GTK_OBJECT(etgl->item), "key_press", GTK_SIGNAL_FUNC(etgl_key_press), etgl); e_canvas_item_request_reflow(item); diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c index 9c873e63f9..987636ed6b 100644 --- a/widgets/table/e-table-group.c +++ b/widgets/table/e-table-group.c @@ -31,6 +31,7 @@ enum { ROW_SELECTION, CURSOR_CHANGE, DOUBLE_CLICK, + RIGHT_CLICK, KEY_PRESS, LAST_SIGNAL }; @@ -273,6 +274,21 @@ e_table_group_double_click (ETableGroup *e_table_group, gint row) } gint +e_table_group_right_click (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event) +{ + gint return_val = 0; + + g_return_val_if_fail (e_table_group != NULL, 0); + g_return_val_if_fail (E_IS_TABLE_GROUP (e_table_group), 0); + + gtk_signal_emit (GTK_OBJECT (e_table_group), + etg_signals [RIGHT_CLICK], + row, col, event, &return_val); + + return return_val; +} + +gint e_table_group_key_press (ETableGroup *e_table_group, gint row, gint col, GdkEvent *event) { gint return_val = 0; @@ -338,6 +354,7 @@ etg_class_init (GtkObjectClass *object_class) klass->row_selection = NULL; klass->cursor_change = NULL; klass->double_click = NULL; + klass->right_click = NULL; klass->key_press = NULL; klass->add = NULL; @@ -379,6 +396,14 @@ etg_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + etg_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableGroupClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + etg_signals [KEY_PRESS] = gtk_signal_new ("key_press", GTK_RUN_LAST, diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h index 2260168cd4..8f9e047959 100644 --- a/widgets/table/e-table-group.h +++ b/widgets/table/e-table-group.h @@ -46,6 +46,7 @@ typedef struct { void (*row_selection) (ETableGroup *etg, int row, gboolean selected); void (*cursor_change) (ETableGroup *etg, int row); void (*double_click) (ETableGroup *etg, int row); + gint (*right_click) (ETableGroup *etg, int row, int col, GdkEvent *event); gint (*key_press) (ETableGroup *etg, int row, int col, GdkEvent *event); /* Virtual functions. */ @@ -107,6 +108,10 @@ void e_table_group_cursor_change (ETableGroup *etg, gint row); void e_table_group_double_click (ETableGroup *etg, gint row); +gint e_table_group_right_click (ETableGroup *etg, + gint row, + gint col, + GdkEvent *event); gint e_table_group_key_press (ETableGroup *etg, gint row, gint col, diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 8d96543eed..e494e5ed2b 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -32,6 +32,7 @@ enum { ROW_SELECTION, CURSOR_CHANGE, DOUBLE_CLICK, + RIGHT_CLICK, KEY_PRESS, LAST_SIGNAL }; @@ -1187,33 +1188,48 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) double x1, y1; int col, row; - if (e->button.button == 5 || - e->button.button == 4) - return FALSE; - - gnome_canvas_item_w2i (item, &e->button.x, &e->button.y); - - if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) - return TRUE; - - if (eti->cursor_row == row && eti->cursor_col == col){ + switch (e->button.button) { + case 1: /* Fall through. */ + case 2: + gnome_canvas_item_w2i (item, &e->button.x, &e->button.y); - ecol = e_table_header_get_column (eti->header, col); - ecell_view = eti->cell_views [col]; - - /* - * Adjust the event positions - */ - e->button.x = x1; - e->button.y = y1; - e_cell_event (ecell_view, e, ecol->col_idx, col, row); - } else { - /* - * Focus the cell, and select the row - */ - e_table_item_leave_edit (eti); - e_table_item_focus (eti, col, row); + if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) + return TRUE; + + if (eti->cursor_row == row && eti->cursor_col == col){ + + ecol = e_table_header_get_column (eti->header, col); + ecell_view = eti->cell_views [col]; + + /* + * Adjust the event positions + */ + e->button.x = x1; + e->button.y = y1; + + e_cell_event (ecell_view, e, ecol->col_idx, col, row); + } else { + /* + * Focus the cell, and select the row + */ + e_table_item_leave_edit (eti); + e_table_item_focus (eti, col, row); + } + break; + case 3: + gnome_canvas_item_w2i (item, &e->button.x, &e->button.y); + if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) + return TRUE; + + gtk_signal_emit (GTK_OBJECT (eti), eti_signals [RIGHT_CLICK], + row, col, e, &return_val); + break; + case 4: + case 5: + return FALSE; + break; + } break; } @@ -1387,6 +1403,7 @@ eti_class_init (GtkObjectClass *object_class) eti_class->row_selection = eti_row_selection; eti_class->cursor_change = NULL; eti_class->double_click = NULL; + eti_class->right_click = NULL; eti_class->key_press = NULL; gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_OBJECT, @@ -1437,6 +1454,14 @@ eti_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + eti_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableItemClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + eti_signals [KEY_PRESS] = gtk_signal_new ("key_press", GTK_RUN_LAST, diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h index 54defe30e1..961103b665 100644 --- a/widgets/table/e-table-item.h +++ b/widgets/table/e-table-item.h @@ -93,6 +93,7 @@ typedef struct { void (*row_selection) (ETableItem *eti, int row, gboolean selected); void (*cursor_change) (ETableItem *eti, int row); void (*double_click) (ETableItem *eti, int row); + gint (*right_click) (ETableItem *eti, int row, int col, GdkEvent *event); gint (*key_press) (ETableItem *eti, int row, int col, GdkEvent *event); } ETableItemClass; diff --git a/widgets/table/e-table-sorted-variable.c b/widgets/table/e-table-sorted-variable.c index 8c7e49cbbd..f7719df3c1 100644 --- a/widgets/table/e-table-sorted-variable.c +++ b/widgets/table/e-table-sorted-variable.c @@ -153,7 +153,7 @@ etsv_add (ETableSubsetVariable *etssv, i = etss->n_map; if (etsv->sort_idle_id == 0) { i = 0; - while (etsv_compare(etsv, etss->map_table[i], row) < 0) + while (i < etss->n_map && etsv_compare(etsv, etss->map_table[i], row) < 0) i++; memmove(etss->map_table + i + 1, etss->map_table + i, (etss->n_map - i) * sizeof(int)); } diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index f928e555ed..21a92f5ecb 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -42,6 +42,7 @@ enum { ROW_SELECTION, CURSOR_CHANGE, DOUBLE_CLICK, + RIGHT_CLICK, KEY_PRESS, LAST_SIGNAL }; @@ -208,6 +209,16 @@ group_double_click (ETableGroup *etg, int row, ETable *et) } static gint +group_right_click (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et) +{ + int return_val; + gtk_signal_emit (GTK_OBJECT (et), + et_signals [RIGHT_CLICK], + row, col, event, &return_val); + return return_val; +} + +static gint group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et) { int return_val; @@ -242,6 +253,8 @@ changed_idle (gpointer data) GTK_SIGNAL_FUNC (group_cursor_change), 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", + GTK_SIGNAL_FUNC (group_right_click), et); gtk_signal_connect (GTK_OBJECT (et->group), "key_press", GTK_SIGNAL_FUNC (group_key_press), et); e_table_fill_table (et, et->model); @@ -328,6 +341,8 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h 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); + gtk_signal_connect (GTK_OBJECT (e_table->group), "right_click", + GTK_SIGNAL_FUNC(group_right_click), e_table); gtk_signal_connect (GTK_OBJECT (e_table->group), "key_press", GTK_SIGNAL_FUNC(group_key_press), e_table); @@ -744,6 +759,7 @@ e_table_class_init (GtkObjectClass *object_class) klass->row_selection = NULL; klass->cursor_change = NULL; klass->double_click = NULL; + klass->right_click = NULL; klass->key_press = NULL; et_signals [ROW_SELECTION] = @@ -770,6 +786,14 @@ e_table_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + et_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + et_signals [KEY_PRESS] = gtk_signal_new ("key_press", GTK_RUN_LAST, diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index df396cd529..ff15628dc5 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -62,6 +62,7 @@ typedef struct { void (*row_selection) (ETable *et, int row, gboolean selected); void (*cursor_change) (ETable *et, int row); void (*double_click) (ETable *et, int row); + gint (*right_click) (ETable *et, int row, int col, GdkEvent *event); gint (*key_press) (ETable *et, int row, int col, GdkEvent *event); } ETableClass; |