Commit 637759ae authored by Arturo Espinosa's avatar Arturo Espinosa

Various small fixes + goto dialogs + improved paste special.



Various small fixes + goto dialogs + improved paste special.
parent a5cd394b
1998-08-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_set_region_status): Support going to a
cell by typing the cell name on the entry line.
(workbook_parse_and_jump): new routine for jumpting to a specific
cell.
* src/dialog-goto-cell.c: New file. Implements the goto cell
dialog box.
* src/clipboard.c: implemented paste-special dialog box.
(clipboard_paste_region): Redraw after clearing and after each
cell is pasted.
* src/sheet.c (sheet_selection_changed_hook): Display the current
selection.
(sheet_selection_walk_step): Fix the movememnt code to walk
correctly over the selection.
* src/cell.c (cell_formula_changed): New function used to notify
of a cell formula change (required for recomputation and to add
the cells to the proper computation lists).
* src/expr.c (expr_decode_tree): Goes from ExprTree to a string
representation. This is required when copying cell values to
recompute the string that is displayed to the user.
* src/util.c (cellref_name): New function, get a string
representation for a CellRef.
(parse_cell_name): New function, returns integers for col, row
from a cell string representation.
Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
* src/xml-io.c: Look in gnome-xml for tree.h and parser.h.
......@@ -5,9 +37,12 @@ Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
Thu Aug 13 00:02:23 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c : adapated to the new version 0.2 of the xml lib
1998-08-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-math.c (gnumeric_bin2dec): finish implementation of
BIN2DEC
* src/item-grid.c (item_grid_event): Call
gnumeric_sheet_accept_pending_output before moving the cursor.
......
1998-08-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_set_region_status): Support going to a
cell by typing the cell name on the entry line.
(workbook_parse_and_jump): new routine for jumpting to a specific
cell.
* src/dialog-goto-cell.c: New file. Implements the goto cell
dialog box.
* src/clipboard.c: implemented paste-special dialog box.
(clipboard_paste_region): Redraw after clearing and after each
cell is pasted.
* src/sheet.c (sheet_selection_changed_hook): Display the current
selection.
(sheet_selection_walk_step): Fix the movememnt code to walk
correctly over the selection.
* src/cell.c (cell_formula_changed): New function used to notify
of a cell formula change (required for recomputation and to add
the cells to the proper computation lists).
* src/expr.c (expr_decode_tree): Goes from ExprTree to a string
representation. This is required when copying cell values to
recompute the string that is displayed to the user.
* src/util.c (cellref_name): New function, get a string
representation for a CellRef.
(parse_cell_name): New function, returns integers for col, row
from a cell string representation.
Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
* src/xml-io.c: Look in gnome-xml for tree.h and parser.h.
......@@ -5,9 +37,12 @@ Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
Thu Aug 13 00:02:23 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c : adapated to the new version 0.2 of the xml lib
1998-08-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-math.c (gnumeric_bin2dec): finish implementation of
BIN2DEC
* src/item-grid.c (item_grid_event): Call
gnumeric_sheet_accept_pending_output before moving the cursor.
......
1998-08-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_set_region_status): Support going to a
cell by typing the cell name on the entry line.
(workbook_parse_and_jump): new routine for jumpting to a specific
cell.
* src/dialog-goto-cell.c: New file. Implements the goto cell
dialog box.
* src/clipboard.c: implemented paste-special dialog box.
(clipboard_paste_region): Redraw after clearing and after each
cell is pasted.
* src/sheet.c (sheet_selection_changed_hook): Display the current
selection.
(sheet_selection_walk_step): Fix the movememnt code to walk
correctly over the selection.
* src/cell.c (cell_formula_changed): New function used to notify
of a cell formula change (required for recomputation and to add
the cells to the proper computation lists).
* src/expr.c (expr_decode_tree): Goes from ExprTree to a string
representation. This is required when copying cell values to
recompute the string that is displayed to the user.
* src/util.c (cellref_name): New function, get a string
representation for a CellRef.
(parse_cell_name): New function, returns integers for col, row
from a cell string representation.
Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
* src/xml-io.c: Look in gnome-xml for tree.h and parser.h.
......@@ -5,9 +37,12 @@ Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
Thu Aug 13 00:02:23 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c : adapated to the new version 0.2 of the xml lib
1998-08-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-math.c (gnumeric_bin2dec): finish implementation of
BIN2DEC
* src/item-grid.c (item_grid_event): Call
gnumeric_sheet_accept_pending_output before moving the cursor.
......
1998-08-13 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_set_region_status): Support going to a
cell by typing the cell name on the entry line.
(workbook_parse_and_jump): new routine for jumpting to a specific
cell.
* src/dialog-goto-cell.c: New file. Implements the goto cell
dialog box.
* src/clipboard.c: implemented paste-special dialog box.
(clipboard_paste_region): Redraw after clearing and after each
cell is pasted.
* src/sheet.c (sheet_selection_changed_hook): Display the current
selection.
(sheet_selection_walk_step): Fix the movememnt code to walk
correctly over the selection.
* src/cell.c (cell_formula_changed): New function used to notify
of a cell formula change (required for recomputation and to add
the cells to the proper computation lists).
* src/expr.c (expr_decode_tree): Goes from ExprTree to a string
representation. This is required when copying cell values to
recompute the string that is displayed to the user.
* src/util.c (cellref_name): New function, get a string
representation for a CellRef.
(parse_cell_name): New function, returns integers for col, row
from a cell string representation.
Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
* src/xml-io.c: Look in gnome-xml for tree.h and parser.h.
......@@ -5,9 +37,12 @@ Thu Aug 13 19:08:28 1998 Tom Tromey <tromey@cygnus.com>
Thu Aug 13 00:02:23 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c : adapated to the new version 0.2 of the xml lib
1998-08-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-math.c (gnumeric_bin2dec): finish implementation of
BIN2DEC
* src/item-grid.c (item_grid_event): Call
gnumeric_sheet_accept_pending_output before moving the cursor.
......
......@@ -17,6 +17,8 @@ GNUMERIC_BASE_SOURCES = \
cell.c \
clipboard.c \
clipboard.h \
dialog-goto-cell.c \
dialogs.h \
eval.c \
expr.c \
expr.h \
......@@ -90,3 +92,5 @@ test_parser_LDADD = \
# $(GNOME_LIBDIR) \
# $(GNOMEUI_LIBS) -lgmp
wc:
wc -l $(gnumeric_SOURCES)
\ No newline at end of file
......@@ -3,6 +3,16 @@
#include "gnumeric.h"
#include "eval.h"
void
cell_formula_changed (Cell *cell)
{
g_return_if_fail (cell != NULL);
sheet_cell_formula_link (cell);
cell_add_dependencies (cell);
cell_queue_recalc (cell);
}
void
cell_set_formula (Cell *cell, char *text)
{
......@@ -21,10 +31,7 @@ cell_set_formula (Cell *cell, char *text)
cell->text = string_get (error_msg);
return;
}
sheet_cell_formula_link (cell);
cell_add_dependencies (cell);
cell_queue_recalc (cell);
cell_formula_changed (cell);
}
void
......
......@@ -71,6 +71,7 @@ void cell_set_formula (Cell *cell, char *text);
void cell_calc_dimensions (Cell *cell);
Cell *cell_copy (Cell *cell);
void cell_destroy (Cell *cell);
void cell_formula_changed (Cell *cell);
#endif /* GNUMERIC_CELL_H */
......@@ -80,6 +80,11 @@ clipboard_paste_region (CellRegion *region, Sheet *dest_sheet, int dest_col, int
dest_col + region->cols - 1,
dest_row + region->rows - 1);
sheet_redraw_cell_region (dest_sheet,
dest_col, dest_row,
dest_col + region->cols - 1,
dest_row + region->rows - 1);
/* Paste each element */
for (l = region->list; l; l = l->next){
CellCopy *c_copy = l->data;
......@@ -89,38 +94,36 @@ clipboard_paste_region (CellRegion *region, Sheet *dest_sheet, int dest_col, int
target_col = dest_col + c_copy->col_offset;
target_row = dest_row + c_copy->row_offset;
/* FIXME: create a cell_copy_flags that uses
* the bits more or less like paste_flags.
*
* In the case of cells with expressions,
* we need to "generate" cell->entered_text
* from the formula (to get the relative references
* correctly).
*/
new_cell = cell_copy (c_copy->cell);
sheet_cell_add (dest_sheet, new_cell, target_col, target_row);
if (new_cell->parsed_node){
char *new_text, *formula;
string_unref (new_cell->entered_text);
new_text = expr_decode_tree (
new_cell->parsed_node,
target_col, target_row);
formula = g_copy_strings ("=", new_text, NULL);
new_cell->entered_text = string_get (formula);
g_free (formula);
g_free (new_text);
cell_queue_recalc (new_cell);
if (paste_formulas){
string_unref (new_cell->entered_text);
new_text = expr_decode_tree (
new_cell->parsed_node,
target_col, target_row);
formula = g_copy_strings ("=", new_text, NULL);
new_cell->entered_text = string_get (formula);
g_free (formula);
g_free (new_text);
cell_formula_changed (new_cell);
} else {
expr_tree_unref (new_cell->parsed_node);
new_cell->parsed_node = NULL;
}
}
sheet_redraw_cell_region (dest_sheet,
target_col, target_row,
target_col, target_row);
}
sheet_redraw_cell_region (dest_sheet,
dest_col, dest_row,
dest_col + region->cols - 1,
dest_row + region->rows - 1);
}
void
......@@ -179,8 +182,8 @@ dialog_paste_special (void)
{
GtkWidget *dialog, *hbox;
GtkWidget *f1, *f1v, *f2, *f2v;
GSList *group;
int i;
GSList *group_type, *group_ops, *l;
int i, result;
dialog = gnome_dialog_new (_("Paste special"),
GNOME_STOCK_BUTTON_OK,
......@@ -194,7 +197,7 @@ dialog_paste_special (void)
f2v = gtk_vbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (f2), f2v);
group = NULL;
group_type = NULL;
for (i = 0; paste_types [i].name; i++){
GtkSignalFunc func;
GtkWidget *r;
......@@ -204,20 +207,20 @@ dialog_paste_special (void)
else
func = GTK_SIGNAL_FUNC (enable_op_group);
r = gtk_radio_button_new_with_label (group, _(paste_types [i].name));
group = GTK_RADIO_BUTTON (r)->group;
r = gtk_radio_button_new_with_label (group_type, _(paste_types [i].name));
group_type = GTK_RADIO_BUTTON (r)->group;
gtk_signal_connect (GTK_OBJECT (r), "toggled", func, f2);
gtk_box_pack_start_defaults (GTK_BOX (f1v), r);
}
group = NULL;
group_ops = NULL;
for (i = 0; paste_ops [i]; i++){
GtkWidget *r;
r = gtk_radio_button_new_with_label (group, _(paste_ops [i]));
group = GTK_RADIO_BUTTON (r)->group;
r = gtk_radio_button_new_with_label (group_ops, _(paste_ops [i]));
group_ops = GTK_RADIO_BUTTON (r)->group;
gtk_box_pack_start_defaults (GTK_BOX (f2v), r);
}
......@@ -229,8 +232,55 @@ dialog_paste_special (void)
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show_all (hbox);
/* Run the dialog */
gnome_dialog_run_modal (GNOME_DIALOG (dialog));
/* Fetch the results */
result = 0;
i = gtk_radio_group_get_selected (group_type);
switch (i){
case 0: /* all */
result = PASTE_ALL_TYPES;
break;
case 1: /* formulas */
result = PASTE_FORMULAS;
break;
case 2: /* values */
result = PASTE_VALUES;
break;
case 3: /* formats */
result = PASTE_FORMATS;
break;
}
/* If it was not just formats, check operation */
if (i != 3){
i = gtk_radio_group_get_selected (group_ops);
switch (i){
case 1: /* Add */
result |= PASTE_OP_ADD;
break;
case 2:
result |= PASTE_OP_SUB;
break;
case 3:
result |= PASTE_OP_MULT;
break;
case 4:
result |= PASTE_OP_DIV;
break;
}
}
gtk_object_destroy (GTK_OBJECT (dialog));
return 0;
return result;
}
......@@ -2,7 +2,7 @@
#define CLIPBOARD_H
enum {
PASTE_TEXT = 0, /* NOte that Text/Formulas are mutually exclusive */
PASTE_VALUES = 0,
PASTE_FORMULAS = 1,
PASTE_FORMATS = 2,
......@@ -13,8 +13,9 @@ enum {
PASTE_OP_DIV = 32
};
#define PASTE_DEFAULT (PASTE_FORMULAS | PASTE_FORMATS)
#define PASTE_OP_MASK (PASTE_OP_ADD | PASTE_OP_SUB | PASTE_OP_MULT | PASTE_OP_DIV)
#define PASTE_ALL_TYPES (PASTE_FORMULAS | PASTE_VALUES | PASTE_FORMATS)
#define PASTE_DEFAULT PASTE_ALL
#define PASTE_OP_MASK (PASTE_OP_ADD | PASTE_OP_SUB | PASTE_OP_MULT | PASTE_OP_DIV)
CellRegion *clipboard_copy_cell_range (Sheet *sheet,
int start_col, int start_row,
......
/*
* dialog-goto-cell.c: Implements the GOTO CELL functionality
* (C) 1998 The Free Software Foundation
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
*/
#include <config.h>
#include <gnome.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "dialogs.h"
static void
cb_goto_cell (GtkEntry *entry, GnomeDialog *dialog)
{
gtk_main_quit ();
}
static void
cb_row_selected (GtkCList *clist, int row, int col, GdkEvent *event, GtkEntry *entry)
{
char *text;
gtk_clist_get_text (clist, row, col, &text);
gtk_entry_set_text (entry, text);
}
void
dialog_goto_cell (Workbook *wb)
{
static GtkWidget *dialog;
static GtkWidget *clist;
static GtkWidget *entry;
char *text;
if (!dialog){
GtkWidget *box;
char *titles [2];
titles [0] = _("Cell");
titles [1] = NULL;
dialog = gnome_dialog_new (_("Go to..."),
GNOME_STOCK_BUTTON_HELP,
_("Special..."),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gnome_dialog_close_hides (GNOME_DIALOG (dialog), TRUE);
clist = gtk_clist_new_with_titles (1, titles);
gtk_clist_set_policy (GTK_CLIST (clist),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
entry = gtk_entry_new ();
gtk_signal_connect (GTK_OBJECT (entry), "activate",
GTK_SIGNAL_FUNC (cb_goto_cell), dialog);
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
GTK_SIGNAL_FUNC (cb_row_selected), entry);
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start_defaults (GTK_BOX (box), clist);
gtk_box_pack_start_defaults (GTK_BOX (box), entry);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
box);
gtk_widget_show_all (box);
} else
gtk_widget_show (dialog);
gtk_widget_grab_focus (entry);
/* Run the dialog */
gnome_dialog_run_modal (GNOME_DIALOG (dialog));
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (workbook_parse_and_jump (wb, text)){
char *texts [1];
texts [0] = text;
gtk_clist_append (GTK_CLIST (clist), texts);
}
gnome_dialog_close (GNOME_DIALOG (dialog));
}
#ifndef DIALOGS_H
#define DIALOGS_H
void dialog_goto_cell (Workbook *wb);
#endif
/*
* dialog-goto-cell.c: Implements the GOTO CELL functionality
* (C) 1998 The Free Software Foundation
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
*/
#include <config.h>
#include <gnome.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "dialogs.h"
static void
cb_goto_cell (GtkEntry *entry, GnomeDialog *dialog)
{
gtk_main_quit ();
}
static void
cb_row_selected (GtkCList *clist, int row, int col, GdkEvent *event, GtkEntry *entry)
{
char *text;
gtk_clist_get_text (clist, row, col, &text);
gtk_entry_set_text (entry, text);
}
void
dialog_goto_cell (Workbook *wb)
{
static GtkWidget *dialog;
static GtkWidget *clist;
static GtkWidget *entry;
char *text;
if (!dialog){
GtkWidget *box;
char *titles [2];
titles [0] = _("Cell");
titles [1] = NULL;
dialog = gnome_dialog_new (_("Go to..."),
GNOME_STOCK_BUTTON_HELP,
_("Special..."),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gnome_dialog_close_hides (GNOME_DIALOG (dialog), TRUE);
clist = gtk_clist_new_with_titles (1, titles);
gtk_clist_set_policy (GTK_CLIST (clist),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
entry = gtk_entry_new ();
gtk_signal_connect (GTK_OBJECT (entry), "activate",
GTK_SIGNAL_FUNC (cb_goto_cell), dialog);
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
GTK_SIGNAL_FUNC (cb_row_selected), entry);
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start_defaults (GTK_BOX (box), clist);
gtk_box_pack_start_defaults (GTK_BOX (box), entry);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
box);
gtk_widget_show_all (box);
} else
gtk_widget_show (dialog);
gtk_widget_grab_focus (entry);
/* Run the dialog */
gnome_dialog_run_modal (GNOME_DIALOG (dialog));
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (workbook_parse_and_jump (wb, text)){
char *texts [1];
texts [0] = text;
gtk_clist_append (GTK_CLIST (clist), texts);
}
gnome_dialog_close (GNOME_DIALOG (dialog));
}
#ifndef DIALOGS_H
#define DIALOGS_H
void dialog_goto_cell (Workbook *wb);
#endif
......@@ -213,6 +213,15 @@ move_cursor (GnumericSheet *gsheet, int col, int row, int clear_selection)
gnumeric_sheet_load_cell_val (gsheet);
}
void
gnumeric_sheet_move_cursor (GnumericSheet *gsheet, int col, int row)
{
g_return_if_fail (gsheet != NULL);
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
move_cursor (gsheet, col, row, 1);
}