Commit 2d9dce82 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

merge with wb_view_open_custom and remove the useless view argument.

2002-04-16  Jody Goldberg <jody@gnome.org>

	* src/workbook-view.c (wb_view_open) : merge with wb_view_open_custom
	  and remove the useless view argument.

	* src/libgnumeric.c : move the application specific code from here.
	* src/main-application.c : to here.
parent f7357bbb
2002-04-16 Jody Goldberg <jody@gnome.org>
* src/workbook-view.c (wb_view_open) : merge with wb_view_open_custom
and remove the useless view argument.
* src/libgnumeric.c : move the application specific code from here.
* src/main-application.c : to here.
* configure.in : Addd gobject & gmodule
2002-04-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
......
2002-04-16 Jody Goldberg <jody@gnome.org>
* src/workbook-view.c (wb_view_open) : merge with wb_view_open_custom
and remove the useless view argument.
* src/libgnumeric.c : move the application specific code from here.
* src/main-application.c : to here.
* configure.in : Addd gobject & gmodule
2002-04-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
......
2002-04-16 Jody Goldberg <jody@gnome.org>
* src/workbook-view.c (wb_view_open) : merge with wb_view_open_custom
and remove the useless view argument.
* src/libgnumeric.c : move the application specific code from here.
* src/main-application.c : to here.
* configure.in : Addd gobject & gmodule
2002-04-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
......
......@@ -102,13 +102,4 @@ void gnm_gconf_set_horizontal_window_fraction (gnum_float val);
gnum_float gnm_gconf_get_vertical_window_fraction (void);
void gnm_gconf_set_vertical_window_fraction (gnum_float val);
#endif /* GNUMERIC_GRAPH_H */
......@@ -18,8 +18,6 @@
#include "command-context.h"
#include "command-context-stderr.h"
#include "workbook.h"
#include "workbook-control-gui.h"
#include "workbook-view.h"
#include "sheet-object.h"
#include "number-match.h"
#include "expr-name.h"
......@@ -41,11 +39,6 @@
#include "gnumeric-gconf.h"
#include "auto-correct.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <gtk/gtkmain.h>
#include <locale.h>
#ifdef WITH_BONOBO
#include "bonobo-io.h"
......@@ -98,44 +91,6 @@ init_init (char const* gnumeric_binary)
setlocale (LC_ALL, "");
}
static void
handle_paint_events (void)
{
/* FIXME: we need to mask input events correctly here */
/* Show something coherent */
while (gtk_events_pending () && !initial_workbook_open_complete)
gtk_main_iteration_do (FALSE);
}
static void
warn_about_ancient_gnumerics (const char *binary, WorkbookControl *wbc)
{
struct stat buf;
time_t now = time (NULL);
int days = 180;
if (binary &&
stat (binary, &buf) != -1 &&
buf.st_mtime != -1 &&
now - buf.st_mtime > days * 24 * 60 * 60) {
handle_paint_events ();
gnumeric_error_system (COMMAND_CONTEXT (wbc),
_("Thank you for using Gnumeric!\n"
"\n"
"The version of Gnumeric you are using is quite old\n"
"by now. It is likely that many bugs have been fixed\n"
"and that new features have been added in the meantime.\n"
"\n"
"Please consider upgrading before reporting any bugs.\n"
"Consult http://www.gnumeric.org/ for details.\n"
"\n"
"-- The Gnumeric Team."));
}
}
#if 0
static void
......@@ -195,54 +150,6 @@ gnm_common_init ()
glade_gnome_init ();
}
void
gnm_application_init (poptContext *ctx)
{
char const **startup_files;
gboolean opened_workbook = FALSE;
WorkbookControl *wbc;
/* Load selected files */
if (ctx)
startup_files = poptGetArgs (*ctx);
else
startup_files = NULL;
#ifdef WITH_BONOBO
bonobo_activate ();
#endif
wbc = workbook_control_gui_new (NULL, NULL);
plugins_init (COMMAND_CONTEXT (wbc));
if (startup_files) {
int i;
for (i = 0; startup_files [i] && !initial_workbook_open_complete ; i++) {
if (wb_view_open (wb_control_view (wbc), wbc,
startup_files[i], TRUE))
opened_workbook = TRUE;
handle_paint_events ();
}
}
/* If we were intentionally short circuited exit now */
if (!initial_workbook_open_complete && !immediate_exit_flag) {
initial_workbook_open_complete = TRUE;
if (!opened_workbook) {
gint n_of_sheets = gnm_gconf_get_initial_sheet_number ();
Sheet *sheet = NULL;
while (n_of_sheets--)
sheet = workbook_sheet_add (wb_control_workbook (wbc),
sheet, FALSE);
handle_paint_events ();
}
warn_about_ancient_gnumerics (g_get_prgname(), wbc);
gtk_main ();
}
}
int
gnm_dump_func_defs (char const* filename)
{
......
......@@ -18,7 +18,6 @@ void init_init (char const* gnumeric_binary);
poptContext gnumeric_arg_parse (int argc, char *argv []);
void gnm_common_init ();
void gnm_application_init (poptContext *ctx);
int gnm_dump_func_defs (char const* filename);
void gnm_shutdown (void);
......
......@@ -8,9 +8,23 @@
*/
#include <gnumeric-config.h>
#include <glib.h>
#include <libgnumeric.h>
#include "gnumeric.h"
#include "libgnumeric.h"
#include "command-context.h"
#include "workbook-control-gui.h"
#include "workbook-view.h"
#include "plugin.h"
#include "workbook.h"
#include "gnumeric-gconf.h"
#include <libgnome/gnome-i18n.h>
#include <gtk/gtkmain.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
static int gnumeric_show_version = FALSE;
static char *dump_file_name = NULL;
......@@ -50,11 +64,52 @@ gnumeric_popt_options[] = {
{ NULL, '\0', 0, NULL, 0 }
};
static void
handle_paint_events (void)
{
/* FIXME: we need to mask input events correctly here */
/* Show something coherent */
while (gtk_events_pending () && !initial_workbook_open_complete)
gtk_main_iteration_do (FALSE);
}
static void
warn_about_ancient_gnumerics (const char *binary, WorkbookControl *wbc)
{
struct stat buf;
time_t now = time (NULL);
int days = 180;
if (binary &&
stat (binary, &buf) != -1 &&
buf.st_mtime != -1 &&
now - buf.st_mtime > days * 24 * 60 * 60) {
handle_paint_events ();
gnumeric_error_system (COMMAND_CONTEXT (wbc),
_("Thank you for using Gnumeric!\n"
"\n"
"The version of Gnumeric you are using is quite old\n"
"by now. It is likely that many bugs have been fixed\n"
"and that new features have been added in the meantime.\n"
"\n"
"Please consider upgrading before reporting any bugs.\n"
"Consult http://www.gnumeric.org/ for details.\n"
"\n"
"-- The Gnumeric Team."));
}
}
int
main (int argc, char *argv [])
{
char const **startup_files;
gboolean opened_workbook = FALSE;
WorkbookControl *wbc;
poptContext ctx;
int ret;
init_init (argv[0]);
......@@ -68,11 +123,55 @@ main (int argc, char *argv [])
gnm_common_init ();
if (dump_file_name) {
if (dump_file_name)
return gnm_dump_func_defs (dump_file_name);
/* Load selected files */
if (ctx)
startup_files = poptGetArgs (ctx);
else
startup_files = NULL;
#ifdef WITH_BONOBO
bonobo_activate ();
#endif
wbc = workbook_control_gui_new (NULL, NULL);
/* TODO : make a dialog based command context and do this earlier. We
* should not arbitrarily be using the 1st workbook as the place to
* link errors or status.
*
* plugin init should be earlier too.
*/
plugins_init (COMMAND_CONTEXT (wbc));
if (startup_files) {
int i;
for (i = 0; startup_files [i] && !initial_workbook_open_complete ; i++) {
if (wb_view_open (startup_files[i], wbc, TRUE, NULL))
opened_workbook = TRUE;
/* cheesy attempt to keep the ui from freezing during load */
handle_paint_events ();
}
}
gnm_application_init (&ctx);
/* If we were intentionally short circuited exit now */
if (!initial_workbook_open_complete && !immediate_exit_flag) {
initial_workbook_open_complete = TRUE;
if (!opened_workbook) {
gint n_of_sheets = gnm_gconf_get_initial_sheet_number ();
while (n_of_sheets--)
workbook_sheet_add (wb_control_workbook (wbc),
NULL, FALSE);
/* cheesy attempt to keep the ui from freezing during load */
handle_paint_events ();
}
warn_about_ancient_gnumerics (g_get_prgname(), wbc);
gtk_main ();
}
gnm_shutdown ();
......
......@@ -577,47 +577,29 @@ wb_view_save (WorkbookView *wbv, CommandContext *context)
}
/**
* wb_view_open:
* @wbv : Workbook View
* @wbc : Workbook Control
* wb_view_open :
* @file_name : File name
* @display_err : should errors messages be generated
*
* Reads @file_name file, automatically detecting file type and using
* appropriate file opener.
*
* Return value: TRUE if file was successfully read and FALSE otherwise.
*/
gboolean
wb_view_open (WorkbookView *wbv, WorkbookControl *wbc,
gchar const *file_name, gboolean display_errors)
{
return wb_view_open_custom (wbv, wbc, NULL, file_name, display_errors);
}
/**
* wb_view_open_custom:
* @wbv : Workbook View
* @wbc : Workbook Control
* @fo : GnumFileOpener object
* @file_name : File name
* @display_errors :
* @fo : Optional GnumFileOpener
*
* Reads @file_name file using given file opener (@fo).
* Reads @file_name file using given file opener @fo, or probes for a valid
* possibility if @fo is NULL.
*
* Return value: TRUE if file was successfully read and FALSE otherwise.
*/
gboolean
wb_view_open_custom (WorkbookView *wbv, WorkbookControl *wbc,
GnumFileOpener const *fo, gchar const *file_name,
gboolean display_errors)
wb_view_open (char const *file_name,
WorkbookControl *wbc,
gboolean display_errors,
GnumFileOpener const *fo)
{
Workbook *new_wb = NULL;
WorkbookView *new_wbv = NULL;
g_return_val_if_fail (IS_WORKBOOK_VIEW (wbv), FALSE);
g_return_val_if_fail (file_name != NULL, FALSE);
g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), FALSE);
g_return_val_if_fail (fo == NULL || IS_GNUM_FILE_OPENER (fo), FALSE);
g_return_val_if_fail (file_name != NULL, FALSE);
if (g_file_test (file_name, G_FILE_TEST_IS_REGULAR)) {
IOContext *io_context = gnumeric_io_context_new (COMMAND_CONTEXT (wbc));
......
......@@ -80,12 +80,10 @@ void wb_view_auto_expr (WorkbookView *wbv,
gboolean wb_view_save_as (WorkbookView *wbv, GnumFileSaver *fs,
char const *file_name, CommandContext *context);
gboolean wb_view_save (WorkbookView *wbv, CommandContext *context);
gboolean wb_view_open (WorkbookView *wbv, WorkbookControl *wbc,
char const *file_name,
gboolean display_errors);
gboolean wb_view_open_custom (WorkbookView *wbv, WorkbookControl *wbc,
GnumFileOpener const *fo, char const *file_name,
gboolean display_errors);
gboolean wb_view_open (char const *file_name,
WorkbookControl *wbc,
gboolean display_errors,
GnumFileOpener const *fo);
#define WORKBOOK_VIEW_FOREACH_CONTROL(wbv, control, code) \
do { \
......
......@@ -845,6 +845,14 @@ workbook_sheet_by_name (Workbook const *wb, char const *sheet_name)
return g_hash_table_lookup (wb->sheet_hash_private, sheet_name);
}
/**
* workbook_sheet_attach :
* @wb :
* @new_sheet :
* @insert_after : optional position.
*
* Add @new_sheet to @wb, either placing it after @insert_after, or appending.
*/
void
workbook_sheet_attach (Workbook *wb, Sheet *new_sheet,
Sheet const *insert_after)
......@@ -933,6 +941,14 @@ workbook_sheet_detach (Workbook *wb, Sheet *sheet)
return TRUE;
}
/**
* workbook_sheet_add :
* @wb :
* @insert_after : optional position.
*
* Create and name a new sheet, either placing it after @insert_after, or
* appending.
*/
Sheet *
workbook_sheet_add (Workbook *wb, Sheet const *insert_after, gboolean make_dirty)
{
......
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