Commit 7f35f591 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa
Browse files

Fixed memory leaks.

1999-09-23  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/widgets/widget-color-combo.c (color_combo_class_init): Fixed
	memory leaks.

	* src/style.h: Keep the original colors handy here.

	* src/print-cell.c (print_cell_range, print_empty_cell): We now
	paint empty cells.  Now we paint the background for the cell.

	* src/print-cell.c

	* src/item-grid.c (item_grid_paint_empty_cell): Style leak fix.

	* src/print-cell.c (print_cell): Changed the way borders are
	printed to improve code reusability.

	* src/print-info.c (save_formats): New format name to fix in an
	upgradable fashion.
	(load_formats): ditto.
	(print_info_new): The defaults to load should use [PAGE] not
	[NUM], which explains why it was never being shown.

	* src/print-preview.c (print_preview_print_done): Close the
	context here so we have information available in the ->size
	field.
parent 37cc982d
1999-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/widgets/widget-color-combo.c (color_combo_class_init): Fixed
memory leaks.
* src/style.h: Keep the original colors handy here.
* src/print-cell.c (print_cell_range, print_empty_cell): We now
paint empty cells. Now we paint the background for the cell.
* src/print-cell.c
* src/item-grid.c (item_grid_paint_empty_cell): Style leak fix.
* src/print-cell.c (print_cell): Changed the way borders are
printed to improve code reusability.
* src/print-info.c (save_formats): New format name to fix in an
upgradable fashion.
(load_formats): ditto.
(print_info_new): The defaults to load should use [PAGE] not
[NUM], which explains why it was never being shown.
* src/print-preview.c (print_preview_print_done): Close the
context here so we have information available in the ->size
field.
1999-09-23 Morten Welinder <terra@diku.dk>
* src/regression.c (exponential_regression): Fix thingo.
......@@ -836,6 +863,48 @@
* src/file.c (workbook_import, workbook_read): Add bonobo_object
_destroy if we have bonobo.
1999-09-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-grid.c: Code now can draw emtpy cells with the correct style.
1999-09-03 Miguel de Icaza <miguel@gnu.org>
* src/dialogs/dialog-printer-setup.c (draw_margins): Added margin
display preview.
* src/print-preview.c (preview_zoom_out_cmd): Zoom-in, zoom-out
and move are now toggle buttons.
* src/workbook.c (italic_cmd, bold_cmd): Simplified the code some.
* src/dialogs/dialog-printer-setup.c (do_setup_page_info): Force
the icon display here.
(preview_page_create): Invert test.
(PAGE_X, PAGE_Y): They are now the same values.
(do_setup_page): Show the images here.
1999-09-02 Miguel de Icaza <miguel@gnu.org>
* src/print-preview.c (create_toplevel): Add a toolbar.
* src/print.c (compute_groups): Include the margins in the
size computation.
* src/print-cell.c (print_cell_range): Start printing from the
start_row, not from zero.
* src/print-preview.c: Change of plans. We now use a metafile, we
render all the code there. And then we use the new metafile
operations for rendering a specific page.
* src/item-cursor.c (item_cursor_autofill_event): Change this to
destroy again.
1999-09-01 Miguel de Icaza <miguel@gnu.org>
* src/print-preview.c (print_preview_print_done): Show the first
page here.
1999-09-03 Michael Meeks <michael@imaginator.com>
* src/sheet-object-container.c (sheet_object_container_land): Add
......@@ -853,6 +922,11 @@
* src/workbook.c (filenames_dropped): Hacked.
1999-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-bar.c (item_bar_event): Use the item_bar->resize_pos
computed during button press. #2090 fixed
1999-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/format.c (format_number): "\" is an escape character for the
......@@ -1173,6 +1247,11 @@
* src/cell.c (cell_set_text_simple): Add checks for over/under
flow on integer reading... fall back to double values.
1999-08-19 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Ok, Paolo corrected me. This
is not what he wanted.
1999-08-16 Michael Meeks <michael@imaginator.com>
* src/fn-lookup.c (gnumeric_indirect): Fix leak
......
1999-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/widgets/widget-color-combo.c (color_combo_class_init): Fixed
memory leaks.
* src/style.h: Keep the original colors handy here.
* src/print-cell.c (print_cell_range, print_empty_cell): We now
paint empty cells. Now we paint the background for the cell.
* src/print-cell.c
* src/item-grid.c (item_grid_paint_empty_cell): Style leak fix.
* src/print-cell.c (print_cell): Changed the way borders are
printed to improve code reusability.
* src/print-info.c (save_formats): New format name to fix in an
upgradable fashion.
(load_formats): ditto.
(print_info_new): The defaults to load should use [PAGE] not
[NUM], which explains why it was never being shown.
* src/print-preview.c (print_preview_print_done): Close the
context here so we have information available in the ->size
field.
1999-09-23 Morten Welinder <terra@diku.dk>
* src/regression.c (exponential_regression): Fix thingo.
......@@ -836,6 +863,48 @@
* src/file.c (workbook_import, workbook_read): Add bonobo_object
_destroy if we have bonobo.
1999-09-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-grid.c: Code now can draw emtpy cells with the correct style.
1999-09-03 Miguel de Icaza <miguel@gnu.org>
* src/dialogs/dialog-printer-setup.c (draw_margins): Added margin
display preview.
* src/print-preview.c (preview_zoom_out_cmd): Zoom-in, zoom-out
and move are now toggle buttons.
* src/workbook.c (italic_cmd, bold_cmd): Simplified the code some.
* src/dialogs/dialog-printer-setup.c (do_setup_page_info): Force
the icon display here.
(preview_page_create): Invert test.
(PAGE_X, PAGE_Y): They are now the same values.
(do_setup_page): Show the images here.
1999-09-02 Miguel de Icaza <miguel@gnu.org>
* src/print-preview.c (create_toplevel): Add a toolbar.
* src/print.c (compute_groups): Include the margins in the
size computation.
* src/print-cell.c (print_cell_range): Start printing from the
start_row, not from zero.
* src/print-preview.c: Change of plans. We now use a metafile, we
render all the code there. And then we use the new metafile
operations for rendering a specific page.
* src/item-cursor.c (item_cursor_autofill_event): Change this to
destroy again.
1999-09-01 Miguel de Icaza <miguel@gnu.org>
* src/print-preview.c (print_preview_print_done): Show the first
page here.
1999-09-03 Michael Meeks <michael@imaginator.com>
* src/sheet-object-container.c (sheet_object_container_land): Add
......@@ -853,6 +922,11 @@
* src/workbook.c (filenames_dropped): Hacked.
1999-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-bar.c (item_bar_event): Use the item_bar->resize_pos
computed during button press. #2090 fixed
1999-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/format.c (format_number): "\" is an escape character for the
......@@ -1173,6 +1247,11 @@
* src/cell.c (cell_set_text_simple): Add checks for over/under
flow on integer reading... fall back to double values.
1999-08-19 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Ok, Paolo corrected me. This
is not what he wanted.
1999-08-16 Michael Meeks <michael@imaginator.com>
* src/fn-lookup.c (gnumeric_indirect): Fix leak
......
AC_INIT(src/gnumeric.h)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(gnumeric,0.36)
AM_INIT_AUTOMAKE(gnumeric,0.37)
AM_MAINTAINER_MODE
AM_ACLOCAL_INCLUDE(macros)
......@@ -167,8 +167,8 @@ if gnome-config --libs print > /dev/null 2>&1; then
. `gnome-config --libdir`/printConf.sh
AC_MSG_CHECKING(for GnomePrint >= 0.6)
case x$MODULE_VERSION in
gnome-print-0.[012345])
AC_MSG_ERROR(You need at least GNOME print 0.6 for this version of Gnumeric)
gnome-print-0.[01234567])
AC_MSG_ERROR(You need at least GNOME print 0.8 for this version of Gnumeric)
;;
esac
AC_MSG_RESULT(found)
......
......@@ -19,9 +19,24 @@ enum {
static gint color_combo_signals [LAST_SIGNAL] = { 0, };
static GtkObjectClass *color_combo_parent_class;
static void
color_combo_finalize (GtkObject *object)
{
ColorCombo *cc = COLOR_COMBO (object);
g_free (cc->items);
(*color_combo_parent_class->finalize) (object);
}
static void
color_combo_class_init (GtkObjectClass *object_class)
{
object_class->finalize = color_combo_finalize;
color_combo_parent_class = gtk_type_class (gtk_combo_box_get_type ());
color_combo_signals [CHANGED] =
gtk_signal_new (
"changed",
......@@ -209,7 +224,7 @@ color_combo_construct (ColorCombo *cc, char **icon, gboolean no_color,
"fill_color", color_names [0],
NULL);
gtk_container_add (GTK_CONTAINER (cc->preview_button), GTK_WIDGET (cc->preview_canvas));
gtk_widget_set_usize (cc->preview_canvas, 24, 24);
gtk_widget_set_usize (GTK_WIDGET (cc->preview_canvas), 24, 24);
gtk_signal_connect (GTK_OBJECT (cc->preview_button), "clicked",
GTK_SIGNAL_FUNC (emit_change), cc);
......
......@@ -39,6 +39,8 @@ typedef struct {
GtkType color_combo_get_type (void);
GtkWidget *color_combo_new (char **icon);
void color_combo_construct (ColorCombo *cc, char **icon, gboolean no_color,
int ncols, int nrows, char **color_names);
GtkWidget *color_combo_new_with_vals (char **icon,
int ncols, int nrows, gboolean no_color,
char **color_names);
......
......@@ -345,8 +345,10 @@ item_grid_paint_empty_cell (GdkDrawable *drawable, ItemGrid *item_grid,
if ((style->valid_flags & STYLE_BACK_COLOR) && (style->back_color)){
Sheet *sheet = item_grid->sheet_view->sheet;
if (style->back_color == sheet->default_style->back_color)
if (style->back_color == sheet->default_style->back_color){
style_destroy (style);
return;
}
gdk_gc_set_foreground (item_grid->empty_gc, &style->back_color->color);
gdk_draw_rectangle (
......@@ -355,6 +357,9 @@ item_grid_paint_empty_cell (GdkDrawable *drawable, ItemGrid *item_grid,
ci->pixels - ci->margin_b,
ri->pixels - ri->margin_b);
}
style_destroy (style);
return;
}
static void
......
......@@ -16,7 +16,9 @@
#include <libgnomeprint/gnome-print.h>
#include "print-cell.h"
#define CELL_DIM(cell,p) (cell->p->units + cell->p->margin_a_pt + cell->p->margin_b_pt)
#define DIM(cri) (cri->units + cri->margin_a_pt + cri->margin_b_pt)
#define CELL_DIM(cell,p) DIM (cell->p)
#define CELL_HEIGHT(cell) CELL_DIM(cell,row)
#define CELL_WIDTH(cell) CELL_DIM(cell,col)
......@@ -83,16 +85,10 @@ print_border (GnomePrintContext *pc, double x1, double y1, double x2, double y2,
}
static void
print_cell_border (GnomePrintContext *context, Cell *cell, double x1, double y1)
print_cell_border (GnomePrintContext *context, StyleBorder *border,
double x1, double y1, double x2, double y2)
{
int i;
gdouble cell_width = CELL_WIDTH (cell);
gdouble cell_height = CELL_HEIGHT (cell);
StyleBorder *border = cell->style->border;
double x2, y2;
x2 = x1 + cell_width;
y2 = y1 - cell_height;
for (i = 0; i < STYLE_ORIENT_MAX; ++i)
print_border (context, x1, y1, x1, y2, border, i);
......@@ -340,22 +336,55 @@ print_cell_text (GnomePrintContext *context, Cell *cell, double base_x, double b
}
static void
print_cell (GnomePrintContext *context, Cell *cell, double x, double y)
print_cell_background (GnomePrintContext *context, StyleColor *back,
double x1, double y1, double x2, double y2)
{
GdkColor *fore;
gnome_print_setrgbcolor (
context,
back->red / (double) 0xffff,
back->green / (double) 0xffff,
back->blue / (double) 0xffff);
gnome_print_moveto (context, x1, y1);
gnome_print_lineto (context, x1, y2);
gnome_print_lineto (context, x2, y2);
gnome_print_lineto (context, x2, y1);
gnome_print_lineto (context, x1, y1);
gnome_print_fill (context);
}
static void
print_cell (GnomePrintContext *context, Cell *cell,
double x1, double y1, double x2, double y2)
{
StyleColor *fore = cell->style->fore_color;
g_assert (cell != NULL);
gnome_print_setrgbcolor (context, 0, 0, 0);
print_cell_border (context, cell, x, y);
fore = &cell->style->fore_color->color;
print_cell_border (context, cell->style->border, x1, y1, x2, y2);
print_cell_background (context, cell->style->back_color, x1, y1, x2, y2);
gnome_print_setrgbcolor (context, fore->red, fore->green, fore->blue);
gnome_print_setrgbcolor (context,
fore->red / (double) 0xfff,
fore->green / (double) 0xffff,
fore->blue / (double) 0xffff);
print_cell_text (context, cell,
x + cell->col->margin_a_pt,
y + cell->row->margin_b_pt);
x1 + cell->col->margin_a_pt,
y1 + cell->row->margin_b_pt);
}
static void
print_empty_cell (GnomePrintContext *context, Sheet *sheet, int col, int row,
double x1, double y1, double x2, double y2)
{
Style *style;
style = sheet_style_compute (sheet, col, row, NULL);
print_cell_background (context, style->back_color, x1, y1, x2, y2);
style_destroy (style);
}
void
......@@ -383,14 +412,26 @@ print_cell_range (GnomePrintContext *context,
x = 0;
for (col = start_col; col <= end_col; col++){
double x1 = base_x + x;
double y1 = base_y + y;
Cell *cell;
cell = sheet_cell_get (sheet, col, row);
if (cell){
print_cell (context, cell, base_x + x, base_y + y);
double x2 = x1 + CELL_WIDTH (cell);
double y2 = y1 - CELL_HEIGHT (cell);
ci = cell->col;
} else
print_cell (context, cell, x1, y1, x2, y2);
} else {
double x2, y2;
ci = sheet_col_get_info (sheet, col);
x2 = x1 + DIM (ci);
y2 = y1 - DIM (ri);
print_empty_cell (context, sheet, col, row, x1, y1, x2, y2);
}
x += ci->units + ci->margin_a_pt + ci->margin_b_pt;
}
......
......@@ -211,7 +211,7 @@ load_formats (void)
}
for (i = 0; i < format_count; i++){
char *str = g_strdup_printf ("Format-%d", i);
char *str = g_strdup_printf ("FormatHF-%d", i);
PrintHF *format;
format = load_hf (str, "", "", "");
......@@ -265,8 +265,8 @@ print_info_new (void)
load_margin ("margin_header", &pi->margins.header, HALF_CENTIMETER_IN_POINTS);
load_margin ("margin_footer", &pi->margins.footer, HALF_CENTIMETER_IN_POINTS);
pi->header = load_hf ("header", "", _("Sheet &[NUM]"), "");
pi->footer = load_hf ("footer", "", _("Page &[NUM]"), "");
pi->header = load_hf ("header", "", _("Sheet &[PAGE]"), "");
pi->footer = load_hf ("footer", "", _("Page &[PAGE]"), "");
s = gnome_config_get_string ("paper=none");
if (strcmp (s, "none") != 0)
......@@ -367,7 +367,7 @@ save_formats (void)
PrintHF *hf = l->data;
char *name;
name = g_strdup_printf ("Format-%d", i);
name = g_strdup_printf ("FormatHF-%d", i);
save_hf (name, hf->left_format, hf->middle_format, hf->right_format);
g_free (name);
}
......
......@@ -573,6 +573,7 @@ print_preview_print_done (PrintPreview *pp)
gtk_widget_show (GTK_WIDGET (pp->toplevel));
pp->current_page = -1;
gnome_print_context_close (pp->metafile);
pp->pages = gnome_print_meta_pages (GNOME_PRINT_META (pp->metafile));
goto_page (pp, 0);
......
......@@ -325,14 +325,22 @@ style_color_new (gushort red, gushort green, gushort blue)
StyleColor *sc;
StyleColor key;
key.color.red = red;
key.color.green = green;
key.color.blue = blue;
key.red = red;
key.green = green;
key.blue = blue;
sc = g_hash_table_lookup (style_color_hash, &key);
if (!sc){
sc = g_new (StyleColor, 1);
key.color.red = red;
key.color.green = green;
key.color.blue = blue;
sc->color = key.color;
sc->red = red;
sc->green = green;
sc->blue = blue;
sc->color.pixel = color_alloc (red, green, blue);
g_hash_table_insert (style_color_hash, sc, sc);
......@@ -577,9 +585,9 @@ color_equal (gconstpointer v, gconstpointer v2)
const StyleColor *k1 = (const StyleColor *) v;
const StyleColor *k2 = (const StyleColor *) v2;
if (k1->color.red == k2->color.red &&
k1->color.green == k2->color.green &&
k1->color.blue == k2->color.blue)
if (k1->red == k2->red &&
k1->green == k2->green &&
k1->blue == k2->blue)
return 1;
return 0;
......@@ -590,7 +598,7 @@ color_hash (gconstpointer v)
{
const StyleColor *k = (const StyleColor *)v;
return (k->color.red << 16) | (k->color.green << 8) | (k->color.blue);
return (k->red << 16) | (k->green << 8) | (k->blue);
}
void
......
......@@ -33,6 +33,9 @@ typedef struct {
int ref_count;
GdkColor color;
char *name;
gushort red;
gushort green;
gushort blue;
} StyleColor;
/**
......
......@@ -19,9 +19,24 @@ enum {
static gint color_combo_signals [LAST_SIGNAL] = { 0, };
static GtkObjectClass *color_combo_parent_class;
static void
color_combo_finalize (GtkObject *object)
{
ColorCombo *cc = COLOR_COMBO (object);
g_free (cc->items);
(*color_combo_parent_class->finalize) (object);
}
static void
color_combo_class_init (GtkObjectClass *object_class)
{
object_class->finalize = color_combo_finalize;
color_combo_parent_class = gtk_type_class (gtk_combo_box_get_type ());
color_combo_signals [CHANGED] =
gtk_signal_new (
"changed",
......@@ -209,7 +224,7 @@ color_combo_construct (ColorCombo *cc, char **icon, gboolean no_color,
"fill_color", color_names [0],
NULL);
gtk_container_add (GTK_CONTAINER (cc->preview_button), GTK_WIDGET (cc->preview_canvas));
gtk_widget_set_usize (cc->preview_canvas, 24, 24);
gtk_widget_set_usize (GTK_WIDGET (cc->preview_canvas), 24, 24);
gtk_signal_connect (GTK_OBJECT (cc->preview_button), "clicked",
GTK_SIGNAL_FUNC (emit_change), cc);
......
......@@ -39,6 +39,8 @@ typedef struct {
GtkType color_combo_get_type (void);
GtkWidget *color_combo_new (char **icon);
void color_combo_construct (ColorCombo *cc, char **icon, gboolean no_color,
int ncols, int nrows, char **color_names);
GtkWidget *color_combo_new_with_vals (char **icon,
int ncols, int nrows, gboolean no_color,
char **color_names);
......
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