Commit c46a2f59 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Use 0.0########## instead. Looks saner.

1999-01-10  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/format.c (format_value): Use 0.0########## instead.  Looks saner.

1999-01-10  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/workbook.c (change_auto_expr_menu): Use the event->button
	field to get the popup menu to behave correctly.
	(workbook_setup_auto_calc): Put the information display inside a
	GtkFrame.

	* src/item-bar.c (set_cursor): This routine can be invoked before
	we are realized.

	* src/workbook.c (sheet_label_button_press): We need to do the
	page flipping ourselves, as the GtkNotebook wont take events if
	they are not for a window it knows about.

	* src/widget-editable-label.c (el_button_press_event): Forward
	events to parent.

	* src/parser.y: New non-terminal "cellref".  Make this
	non-terminal include CELLREF and SHEETREF!CELLREF constructions.

	* src/expr.c: Changed the whole module according to the dropping
	of VALUE_CELLREF.

	* src/expr.h: VALUE_CELLREF did not make much sense.  Better add
	to the ExprTree union a CellRef field specifically for OPER_VAR
	nodes.
parent aeefc6b0
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/format.c (format_value): Use 0.0########## instead. Looks saner.
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (change_auto_expr_menu): Use the event->button
field to get the popup menu to behave correctly.
(workbook_setup_auto_calc): Put the information display inside a
GtkFrame.
* src/item-bar.c (set_cursor): This routine can be invoked before
we are realized.
* src/workbook.c (sheet_label_button_press): We need to do the
page flipping ourselves, as the GtkNotebook wont take events if
they are not for a window it knows about.
* src/widget-editable-label.c (el_button_press_event): Forward
events to parent.
* src/parser.y: New non-terminal "cellref". Make this
non-terminal include CELLREF and SHEETREF!CELLREF constructions.
* src/expr.c: Changed the whole module according to the dropping
of VALUE_CELLREF.
* src/expr.h: VALUE_CELLREF did not make much sense. Better add
to the ExprTree union a CellRef field specifically for OPER_VAR
nodes.
1999-01-10 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excelReadWorkbook): Only believe the
* plugins/excel/ms-excel.c (ms_excelReadWorkbook): Only believe the
first BOF with regard to BIFF version number, other BOFs seem to lie.
1999-01-10 Nick Lamb <njl98r@ecs.soton.ac.uk>
......
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/format.c (format_value): Use 0.0########## instead. Looks saner.
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (change_auto_expr_menu): Use the event->button
field to get the popup menu to behave correctly.
(workbook_setup_auto_calc): Put the information display inside a
GtkFrame.
* src/item-bar.c (set_cursor): This routine can be invoked before
we are realized.
* src/workbook.c (sheet_label_button_press): We need to do the
page flipping ourselves, as the GtkNotebook wont take events if
they are not for a window it knows about.
* src/widget-editable-label.c (el_button_press_event): Forward
events to parent.
* src/parser.y: New non-terminal "cellref". Make this
non-terminal include CELLREF and SHEETREF!CELLREF constructions.
* src/expr.c: Changed the whole module according to the dropping
of VALUE_CELLREF.
* src/expr.h: VALUE_CELLREF did not make much sense. Better add
to the ExprTree union a CellRef field specifically for OPER_VAR
nodes.
1999-01-10 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excelReadWorkbook): Only believe the
* plugins/excel/ms-excel.c (ms_excelReadWorkbook): Only believe the
first BOF with regard to BIFF version number, other BOFs seem to lie.
1999-01-10 Nick Lamb <njl98r@ecs.soton.ac.uk>
......
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/format.c (format_value): Use 0.0########## instead. Looks saner.
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (change_auto_expr_menu): Use the event->button
field to get the popup menu to behave correctly.
(workbook_setup_auto_calc): Put the information display inside a
GtkFrame.
* src/item-bar.c (set_cursor): This routine can be invoked before
we are realized.
* src/workbook.c (sheet_label_button_press): We need to do the
page flipping ourselves, as the GtkNotebook wont take events if
they are not for a window it knows about.
* src/widget-editable-label.c (el_button_press_event): Forward
events to parent.
* src/parser.y: New non-terminal "cellref". Make this
non-terminal include CELLREF and SHEETREF!CELLREF constructions.
* src/expr.c: Changed the whole module according to the dropping
of VALUE_CELLREF.
* src/expr.h: VALUE_CELLREF did not make much sense. Better add
to the ExprTree union a CellRef field specifically for OPER_VAR
nodes.
1999-01-10 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excelReadWorkbook): Only believe the
* plugins/excel/ms-excel.c (ms_excelReadWorkbook): Only believe the
first BOF with regard to BIFF version number, other BOFs seem to lie.
1999-01-10 Nick Lamb <njl98r@ecs.soton.ac.uk>
......
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/format.c (format_value): Use 0.0########## instead. Looks saner.
1999-01-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (change_auto_expr_menu): Use the event->button
field to get the popup menu to behave correctly.
(workbook_setup_auto_calc): Put the information display inside a
GtkFrame.
* src/item-bar.c (set_cursor): This routine can be invoked before
we are realized.
* src/workbook.c (sheet_label_button_press): We need to do the
page flipping ourselves, as the GtkNotebook wont take events if
they are not for a window it knows about.
* src/widget-editable-label.c (el_button_press_event): Forward
events to parent.
* src/parser.y: New non-terminal "cellref". Make this
non-terminal include CELLREF and SHEETREF!CELLREF constructions.
* src/expr.c: Changed the whole module according to the dropping
of VALUE_CELLREF.
* src/expr.h: VALUE_CELLREF did not make much sense. Better add
to the ExprTree union a CellRef field specifically for OPER_VAR
nodes.
1999-01-10 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excelReadWorkbook): Only believe the
* plugins/excel/ms-excel.c (ms_excelReadWorkbook): Only believe the
first BOF with regard to BIFF version number, other BOFs seem to lie.
1999-01-10 Nick Lamb <njl98r@ecs.soton.ac.uk>
......
......@@ -17,9 +17,16 @@ void cursors_init (void);
void cursors_shutdown (void);
#define cursor_set(win,c) \
gdk_window_set_cursor (win, gnumeric_cursors [c].cursor)
do { \
if (win) \
gdk_window_set_cursor (win, gnumeric_cursors [c].cursor); \
} while (0)
#define cursor_set_widget(w,c) \
gdk_window_set_cursor (GTK_WIDGET (w)->window, gnumeric_cursors [c].cursor)
do { \
if (GTK_WIDGET (w)->window) \
gdk_window_set_cursor (GTK_WIDGET (w)->window, gnumeric_cursors [c].cursor); \
} while (0)
#endif /* GNUMERIC_CURSORS_H */
......@@ -164,14 +164,6 @@ add_value_deps (Cell *cell, Value *value)
&value->v.cell_range.cell_a,
&value->v.cell_range.cell_b);
break;
case VALUE_CELLREF:
add_cell_range_deps (
cell,
&value->v.cell,
&value->v.cell);
return;
}
}
......@@ -202,6 +194,12 @@ add_tree_deps (Cell *cell, ExprTree *tree)
return;
case OPER_VAR:
add_cell_range_deps (
cell,
&tree->u.ref,
&tree->u.ref);
return;
case OPER_CONSTANT:
add_value_deps (cell, tree->u.constant);
return;
......
......@@ -164,14 +164,6 @@ add_value_deps (Cell *cell, Value *value)
&value->v.cell_range.cell_a,
&value->v.cell_range.cell_b);
break;
case VALUE_CELLREF:
add_cell_range_deps (
cell,
&value->v.cell,
&value->v.cell);
return;
}
}
......@@ -202,6 +194,12 @@ add_tree_deps (Cell *cell, ExprTree *tree)
return;
case OPER_VAR:
add_cell_range_deps (
cell,
&tree->u.ref,
&tree->u.ref);
return;
case OPER_CONSTANT:
add_value_deps (cell, tree->u.constant);
return;
......
......@@ -193,8 +193,6 @@ value_string (Value *value)
case VALUE_CELLRANGE:
return g_strdup ("Internal problem");
case VALUE_CELLREF:
g_assert_not_reached ();
}
return g_strdup (buffer);
}
......@@ -228,9 +226,6 @@ value_release (Value *value)
case VALUE_CELLRANGE:
break;
case VALUE_CELLREF:
break;
}
g_free (value);
}
......@@ -276,10 +271,6 @@ value_copy_to (Value *dest, Value *source)
case VALUE_CELLRANGE:
dest->v.cell_range = source->v.cell_range;
break;
case VALUE_CELLREF:
dest->v.cell = source->v.cell;
break;
}
}
......@@ -453,14 +444,6 @@ eval_cell_value (Sheet *sheet, Value *value)
case VALUE_CELLRANGE:
res->v.cell_range = value->v.cell_range;
break;
case VALUE_CELLREF:
/*
* This case shoudl be handled as part of the OPER_VAR
* case in the ExprTree, not here
*/
g_assert_not_reached ();
}
return res;
}
......@@ -907,7 +890,7 @@ eval_expr (void *asheet, ExprTree *tree, int eval_col, int eval_row, char **erro
return res;
}
ref = &tree->u.constant->v.cell;
ref = &tree->u.ref;
cell_get_abs_col_row (ref, eval_col, eval_row, &col, &row);
cell_sheet = ref->sheet ? ref->sheet : sheet;
......@@ -1105,7 +1088,7 @@ do_expr_decode_tree (ExprTree *tree, void *sheet, int col, int row, Operation pa
case OPER_VAR: {
CellRef *cell_ref;
cell_ref = &tree->u.constant->v.cell;
cell_ref = &tree->u.ref;
return cellref_name (cell_ref, sheet, col, row);
}
......@@ -1201,20 +1184,21 @@ do_expr_tree_relocate (ExprTree *tree, int coldiff, int rowdiff)
break;
}
case OPER_VAR:
case OPER_CONSTANT: {
case OPER_VAR: {
CellRef *ref;
ref = &new_tree->u.ref;
ref->col -= coldiff;
ref->row -= rowdiff;
break;
}
case OPER_CONSTANT:
new_tree->u.constant = value_duplicate (tree->u.constant);
switch (new_tree->u.constant->type){
case VALUE_CELLREF:
ref = &new_tree->u.constant->v.cell;
ref->col -= coldiff;
ref->row -= rowdiff;
break;
case VALUE_CELLRANGE:
if (new_tree->u.constant->type == VALUE_CELLRANGE){
CellRef *ref;
ref = &new_tree->u.constant->v.cell_range.cell_a;
ref->col -= coldiff;
ref->row -= rowdiff;
......@@ -1223,11 +1207,8 @@ do_expr_tree_relocate (ExprTree *tree, int coldiff, int rowdiff)
ref->col -= coldiff;
ref->row -= rowdiff;
break;
default:
}
break;
}
case OPER_NEG:
new_tree->u.value = do_expr_tree_relocate (tree->u.value, coldiff, rowdiff);
......
......@@ -29,7 +29,6 @@ typedef enum {
VALUE_FLOAT,
VALUE_CELLRANGE,
VALUE_ARRAY,
VALUE_CELLREF,
} ValueType;
typedef struct {
......@@ -78,6 +77,8 @@ struct ExprTree {
} binary;
struct ExprTree *value;
CellRef ref;
} u;
};
......
......@@ -1027,7 +1027,7 @@ format_value (StyleFormat *format, Value *value, StyleColor **color)
if (floor (value->v.v_float) == value->v.v_float)
entry.format = "0";
else
entry.format = "0.00########";
entry.format = "0.0########";
}
if (finite (value->v.v_float))
v = format_number (value->v.v_float, &entry);
......
......@@ -83,14 +83,6 @@ function_iterate_do_value (Sheet *sheet,
}
break;
case VALUE_CELLREF:
/*
* eval_expr will never return a value of
* type VALUE_CELLREF
*/
g_assert_not_reached ();
break;
case VALUE_CELLRANGE: {
IterateCallbackClosure data;
int start_col, start_row, end_col, end_row;
......
......@@ -302,6 +302,10 @@ set_cursor (ItemBar *item_bar, int pos)
{
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item_bar)->canvas);
/* We might be invoked before we are realized */
if (!canvas->window)
return;
if (is_pointer_on_division (item_bar, pos, NULL, NULL))
gdk_window_set_cursor(canvas->window, item_bar->change_cursor);
else
......@@ -411,7 +415,7 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
int resizing;
resizing = ITEM_BAR_RESIZING (item_bar);
switch (e->type){
case GDK_ENTER_NOTIFY:
convert (canvas, e->crossing.x, e->crossing.y, &x, &y);
......
......@@ -75,6 +75,7 @@ build_binop (ExprTree *l, Operation op, ExprTree *r)
%type <list> arg_list
%token <tree> NUMBER STRING FUNCALL CONSTANT CELLREF GTE LTE NE
%token <sheetref> SHEETREF
%type <tree> cellref
%left '<' '>' '=' GTE LTE NE
%left '-' '+' '&'
......@@ -96,7 +97,7 @@ line: exp { parser_result = $1;
exp: NUMBER { $$ = $1 }
| STRING { $$ = $1 }
| CELLREF { $$ = $1 }
| cellref { $$ = $1 }
| CONSTANT { $$ = $1 }
| exp '+' exp { $$ = build_binop ($1, OPER_ADD, $3); }
| exp '-' exp { $$ = build_binop ($1, OPER_SUB, $3); }
......@@ -123,11 +124,11 @@ exp: NUMBER { $$ = $1 }
$$ = $2;
}
| CELLREF ':' CELLREF {
| cellref ':' cellref {
CellRef a, b;
a = $1->u.constant->v.cell;
b = $3->u.constant->v.cell;
a = $1->u.ref;
b = $3->u.ref;
$$ = p_new (ExprTree);
$$->ref_count = 1;
......@@ -141,10 +142,6 @@ exp: NUMBER { $$ = $1 }
forget_tree ($3);
}
| SHEETREF '!' CELLREF {
$$ = $3;
$$->u.constant->v.cell.sheet = $1;
}
| FUNCALL '(' arg_list ')' {
$$ = $1;
......@@ -152,6 +149,16 @@ exp: NUMBER { $$ = $1 }
}
;
cellref: CELLREF {
$$ = $1;
}
| SHEETREF '!' CELLREF {
$$ = $3;
$$->u.ref.sheet = $1;
}
;
arg_list: exp {
$$ = g_list_prepend (NULL, $1);
alloc_glist ($$);
......@@ -174,7 +181,6 @@ return_cellref (char *p)
int col = 0;
int row = 0;
ExprTree *e;
Value *v;
CellRef *ref;
/* Try to parse a column */
......@@ -208,12 +214,10 @@ return_cellref (char *p)
/* Ok, parsed successfully, create the return value */
e = p_new (ExprTree);
e->ref_count = 1;
v = v_new ();
v->type = VALUE_CELLREF;
e->oper = OPER_VAR;
ref = &v->v.cell;
ref = &e->u.ref;
/* Setup the cell reference information */
if (row_relative)
......@@ -230,8 +234,6 @@ return_cellref (char *p)
ref->row_relative = row_relative;
ref->sheet = parser_sheet;
e->u.constant = v;
yylval.tree = e;
return CELLREF;
......
......@@ -368,7 +368,7 @@ void workbook_set_region_status (Workbook *wb, char *str);
int workbook_parse_and_jump (Workbook *wb, char *text);
Sheet *workbook_sheet_lookup (Workbook *wb, char *sheet_name);
void workbook_mark_clean (Workbook *wb);
void workbook_rename_sheet (Workbook *wb,
gboolean workbook_rename_sheet (Workbook *wb,
const char *old_name,
const char *new_name);
......
......@@ -243,6 +243,7 @@ el_button_press_event (GtkWidget *widget, GdkEventButton *button)
return FALSE;
}
gtk_widget_event (GTK_WIDGET (el)->parent, button);
return FALSE;
}
......
......@@ -243,6 +243,7 @@ el_button_press_event (GtkWidget *widget, GdkEventButton *button)
return FALSE;
}
gtk_widget_event (GTK_WIDGET (el)->parent, button);
return FALSE;
}
......
......@@ -1128,7 +1128,7 @@ change_auto_expr_menu (GtkWidget *widget, GdkEventButton *event, Workbook *wb)
_(quick_compute_routines [i].displayed_name));
}
}
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, 0, NULL, 1, event->time);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, 0, NULL, event->button, event->time);
}
/*
......@@ -1153,7 +1153,7 @@ workbook_setup_auto_calc (Workbook *wb)
{
GtkWidget *canvas;
GnomeCanvasGroup *root;
GtkWidget *l;
GtkWidget *l, *frame;
canvas = gnome_canvas_new ();
......@@ -1173,12 +1173,16 @@ workbook_setup_auto_calc (Workbook *wb)
gtk_widget_set_usize (
GTK_WIDGET (canvas),
gdk_text_measure (l->style->font, "W", 1) * 15, -1);
gtk_box_pack_start (GTK_BOX (wb->appbar), canvas, FALSE, TRUE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (frame), canvas);
gtk_box_pack_start (GTK_BOX (wb->appbar), frame, FALSE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (canvas), "button_press_event",
GTK_SIGNAL_FUNC (change_auto_expr_menu), wb);
gtk_object_destroy (GTK_OBJECT (l));
gtk_widget_show (canvas);
gtk_widget_show_all (frame);
}
/*
......@@ -1346,21 +1350,37 @@ buttons (Sheet *sheet, GtkTable *table)
}
void
/**
* workbook_rename_sheet:
* @wb: the workbook where the sheet is
* @old_name: the name of the sheet we want to rename
* @new_name: new name we want to assing to the sheet.
*
* Returns TRUE if it was possible to rename the sheet to @new_name,
* otherwise it returns FALSE for any possible error condition.
*/
gboolean
workbook_rename_sheet (Workbook *wb, const char *old_name, const char *new_name)
{
Sheet *sheet;
g_return_if_fail (wb != NULL);
g_return_if_fail (old_name != NULL);
g_return_if_fail (new_name != NULL);
g_return_val_if_fail (wb != NULL, FALSE);
g_return_val_if_fail (old_name != NULL, FALSE);
g_return_val_if_fail (new_name != NULL, FALSE);
/* Do not let two sheets in the workbook have the same name */
if (g_hash_table_lookup (wb->sheets, new_name))
return FALSE;
sheet = (Sheet *) g_hash_table_lookup (wb->sheets, old_name);
g_return_if_fail (sheet != NULL);
if (sheet == NULL)
return FALSE;
g_hash_table_remove (wb->sheets, old_name);
sheet_rename (sheet, new_name);
g_hash_table_insert (wb->sheets, sheet->name, sheet);
return TRUE;
}
/*
......@@ -1374,9 +1394,29 @@ sheet_label_text_changed_signal (EditableLabel *el, const char *new_name, Workbo
if (strchr (new_name, '\''))
return FALSE;
workbook_rename_sheet (wb, el->text, new_name);
return workbook_rename_sheet (wb, el->text, new_name);
}
return TRUE;
/**
* sheet_label_button_press:
*
* Invoked when the user has clicked on the EditableLabel widget.
* This takes care of switching to the notebook that contains the label
*/
static gint
sheet_label_button_press (GtkWidget *widget, GdkEventButton *event, GtkWidget *child)
{
if (event->type == GDK_BUTTON_PRESS && event->button == 1){
GtkWidget *notebook;
gint number;
notebook = child->parent;
number = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), child);
gtk_notebook_set_page (GTK_NOTEBOOK (notebook), number);
return TRUE;
}
return FALSE;
}
void
......@@ -1401,7 +1441,10 @@ workbook_attach_sheet (Workbook *wb, Sheet *sheet)
gtk_signal_connect (
GTK_OBJECT (sheet_label), "text_changed",
GTK_SIGNAL_FUNC (sheet_label_text_changed_signal), wb);
gtk_signal_connect (
GTK_OBJECT (sheet_label), "button_press_event",
GTK_SIGNAL_FUNC (sheet_label_button_press), t);
gtk_widget_show (sheet_label);
gtk_notebook_append_page (GTK_NOTEBOOK (wb->notebook),
t, sheet_label);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment