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

New routine.

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

	* src/sheet.c (sheet_rename): New routine.

	* src/workbook.c (workbook_attach_sheet): Use a EditableLabel for
	the notebook tab.
	(workbook_rename_sheet): New routine.

	* src/widget-editable-label.c:  New widget.  This is a label that
	can be edited if you double click on it.  This uses the same trick
	of the gnome-icon-item to provide the editing facilities.

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

	* src/workbook.c (workbook_setup_status_area): Use the style font,
	not "fixed".
	(workbook_setup_status_area): One hack down.  Use GTK_ANCHOR_NW to
	achieve the same effect I had with my previous hack.

	* src/dialog-cell-comment.c (dialog_cell_comment): New file.
	Implements the cell comment dialog box.

	* src/cell.c (cell_relocate): Only call cell_comment_reposition is
	there is a cell comment bound to this cell.

	* src/format.c (format_value): No format means "General" format as
	well.
	If the value has decimal numbers use "0.00##########" for the
	formatting instead of 0.00.
parent 0492e214
1999-01-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_rename): New routine.
* src/workbook.c (workbook_attach_sheet): Use a EditableLabel for
the notebook tab.
(workbook_rename_sheet): New routine.
* src/widget-editable-label.c: New widget. This is a label that
can be edited if you double click on it. This uses the same trick
of the gnome-icon-item to provide the editing facilities.
1999-01-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_setup_status_area): Use the style font,
not "fixed".
(workbook_setup_status_area): One hack down. Use GTK_ANCHOR_NW to
achieve the same effect I had with my previous hack.
* src/dialog-cell-comment.c (dialog_cell_comment): New file.
Implements the cell comment dialog box.
* src/cell.c (cell_relocate): Only call cell_comment_reposition is
there is a cell comment bound to this cell.
* src/format.c (format_value): No format means "General" format as
well.
If the value has decimal numbers use "0.00##########" for the
formatting instead of 0.00.
1998-01-03 Jeff Garzik <jgarzik@pobox.com>
* src/number-match.c, src/plugin-manager.c, src/sheet.c:
......
1999-01-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_rename): New routine.
* src/workbook.c (workbook_attach_sheet): Use a EditableLabel for
the notebook tab.
(workbook_rename_sheet): New routine.
* src/widget-editable-label.c: New widget. This is a label that
can be edited if you double click on it. This uses the same trick
of the gnome-icon-item to provide the editing facilities.
1999-01-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_setup_status_area): Use the style font,
not "fixed".
(workbook_setup_status_area): One hack down. Use GTK_ANCHOR_NW to
achieve the same effect I had with my previous hack.
* src/dialog-cell-comment.c (dialog_cell_comment): New file.
Implements the cell comment dialog box.
* src/cell.c (cell_relocate): Only call cell_comment_reposition is
there is a cell comment bound to this cell.
* src/format.c (format_value): No format means "General" format as
well.
If the value has decimal numbers use "0.00##########" for the
formatting instead of 0.00.
1998-01-03 Jeff Garzik <jgarzik@pobox.com>
* src/number-match.c, src/plugin-manager.c, src/sheet.c:
......
1999-01-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_rename): New routine.
* src/workbook.c (workbook_attach_sheet): Use a EditableLabel for
the notebook tab.
(workbook_rename_sheet): New routine.
* src/widget-editable-label.c: New widget. This is a label that
can be edited if you double click on it. This uses the same trick
of the gnome-icon-item to provide the editing facilities.
1999-01-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_setup_status_area): Use the style font,
not "fixed".
(workbook_setup_status_area): One hack down. Use GTK_ANCHOR_NW to
achieve the same effect I had with my previous hack.
* src/dialog-cell-comment.c (dialog_cell_comment): New file.
Implements the cell comment dialog box.
* src/cell.c (cell_relocate): Only call cell_comment_reposition is
there is a cell comment bound to this cell.
* src/format.c (format_value): No format means "General" format as
well.
If the value has decimal numbers use "0.00##########" for the
formatting instead of 0.00.
1998-01-03 Jeff Garzik <jgarzik@pobox.com>
* src/number-match.c, src/plugin-manager.c, src/sheet.c:
......
1999-01-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_rename): New routine.
* src/workbook.c (workbook_attach_sheet): Use a EditableLabel for
the notebook tab.
(workbook_rename_sheet): New routine.
* src/widget-editable-label.c: New widget. This is a label that
can be edited if you double click on it. This uses the same trick
of the gnome-icon-item to provide the editing facilities.
1999-01-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/workbook.c (workbook_setup_status_area): Use the style font,
not "fixed".
(workbook_setup_status_area): One hack down. Use GTK_ANCHOR_NW to
achieve the same effect I had with my previous hack.
* src/dialog-cell-comment.c (dialog_cell_comment): New file.
Implements the cell comment dialog box.
* src/cell.c (cell_relocate): Only call cell_comment_reposition is
there is a cell comment bound to this cell.
* src/format.c (format_value): No format means "General" format as
well.
If the value has decimal numbers use "0.00##########" for the
formatting instead of 0.00.
1998-01-03 Jeff Garzik <jgarzik@pobox.com>
* src/number-match.c, src/plugin-manager.c, src/sheet.c:
......
......@@ -2,15 +2,11 @@
GNOME Spread Sheet task list
* Comments
Comments location needs to be reset on col/row dimenssion changes.
* Cell range naming
Finish implementing.
* Cell references to other sheets.
* Cell dimensio computation is broken on font change for multilines.
* Number formatting
......@@ -30,6 +26,8 @@ GNOME Spread Sheet task list
If sheet->mode is OBJECT_SELECTED cut/copy/paste should operate on
the object.
Object properties.
** Paste special
needs some little changes:
......@@ -54,8 +52,8 @@ GNOME Spread Sheet task list
I have the specs for the XS3 format. SC should be
trivial to support as well (from the guile sources)
Add a format registration input point.
Add "hints" to the file save routine based on the registered
formats.
* CORBA exporting
......
plugins/stat/stat.c
src/about.c
src/dates.c
src/dialog-cell-comment.c
src/dialog-cell-format.c
src/dialog-define-names.c
src/dialog-delete-cells.c
......
......@@ -26,6 +26,7 @@ GNUMERIC_BASE_SOURCES = \
cursors.h \
dates.c \
dates.h \
dialog-cell-comment.c \
dialog-cell-format.c \
dialog-goto-cell.c \
dialog-insert-cells.c \
......@@ -97,6 +98,8 @@ GNUMERIC_BASE_SOURCES = \
symbol.c \
utils.c \
utils.h \
widget-editable-label.c \
widget-editable-label.h \
workbook.c \
xml-io.c \
xml-io.h
......
......@@ -321,7 +321,6 @@ cell_comment_unrealize (Cell *cell)
for (l = cell->comment->realized_list; l; l = l->next){
GnomeCanvasItem *o = l->data;
printf ("Destruyendo: %p\n", o);
gtk_object_destroy (GTK_OBJECT (o));
}
g_list_free (cell->comment->realized_list);
......@@ -871,7 +870,8 @@ cell_relocate (Cell *cell, int target_col, int target_row)
}
/* 3. Move any auxiliary canvas items */
cell_comment_reposition (cell);
if (cell->comment)
cell_comment_reposition (cell);
}
/*
......
......@@ -19,6 +19,7 @@ dialog_insert_cells (Workbook *wb, Sheet *sheet)
char *ret;
int cols, rows;
g_return_if_fail (wb != NULL);
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
......
......@@ -10,5 +10,6 @@ void dialog_zoom (Workbook *wb, Sheet *sheet);
char *dialog_query_load_file (Workbook *wb);
void dialog_about (Workbook *wb);
void dialog_define_names (Workbook *wb);
void dialog_cell_comment (Workbook *wb, Cell *cell);
#endif /* GNUMERIC_DIALOGS_H */
......@@ -19,6 +19,7 @@ dialog_insert_cells (Workbook *wb, Sheet *sheet)
char *ret;
int cols, rows;
g_return_if_fail (wb != NULL);
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
......
......@@ -10,5 +10,6 @@ void dialog_zoom (Workbook *wb, Sheet *sheet);
char *dialog_query_load_file (Workbook *wb);
void dialog_about (Workbook *wb);
void dialog_define_names (Workbook *wb);
void dialog_cell_comment (Workbook *wb, Cell *cell);
#endif /* GNUMERIC_DIALOGS_H */
......@@ -251,7 +251,8 @@ append_half (GString *string, gchar *format, struct tm *time_split)
}
/*
* Does some analisis before hand on the format
* Since the Excel formating codes contain a number of ambiguities,
* this routine does some analisis on the format first.
*/
static void
pre_parse_format (StyleFormatEntry *style)
......@@ -295,8 +296,8 @@ typedef struct
} xformat_info;
/*
* This routine should always return, it cant fail, in the worst
* case it should just downgrade to stupid formatting
* This routine should always return, it can not fail, in the worst
* case it should just downgrade to simplistic formatting
*/
void
format_compile (StyleFormat *format)
......@@ -315,11 +316,10 @@ format_compile (StyleFormat *format)
for (i = 0; i < length; i++){
switch (format->format[i])
{
switch (format->format[i]){
case ';':
if (which < 4)
{
if (which < 4){
standard_entries [which].format = g_malloc0 (string->len + 1);
strncpy (standard_entries[which].format, string->str, string->len);
standard_entries [which].format[string->len] = 0;
......@@ -345,8 +345,8 @@ format_compile (StyleFormat *format)
/* Set up restriction types. */
standard_entries[1].restriction_type = '<';
standard_entries[1].restriction_value = 0;
switch (which)
{
switch (which){
case 4:
standard_entries[3].restriction_type = '@';
/* Fall through. */
......@@ -361,13 +361,14 @@ format_compile (StyleFormat *format)
standard_entries[0].restriction_value = 0;
break;
}
for (i = 0; i < which; i++)
{
for (i = 0; i < which; i++){
temp = g_new (StyleFormatEntry, 1);
*temp = standard_entries[i];
pre_parse_format (temp);
format->format_list = g_list_append (format->format_list, temp);
}
g_string_free (string, TRUE);
}
......@@ -380,16 +381,16 @@ style_entry_free(gpointer data, gpointer user_data)
g_free (entry);
}
/*
* This routine is invoked when the last user of the
* format is gone (ie, refcount has reached zero) just
* before the StyleFormat structure is actually released.
*
* resources allocated in format_compile should be disposed here
*/
void
format_destroy (StyleFormat *format)
{
/* This routine is invoked when the last user of the
* format is gone (ie, refcount has reached zero) just
* before the StyleFormat structure is actually released.
*
* resources allocated in format_compile should be disposed here
*/
g_list_foreach (format->format_list, style_entry_free, NULL);
g_list_free (format->format_list);
format->format_list = NULL;
......@@ -444,7 +445,7 @@ lookup_color (char *str, char *end)
int len = strlen (format_colors [i].name);
if ((strncasecmp (format_colors [i].name, str, len) == 0) ||
(strncasecmp (_(format_colors [i].name), str, len) == 0)){
(strncasecmp (_(format_colors [i].name), str, len) == 0)){
style_color_ref (format_colors [i].color);
return format_colors [i].color;
}
......@@ -928,53 +929,56 @@ format_number (gdouble number, StyleFormatEntry *style_format_entry)
static gboolean
check_valid (StyleFormatEntry *entry, Value *value)
{
switch (value->type)
{
case VALUE_STRING:
return entry->restriction_type == '@';
case VALUE_FLOAT:
switch (entry->restriction_type)
{
case '*':
return TRUE;
case '<':
return value->v.v_float < entry->restriction_value;
case '>':
return value->v.v_float > entry->restriction_value;
case '=':
return value->v.v_float == entry->restriction_value;
case ',':
return value->v.v_float <= entry->restriction_value;
case '.':
return value->v.v_float >= entry->restriction_value;
case '+':
return value->v.v_float != entry->restriction_value;
switch (value->type){
case VALUE_STRING:
return entry->restriction_type == '@';
case VALUE_FLOAT:
switch (entry->restriction_type){
case '*':
return TRUE;
case '<':
return value->v.v_float < entry->restriction_value;
case '>':
return value->v.v_float > entry->restriction_value;
case '=':
return value->v.v_float == entry->restriction_value;
case ',':
return value->v.v_float <= entry->restriction_value;
case '.':
return value->v.v_float >= entry->restriction_value;
case '+':
return value->v.v_float != entry->restriction_value;
default:
return FALSE;
}
case VALUE_INTEGER:
switch (entry->restriction_type){
case '*':
return TRUE;
case '<':
return value->v.v_int < entry->restriction_value;
case '>':
return value->v.v_int > entry->restriction_value;
case '=':
return value->v.v_int == entry->restriction_value;
case ',':
return value->v.v_int <= entry->restriction_value;
case '.':
return value->v.v_int >= entry->restriction_value;
case '+':
return value->v.v_int != entry->restriction_value;
default:
return FALSE;
}
default:
return FALSE;
return FALSE;
}
case VALUE_INTEGER:
switch (entry->restriction_type)
{
case '*':
return TRUE;
case '<':
return value->v.v_int < entry->restriction_value;
case '>':
return value->v.v_int > entry->restriction_value;
case '=':
return value->v.v_int == entry->restriction_value;
case ',':
return value->v.v_int <= entry->restriction_value;
case '.':
return value->v.v_int >= entry->restriction_value;
case '+':
return value->v.v_int != entry->restriction_value;
default:
return FALSE;
}
default:
return FALSE;
}
}
gchar *
......@@ -1009,6 +1013,9 @@ format_value (StyleFormat *format, Value *value, StyleColor **color)
}
}
if (entry.format [0] == 0)
is_general = 1;
if (strcmp (entry.format, "General") == 0){
entry.format += 7;
is_general = 1;
......@@ -1020,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.##";
entry.format = "0.00########";
}
if (finite (value->v.v_float))
v = format_number (value->v.v_float, &entry);
......
......@@ -1173,7 +1173,7 @@ gnumeric_sheet_class_init (GnumericSheetClass *class)
widget_class = (GtkWidgetClass *) class;
canvas_class = (GnomeCanvasClass *) class;
sheet_parent_class = gtk_type_class (gnome_canvas_get_type());
sheet_parent_class = gtk_type_class (gnome_canvas_get_type ());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
......
......@@ -1173,7 +1173,7 @@ gnumeric_sheet_class_init (GnumericSheetClass *class)
widget_class = (GtkWidgetClass *) class;
canvas_class = (GnomeCanvasClass *) class;
sheet_parent_class = gtk_type_class (gnome_canvas_get_type());
sheet_parent_class = gtk_type_class (gnome_canvas_get_type ());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
......
......@@ -22,6 +22,7 @@ static char *dump_file_name = NULL;
static char **startup_files = NULL;
poptContext ctx;
const struct poptOption gnumeric_popt_options [] = {
{ "dump-func-defs", '\0', POPT_ARG_STRING, &dump_file_name, 0,
N_("Dumps the function definitions"), N_("FILE") },
......
......@@ -22,6 +22,7 @@ static char *dump_file_name = NULL;
static char **startup_files = NULL;
poptContext ctx;
const struct poptOption gnumeric_popt_options [] = {
{ "dump-func-defs", '\0', POPT_ARG_STRING, &dump_file_name, 0,
N_("Dumps the function definitions"), N_("FILE") },
......
......@@ -126,6 +126,17 @@ cell_compare (gconstpointer a, gconstpointer b)
return 1;
}
void
sheet_rename (Sheet *sheet, const char *new_name)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (new_name != NULL);
g_free (sheet->name);
sheet->name = g_strdup (new_name);
}
Sheet *
sheet_new (Workbook *wb, char *name)
{
......@@ -133,6 +144,9 @@ sheet_new (Workbook *wb, char *name)
Sheet *sheet;
Style *sheet_style;
g_return_val_if_fail (wb != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
sheet = g_new0 (Sheet, 1);
sheet->signature = SHEET_SIGNATURE;
sheet->workbook = wb;
......
......@@ -143,6 +143,7 @@ typedef int (*sheet_cell_foreach_callback)(Sheet *sheet, int col, int row,
Cell *cell, void *user_data);
Sheet *sheet_new (Workbook *wb, char *name);
void sheet_rename (Sheet *sheet, const char *new_name);
void sheet_destroy (Sheet *sheet);
void sheet_foreach_col (Sheet *sheet,
sheet_col_row_callback callback,
......@@ -364,6 +365,9 @@ 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,
const char *old_name,
const char *new_name);
/*
* Does any pending recalculations
......
......@@ -18,6 +18,7 @@
#include "xml-io.h"
#include "plugin.h"
#include "pixmaps.h"
#include "widget-editable-label.h"
/* The locations within the main table in the workbook */
#define WB_EA_LINE 0
......@@ -620,8 +621,8 @@ workbook_edit_comment (GtkWidget *widget, Workbook *wb)
cell = sheet_cell_new (sheet, sheet->cursor_col, sheet->cursor_row);
cell_set_text (cell, "");
}
cell_set_comment (cell, "Test comment");
dialog_cell_comment (wb, cell);
}
static void
......@@ -1116,12 +1117,29 @@ change_auto_expr_menu (GtkWidget *widget, GdkEventButton *event, Workbook *wb)
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, 0, NULL, 1, event->time);
}
/*
* Sets up the autocalc label on the workbook.
*
* This code is more complex than it should for a number of
* reasons:
*
* 1. GtkLabels flicker a lot, so we use a GnomeCanvas to
* avoid the unnecessary flicker
*
* 2. Using a Canvas to display a label is tricky, there
* are a number of ugly hacks here to do what we want
* to do.
*
* When GTK+ gets a flicker free label (Owen mentions that the
* new repaint engine in GTK+ he is working on will be flicker free)
* we can remove most of these hacks
*/
static void
workbook_setup_status_area (Workbook *wb)
workbook_setup_auto_calc (Workbook *wb)
{
GtkWidget *canvas;
GnomeCanvasGroup *root;
GtkWidget *t;
GtkWidget *t, *l;
t = gtk_table_new (0, 0, 0);
gtk_table_attach (GTK_TABLE (wb->table), t,
......@@ -1129,15 +1147,17 @@ workbook_setup_status_area (Workbook *wb)
canvas = gnome_canvas_new ();
l = gtk_label_new ("Info");
/* The canvas that displays text */
root = GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root);
wb->auto_expr_label = GNOME_CANVAS_ITEM (gnome_canvas_item_new (
root, gnome_canvas_text_get_type (),
"text", "x",
"x", (double) 0,
"y", (double) 10, /* FIXME :-) */
"font", "fixed", /* FIXME :-) */
"anchor", GTK_ANCHOR_W,
"text", "x",
"x", (double) 0,
"y", (double) 0, /* FIXME :-) */
"font_gdk", l->style->font,
"anchor", GTK_ANCHOR_NW,
"fill_color", "black",
NULL));
......@@ -1152,11 +1172,21 @@ workbook_setup_status_area (Workbook *wb)
gtk_signal_connect (GTK_OBJECT (canvas), "button_press_event",
GTK_SIGNAL_FUNC (change_auto_expr_menu), wb);
gtk_table_attach (GTK_TABLE (t), gtk_label_new ("Info"), 0, 1, 0, 1,
gtk_table_attach (GTK_TABLE (t), l, 0, 1, 0, 1,
GTK_FILL | GTK_EXPAND, 0, 0, 0);
gtk_widget_show_all (t);
}
/*
* Sets up the status display area
*/
static void
workbook_setup_status_area (Workbook *wb)
{
workbook_setup_auto_calc (wb);
}
void
workbook_auto_expr_label_set (Workbook *wb, char *text)
{
......@@ -1165,11 +1195,8 @@ workbook_auto_expr_label_set (Workbook *wb, char *text)
g_return_if_fail (wb != NULL);
g_return_if_fail (text != NULL);
res = g_strconcat (wb->auto_expr_desc->str, "=",
text, NULL);
gnome_canvas_item_set (wb->auto_expr_label,
"text", res,
NULL);
res = g_strconcat (wb->auto_expr_desc->str, "=", text, NULL);
gnome_canvas_item_set (wb->auto_expr_label, "text", res, NULL);
g_free (res);
}
......@@ -1182,8 +1209,6 @@ workbook_set_focus (GtkWindow *window, GtkWidget *focus, Workbook *wb)
/*