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

Check the return value from symbol_lookup.


1998-09-27  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/expr.c (function_call_with_values): Check the return value
	from symbol_lookup.

1998-09-26  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/sheet-object.c (sheet_view_object_realize): Swap coordinates
	before passing to the canvas item.

	* plugins/python/python.c (init_plugin): Use the system
	installation directory to load the python scripts.

	* autogen.sh: Hack to make libtool add library dependcy
	information (it modifies the libtool file after it has been
	created).

	* src/workbook.c (workbook_set_filename): New routine to set the
	filename being edited of the workbook.

	* src/sheet-object.c (create_object): Swap arguments to the
	ellipse object to guarrantee we pass valid information.

	* src/render-ascii.c (cell_region_render_ascii): Ok, remove the
	leaks now.
parent fc037b0e
......@@ -32,7 +32,8 @@ dialog_about (void)
about = gnome_about_new (_("Gnumeric"), VERSION,
"(C) 1998 Miguel de Icaza",
authors,
_("The GNOME spreadsheet."),
_("The GNOME spreadsheet.\n"
"http://www.gnome.org/gnumeric"),
NULL);
gnome_dialog_set_modal (GNOME_DIALOG (about));
gnome_dialog_set_close (GNOME_DIALOG (about), TRUE);
......
......@@ -84,7 +84,7 @@ cell_set_halign (Cell *cell, StyleHAlignFlags halign)
{
g_return_if_fail (cell != NULL);
if (cell->style->halign == halign)
if (cell->style->halign == (unsigned int) halign)
return;
cell_queue_redraw (cell);
......
......@@ -13,6 +13,11 @@
#include "eval.h"
#include "render-ascii.h"
/*
* x_selection_clear:
*
* Callback for the "we lost the X selection" signal
*/
static gint
x_selection_clear (GtkWidget *widget, GdkEventSelection *event, Workbook *wb)
{
......@@ -21,6 +26,11 @@ x_selection_clear (GtkWidget *widget, GdkEventSelection *event, Workbook *wb)
return TRUE;
}
/*
* x_selection_handler:
*
* Callback invoked when another application requests we render the selection.
*/
static void
x_selection_handler (GtkWidget *widget, GtkSelectionData *selection_data, gpointer data)
{
......@@ -36,6 +46,28 @@ x_selection_handler (GtkWidget *widget, GtkSelectionData *selection_data, gpoint
rendered_selection, strlen (rendered_selection));
}
/*
* x_selection_received
*
* Invoked when the selection has been received by our application.
* This is triggered by a call we do to gtk_selection_convert.
*/
static void
x_selection_received (GtkWidget *widget, GtkSelectionData *sel, gpointer data)
{
Workbook *wb = data;
/* Did X provide any selection? */
if (sel->length < 0){
}
}
/*
* x_clipboard_bind_workbook
*
* Binds the signals related to the X selection to the Workbook
*/
void
x_clipboard_bind_workbook (Workbook *wb)
{
......@@ -49,6 +81,9 @@ x_clipboard_bind_workbook (Workbook *wb)
wb->toplevel,
GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING,
x_selection_handler, wb);
gtk_signal_connect (
GTK_OBJECT (wb->toplevel), "selection_received",
GTK_SIGNAL_FUNC(x_selection_received), wb);
}
/*
......@@ -101,17 +136,12 @@ CellRegion *
clipboard_copy_cell_range (Sheet *sheet, int start_col, int start_row, int end_col, int end_row)
{
append_cell_closure_t c;
GtkEditable *editable;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (start_col <= end_col, NULL);
g_return_val_if_fail (start_row <= end_row, NULL);
if (!editable){
editable = GTK_EDITABLE (gtk_type_new (gtk_editable_get_type ()));
}
c.r = g_new0 (CellRegion, 1);
c.base_col = start_col;
......@@ -161,11 +191,14 @@ paste_cell (Sheet *dest_sheet, Cell *new_cell, int target_col, int target_row, i
return new_cell->parsed_node != 0;
}
/*
* Main entry point for the paste code
*/
void
clipboard_paste_region (CellRegion *region, Sheet *dest_sheet,
int dest_col, int dest_row,
int paste_width, int paste_height,
int paste_flags)
int dest_col, int dest_row,
int paste_width, int paste_height,
int paste_flags, guint32 time)
{
CellCopyList *l;
GList *deps;
......@@ -242,6 +275,9 @@ clipboard_paste_region (CellRegion *region, Sheet *dest_sheet,
workbook_recalc (dest_sheet->workbook);
}
/*
* Destroys the contents of a CellRegion
*/
void
clipboard_release (CellRegion *region)
{
......
......@@ -27,7 +27,8 @@ void clipboard_paste_region (CellRegion *region,
int dest_row,
int paste_width,
int paste_height,
int paste_flags);
int paste_flags,
guint32 time);
void clipboard_release (CellRegion *region);
......
......@@ -32,7 +32,8 @@ dialog_about (void)
about = gnome_about_new (_("Gnumeric"), VERSION,
"(C) 1998 Miguel de Icaza",
authors,
_("The GNOME spreadsheet."),
_("The GNOME spreadsheet.\n"
"http://www.gnome.org/gnumeric"),
NULL);
gnome_dialog_set_modal (GNOME_DIALOG (about));
gnome_dialog_set_close (GNOME_DIALOG (about), TRUE);
......
......@@ -476,6 +476,10 @@ function_call_with_values (Sheet *sheet, char *name, int argc, Value *values[],
g_return_val_if_fail (name != NULL, NULL);
sym = symbol_lookup (name);
if (sym == NULL){
*error_string = "Function does not exist";
return NULL;
}
if (sym->type != SYMBOL_FUNCTION){
*error_string = "Calling non-function";
return NULL;
......
......@@ -98,7 +98,7 @@ static char *month_short [] =
static char *month_long [] =
{
N_("January"),
N_("Februrary"),
N_("February"),
N_("March"),
N_("April"),
N_("May"),
......
/*
* sheet-object.c: Implements the drawing object manipulation for Gnumeric
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*/
#include <config.h>
#include <gnome.h>
#include <gdk/gdkkeysyms.h>
......@@ -43,6 +49,11 @@ sheet_release_coords (Sheet *sheet)
sheet->coords = NULL;
}
/*
* sheet_object_new:
*
* Creates a new simple object
*/
static inline SheetObject *
sheet_object_new (Sheet *sheet)
{
......@@ -55,6 +66,11 @@ sheet_object_new (Sheet *sheet)
return so;
}
/*
* sheet_object_new:
*
* Creates a new filled object.
*/
static inline SheetObject *
sheet_filled_object_new (Sheet *sheet)
{
......@@ -67,6 +83,11 @@ sheet_filled_object_new (Sheet *sheet)
return (SheetObject *) sfo;
}
/*
* sheet_object_create_filled:
*
* Creates and initializes a filled object of type TYPE.
*/
SheetObject *
sheet_object_create_filled (Sheet *sheet, int type,
double x1, double y1,
......@@ -102,6 +123,11 @@ sheet_object_create_filled (Sheet *sheet, int type,
return (SheetObject *) sfo;
}
/*
* sheet_object_create_line
*
* Creates a line object
*/
SheetObject *
sheet_object_create_line (Sheet *sheet, int is_arrow, double x1, double y1, double x2, double y2, char *color, int w)
{
......@@ -126,6 +152,11 @@ sheet_object_create_line (Sheet *sheet, int is_arrow, double x1, double y1, doub
return so;
}
/*
* sheet_view_object_realize
*
* Creates the actual object on the Canvas of a SheetView
*/
static GnomeCanvasItem *
sheet_view_object_realize (SheetView *sheet_view, SheetObject *object)
{
......@@ -179,14 +210,16 @@ sheet_view_object_realize (SheetView *sheet_view, SheetObject *object)
NULL);
break;
case SHEET_OBJECT_ELLIPSE:
case SHEET_OBJECT_ELLIPSE: {
double *c = object->points->coords;
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_ellipse_get_type (),
"x1", object->points->coords [0],
"y1", object->points->coords [1],
"x2", object->points->coords [2],
"y2", object->points->coords [3],
"x1", MIN (c [0], c [2]),
"y1", MIN (c [1], c [3]),
"x2", MAX (c [0], c [2]),
"y2", MAX (c [1], c [3]),
"fill_color", filled_object->fill_color ?
filled_object->fill_color->str : NULL,
"outline_color", object->color->str,
......@@ -194,6 +227,7 @@ sheet_view_object_realize (SheetView *sheet_view, SheetObject *object)
NULL);
break;
}
}
gtk_signal_connect (GTK_OBJECT (item), "event",
GTK_SIGNAL_FUNC (object_event), object);
......@@ -205,6 +239,11 @@ sheet_view_object_realize (SheetView *sheet_view, SheetObject *object)
return item;
}
/*
* sheet_view_object_unrealize
*
* Removes the object from the canvas in the SheetView.
*/
static void
sheet_view_object_unrealize (SheetView *sheet_view, SheetObject *object)
{
......@@ -228,6 +267,12 @@ sheet_view_object_unrealize (SheetView *sheet_view, SheetObject *object)
}
}
/*
* sheet_object_realize
*
* Realizes the on a Sheet (this in turn realizes the object
* on every existing SheetView)
*/
void
sheet_object_realize (Sheet *sheet, SheetObject *object)
{
......@@ -247,6 +292,12 @@ sheet_object_realize (Sheet *sheet, SheetObject *object)
}
}
/*
* sheet_object_unrealize
*
* Destroys the Canvas Item that represents this SheetObject from
* every SheetViews.
*/
void
sheet_object_unrealize (Sheet *sheet, SheetObject *object)
{
......@@ -265,6 +316,12 @@ sheet_object_unrealize (Sheet *sheet, SheetObject *object)
}
}
/*
* create_object
*
* Creates an object with the data stored from the creation or
* previous mouse samples to the location to_x, to_y.
*/
static SheetObject *
create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
{
......@@ -323,6 +380,12 @@ create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
return o;
}
/*
* sheet_motion_notify
*
* Invoked when the sheet is in a SHEET_MODE_CREATE mode to keep track
* of the cursor position.
*/
static int
sheet_motion_notify (GnumericSheet *gsheet, GdkEvent *event, Sheet *sheet)
{
......@@ -339,6 +402,11 @@ sheet_motion_notify (GnumericSheet *gsheet, GdkEvent *event, Sheet *sheet)
return 1;
}
/*
* sheet_button_release
*
* Invoked as the last step in object creation.
*/
static int
sheet_button_release (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
{
......@@ -360,6 +428,12 @@ sheet_button_release (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet
return 1;
}
/*
* sheet_button_press
*
* Starts the process of creating a SheetObject. Handles the initial
* button press on the GnumericSheet.
*/
static int
sheet_button_press (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
{
......@@ -386,6 +460,14 @@ sheet_button_press (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
return 1;
}
/*
* sheet_finish_object_creation
*
* Last step of the creation of an object: sets the sheet mode to
* select the current object, releases the datastructures used
* during object creation and disconnects the signal handlers
* used during object creation
*/
static void
sheet_finish_object_creation (Sheet *sheet, SheetObject *o)
{
......@@ -474,6 +556,11 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
}
}
/*
* sheet_object_destroy_control_points
*
* Destroys the Canvas Items used as sheet control points
*/
static void
sheet_object_destroy_control_points (Sheet *sheet)
{
......@@ -499,6 +586,11 @@ sheet_object_stop_editing (SheetObject *object)
sheet_object_destroy_control_points (sheet);
}
/*
* sheet_object_destroy
*
* Destroys a SheetObject
*/
void
sheet_object_destroy (SheetObject *object)
{
......@@ -544,6 +636,11 @@ sheet_object_destroy (SheetObject *object)
#define POINT(x) (1 << x)
/*
* set_item_x:
*
* chantes the x position of the idxth control point
*/
static void
set_item_x (SheetView *sheet_view, int idx, double x)
{
......@@ -554,6 +651,11 @@ set_item_x (SheetView *sheet_view, int idx, double x)
NULL);
}
/*
* set_item_x:
*
* chantes the y position of the idxth control point
*/
static void
set_item_y (SheetView *sheet_view, int idx, double y)
{
......@@ -565,10 +667,15 @@ set_item_y (SheetView *sheet_view, int idx, double y)
}
/*
* This hooks to the event for the handlebox
* control_point_handle_event
*
* Event handler for the control points.
*
* The index for this control point is retrieved from the Gtk user object_data
*
*/
static int
object_handle_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *object)
control_point_handle_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *object)
{
int idx;
GList *l;
......@@ -711,6 +818,11 @@ object_handle_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *object
return TRUE;
}
/*
* object_event
*
* Event handler for a SheetObject
*/
static int
object_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *object)
{
......@@ -812,13 +924,19 @@ new_control_point (GnomeCanvasGroup *group, SheetObject *object, int idx, double
NULL);
gtk_signal_connect (GTK_OBJECT (item), "event",
GTK_SIGNAL_FUNC (object_handle_event), object);
GTK_SIGNAL_FUNC (control_point_handle_event),
object);
gtk_object_set_user_data (GTK_OBJECT (item), GINT_TO_POINTER (idx));
return item;
}
/*
* sheet_object_start_editing
*
* Makes an object editable (adds its control points).
*/
static void
sheet_object_start_editing (SheetObject *object)
{
......@@ -842,6 +960,12 @@ sheet_object_start_editing (SheetObject *object)
}
}
/*
* sheet_object_make_current
*
* Makes the object the currently selected object and prepares it for
* user edition.
*/
void
sheet_object_make_current (Sheet *sheet, SheetObject *object)
{
......
......@@ -2195,10 +2195,10 @@ sheet_selection_cut (Sheet *sheet)
}
void
sheet_selection_paste (Sheet *sheet, int dest_col, int dest_row, int paste_flags)
sheet_selection_paste (Sheet *sheet, int dest_col, int dest_row, int paste_flags, guint32 time)
{
SheetSelection *ss;
CellRegion *content;
int end_col, end_row, paste_width, paste_height;
g_return_if_fail (sheet != NULL);
......@@ -2230,7 +2230,7 @@ sheet_selection_paste (Sheet *sheet, int dest_col, int dest_row, int paste_flags
end_row = dest_row + paste_height - 1;
clipboard_paste_region (content, sheet, dest_col, dest_row,
paste_width, paste_height, paste_flags);
paste_width, paste_height, paste_flags, time);
sheet_cursor_set (sheet, dest_col, dest_row, end_col, end_row);
sheet_selection_reset_only (sheet);
......
......@@ -168,8 +168,8 @@ void sheet_selection_clear (Sheet *sheet);
gboolean sheet_selection_copy (Sheet *sheet);
gboolean sheet_selection_cut (Sheet *sheet);
void sheet_selection_paste (Sheet *sheet,
int dest_col, int dest_row,
int paste_flags);
int dest_col, int dest_row,
int paste_flags, guint32 time);
int sheet_selection_walk_step (Sheet *sheet,
int forward, int horizontal,
int current_col, int current_row,
......
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