Commit a1a6847e authored by Chyla Zbigniew's avatar Chyla Zbigniew

Support for reporting i/o progress via IOContext.


Support for reporting i/o progress via IOContext.

* src/command-context-priv.h (struct CommandContextClass): Added
progress_message_set virtual.

* src/command-context.[ch] (gnumeric_progress_message_set): New.

* src/io-context-priv.h
Made IOContext a GtkObject.
(enum GnumProgressHelperType, struct GnumProgressHelper): New.

* src/io-context.[ch]
Made IOContext a GtkObject.
(io_progress_update, io_progress_message,
file_io_progress_set, file_io_progress_update,
memory_io_progress_set, memory_io_progress_update,
count_io_progress_set, count_io_progress_update,
io_progress_unset): New functions.
(gnumeric_io_context_free): Removed, use gtk_object_destroy instead.

* src/workbook-control-gui.c (wbcg_progress_message_set): New,
implementation of CommandContext virtual.

* src/workbook-view.c
(wb_view_save_as, wb_view_save, wb_view_open_custom):
s/gnumeric_io_context_free/gtk_object_destroy

* src/xml-io.h
(struct _XmlParseContext): New members (io_context, element_counter) for
progress reporting.

* src/xml-io.c
(xml_read_styles): Update i/o progress every N_ELEMENTS_BETWEEN_UPDATES
styles.
(xml_sheet_read): Ditto for cells.
(xml_get_n_children, xml_read_sheet_n_elements,
xml_read_workbook_n_elements): Internal functions, calculating the
number of "elements" (styles and cells) in workbook.
(xml_workbook_read): Set up io progress to "Processing XML tree" stage.
(gnumeric_xml_read_workbook): Load the file into an XML tree using the
Push mode and update i/o progress regularly.

