Commit f7e5cba3 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

ditto. delete. We can handle this via libgsf now.


2003-06-26  Jody Goldberg <jody@gnome.org>

	* src/gui-file.c (ask_for_file_saver) : ditto.
	* src/file.c (gnm_file_saver_save_to_stream_real) : delete.  We can
	  handle this via libgsf now.

	* src/workbook-control-gui-priv.h : some cleanup.
parent d9eaf400
2003-06-26 Jody Goldberg <jody@gnome.org>
* src/gui-file.c (ask_for_file_saver) : ditto.
* src/file.c (gnm_file_saver_save_to_stream_real) : delete. We can
handle this via libgsf now.
* src/workbook-control-gui-priv.h : some cleanup.
2003-06-27 Jon K Hellan <hellan@acm.org>
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
......
......@@ -21,7 +21,7 @@ Jean Brefort:
* Support image files in chart areas (background, bar/col or pie)
Jody:
* Fix the generated files.
* Fix the generated source files.
* Cleanout the internals of PreviewGrid.
* Cleanup AutoFormat dialog.
* Printing support for charting engine.
......
2003-06-26 Jody Goldberg <jody@gnome.org>
* src/gui-file.c (ask_for_file_saver) : ditto.
* src/file.c (gnm_file_saver_save_to_stream_real) : delete. We can
handle this via libgsf now.
* src/workbook-control-gui-priv.h : some cleanup.
2003-06-27 Jon K Hellan <hellan@acm.org>
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
......
2003-06-26 Jody Goldberg <jody@gnome.org>
* src/gui-file.c (ask_for_file_saver) : ditto.
* src/file.c (gnm_file_saver_save_to_stream_real) : delete. We can
handle this via libgsf now.
* src/workbook-control-gui-priv.h : some cleanup.
2003-06-27 Jon K Hellan <hellan@acm.org>
* src/workbook-control-gui-priv.h (struct _WorkbookControlGUI):
......
......@@ -32,7 +32,7 @@ struct _GogAxis {
GogAxisType type;
GogAxisPosition pos;
GSList *i_cross, *crosses_me, *series;
GSList *i_cross, *crosses_me, *plots;
GOData *min_source, *max_source;
};
......@@ -45,7 +45,19 @@ static GObjectClass *parent_klass;
static void
gog_axis_finalize (GObject *obj)
{
/* GogAxis *axis = GOG_AXIS (obj); */
GogAxis *axis = GOG_AXIS (obj);
g_slist_free (axis->i_cross); axis->i_cross = NULL;
g_slist_free (axis->crosses_me); axis->crosses_me = NULL;
g_slist_free (axis->plots); axis->plots = NULL;
if (axis->min_source != NULL) {
g_object_unref (axis->min_source);
axis->min_source = NULL;
}
if (axis->max_source != NULL) {
g_object_unref (axis->max_source);
axis->max_source = NULL;
}
if (parent_klass != NULL && parent_klass->finalize != NULL)
(parent_klass->finalize) (obj);
......
......@@ -296,92 +296,6 @@ gnm_file_saver_save_real (GnmFileSaver const *fs, IOContext *io_context,
fs->save_func (fs, io_context, wbv, output);
}
#if defined(GNOME2_CONVERSION_COMPLETE) && defined(WITH_BONOBO)
#include <bonobo.h>
#include <bonobo/bonobo-stream.h>
#include <sys/stat.h>
#include <unistd.h>
#define FILE_COPY_CHUNK_SIZE 0x10000
static void
gnm_file_saver_save_to_stream_real (GnmFileSaver const *fs,
IOContext *io_context,
WorkbookView *wbv,
BonoboStream *stream,
CORBA_Environment *ev)
{
gchar *tmp_name;
gint old_umask;
gint fd;
tmp_name = g_build_filename (g_get_tmp_dir (), "gnumeric-file-XXXXXX", NULL);
old_umask = umask (0077);
fd = mkstemp (tmp_name);
if (fd == -1) {
gnumeric_io_error_info_set (io_context, error_info_new_str_with_details (
_("Cannot create temporary file."),
error_info_new_from_errno ()));
} else {
struct stat sbuf;
io_progress_range_push (io_context, 0.0, 0.5);
gnm_file_saver_save (fs, io_context, wbv, tmp_name);
io_progress_range_pop (io_context);
(void) unlink (tmp_name);
if (gnumeric_io_error_occurred (io_context)) {
gnumeric_io_error_push (io_context, error_info_new_str (
_("Error saving to temporary file.")));
} else if (fstat (fd, &sbuf) == -1) {
gnumeric_io_error_info_set (io_context, error_info_new_str_with_details (
_("Cannot get temporary file size."),
error_info_new_from_errno ()));
} else {
Bonobo_Stream_iobuf *iobuf;
gint offset;
io_progress_message (io_context, _("Saving file to stream."));
io_progress_range_push (io_context, 0.5, 1.0);
iobuf = Bonobo_Stream_iobuf__alloc ();
value_io_progress_set (io_context, sbuf.st_size, FILE_COPY_CHUNK_SIZE);
offset = 0;
while (1) {
guchar buf[FILE_COPY_CHUNK_SIZE];
gint read_bytes;
value_io_progress_update (io_context, offset);
read_bytes = read (fd, buf, FILE_COPY_CHUNK_SIZE);
if (read_bytes == -1 && errno != EINTR) {
gnumeric_io_error_info_set (io_context, error_info_new_str_with_details (
_("Error reading temporary file."),
error_info_new_from_errno ()));
break;
} else if (read_bytes == -1) {
continue;
} else if (read_bytes == 0) {
break;
}
iobuf->_buffer = buf;
iobuf->_length = read_bytes;
Bonobo_Stream_write (BONOBO_OBJREF (stream), iobuf, ev);
if (BONOBO_EX (ev)) {
gnumeric_io_error_string (
io_context, _("Exception occurred while saving to stream."));
break;
}
offset += read_bytes;
}
io_progress_unset (io_context);
CORBA_free (iobuf);
io_progress_range_pop (io_context);
}
(void) close (fd);
}
g_free (tmp_name);
(void) umask (old_umask);
}
#endif
static void
gnm_file_saver_class_init (GnmFileSaverClass *klass)
{
......
......@@ -290,9 +290,8 @@ x_clipboard_received (GtkClipboard *clipboard, GtkSelectionData *sel,
gpointer closure)
{
GnmGtkClipboardCtxt *ctxt = closure;
WorkbookControlGUI *wbcg = ctxt->wbcg;
GdkAtom table_atom = GDK_NONE, string_atom = GDK_NONE;
GdkAtom preferred = GDK_NONE, fallback = GDK_NONE;
GdkAtom preferred = GDK_NONE;
GdkAtom const *targets = (GdkAtom *) sel->data;
unsigned const atom_count = (sel->length / sizeof (GdkAtom));
unsigned i, j;
......@@ -355,11 +354,10 @@ x_clipboard_received (GtkClipboard *clipboard, GtkSelectionData *sel,
ctxt->fallback = GDK_NONE;
}
if (preferred != GDK_NONE) {
gtk_clipboard_request_contents
(clipboard, preferred,
if (preferred != GDK_NONE)
gtk_clipboard_request_contents (clipboard, preferred,
complex_content_received, ctxt);
} else {
else {
/* Nothing we can use - time to give up */
g_free (ctxt->paste_target);
g_free (ctxt);
......@@ -416,8 +414,8 @@ table_cellregion_write (WorkbookControl *wbc, CellRegion *cr,
gsf_output_close (output);
g_object_unref (wb_view);
g_object_unref (wb);
g_object_unref (G_OBJECT (ioc));
g_object_unref (G_OBJECT (output));
g_object_unref (ioc);
g_object_unref (output);
return ret;
}
......
......@@ -422,94 +422,3 @@ gui_file_save (WorkbookControlGUI *wbcg, WorkbookView *wb_view)
else
return wb_view_save (wb_view, COMMAND_CONTEXT (wbcg));
}
#ifdef WITH_BONOBO
#ifdef GNOME2_CONVERSION_COMPLETE
static GnmFileSaver *
ask_for_file_saver (WorkbookControlGUI *wbcg, WorkbookView *wb_view)
{
GtkWidget *dialog;
GtkWidget *format_chooser;
GtkOptionMenu *omenu;
GList *savers;
GnmFileSaver *fs;
dialog = gtk_message_dialog_new (wbcg_toplevel (wbcg),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_OK_CANCEL,
_("Which file format would you like?"));
/* Add the format chooser */
savers = g_list_copy (get_file_savers ());
savers = g_list_sort (savers, file_saver_description_cmp);
omenu = GTK_OPTION_MENU (gtk_option_menu_new ());
format_chooser = make_format_chooser (savers, omenu);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
format_chooser, FALSE, FALSE, 0);
/* Set default file saver */
fs = wbcg->current_saver;
if (fs == NULL) {
fs = (GnmFileSaver *) workbook_get_file_saver (
wb_view_workbook (wb_view));
}
if (fs == NULL || g_list_find (savers, fs) == NULL) {
fs = gnm_file_saver_get_default ();
}
gtk_option_menu_set_history (omenu, g_list_index (savers, fs));
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
switch (gnumeric_dialog_run (wbcg, GTK_DIALOG (dialog))) {
case GTK_RESPONSE_OK: /* Ok */
fs = g_list_nth_data (savers,
gtk_option_menu_get_history (omenu));
break;
default: /* Cancel */
fs = NULL;
break;
}
g_list_free (savers);
return (fs);
}
void
gui_file_save_to_stream (BonoboStream *stream, WorkbookControlGUI *wbcg,
WorkbookView *wb_view, gchar const *mime_type,
CORBA_Environment *ev)
{
GnmFileSaver *fs = NULL;
IOContext *io_context;
/* If no mime type is given, we need to ask. */
if (!mime_type) {
fs = ask_for_file_saver (wbcg, wb_view);
if (!fs) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_IOError, NULL);
return;
}
} else {
fs = gnm_file_saver_for_mime_type (mime_type);
if (!fs) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Stream_NotSupported,
NULL);
return;
}
}
if (!check_multiple_sheet_support_if_needed (fs, wbcg, wb_view)) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_IOError, NULL);
return;
}
io_context = gnumeric_io_context_new (COMMAND_CONTEXT (wbcg));
gnm_file_saver_save_to_stream (fs, io_context, wb_view, stream, ev);
gtk_object_destroy (GTK_OBJECT (io_context));
}
#endif
#endif
......@@ -20,53 +20,6 @@ struct _WorkbookControlGUI {
GtkNotebook *notebook;
unsigned file_history_size;
#ifdef WITH_BONOBO
GHashTable *custom_ui_components;
BonoboUIComponent *uic;
GtkWidget *progress_bar;
#else
/* The status bar */
GnomeAppBar *appbar;
/* Menu items that get enabled/disabled */
GtkWidget *menu_item_undo;
GtkWidget *menu_item_redo;
GtkWidget *menu_item_paste_special;
GtkWidget *menu_item_insert_rows;
GtkWidget *menu_item_insert_cols;
GtkWidget *menu_item_insert_cells;
GtkWidget *menu_item_show_detail;
GtkWidget *menu_item_hide_detail;
GtkWidget *menu_item_sheet_remove;
GtkWidget *menu_item_sheets_edit_reorder;
GtkWidget *menu_item_sheets_format_reorder;
GtkWidget *menu_item_page_setup;
GtkWidget *menu_item_search_replace;
GtkWidget *menu_item_define_name;
GtkWidget *menu_item_consolidate;
GtkWidget *menu_item_freeze_panes;
GtkWidget *menu_item_auto_filter;
/* Menu items that get toggled */
GtkWidget *menu_item_sheet_display_formulas;
GtkWidget *menu_item_sheet_hide_zero;
GtkWidget *menu_item_sheet_hide_grid;
GtkWidget *menu_item_sheet_hide_col_header;
GtkWidget *menu_item_sheet_hide_row_header;
GtkWidget *menu_item_sheet_display_outlines;
GtkWidget *menu_item_sheet_outline_symbols_below;
GtkWidget *menu_item_sheet_outline_symbols_right;
GtkWidget *menu_item_filter_show_all;
/* Toolbars */
GtkWidget *standard_toolbar;
GtkWidget *format_toolbar;
GtkWidget *object_toolbar;
#endif
/* Combos */
GtkWidget *font_name_selector;
......@@ -95,9 +48,9 @@ struct _WorkbookControlGUI {
gboolean toolbar_is_sensitive;
/* Auto completion */
void *auto_complete; /* GtkType is (Complete *) */
gboolean auto_completing;
char *auto_complete_text;
void *auto_complete; /* GtkType is (Complete *) */
gboolean auto_completing;
char *auto_complete_text;
/* Used to detect if the user has backspaced, so we turn off auto-complete */
int auto_max_size;
......@@ -120,6 +73,54 @@ struct _WorkbookControlGUI {
PangoFontDescription *font_desc;
GnmFileSaver *current_saver;
#ifdef WITH_BONOBO
GHashTable *custom_ui_components;
BonoboUIComponent *uic;
GtkWidget *progress_bar;
#else
/* The status bar */
GnomeAppBar *appbar;
/* Menu items that get enabled/disabled */
GtkWidget *menu_item_undo;
GtkWidget *menu_item_redo;
GtkWidget *menu_item_paste_special;
GtkWidget *menu_item_insert_rows;
GtkWidget *menu_item_insert_cols;
GtkWidget *menu_item_insert_cells;
GtkWidget *menu_item_show_detail;
GtkWidget *menu_item_hide_detail;
GtkWidget *menu_item_sheet_remove;
GtkWidget *menu_item_sheets_edit_reorder;
GtkWidget *menu_item_sheets_format_reorder;
GtkWidget *menu_item_page_setup;
GtkWidget *menu_item_search_replace;
GtkWidget *menu_item_define_name;
GtkWidget *menu_item_consolidate;
GtkWidget *menu_item_freeze_panes;
GtkWidget *menu_item_auto_filter;
/* Menu items that get toggled */
GtkWidget *menu_item_sheet_display_formulas;
GtkWidget *menu_item_sheet_hide_zero;
GtkWidget *menu_item_sheet_hide_grid;
GtkWidget *menu_item_sheet_hide_col_header;
GtkWidget *menu_item_sheet_hide_row_header;
GtkWidget *menu_item_sheet_display_outlines;
GtkWidget *menu_item_sheet_outline_symbols_below;
GtkWidget *menu_item_sheet_outline_symbols_right;
GtkWidget *menu_item_filter_show_all;
/* Toolbars */
GtkWidget *standard_toolbar;
GtkWidget *format_toolbar;
GtkWidget *object_toolbar;
#endif
};
typedef struct {
......
......@@ -1889,104 +1889,6 @@ cb_file_save_as (GtkWidget *widget, WorkbookControlGUI *wbcg)
wbcg_focus_cur_scg (wbcg); /* force focus back to sheet */
}
#ifdef WITH_BONOBO
#ifdef GNOME2_CONVERSION_COMPLETE
#ifdef ENABLE_EVOLUTION
static void
cb_file_send (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
CORBA_Object composer;
CORBA_Environment ev;
BonoboStream *stream;
#if 0
Bonobo_StorageInfo *info;
#else
const gchar *filename;
#endif
GNOME_Evolution_Composer_AttachmentData *attachment_data;
CORBA_exception_init (&ev);
composer = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Mail_Composer",
0, NULL, &ev);
if (BONOBO_EX (&ev)) {
g_warning ("Unable to start composer: %s",
bonobo_exception_get_text (&ev));
CORBA_exception_free (&ev);
return;
}
if (composer == CORBA_OBJECT_NIL) {
g_warning ("Unable to start composer.");
CORBA_exception_free (&ev);
return;
}
stream = bonobo_stream_mem_create (NULL, 0, FALSE, TRUE);
gui_file_save_to_stream (stream, wbcg,
wb_control_view (WORKBOOK_CONTROL (wbcg)),
NULL, &ev);
if (BONOBO_EX (&ev)) {
g_warning ("Unable to save workbook to stream: %s",
bonobo_exception_get_text (&ev));
CORBA_exception_free (&ev);
bonobo_object_release_unref (composer, NULL);
return;
}
attachment_data = GNOME_Evolution_Composer_AttachmentData__alloc ();
attachment_data->_buffer = BONOBO_STREAM_MEM (stream)->buffer;
attachment_data->_length = BONOBO_STREAM_MEM (stream)->size;
BONOBO_STREAM_MEM (stream)->buffer = NULL;
bonobo_object_unref (BONOBO_OBJECT (stream));
#if 0
/*
* FIXME: Enable this code when BonoboStreamMemory has [get,set]Info
* capabilities.
*/
info = Bonobo_Stream_getInfo (BONOBO_OBJREF (stream), 0, &ev);
if (BONOBO_EX (&ev)) {
g_warning ("Could not get information about stream: %s",
bonobo_exception_get_text (&ev));
CORBA_exception_free (&ev);
bonobo_object_release_unref (composer, NULL);
return;
}
GNOME_Evolution_Composer_attachData (composer, info->content_type,
info->name, info->name, FALSE,
attachment_data, &ev);
CORBA_free (info);
#else
#error "FIXME filename is not UTF-8."
filename = workbook_get_filename (wb_view_workbook (wb_control_view (
WORKBOOK_CONTROL (wbcg))));
GNOME_Evolution_Composer_attachData (composer, "application/x-gnumeric",
filename, filename, FALSE,
attachment_data, &ev);
#endif
CORBA_free (attachment_data);
if (BONOBO_EX (&ev)) {
g_warning ("Unable to attach image: %s",
bonobo_exception_get_text (&ev));
CORBA_exception_free (&ev);
bonobo_object_release_unref (composer, NULL);
return;
}
GNOME_Evolution_Composer_show (composer, &ev);
if (BONOBO_EX (&ev)) {
g_warning ("Unable to show composer: %s",
bonobo_exception_get_text (&ev));
CORBA_exception_free (&ev);
bonobo_object_release_unref (composer, NULL);
return;
}
CORBA_exception_free (&ev);
}
#endif
#endif
#endif
static void
cb_file_page_setup (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
......
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