Commit 0f10b264 authored by Michael Meeks's avatar Michael Meeks

Fixed mmap bug in ole layer,

Re-vamped & improved D&D code moved around too :-)
parent 087a811a
1999-09-08 Michael Meeks <michael@nuclecu.unam.mx>
* src/sheet-view.c (filenames_dropped, sheet_view_construct): Move
D&D activation to here, so we get sensible handling of positions.
* src/sheet-object-container.c (user_activation_request_cb): typo.
(sheet_object_drop_file): Emit the correct signal to realize, take
a SheetView argument, clean 'msg's up.
(sheet_object_container_new): Squashed warning.
* src/workbook.c (filenames_dropped, workbook_new): Move D&D into
sheet-view.c.
* src/file.c (workbook_try_read): Split from workbook_read.
(workbook_import, workbook_read): Correct casts & updated.
* src/dialogs/dialog-function-select.c (function_definition_update),
(function_categories_fill): Add casts to get round daft clist_append
constification.
1999-09-08 Vincent Renardias <vincent@ldsol.com>
* src/dialogs/dialog-analysis-tools.c: A number of displayed strings
......
1999-09-08 Michael Meeks <michael@nuclecu.unam.mx>
* src/sheet-view.c (filenames_dropped, sheet_view_construct): Move
D&D activation to here, so we get sensible handling of positions.
* src/sheet-object-container.c (user_activation_request_cb): typo.
(sheet_object_drop_file): Emit the correct signal to realize, take
a SheetView argument, clean 'msg's up.
(sheet_object_container_new): Squashed warning.
* src/workbook.c (filenames_dropped, workbook_new): Move D&D into
sheet-view.c.
* src/file.c (workbook_try_read): Split from workbook_read.
(workbook_import, workbook_read): Correct casts & updated.
* src/dialogs/dialog-function-select.c (function_definition_update),
(function_categories_fill): Add casts to get round daft clist_append
constification.
1999-09-08 Vincent Renardias <vincent@ldsol.com>
* src/dialogs/dialog-analysis-tools.c: A number of displayed strings
......
1999-09-08 Michael Meeks <michael@imaginator.com>
* README: More random thoughts to pass the time of day.
1999-09-05 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_value) : Always use mode 2 for ints.
......
......@@ -44,5 +44,16 @@ savings over elegance, speed and maintainability ) the abstraction of the lower
biff-records will become more and more integraly tied into the upper layers to
remove problems with 'continue' records in several places.
Actualy, upon further thought I'll retract some of what I said above, its
still ugly, but I think the source of the problem is twofold:
1) Segmentation - whoever was responsible for this should be given a very
very hard stare.
2) Minimal Changes - later versions of Biff should have been handled
totaly differently with regard to the file format, perhaps they wanted
minimal forwards compatibility; but seems unlikely.
1999-09-03 Michael Meeks <michael@imaginator.com>
1999-09-08 Michael Meeks <michael@nuclecu.unam.mx>
* ms-ole.c (ms_ole_open, extend_file): Added trap for MAP_FAILED.
MM to MW: Thanks, my new mail address is as above.
1999-08-29 Morten Welinder <terra@diku.dk>
MW to MM: your primary mail server (mail.imaginator.com) is out;
......
......@@ -472,9 +472,13 @@ extend_file (MsOle *f, guint blocks)
if (newptr != f->mem)
printf ("Memory map moved from %p to %p\n",
f->mem, newptr);
if (newptr == MAP_FAILED) {
f->mem = 0;
g_warning ("panic: re-map failed!");
}
#endif
f->mem = newptr;
#endif
}
......@@ -1165,6 +1169,11 @@ ms_ole_open (const char *name)
if (!f->mem) {
printf ("Obscure internal error, leak.\n");
g_free (f);
return 0;
} else if (f->mem == MAP_FAILED) {
g_warning ("Failed to mmap '%s' copy it to an mmappable mount point", name);
g_free (f);
return 0;
}
#else
......
......@@ -161,6 +161,46 @@ workbook_load_from (Workbook *wb, const char *filename)
return ret;
}
/**
* workbook_try_read:
* @filename: gives the URI of the file.
*
* This function attempts to read the file
*
* Return value: a loaded workbook on success or
* NULL on failure.
**/
Workbook *
workbook_try_read (const char *filename)
{
Workbook *wb;
g_return_val_if_fail (filename != NULL, NULL);
wb = workbook_new ();
if (!workbook_load_from (wb, filename)) {
char *s;
#ifdef ENABLE_BONOBO
gnome_object_destroy (GNOME_OBJECT (wb));
#else
gtk_object_destroy (GTK_OBJECT (wb));
#endif
wb = NULL;
}
return wb;
}
/**
* workbook_read:
* @filename: the file's URI
*
* This attempts to read a workbook, if the file doesn't
* exist it will create a blank 1 sheet workbook, otherwise
* it will flag a user error message.
*
* Return value: a pointer to a Workbook or NULL.
**/
Workbook *
workbook_read (const char *filename)
{
......@@ -175,16 +215,10 @@ workbook_read (const char *filename)
return wb;
}
wb = workbook_new ();
if (!workbook_load_from (wb, filename)) {
wb = workbook_try_read (filename);
if (!wb) {
char *s;
#ifdef ENABLE_BONOBO
gnome_object_destroy (GTK_OBJECT (wb));
#else
gtk_object_destroy (GTK_OBJECT (wb));
#endif
wb = NULL;
s = g_strdup_printf (
N_("Could not read file %s"), filename);
......@@ -263,7 +297,7 @@ workbook_import (Workbook *parent, const char *filename)
wb = workbook_new ();
if (!fo->open (wb, filename)){
#ifdef ENABLE_BONOBO
gnome_object_destroy (GTK_OBJECT (wb));
gnome_object_destroy (GNOME_OBJECT (wb));
#else
gtk_object_destroy (GTK_OBJECT (wb));
#endif
......
......@@ -13,6 +13,7 @@
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "sheet-object.h"
#include "item-cursor.h"
#include "utils.h"
......@@ -439,6 +440,33 @@ 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)
{
......@@ -446,6 +474,11 @@ 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);
......@@ -481,6 +514,17 @@ sheet_view_construct (SheetView *sheet_view)
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",
......@@ -741,7 +785,7 @@ sheet_view_comment_relocate (SheetView *sheet_view, int col, int row, GnomeCanva
void
sheet_view_insert_object (SheetView *sheet_view, GnomeObjectClient *object)
{
GtkWidget *view;
/* GtkWidget *view;*/
/*
* Commented out because the new_view api changed and it isn't
......
......@@ -80,7 +80,7 @@ user_activation_request_cb (GnomeViewFrame *view_frame, SheetObject *so)
{
Sheet *sheet = so->sheet;
printf ("user activation rqeuest\n");
printf ("user activation request\n");
if (sheet->active_object_frame){
gnome_view_frame_view_deactivate (sheet->active_object_frame);
if (sheet->active_object_frame != NULL)
......@@ -449,7 +449,6 @@ sheet_object_container_new (Sheet *sheet,
{
SheetObjectContainer *c;
SheetObject *so;
GnomeObjectClient *object_server;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
......@@ -457,6 +456,8 @@ sheet_object_container_new (Sheet *sheet,
g_return_val_if_fail (y1 <= y2, NULL);
#if 0
GnomeObjectClient *object_server;
if (!object_server)
return NULL;
......
......@@ -159,14 +159,15 @@ sheet_object_construct (SheetObject *sheet_object, Sheet *sheet)
}
void
sheet_object_drop_file (Sheet *sheet, gint x, gint y, const char *fname)
sheet_object_drop_file (SheetView *sheet_view, 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 != NULL);
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (sheet_view->sheet != NULL);
if (!(mime_type = gnome_mime_type (fname))) {
msg = g_strdup_printf ("unknown mime type for '%s'", (char *)fname);
......@@ -181,24 +182,21 @@ sheet_object_drop_file (Sheet *sheet, gint x, gint y, const char *fname)
printf ("So far so good: the goad id = '%s'\n", mime_goad_id);
g_return_if_fail (sheet->sheet_views != NULL);
g_return_if_fail (sheet->sheet_views->data != NULL);
gsheet = GNUMERIC_SHEET (((SheetView *)sheet->sheet_views->data)->sheet_view);
gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
pos.x = x;
pos.y = y;
window_to_world (GNOME_CANVAS (gsheet), &pos.x, &pos.y);
obj = sheet_object_container_new (sheet, pos.x, pos.y, pos.x+100.0, pos.y+100.0,
obj = sheet_object_container_new (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)) {
char *msg = g_strdup_printf ("Failed to bind or create client site for '%s'",
mime_goad_id);
msg = g_strdup_printf ("Failed to bind or create client site for '%s'",
mime_goad_id);
gnome_dialog_run_and_close (GNOME_DIALOG (gnome_error_dialog (msg)));
gnome_object_destroy (GNOME_OBJECT (obj));
g_free (msg);
} else
sheet_object_realize (obj);
gtk_signal_emit_by_name (GTK_OBJECT (obj), "realize");
}
if (msg)
g_free (msg);
......
......@@ -39,7 +39,7 @@ typedef struct {
GtkType sheet_object_get_type (void);
void sheet_object_construct (SheetObject *sheet_object, Sheet *sheet);
void sheet_object_drop_file (Sheet *sheet, gint x, gint y,
void sheet_object_drop_file (SheetView *sheet_view, gint x, gint y,
const char *fname);
/*
......
......@@ -13,6 +13,7 @@
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "sheet-object.h"
#include "item-cursor.h"
#include "utils.h"
......@@ -439,6 +440,33 @@ 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)
{
......@@ -446,6 +474,11 @@ 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);
......@@ -481,6 +514,17 @@ sheet_view_construct (SheetView *sheet_view)
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",
......@@ -741,7 +785,7 @@ sheet_view_comment_relocate (SheetView *sheet_view, int col, int row, GnomeCanva
void
sheet_view_insert_object (SheetView *sheet_view, GnomeObjectClient *object)
{
GtkWidget *view;
/* GtkWidget *view;*/
/*
* Commented out because the new_view api changed and it isn't
......
......@@ -123,6 +123,7 @@ Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_set_filename (Workbook *, const char *);
void workbook_set_title (Workbook *, const char *);
Workbook *workbook_try_read (const char *filename);
Workbook *workbook_read (const char *filename);
void workbook_save_as (Workbook *);
......
......@@ -871,34 +871,6 @@ about_cmd (GtkWidget *widget, Workbook *wb)
dialog_about (wb);
}
static void
filenames_dropped (GtkWidget * widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time,
Workbook *wb)
{
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_read (tmp_list->data)))
gtk_widget_show (new_wb->toplevel);
else
sheet_object_drop_file (workbook_get_current_sheet (wb),
x, y, tmp_list->data);
tmp_list = tmp_list->next;
}
}
#ifdef ENABLE_BONOBO
static void
insert_object_cmd (GtkWidget *widget, Workbook *wb)
......@@ -2004,12 +1976,6 @@ workbook_new (void)
GtkWidget *toolbar;
Workbook *wb;
static GtkTargetEntry drag_types[] =
{
{ "text/uri-list", 0, 0 },
};
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
wb = gtk_type_new (workbook_get_type ());
wb->toplevel = gnome_app_new ("Gnumeric", "Gnumeric");
wb->table = gtk_table_new (0, 0, 0);
......@@ -2059,6 +2025,7 @@ workbook_new (void)
GTK_OBJECT (wb->toplevel), "delete_event",
GTK_SIGNAL_FUNC (workbook_widget_delete_event), wb);
#if 0
/* Enable toplevel as a drop target */
gtk_drag_dest_set (wb->toplevel,
......@@ -2069,6 +2036,7 @@ workbook_new (void)
gtk_signal_connect (GTK_OBJECT(wb->toplevel),
"drag_data_received",
GTK_SIGNAL_FUNC(filenames_dropped), wb);
#endif
/* clipboard setup */
x_clipboard_bind_workbook (wb);
......
......@@ -123,6 +123,7 @@ Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_set_filename (Workbook *, const char *);
void workbook_set_title (Workbook *, const char *);
Workbook *workbook_try_read (const char *filename);
Workbook *workbook_read (const char *filename);
void workbook_save_as (Workbook *);
......
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