Commit 666ae841 authored by Arturo Espinosa's avatar Arturo Espinosa

Add missing file

parent 0ef3dbc4
/*
* file.c: File loading and saving routines
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*/
#include <config.h>
#include <gnome.h>
#include "gnumeric.h"
#include "dialogs.h"
#include "xml-io.h"
static void
set_ok (GtkWidget *widget, gboolean *dialog_result)
{
*dialog_result = TRUE;
gtk_main_quit ();
}
void
workbook_save_as (Workbook *wb)
{
GtkFileSelection *fsel;
gboolean accepted = FALSE;
g_return_if_fail (wb != NULL);
fsel = (GtkFileSelection *)gtk_file_selection_new (_("Save workbook as"));
if (wb->filename)
gtk_file_selection_set_filename (fsel, wb->filename);
/* Connect the signals for Ok and Cancel */
gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked",
GTK_SIGNAL_FUNC (set_ok), &accepted);
gtk_signal_connect (GTK_OBJECT (fsel->cancel_button), "clicked",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
/* Run the dialog */
gtk_widget_show (GTK_WIDGET (fsel));
gtk_grab_add (GTK_WIDGET (fsel));
gtk_main ();
if (accepted){
char *name = gtk_file_selection_get_filename (fsel);
if (name [strlen (name)-1] != '/'){
if (wb->filename)
g_free (wb->filename);
wb->filename = g_strdup (name);
gnumericWriteXmlWorkbook (wb, wb->filename);
}
}
gtk_widget_destroy (GTK_WIDGET (fsel));
}
void
workbook_save (Workbook *wb)
{
g_return_if_fail (wb != NULL);
if (!wb->filename){
workbook_save_as (wb);
return;
}
gnumericWriteXmlWorkbook (wb, wb->filename);
}
char *
dialog_query_load_file (void)
{
GtkFileSelection *fsel;
gboolean accepted;
char *result;
fsel = (GtkFileSelection *) gtk_file_selection_new (_("Load file"));
/* Connect the signals for Ok and Cancel */
gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked",
GTK_SIGNAL_FUNC (set_ok), &accepted);
gtk_signal_connect (GTK_OBJECT (fsel->cancel_button), "clicked",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
/* Run the dialog */
gtk_widget_show (GTK_WIDGET (fsel));
gtk_grab_add (GTK_WIDGET (fsel));
gtk_main ();
if (accepted){
char *name = gtk_file_selection_get_filename (fsel);
if (name [strlen (name)-1] == '/')
result = NULL;
else
result = g_strdup (name);
} else
result = NULL;
gtk_widget_destroy (GTK_WIDGET (fsel));
return result;
}
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