diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-table.c | 49 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 48 |
2 files changed, 33 insertions, 64 deletions
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 4474d3e093..dca3a74049 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -480,43 +480,28 @@ group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et { int return_val = 0; GdkEventKey *key = (GdkEventKey *) event; - GdkEventButton click; + int y, row_local, col_local; + GtkAdjustment *vadj; + switch (key->keyval) { case GDK_Page_Down: - gtk_adjustment_set_value( - gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas)), - CLAMP(gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->value + - (gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->page_size - 20), - 0, - gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->upper - - gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->page_size)); - click.type = GDK_BUTTON_PRESS; - click.window = GTK_LAYOUT (et->table_canvas)->bin_window; - click.send_event = key->send_event; - click.time = key->time; - click.x = 30; - click.y = gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->page_size - 1; - click.state = key->state; - click.button = 1; - gtk_widget_event(GTK_WIDGET(et->table_canvas), - (GdkEvent *) &click); + vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas)); + y = CLAMP(vadj->value + (2 * vadj->page_size - 20), 0, vadj->upper); + y -= vadj->value; + e_table_get_cell_at (et, 30, y, &row_local, &col_local); + row_local = e_table_view_to_model_row (et, row_local); + col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->selection)); + e_selection_model_do_something(E_SELECTION_MODEL (et->selection), row_local, col_local, key->state); return_val = 1; break; case GDK_Page_Up: - gtk_adjustment_set_value( - gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas)), - gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->value - - (gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas))->page_size - 20)); - click.type = GDK_BUTTON_PRESS; - click.window = GTK_LAYOUT (et->table_canvas)->bin_window; - click.send_event = key->send_event; - click.time = key->time; - click.x = 30; - click.y = 1; - click.state = key->state; - click.button = 1; - gtk_widget_event(GTK_WIDGET(et->table_canvas), - (GdkEvent *) &click); + vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->table_canvas)); + y = CLAMP(vadj->value - (vadj->page_size - 20), 0, vadj->upper); + y -= vadj->value; + e_table_get_cell_at (et, 30, y, &row_local, &col_local); + row_local = e_table_view_to_model_row (et, row_local); + col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->selection)); + e_selection_model_do_something(E_SELECTION_MODEL (et->selection), row_local, col_local, key->state); return_val = 1; break; default: diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 7823c055f9..5064e582c6 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -528,45 +528,29 @@ item_key_press (ETableItem *eti, int row, int col, GdkEvent *event, ETree *et) { int return_val = 0; GdkEventKey *key = (GdkEventKey *) event; - GdkEventButton click; ETreePath path; + int y, row_local, col_local; + GtkAdjustment *vadj; switch (key->keyval) { case GDK_Page_Down: - gtk_adjustment_set_value( - gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas)), - CLAMP(gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->value + - (gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->page_size - 20), - 0, - gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->upper - - gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->page_size)); - click.type = GDK_BUTTON_PRESS; - click.window = GTK_LAYOUT (et->priv->table_canvas)->bin_window; - click.send_event = key->send_event; - click.time = key->time; - click.x = 30; - click.y = gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->page_size - 1; - click.state = key->state; - click.button = 1; - gtk_widget_event(GTK_WIDGET(et->priv->table_canvas), - (GdkEvent *) &click); + vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas)); + y = CLAMP(vadj->value + (2 * vadj->page_size - 20), 0, vadj->upper); + y -= vadj->value; + e_tree_get_cell_at (et, 30, y, &row_local, &col_local); + row_local = e_tree_view_to_model_row (et, row_local); + col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->priv->selection)); + e_selection_model_do_something(E_SELECTION_MODEL (et->priv->selection), row_local, col_local, key->state); return_val = 1; break; case GDK_Page_Up: - gtk_adjustment_set_value( - gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas)), - gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->value - - (gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas))->page_size - 20)); - click.type = GDK_BUTTON_PRESS; - click.window = GTK_LAYOUT (et->priv->table_canvas)->bin_window; - click.send_event = key->send_event; - click.time = key->time; - click.x = 30; - click.y = 1; - click.state = key->state; - click.button = 1; - gtk_widget_event(GTK_WIDGET(et->priv->table_canvas), - (GdkEvent *) &click); + vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (et->priv->table_canvas)); + y = CLAMP(vadj->value - (vadj->page_size - 20), 0, vadj->upper); + y -= vadj->value; + e_tree_get_cell_at (et, 30, y, &row_local, &col_local); + row_local = e_tree_view_to_model_row (et, row_local); + col_local = e_selection_model_cursor_col(E_SELECTION_MODEL (et->priv->selection)); + e_selection_model_do_something(E_SELECTION_MODEL (et->priv->selection), row_local, col_local, key->state); return_val = 1; break; case '=': |