* src/plugin-util.c
#include <libgnome/libgnome.h> instead of <gnome.h>.
parent 79b8aa29
2001-06-01 Zbigniew Chyla <cyba@gnome.pl>
Support for reporting i/o progress via IOContext.
* src/command-context-priv.h (struct CommandContextClass): Added
progress_message_set virtual.
* src/command-context.[ch] (gnumeric_progress_message_set): New.
* src/io-context-priv.h
Made IOContext a GtkObject.
(enum GnumProgressHelperType, struct GnumProgressHelper): New.
* src/io-context.[ch]
Made IOContext a GtkObject.
(io_progress_update, io_progress_message,
file_io_progress_set, file_io_progress_update,
memory_io_progress_set, memory_io_progress_update,
count_io_progress_set, count_io_progress_update,
io_progress_unset): New functions.
(gnumeric_io_context_free): Removed, use gtk_object_destroy instead.
* src/workbook-control-gui.c (wbcg_progress_message_set): New,
implementation of CommandContext virtual.
* src/workbook-view.c
(wb_view_save_as, wb_view_save, wb_view_open_custom):
s/gnumeric_io_context_free/gtk_object_destroy
* src/xml-io.h
(struct _XmlParseContext): New members (io_context, element_counter) for
progress reporting.
* src/xml-io.c
(xml_read_styles): Update i/o progress every N_ELEMENTS_BETWEEN_UPDATES
styles.
(xml_sheet_read): Ditto for cells.
(xml_get_n_children, xml_read_sheet_n_elements,
xml_read_workbook_n_elements): Internal functions, calculating the
number of "elements" (styles and cells) in workbook.
(xml_workbook_read): Set up io progress to "Processing XML tree" stage.
(gnumeric_xml_read_workbook): Load the file into an XML tree using the
Push mode and update i/o progress regularly.
* src/plugin-util.c
#include <libgnome/libgnome.h> instead of <gnome.h>.
2001-05-31 Jody Goldberg <jgoldberg@home.com>
* src/solver-lp.c : Use cell_eval in place of cell_eval_content.
......
2001-06-01 Zbigniew Chyla <cyba@gnome.pl>
Support for reporting i/o progress via IOContext.
* src/command-context-priv.h (struct CommandContextClass): Added
progress_message_set virtual.
* src/command-context.[ch] (gnumeric_progress_message_set): New.
* src/io-context-priv.h
Made IOContext a GtkObject.
(enum GnumProgressHelperType, struct GnumProgressHelper): New.
* src/io-context.[ch]
Made IOContext a GtkObject.
(io_progress_update, io_progress_message,
file_io_progress_set, file_io_progress_update,
memory_io_progress_set, memory_io_progress_update,
count_io_progress_set, count_io_progress_update,
io_progress_unset): New functions.
(gnumeric_io_context_free): Removed, use gtk_object_destroy instead.
* src/workbook-control-gui.c (wbcg_progress_message_set): New,
implementation of CommandContext virtual.
* src/workbook-view.c
(wb_view_save_as, wb_view_save, wb_view_open_custom):
s/gnumeric_io_context_free/gtk_object_destroy
* src/xml-io.h
(struct _XmlParseContext): New members (io_context, element_counter) for
progress reporting.
* src/xml-io.c
(xml_read_styles): Update i/o progress every N_ELEMENTS_BETWEEN_UPDATES
styles.
(xml_sheet_read): Ditto for cells.
(xml_get_n_children, xml_read_sheet_n_elements,
xml_read_workbook_n_elements): Internal functions, calculating the
number of "elements" (styles and cells) in workbook.
(xml_workbook_read): Set up io progress to "Processing XML tree" stage.
(gnumeric_xml_read_workbook): Load the file into an XML tree using the
Push mode and update i/o progress regularly.
* src/plugin-util.c
#include <libgnome/libgnome.h> instead of <gnome.h>.
2001-05-31 Jody Goldberg <jgoldberg@home.com>
* src/solver-lp.c : Use cell_eval in place of cell_eval_content.
......
2001-06-01 Zbigniew Chyla <cyba@gnome.pl>
Support for reporting i/o progress via IOContext.
* src/command-context-priv.h (struct CommandContextClass): Added
progress_message_set virtual.
* src/command-context.[ch] (gnumeric_progress_message_set): New.
* src/io-context-priv.h
Made IOContext a GtkObject.
(enum GnumProgressHelperType, struct GnumProgressHelper): New.
* src/io-context.[ch]
Made IOContext a GtkObject.
(io_progress_update, io_progress_message,
file_io_progress_set, file_io_progress_update,
memory_io_progress_set, memory_io_progress_update,
count_io_progress_set, count_io_progress_update,
io_progress_unset): New functions.
(gnumeric_io_context_free): Removed, use gtk_object_destroy instead.
* src/workbook-control-gui.c (wbcg_progress_message_set): New,
implementation of CommandContext virtual.
* src/workbook-view.c
(wb_view_save_as, wb_view_save, wb_view_open_custom):
s/gnumeric_io_context_free/gtk_object_destroy
* src/xml-io.h
(struct _XmlParseContext): New members (io_context, element_counter) for
progress reporting.
* src/xml-io.c
(xml_read_styles): Update i/o progress every N_ELEMENTS_BETWEEN_UPDATES
styles.
(xml_sheet_read): Ditto for cells.
(xml_get_n_children, xml_read_sheet_n_elements,
xml_read_workbook_n_elements): Internal functions, calculating the
number of "elements" (styles and cells) in workbook.
(xml_workbook_read): Set up io progress to "Processing XML tree" stage.
(gnumeric_xml_read_workbook): Load the file into an XML tree using the
Push mode and update i/o progress regularly.
* src/plugin-util.c
#include <libgnome/libgnome.h> instead of <gnome.h>.
2001-05-31 Jody Goldberg <jgoldberg@home.com>
* src/solver-lp.c : Use cell_eval in place of cell_eval_content.
......
2001-06-01 Zbigniew Chyla <cyba@gnome.pl>
Support for reporting i/o progress via IOContext.
* src/command-context-priv.h (struct CommandContextClass): Added
progress_message_set virtual.
* src/command-context.[ch] (gnumeric_progress_message_set): New.
* src/io-context-priv.h
Made IOContext a GtkObject.
(enum GnumProgressHelperType, struct GnumProgressHelper): New.
* src/io-context.[ch]
Made IOContext a GtkObject.
(io_progress_update, io_progress_message,
file_io_progress_set, file_io_progress_update,
memory_io_progress_set, memory_io_progress_update,
count_io_progress_set, count_io_progress_update,
io_progress_unset): New functions.
(gnumeric_io_context_free): Removed, use gtk_object_destroy instead.
* src/workbook-control-gui.c (wbcg_progress_message_set): New,
implementation of CommandContext virtual.
* src/workbook-view.c
(wb_view_save_as, wb_view_save, wb_view_open_custom):
s/gnumeric_io_context_free/gtk_object_destroy
* src/xml-io.h
(struct _XmlParseContext): New members (io_context, element_counter) for
progress reporting.
* src/xml-io.c
(xml_read_styles): Update i/o progress every N_ELEMENTS_BETWEEN_UPDATES
styles.
(xml_sheet_read): Ditto for cells.
(xml_get_n_children, xml_read_sheet_n_elements,
xml_read_workbook_n_elements): Internal functions, calculating the
number of "elements" (styles and cells) in workbook.
(xml_workbook_read): Set up io progress to "Processing XML tree" stage.
(gnumeric_xml_read_workbook): Load the file into an XML tree using the
Push mode and update i/o progress regularly.
* src/plugin-util.c
#include <libgnome/libgnome.h> instead of <gnome.h>.
2001-05-31 Jody Goldberg <jgoldberg@home.com>
* src/solver-lp.c : Use cell_eval in place of cell_eval_content.
......
2001-06-01 Zbigniew Chyla <cyba@gnome.pl>
Support for reporting i/o progress via IOContext.
* src/command-context-priv.h (struct CommandContextClass): Added
progress_message_set virtual.
* src/command-context.[ch] (gnumeric_progress_message_set): New.
* src/io-context-priv.h
Made IOContext a GtkObject.
(enum GnumProgressHelperType, struct GnumProgressHelper): New.
* src/io-context.[ch]
Made IOContext a GtkObject.
(io_progress_update, io_progress_message,
file_io_progress_set, file_io_progress_update,
memory_io_progress_set, memory_io_progress_update,
count_io_progress_set, count_io_progress_update,
io_progress_unset): New functions.
(gnumeric_io_context_free): Removed, use gtk_object_destroy instead.
* src/workbook-control-gui.c (wbcg_progress_message_set): New,
implementation of CommandContext virtual.
* src/workbook-view.c
(wb_view_save_as, wb_view_save, wb_view_open_custom):
s/gnumeric_io_context_free/gtk_object_destroy
* src/xml-io.h
(struct _XmlParseContext): New members (io_context, element_counter) for
progress reporting.
* src/xml-io.c
(xml_read_styles): Update i/o progress every N_ELEMENTS_BETWEEN_UPDATES
styles.
(xml_sheet_read): Ditto for cells.
(xml_get_n_children, xml_read_sheet_n_elements,
xml_read_workbook_n_elements): Internal functions, calculating the
number of "elements" (styles and cells) in workbook.
(xml_workbook_read): Set up io progress to "Processing XML tree" stage.
(gnumeric_xml_read_workbook): Load the file into an XML tree using the
Push mode and update i/o progress regularly.
* src/plugin-util.c
#include <libgnome/libgnome.h> instead of <gnome.h>.
2001-05-31 Jody Goldberg <jgoldberg@home.com>
* src/solver-lp.c : Use cell_eval in place of cell_eval_content.
......
......@@ -12,7 +12,8 @@ struct _CommandContext {
typedef struct {
GtkObjectClass gtk_object_class;
void (*progress_set) (CommandContext *context, gfloat val);
void (*progress_set) (CommandContext *context, gfloat val);
void (*progress_message_set) (CommandContext *context, gchar const *msg);
struct {
void (*system) (CommandContext *ctxt, char const *msg);
void (*plugin) (CommandContext *ctxt, char const *msg);
......
......@@ -102,6 +102,14 @@ gnumeric_progress_set (CommandContext *context, gfloat f)
CC_CLASS (context)->progress_set (context, f);
}
void
gnumeric_progress_message_set (CommandContext *context, gchar const *msg)
{
g_return_if_fail (IS_COMMAND_CONTEXT (context));
CC_CLASS (context)->progress_message_set (context, msg);
}
/**
* command_context_push_template
* @template: printf template to display message
......
......@@ -23,7 +23,8 @@ void gnumeric_error_invalid (CommandContext *context,
char const *msg, char const *val);
void gnumeric_error_splits_array (CommandContext *context,
char const *cmd, Range const *array);
void gnumeric_progress_set (CommandContext *context, gfloat f);
void gnumeric_progress_set (CommandContext *context, gfloat f);
void gnumeric_progress_message_set (CommandContext *context, gchar const *msg);
/* Push a printf template to the list. The template is used to provide
* context for error messages. E.g.: "Could not read file: %s". */
......
#ifndef GNUMERIC_IO_CONTEXT_PRIV_H
#define GNUMERIC_IO_CONTEXT_PRIV_H
#include <gtk/gtkobject.h>
#include "io-context.h"
#include "workbook-control.h"
#include "error-info.h"
/* FIXME : This is a placeholder implementation */
#define IO_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_IO_CONTEXT, IOContext))
#define IS_IO_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_IO_CONTEXT))
typedef enum {
GNUM_PROGRESS_HELPER_NONE,
GNUM_PROGRESS_HELPER_FILE,
GNUM_PROGRESS_HELPER_MEM,
GNUM_PROGRESS_HELPER_COUNT,
GNUM_PROGRESS_HELPER_LAST
} GnumProgressHelperType;
typedef struct {
GnumProgressHelperType helper_type;
gdouble min_f, max_f;
union {
struct {
FILE *f;
glong size;
} file;
struct {
gchar *start;
gint size;
} mem;
struct {
gint total;
} count;
} v;
} GnumProgressHelper;
struct _IOContext {
GtkObject parent;
WorkbookControl *impl;
ErrorInfo *error_info;
gboolean error_occurred;
gdouble last_progress;
gdouble last_time;
GnumProgressHelper helper;
};
struct _IOContextClass {
GtkObjectClass parent_class;
};
#endif /* GNUMERIC_IO_CONTEXT_PRIV_H */
......@@ -3,38 +3,74 @@
* It is intended to become a place to handle errors
* as well as storing non-fatal warnings.
*
* Author:
* Authors:
* Jody Goldberg <jgoldberg@home.com>
* Zbigniew Chyla <cyba@gnome.pl>
*
* (C) 2000 Jody Goldberg
*/
#include <config.h>
#include "io-context-priv.h"
#include <limits.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <unistd.h>
#include "gnumeric.h"
#include "command-context.h"
#include "gnumeric-util.h"
#include "io-context.h"
#include "io-context-priv.h"
IOContext *
gnumeric_io_context_new (WorkbookControl *wbc)
#define PROGRESS_UPDATE_STEP 0.01
#define PROGRESS_UPDATE_PERIOD_SEC 0.20
static void
io_context_init (IOContext *io_context)
{
io_context->impl = NULL;
io_context->error_info = NULL;
io_context->error_occurred = FALSE;
io_context->last_progress = 0.0;
io_context->last_time = 0.0;
io_context->helper.helper_type = GNUM_PROGRESS_HELPER_NONE;
}
static void
io_context_destroy (GtkObject *obj)
{
IOContext *context;
IOContext *io_context;
g_return_val_if_fail (wbc != NULL, NULL);
g_return_if_fail (IS_IO_CONTEXT (obj));
context = g_new (IOContext, 1);
context->impl = wbc;
context->error_info = NULL;
context->error_occurred = FALSE;
io_context = IO_CONTEXT (obj);
error_info_free (io_context->error_info);
gnumeric_progress_set (COMMAND_CONTEXT (io_context->impl), 0.0);
gnumeric_progress_message_set (COMMAND_CONTEXT (io_context->impl), NULL);
return context;
GTK_OBJECT_CLASS (gtk_type_class (GTK_TYPE_OBJECT))->destroy (obj);
}
void
gnumeric_io_context_free (IOContext *context)
static void
io_context_class_init (IOContextClass *klass)
{
g_return_if_fail (context != NULL);
GTK_OBJECT_CLASS (klass)->destroy = io_context_destroy;
}
error_info_free (context->error_info);
g_free (context);
E_MAKE_TYPE (io_context, "GnumIOContext", IOContext, \
io_context_class_init, io_context_init, \
GTK_TYPE_OBJECT)
IOContext *
gnumeric_io_context_new (WorkbookControl *wbc)
{
IOContext *io_context;
g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), NULL);
io_context = IO_CONTEXT (gtk_type_new (TYPE_IO_CONTEXT));
io_context->impl = wbc;
return io_context;
}
void
......@@ -156,10 +192,132 @@ gnumeric_io_error_occurred (IOContext *context)
}
void
gnumeric_io_progress_set (IOContext *context, gfloat f)
io_progress_update (IOContext *io_context, gdouble f)
{
g_return_if_fail (context != NULL);
g_return_if_fail (context->impl != NULL);
g_return_if_fail (IS_IO_CONTEXT (io_context));
if (f - io_context->last_progress >= PROGRESS_UPDATE_STEP) {
struct timeval tv;
double t;
(void) gettimeofday (&tv, NULL);
t = tv.tv_sec + tv.tv_usec / 1000000.0;
if (t - io_context->last_time >= PROGRESS_UPDATE_PERIOD_SEC) {
gnumeric_progress_set (COMMAND_CONTEXT (io_context->impl), f);
io_context->last_time = t;
io_context->last_progress = f;
}
}
while (gtk_main_iteration_do (FALSE));
}
void
io_progress_message (IOContext *io_context, const gchar *msg)
{
g_return_if_fail (IS_IO_CONTEXT (io_context));
gnumeric_progress_message_set (COMMAND_CONTEXT (io_context->impl), msg);
}
void
file_io_progress_set (IOContext *io_context, const gchar *file_name,
FILE *f, gdouble min_f, gdouble max_f)
{
struct stat sbuf;
g_return_if_fail (IS_IO_CONTEXT (io_context));
g_return_if_fail (file_name != NULL && f != NULL);
g_return_if_fail (min_f <= max_f);
io_context->helper.helper_type = GNUM_PROGRESS_HELPER_FILE;
io_context->helper.v.file.f = f;
if (stat (file_name, &sbuf) == 0) {
io_context->helper.v.file.size = MAX ((glong) sbuf.st_size, 1);
} else {
io_context->helper.v.file.size = LONG_MAX;
}
io_context->helper.min_f = min_f;
io_context->helper.max_f = max_f;
}
void
file_io_progress_update (IOContext *io_context)
{
glong pos;
gdouble complete;
g_return_if_fail (IS_IO_CONTEXT (io_context));
g_return_if_fail (io_context->helper.helper_type = GNUM_PROGRESS_HELPER_FILE);
pos = ftell (io_context->helper.v.file.f);
if (pos == -1) {
pos = io_context->helper.v.file.size;
}
complete = (io_context->helper.max_f - io_context->helper.min_f)
* pos / io_context->helper.v.file.size;
io_progress_update (io_context, io_context->helper.min_f + complete);
}
void
memory_io_progress_set (IOContext *io_context, gpointer mem_start,
gint mem_size, gdouble min_f, gdouble max_f)
{
g_return_if_fail (IS_IO_CONTEXT (io_context));
g_return_if_fail (mem_start != NULL && mem_size >=0);
g_return_if_fail (min_f <= max_f);
io_context->helper.helper_type = GNUM_PROGRESS_HELPER_MEM;
io_context->helper.v.mem.start = mem_start;
io_context->helper.v.mem.size = MAX (mem_size, 1);
io_context->helper.min_f = min_f;
io_context->helper.max_f = max_f;
}
void
memory_io_progress_update (IOContext *io_context, void *mem_current)
{
gchar *cur = mem_current;
gdouble complete;
g_return_if_fail (IS_IO_CONTEXT (io_context));
g_return_if_fail (io_context->helper.helper_type = GNUM_PROGRESS_HELPER_MEM);
complete = (io_context->helper.max_f - io_context->helper.min_f)
* (cur - io_context->helper.v.mem.start) / io_context->helper.v.mem.size;
io_progress_update (io_context, io_context->helper.min_f + complete);
}
void
count_io_progress_set (IOContext *io_context, gint total,
gdouble min_f, gdouble max_f)
{
g_return_if_fail (IS_IO_CONTEXT (io_context));
g_return_if_fail (total >=0);
g_return_if_fail (min_f <= max_f);
io_context->helper.helper_type = GNUM_PROGRESS_HELPER_COUNT;
io_context->helper.v.count.total = MAX (total, 1);
io_context->helper.min_f = min_f;
io_context->helper.max_f = max_f;
}
void
count_io_progress_update (IOContext *io_context, gint count)
{
gdouble complete;
g_return_if_fail (IS_IO_CONTEXT (io_context));
g_return_if_fail (io_context->helper.helper_type = GNUM_PROGRESS_HELPER_COUNT);
complete = (io_context->helper.max_f - io_context->helper.min_f)
* count / io_context->helper.v.count.total;
io_progress_update (io_context, io_context->helper.min_f + complete);
}
void
io_progress_unset (IOContext *io_context)
{
g_return_if_fail (IS_IO_CONTEXT (io_context));
gnumeric_progress_set (COMMAND_CONTEXT (context->impl), f);
io_context->helper.helper_type = GNUM_PROGRESS_HELPER_NONE;
}
#ifndef GNUMERIC_IO_CONTEXT_H
#define GNUMERIC_IO_CONTEXT_H
#include <stdio.h>
#include <gtk/gtkobject.h>
#include <gal/util/e-util.h>
#include "gnumeric.h"
#include "error-info.h"
#define IO_CONTEXT_TYPE (io_context_get_type ())
#define IO_CONTEXT(o) (GTK_CHECK_CAST ((o), IO_CONTEXT_TYPE, IOContext))
#define IS_IO_CONTEXT(o) (GTK_CHECK_TYPE ((o), IO_CONTEXT_TYPE))
/* typedef struct _IOContext IOContext; */
typedef struct _IOContextClass IOContextClass;
#define TYPE_IO_CONTEXT (io_context_get_type ())
#define IO_CONTEXT(obj) (GTK_CHECK_CAST ((obj), TYPE_IO_CONTEXT, IOContext))
#define IS_IO_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), TYPE_IO_CONTEXT))
GtkType io_context_get_type (void);
......@@ -17,7 +22,6 @@ GtkType io_context_get_type (void);
* inheritance (single or multiple).
*/
IOContext *gnumeric_io_context_new (WorkbookControl *wbc);
void gnumeric_io_context_free (IOContext *context);
void gnumeric_io_error_system (IOContext *context, char const *msg);
void gnumeric_io_error_read (IOContext *context, char const *msg);
......@@ -34,10 +38,25 @@ gboolean gnumeric_io_has_error_info (IOContext *context);
void gnumeric_io_clear_error (IOContext *context);
gboolean gnumeric_io_error_occurred (IOContext *context);
void io_progress_message (IOContext *io_context, const gchar *msg);
void io_progress_update (IOContext *io_context, gdouble f);
void file_io_progress_set (IOContext *io_context, const gchar *file_name,
FILE *f, gdouble min_f, gdouble max_f);
void file_io_progress_update (IOContext *io_context);
void memory_io_progress_set (IOContext *io_context, void *mem_start,
gint mem_size, gdouble min_f, gdouble max_f);
void memory_io_progress_update (IOContext *io_context, void *mem_current);
void count_io_progress_set (IOContext *io_context, gint total,
gdouble min_f, gdouble max_f);
void count_io_progress_update (IOContext *io_context, gint count);
void io_progress_unset (IOContext *io_context);
void gnumeric_warning_unknown_font (IOContext *context, char const *msg);
void gnumeric_warning_unknown_feature (IOContext *context, char const *msg);
void gnumeric_warning_unknown_function (IOContext *context, char const *msg);
void gnumeric_io_progress_set (IOContext *context, gfloat f);
#endif /* GNUMERIC_IO_CONTEXT_H */
......@@ -15,7 +15,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <gnome.h>
#include <string.h>
#include <libgnome/libgnome.h>
#include "plugin-util.h"
#include "command-context.h"
......
......@@ -1010,7 +1010,8 @@ wbcg_claim_selection (WorkbookControl *wbc)
static void
wbcg_progress_set (CommandContext *cc, gfloat val)
{
WorkbookControlGUI *wbcg = (WorkbookControlGUI *)cc;
WorkbookControlGUI *wbcg = WORKBOOK_CONTROL_GUI (cc);
#ifdef ENABLE_BONOBO
gtk_progress_bar_update (GTK_PROGRESS_BAR (wbcg->progress_bar), val);
#else
......@@ -1018,6 +1019,25 @@ wbcg_progress_set (CommandContext *cc, gfloat val)
#endif
}
static void
wbcg_progress_message_set (CommandContext *cc, gchar const *msg)
{
WorkbookControlGUI *wbcg = WORKBOOK_CONTROL_GUI (cc);
GtkProgress *progress;
#ifdef ENABLE_BONOBO
progress = GTK_PROGRESS (wbcg->progress_bar);
#else
progress = gnome_appbar_get_progress (wbcg->appbar);
#endif
if (msg != NULL) {
gtk_progress_set_format_string (progress, msg);
gtk_progress_set_show_text (progress, TRUE);
} else {
gtk_progress_set_show_text (progress, FALSE);
}
}
static void
wbcg_error_system (CommandContext *cc, char const *msg)
{
......@@ -3374,9 +3394,17 @@ show_gui (WorkbookControlGUI *wbcg)
gtk_window_set_geometry_hints (wbcg->toplevel, NULL,
&geometry, GDK_HINT_MAX_SIZE);
} else {
sx = (sx * 3) / 4;
sy = (sy * 3) / 4;
gtk_window_set_default_size (wbcg->toplevel, sx, sy);
gdouble fx, fy;
fx = gnome_config_get_float_with_default (
"Gnumeric/Placement/WindowRelativeSizeX=0.75", NULL);
fy = gnome_config_get_float_with_default (
"Gnumeric/Placement/WindowRelativeSizeY=0.75", NULL);
fx = MIN (fx, 1.0);
fx = MAX (0.25, fx);
fy = MIN (fy, 1.0);
fy = MAX (0.2, fy);
gtk_window_set_default_size (wbcg->toplevel, sx * fx, sy * fy);
}
gtk_widget_show_all (GTK_WIDGET (wbcg->toplevel));
......@@ -3572,7 +3600,8 @@ workbook_control_gui_ctor_class (GtkObjectClass *object_class)
object_class->destroy = wbcg_destroy;
wbc_class->context_class.progress_set = wbcg_progress_set;
wbc_class->context_class.progress_set = wbcg_progress_set;
wbc_class->context_class.progress_message_set = wbcg_progress_message_set;
wbc_class->context_class.error.system = wbcg_error_system;
wbc_class->context_class.error.plugin = wbcg_error_plugin;
wbc_class->context_class.error.read = wbcg_error_read;
......
......@@ -611,7 +611,7 @@ wb_view_save_as (WorkbookView *wbv, WorkbookControl *wbc,
} else {
success = FALSE;
}
gnumeric_io_context_free (io_context);
gtk_object_destroy (GTK_OBJECT (io_context));
return success;
}
......@@ -658,7 +658,7 @@ wb_view_save (WorkbookView *wbv, WorkbookControl *wbc)
} else {
success = FALSE;
}
gnumeric_io_context_free (io_context);
gtk_object_destroy (GTK_OBJECT (io_context));
return success;
}
......@@ -750,7 +750,7 @@ wb_view_open_custom (WorkbookView *wbv, WorkbookControl *wbc,
if (gnumeric_io_has_error_info (io_context))
gnumeric_io_error_info_display (io_context);
gnumeric_io_context_free (io_context);
gtk_object_destroy (GTK_OBJECT (io_context));
} else {
new_wb = workbook_new_with_sheets (1);
new_wbv = workbook_view_new (new_wb);
......
......@@ -37,7 +37,12 @@
#include "ranges.h"
#include "file.h"
#include "str.h"
#include "plugin-util.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <zlib.h>
#include <gal/util/e-xml-utils.h>
#include <gnome.h>
#include <locale.h>
......@@ -47,6 +52,10 @@
/* Precision to use when saving point measures. */