Commit cc5261fa authored by Michael Meeks's avatar Michael Meeks

Correct size, better looking print preview icon,

Array input fixed for wierd locales,
bug in header read fixed,
sheet-object window_to_world cleaned,
my D&D stuff moved to more sensible place,
parent 66253453
1999-09-15 Michael Meeks <michael@nuclecu.unam.mx>
* src/sheet-object.c (window_to_world): Remove.
(sheet_motion_notify, sheet_button_release, sheet_object_drop_file):
clean to use gnome_canvas_window_to_world.
* src/sheet-view.c (sheet_view_construct, (filenames_dropped): move
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped),
(gnumeric_sheet_new): to here + rename; makes more sense.
* src/sheet-object.c (sheet_object_drop_file): Take a GnumericSheet.
* src/parser.y (array_row:): Manged to support wierd MS style array
semantics some people get {1\2\3;4\5\6} instead of {1,2,3;4,5,6}.
* src/workbook.c (workbook_file_toolbar): Remove duplicate print icon.
* src/pixmaps/preview.xpm: Stop gap icon; improved.
* src/xml-io.c (xml_get_print_hf): Remove redundant precondition.
1999-09-14 Miguel de Icaza <miguel@gnu.org>
* src/workbook.c: Split toolbars into mulitple toolbars; Add a
......
1999-09-15 Michael Meeks <michael@nuclecu.unam.mx>
* src/sheet-object.c (window_to_world): Remove.
(sheet_motion_notify, sheet_button_release, sheet_object_drop_file):
clean to use gnome_canvas_window_to_world.
* src/sheet-view.c (sheet_view_construct, (filenames_dropped): move
* src/gnumeric-sheet.c (gnumeric_sheet_filenames_dropped),
(gnumeric_sheet_new): to here + rename; makes more sense.
* src/sheet-object.c (sheet_object_drop_file): Take a GnumericSheet.
* src/parser.y (array_row:): Manged to support wierd MS style array
semantics some people get {1\2\3;4\5\6} instead of {1,2,3;4,5,6}.
* src/workbook.c (workbook_file_toolbar): Remove duplicate print icon.
* src/pixmaps/preview.xpm: Stop gap icon; improved.
* src/xml-io.c (xml_get_print_hf): Remove redundant precondition.
1999-09-14 Miguel de Icaza <miguel@gnu.org>
* src/workbook.c: Split toolbars into mulitple toolbars; Add a
......
......@@ -908,6 +908,33 @@ gnumeric_sheet_drag_data_get (GtkWidget *widget,
#endif
}
static void
gnumeric_sheet_filenames_dropped (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
GnumericSheet *gsheet)
{
GList *names, *tmp_list;
names = gnome_uri_list_extract_filenames ((char *)selection_data->data);
tmp_list = names;
while (tmp_list) {
Workbook *new_wb;
if ((new_wb = workbook_try_read (tmp_list->data)))
gtk_widget_show (new_wb->toplevel);
else
sheet_object_drop_file (gsheet, x, y, tmp_list->data);
tmp_list = tmp_list->next;
}
}
GtkWidget *
gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
{
......@@ -919,6 +946,10 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
GtkWidget *entry;
Sheet *sheet;
Workbook *workbook;
static GtkTargetEntry drag_types[] = {
{ "text/uri-list", 0, 0 },
};
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
g_return_val_if_fail (sheet_view != NULL, NULL);
g_return_val_if_fail (IS_SHEET_VIEW (sheet_view), NULL);
......@@ -964,7 +995,17 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
gtk_signal_connect (
GTK_OBJECT (widget), "drag_data_get",
GTK_SIGNAL_FUNC (gnumeric_sheet_drag_data_get), NULL);
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_ALL,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (widget),
"drag_data_received",
GTK_SIGNAL_FUNC (gnumeric_sheet_filenames_dropped),
widget);
return widget;
}
......
......@@ -908,6 +908,33 @@ gnumeric_sheet_drag_data_get (GtkWidget *widget,
#endif
}
static void
gnumeric_sheet_filenames_dropped (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
GnumericSheet *gsheet)
{
GList *names, *tmp_list;
names = gnome_uri_list_extract_filenames ((char *)selection_data->data);
tmp_list = names;
while (tmp_list) {
Workbook *new_wb;
if ((new_wb = workbook_try_read (tmp_list->data)))
gtk_widget_show (new_wb->toplevel);
else
sheet_object_drop_file (gsheet, x, y, tmp_list->data);
tmp_list = tmp_list->next;
}
}
GtkWidget *
gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
{
......@@ -919,6 +946,10 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
GtkWidget *entry;
Sheet *sheet;
Workbook *workbook;
static GtkTargetEntry drag_types[] = {
{ "text/uri-list", 0, 0 },
};
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
g_return_val_if_fail (sheet_view != NULL, NULL);
g_return_val_if_fail (IS_SHEET_VIEW (sheet_view), NULL);
......@@ -964,7 +995,17 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
gtk_signal_connect (
GTK_OBJECT (widget), "drag_data_get",
GTK_SIGNAL_FUNC (gnumeric_sheet_drag_data_get), NULL);
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_ALL,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (widget),
"drag_data_received",
GTK_SIGNAL_FUNC (gnumeric_sheet_filenames_dropped),
widget);
return widget;
}
......
......@@ -72,6 +72,7 @@ static const char **parser_desired_format;
/* Locale info. */
static char parser_decimal_point;
static char parser_separator;
static char parser_array_col_separator;
static ExprTree **parser_result;
......@@ -276,10 +277,21 @@ array_row: array_exp {
$$ = g_list_prepend (NULL, $1);
alloc_glist ($$);
}
| array_exp SEPARATOR array_row {
forget_glist ($3);
$$ = g_list_prepend ($3, $1);
alloc_glist ($$);
| array_exp ',' array_row {
if (parser_array_col_separator == ',') {
forget_glist ($3);
$$ = g_list_prepend ($3, $1);
alloc_glist ($$);
} else
parser_error = PARSE_ERR_SYNTAX;
}
| array_exp '\\' array_row {
if (parser_array_col_separator == '\\') {
forget_glist ($3);
$$ = g_list_prepend ($3, $1);
alloc_glist ($$);
} else
parser_error = PARSE_ERR_SYNTAX;
}
| { $$ = NULL; }
;
......@@ -783,11 +795,14 @@ gnumeric_expr_parser (const char *expr, const ParsePosition *pp,
else
parser_decimal_point = '.';
if (parser_decimal_point == ',')
if (parser_decimal_point == ',') {
parser_separator = ';';
else
parser_array_col_separator = '\\'; /* ! */
} else {
parser_separator = ',';
parser_array_col_separator = ',';
}
yyparse ();
if (parser_error == PARSE_OK)
......
/* XPM */
static char * preview_xpm[] = {
"32 32 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .... ",
" ...... ",
" .. ... ",
" .. ... ",
" .. .. ",
" .. .. ",
" .. .. ",
" ... .. ",
" .. .. ",
" ....... ",
" ..... ",
" ..... ",
" .... ",
" .... ",
" .... ",
" ... ",
" .. ",
" ",
" ",
" ",
" "};
"24 24 184 2",
" c None",
". c #000000",
"+ c #171719",
"@ c #F6F6F4",
"# c #CDCDCD",
"$ c #646464",
"% c #161617",
"& c #1D1E4E",
"* c #0000E7",
"= c #000057",
"- c #00005E",
"; c #00008B",
"> c #1414F0",
", c #C4C4C3",
"' c #464646",
") c #0A0A93",
"! c #2425E7",
"~ c #6869F3",
"{ c #CACCE5",
"] c #B8B9EB",
"^ c #969AE8",
"/ c #4249F1",
"( c #2626EA",
"_ c #D5D4E3",
": c #E4E3DF",
"< c #A5A29E",
"[ c #2B2DD5",
"} c #484AEC",
"| c #AFB1EC",
"1 c #E9EAED",
"2 c #BABCEE",
"3 c #A2A5ED",
"4 c #7578EC",
"5 c #0000EC",
"6 c #8486E7",
"7 c #B3B2D3",
"8 c #131314",
"9 c #0000D4",
"0 c #666AF0",
"a c #9FA2EF",
"b c #EFF4EB",
"c c #E8E6EB",
"d c #B0B3EB",
"e c #A0A7EB",
"f c #999EEB",
"g c #4B4FF3",
"h c #0000E1",
"i c #3C3EB4",
"j c #D0D0D0",
"k c #00003B",
"l c #B7B8D4",
"m c #ECEDF0",
"n c #FEFEEA",
"o c #9DA0EB",
"p c #9499EB",
"q c #8C94EA",
"r c #8088EA",
"s c #757CFA",
"t c #000086",
"u c #1B1B62",
"v c #CBCBCB",
"w c #E9E9E9",
"x c #EDEDED",
"y c #000058",
"z c #A5A6DC",
"A c #CED0F1",
"B c #DBE1EB",
"C c #8F92EB",
"D c #8A8EEB",
"E c #7D82EB",
"F c #6A70EB",
"G c #666EFB",
"H c #000088",
"I c #3C3B83",
"J c #6E6E6E",
"K c #8D8D8D",
"L c #B7B7B7",
"M c #EBEBEB",
"N c #FAFAFA",
"O c #F5F5F5",
"P c #0000BF",
"Q c #696BEB",
"R c #9095EE",
"S c #BBC0EB",
"T c #898FEB",
"U c #7B7FEB",
"V c #7178EC",
"W c #636AF4",
"X c #484CFF",
"Y c #0000E4",
"Z c #4B4BB7",
"` c #494949",
" . c #2E2E2E",
".. c #ACACAC",
"+. c #AAAAAA",
"@. c #A8A8A8",
"#. c #BBBBBB",
"$. c #E1E1E1",
"%. c #4B4EF0",
"&. c #4347EE",
"*. c #5556EC",
"=. c #949BEC",
"-. c #8B90ED",
";. c #7379ED",
">. c #676EEF",
",. c #565CFF",
"'. c #2423A4",
"). c #0000BA",
"!. c #393896",
"~. c #363636",
"{. c #3A3A3A",
"]. c #B3B3B3",
"^. c #B1B1B1",
"/. c #AFAFAF",
"(. c #A9A9A9",
"_. c #4545E3",
":. c #0D0DEB",
"<. c #4B50F3",
"[. c #8A8DF0",
"}. c #7075F5",
"|. c #5D60F5",
"1. c #3137EE",
"2. c #3D3B30",
"3. c #474747",
"4. c #414141",
"5. c #696969",
"6. c #A1A1A1",
"7. c #B4B4B4",
"8. c #B2B2B2",
"9. c #A2A2A2",
"0. c #8F90B9",
"a. c #000059",
"b. c #00005F",
"c. c #00008F",
"d. c #0000FE",
"e. c #444AFF",
"f. c #0B0C44",
"g. c #050505",
"h. c #3B3B3B",
"i. c #666666",
"j. c #636363",
"k. c #A3A3A3",
"l. c #ADADAD",
"m. c #ABABAB",
"n. c #AAAAAB",
"o. c #ADAEB4",
"p. c #909090",
"q. c #565658",
"r. c #56565E",
"s. c #010101",
"t. c #0A0A0A",
"u. c #5B5B5B",
"v. c #4B4B4B",
"w. c #4A4A4A",
"x. c #606060",
"y. c #868686",
"z. c #A0A0A0",
"A. c #9E9E9E",
"B. c #7F7F7F",
"C. c #373737",
"D. c #3D3D3D",
"E. c #1A1A1A",
"F. c #161616",
"G. c #101010",
"H. c #4D4D4D",
"I. c #505050",
"J. c #555555",
"K. c #4F4F4F",
"L. c #454545",
"M. c #4E4E4E",
"N. c #616161",
"O. c #7B7B7B",
"P. c #393939",
"Q. c #2D2D2D",
"R. c #353535",
"S. c #252525",
"T. c #717171",
"U. c #6F6F6F",
"V. c #404040",
"W. c #313131",
"X. c #484848",
"Y. c #707070",
"Z. c #727272",
"`. c #3E3E3E",
" ",
" ",
" ",
" . . ",
" + @ # $ % . ",
" & * = - ; > , ' . . . ",
" ) ! ~ { ] ^ / ( _ : < . ",
" [ } | 1 2 3 4 5 6 7 . ",
" 8 9 0 a b c d e f g h i ",
" . . j k l m n o p q r s t u . ",
" . . v w x y z A B C D E F G H I J . . ",
" . K L M N O P Q R S T U V W X Y Z ` .. ",
" . ..+.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.. ",
" . ].^./.(.@.(._.:.<.[.}.|.1.. . 2.3.4.. ",
" . 5.6.L 7.8.+.9.0.* a.b.c.d.e.f.. g.h.. ",
" . i.3.j.k.l.m.(.n.o.k.p.q.r.. . . s.t.. ",
" . u.u.v.' w.x.y.9.z.A.B.C.D.E.F.G.. . . ",
" . . H.I.J.K.' L.M.N.O.P.h.Q.R.S.. . . . ",
" . . . 4.u.J.$ T.U.V.W.C.. . . . . . ",
" . . . X.Y.Z.{.`.. . . . ",
" . . . . . ",
" ",
" ",
" "};
......@@ -458,33 +458,6 @@ sheet_view_init (SheetView *sheet_view)
gtk_table_resize (table, 4, 4);
}
static void
filenames_dropped (GtkWidget * widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
SheetView *sheet_view)
{
GList *names, *tmp_list;
names = gnome_uri_list_extract_filenames ((char *)selection_data->data);
tmp_list = names;
while (tmp_list) {
Workbook *new_wb;
if ((new_wb = workbook_try_read (tmp_list->data)))
gtk_widget_show (new_wb->toplevel);
else
sheet_object_drop_file (sheet_view, x, y, tmp_list->data);
tmp_list = tmp_list->next;
}
}
static void
sheet_view_construct (SheetView *sheet_view)
{
......@@ -492,11 +465,6 @@ sheet_view_construct (SheetView *sheet_view)
GtkTable *table = GTK_TABLE (sheet_view);
GtkWidget *select_all;
Sheet *sheet = sheet_view->sheet;
static GtkTargetEntry drag_types[] = {
{ "text/uri-list", 0, 0 },
};
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
/* Column canvas */
sheet_view->col_canvas = new_canvas_bar (sheet_view, GTK_ORIENTATION_HORIZONTAL, &sheet_view->col_item);
......@@ -533,17 +501,6 @@ sheet_view_construct (SheetView *sheet_view)
ITEM_BAR (sheet_view->col_item),
ITEM_BAR (sheet_view->row_item));
/* Enable the sheet as a drop target */
gtk_drag_dest_set (sheet_view->sheet_view,
GTK_DEST_DEFAULT_ALL,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT(sheet_view->sheet_view),
"drag_data_received",
GTK_SIGNAL_FUNC(filenames_dropped),
sheet_view);
gtk_signal_connect_after (
GTK_OBJECT (sheet_view), "size_allocate",
GTK_SIGNAL_FUNC (sheet_view_size_allocate), sheet_view);
......
......@@ -39,29 +39,6 @@ typedef struct {
gdouble x, y;
} ObjectCoords;
static void
window_to_world (GnomeCanvas *canvas, gdouble *x, gdouble *y)
{
/* double zoom = so->sheet->last_zoom_factor_used;*/
#define DISPLAY_X1(canvas) (GNOME_CANVAS (canvas)->layout.xoffset)
#define DISPLAY_Y1(canvas) (GNOME_CANVAS (canvas)->layout.yoffset)
/* printf ("w2w %f %f -> ", *x, *y); */
*x = canvas->scroll_x1 +
(*x + DISPLAY_X1 (canvas) - canvas->zoom_xofs) /
canvas->pixels_per_unit;
*y = canvas->scroll_y1 +
(*y + DISPLAY_Y1 (canvas) - canvas->zoom_yofs) /
canvas->pixels_per_unit;
/* printf ("%f %f, offsets %d %d, display %d %d ppu %f\n", *x, *y,
canvas->zoom_xofs, canvas->zoom_yofs, DISPLAY_X1 (canvas),
DISPLAY_Y1 (canvas), canvas->pixels_per_unit); */
/* *x = canvas->scroll_x1 +
(*x + DISPLAY_X1 (canvas) - canvas->zoom_xofs) * zoom;
*y = canvas->scroll_y1 +
(*y + DISPLAY_Y1 (canvas) - canvas->zoom_yofs) * zoom;*/
}
static void
sheet_release_coords (Sheet *sheet)
{
......@@ -166,15 +143,16 @@ sheet_object_construct (SheetObject *sheet_object, Sheet *sheet)
}
void
sheet_object_drop_file (SheetView *sheet_view, gint x, gint y, const char *fname)
sheet_object_drop_file (GnumericSheet *gsheet, gint x, gint y, const char *fname)
{
#if ENABLE_BONOBO
const char *mime_type;
const char *mime_goad_id;
char *msg = NULL;
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (sheet_view->sheet != NULL);
g_return_if_fail (gsheet != NULL);
g_return_if_fail (gsheet->sheet_view != NULL);
g_return_if_fail (gsheet->sheet_view->sheet != NULL);
if (!(mime_type = gnome_mime_type (fname))) {
msg = g_strdup_printf ("unknown mime type for '%s'", (char *)fname);
......@@ -183,17 +161,13 @@ sheet_object_drop_file (SheetView *sheet_view, gint x, gint y, const char *fname
msg = g_strdup_printf ("no mime mapping for '%s'", mime_type);
gnome_dialog_run_and_close (GNOME_DIALOG (gnome_error_dialog (msg)));
} else {
GnumericSheet *gsheet;
SheetObject *obj;
ObjectCoords pos;
gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
pos.x = x;
pos.y = y;
window_to_world (GNOME_CANVAS (gsheet), &pos.x, &pos.y);
gnome_canvas_window_to_world (GNOME_CANVAS (gsheet), x, y, &pos.x, &pos.y);
obj = sheet_object_container_new (sheet_view->sheet, pos.x, pos.y,
pos.x+100.0, pos.y+100.0,
obj = sheet_object_container_new (gsheet->sheet_view->sheet, pos.x, pos.y,
pos.x + 100.0, pos.y + 100.0,
mime_goad_id);
if (!sheet_object_container_land (obj, fname, TRUE)) {
msg = g_strdup_printf ("Failed to bind or create client site for '%s'",
......@@ -507,9 +481,7 @@ sheet_motion_notify (GnumericSheet *gsheet, GdkEvent *event, Sheet *sheet)
so = SHEET_OBJECT (sheet->current_object);
brx = event->button.x;
bry = event->button.y;
window_to_world (GNOME_CANVAS (gsheet), &brx, &bry);
gnome_canvas_window_to_world (GNOME_CANVAS (gsheet), event->button.x, event->button.y, &brx, &bry);
tl = (ObjectCoords *)sheet->coords->data;
......@@ -543,10 +515,7 @@ sheet_button_release (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet
/* Do not propagate this event further */
gtk_signal_emit_stop_by_name (GTK_OBJECT (gsheet), "button_release_event");
brx = event->x;
bry = event->y;
window_to_world (GNOME_CANVAS (gsheet), &brx, &bry);
gnome_canvas_window_to_world (GNOME_CANVAS (gsheet), event->x, event->y,&brx, &bry);
tl = (ObjectCoords *)sheet->coords->data;
......@@ -581,9 +550,7 @@ sheet_button_press (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
oc = g_new (ObjectCoords, 1);
oc->x = event->x;
oc->y = event->y;
window_to_world (GNOME_CANVAS (gsheet), &oc->x, &oc->y);
gnome_canvas_window_to_world (GNOME_CANVAS (gsheet), event->x, event->y, &oc->x, &oc->y);
sheet->coords = g_list_append (sheet->coords, oc);
......@@ -627,7 +594,7 @@ sheet_finish_object_creation (Sheet *sheet, SheetObject *o)
sheet->modified = TRUE;
/* Disconnect the signal handlers for object creation */
for (l = sheet->sheet_views; l; l = l->next){
for (l = sheet->sheet_views; l; l = l->next) {
SheetView *sheet_view = l->data;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
......@@ -700,7 +667,7 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
return;
}
switch (sheet->mode){
switch (sheet->mode) {
case SHEET_MODE_CREATE_LINE:
case SHEET_MODE_CREATE_ARROW:
case SHEET_MODE_CREATE_OVAL:
......@@ -708,7 +675,8 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
case SHEET_MODE_CREATE_GRAPHIC:
case SHEET_MODE_CREATE_BUTTON:
case SHEET_MODE_CREATE_CHECKBOX:
for (l = sheet->sheet_views; l; l = l->next){
for (l = sheet->sheet_views; l; l = l->next) {
SheetView *sheet_view = l->data;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
......@@ -733,11 +701,11 @@ sheet_object_destroy_control_points (Sheet *sheet)