Commit c6cea719 authored by Jukka-Pekka Iivonen's avatar Jukka-Pekka Iivonen Committed by jpekka

Implemented ``Auto Save'' tool.

2000-01-13  Jukka-Pekka Iivonen  <iivonen@iki.fi>

	* src/dialogs/dialog-autosave.c: Implemented ``Auto Save'' tool.

	* src/dialogs/autosave.glade: New file.

	* src/dialogs/autosave-prompt.glade: New file.

	* src/workbook.c: Added Autosave tool.

	* src/workbook.h: Added autosave paramters to the Workbook struct.

	* src/dialog-solver: Fixed a constraint delete bug.
parent f1c28c25
2000-01-13 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/dialog-autosave.c: Implemented ``Auto Save'' tool.
* src/dialogs/autosave.glade: New file.
* src/dialogs/autosave-prompt.glade: New file.
* src/workbook.c: Added Autosave tool.
* src/workbook.h: Added autosave paramters to the Workbook struct.
* src/dialog-solver: Fixed a constraint delete bug.
2000-01-13 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c (gnumeric_xml_write_sheet, gnumeric_xml_write_workbook,
......
......@@ -24,6 +24,10 @@ Ariel:
* Improvements on VALUE_BOOL management on the guile plugin.
* Bug fixes.
Jukka:
* Implemented `AutoSave' tool.
* Some minor improvements to the Solver tool.
--------------------------------------------------------------------------
Gnumeric 0.47
......
2000-01-13 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/dialog-autosave.c: Implemented ``Auto Save'' tool.
* src/dialogs/autosave.glade: New file.
* src/dialogs/autosave-prompt.glade: New file.
* src/workbook.c: Added Autosave tool.
* src/workbook.h: Added autosave paramters to the Workbook struct.
* src/dialog-solver: Fixed a constraint delete bug.
2000-01-13 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c (gnumeric_xml_write_sheet, gnumeric_xml_write_workbook,
......
......@@ -17,6 +17,7 @@ noinst_LIBRARIES = libdialogs.a
libdialogs_a_SOURCES = \
dialog-analysis-tools.c \
dialog-autosave.c \
dialog-cell-comment.c \
dialog-cell-format.c \
dialog-cell-sort.c \
......@@ -43,6 +44,8 @@ libdialogs_a_SOURCES = \
gladedir = $(datadir)/gnumeric/glade
glade_DATA = \
autosave.glade \
autosave-prompt.glade \
col-width.glade \
font-sel.glade \
hf-config.glade \
......
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Autosave-prompt</name>
<program_name>autosave-prompt</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<use_widget_names>False</use_widget_names>
<output_main_file>True</output_main_file>
<output_support_files>True</output_support_files>
<output_build_files>True</output_build_files>
<backup_source_files>True</backup_source_files>
<main_source_file>interface.c</main_source_file>
<main_header_file>interface.h</main_header_file>
<handler_source_file>callbacks.c</handler_source_file>
<handler_header_file>callbacks.h</handler_header_file>
<support_source_file>support.c</support_source_file>
<support_header_file>support.h</support_header_file>
<translatable_strings_file></translatable_strings_file>
</project>
<widget>
<class>GnomeDialog</class>
<name>AutoSavePrompt</name>
<title>Auto Save</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label1</name>
<label>Do you want to save the workbook?</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_YES</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_NO</stock_button>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>AutoSave.glade</name>
<program_name>autosave.glade</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<use_widget_names>False</use_widget_names>
<output_main_file>True</output_main_file>
<output_support_files>True</output_support_files>
<output_build_files>True</output_build_files>
<backup_source_files>True</backup_source_files>
<main_source_file>interface.c</main_source_file>
<main_header_file>interface.h</main_header_file>
<handler_source_file>callbacks.c</handler_source_file>
<handler_header_file>callbacks.h</handler_header_file>
<support_source_file>support.c</support_source_file>
<support_header_file>support.h</support_header_file>
<translatable_strings_file></translatable_strings_file>
</project>
<widget>
<class>GnomeDialog</class>
<name>AutoSave</name>
<title>Auto Save</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox2</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox2</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkCheckButton</class>
<name>autosave_on_off</name>
<can_focus>True</can_focus>
<label>Automatic Save Every</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>minutes</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>3</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>prompt_on_off</name>
<can_focus>True</can_focus>
<label>Prompt Before Saving</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox3</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label1</name>
<label>Minutes</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>Placeholder</class>
</widget>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button2</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>
/*
* dialog-autosave.c:
*
* Author:
* Jukka-Pekka Iivonen <iivonen@iki.fi>
*
* (C) Copyright 2000 by Jukka-Pekka Iivonen <iivonen@iki.fi>
**/
#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "gnumeric-sheet.h"
#include "dialogs.h"
static void
autosave_on_off_toggled(GtkWidget *widget, Workbook *wb)
{
wb->autosave = GTK_TOGGLE_BUTTON (widget)->active;
}
static void
prompt_on_off_toggled(GtkWidget *widget, Workbook *wb)
{
wb->autosave_prompt = GTK_TOGGLE_BUTTON (widget)->active;
}
gint
dialog_autosave_callback (gpointer *data)
{
Workbook *wb = (Workbook *) data;
if (wb->autosave) {
if (wb->autosave_prompt) {
GladeXML *gui =
glade_xml_new (GNUMERIC_GLADEDIR
"/autosave-prompt.glade", NULL);
GtkWidget *dia;
gint v;
dia = glade_xml_get_widget (gui, "AutoSavePrompt");
if (!dia) {
printf("Corrupt file autosave-prompt.glade\n");
return 0;
}
gnome_dialog_set_parent (GNOME_DIALOG (dia),
GTK_WINDOW (wb->toplevel));
v = gnome_dialog_run (GNOME_DIALOG (dia));
if (v != -1)
gtk_object_destroy (GTK_OBJECT (dia));
gtk_object_unref (GTK_OBJECT (gui));
if (v != 0)
goto out;
}
workbook_save (wb);
}
out:
wb->autosave_timer = gtk_timeout_add(wb->autosave_minutes*60000,
dialog_autosave_callback, wb);
return 0;
}
void
dialog_autosave (Workbook *wb)
{
GladeXML *gui = glade_xml_new (GNUMERIC_GLADEDIR "/autosave.glade",
NULL);
GtkWidget *dia;
GtkWidget *autosave_on_off;
GtkWidget *minutes;
GtkWidget *prompt_on_off;
gchar *buf[20];
gint v, old_autosave, old_prompt, old_minutes;
old_autosave = wb->autosave;
old_prompt = wb->autosave_prompt;
old_minutes = wb->autosave_minutes;
gtk_timeout_remove (wb->autosave_timer);
if (!gui) {
printf ("Could not find autosave.glade\n");
return;
}
dia = glade_xml_get_widget (gui, "AutoSave");
if (!dia) {
printf ("Corrupt file autosave.glade\n");
return;
}
gnome_dialog_set_parent (GNOME_DIALOG (dia),
GTK_WINDOW (wb->toplevel));
autosave_on_off = glade_xml_get_widget (gui, "autosave_on_off");
if (wb->autosave)
gtk_toggle_button_set_active (autosave_on_off, wb->autosave);
gtk_signal_connect (GTK_OBJECT (autosave_on_off), "toggled",
GTK_SIGNAL_FUNC (autosave_on_off_toggled), wb);
prompt_on_off = glade_xml_get_widget (gui, "prompt_on_off");
if (wb->autosave_prompt)
gtk_toggle_button_set_active (prompt_on_off,
wb->autosave_prompt);
gtk_signal_connect (GTK_OBJECT (prompt_on_off), "toggled",
GTK_SIGNAL_FUNC (prompt_on_off_toggled), wb);
minutes = glade_xml_get_widget (gui, "minutes");
sprintf(buf, "%d", wb->autosave_minutes);
gtk_entry_set_text (GTK_ENTRY (minutes), buf);
loop:
v = gnome_dialog_run (GNOME_DIALOG (dia));
if (v == 0) {
gchar *txt;
txt = gtk_entry_get_text (GTK_ENTRY (minutes));
wb->autosave_minutes = atoi(txt);
if (wb->autosave_minutes <= 0) {
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR,
_("You should introduce a proper "
"number of minutes in the entry."));
gtk_widget_grab_focus (minutes);
goto loop;
}
wb->autosave_timer =
gtk_timeout_add(wb->autosave_minutes*60000,
dialog_autosave_callback, wb);
} else {
wb->autosave = old_autosave;
wb->autosave_prompt = old_prompt;
wb->autosave_minutes = old_minutes;
}
if (v != -1)
gtk_object_destroy (GTK_OBJECT (dia));
gtk_object_unref (GTK_OBJECT (gui));
}
......@@ -20,8 +20,8 @@
/* Different constraint types */
static const char *constraint_strs[] = {
N_("<="),
/* N_("="),
N_(">="),
/* N_(">="),
N_("="),
N_("int"),
N_("bool"), */
NULL
......@@ -179,7 +179,7 @@ dialog_solver_options (Workbook *wb, Sheet *sheet)
}
static void
static int
add_constraint(constraint_dialog_t *constraint_dialog,
int lhs_col, int lhs_row, int rhs_col, int rhs_row,
char *type_str)
......@@ -187,19 +187,30 @@ add_constraint(constraint_dialog_t *constraint_dialog,
SolverConstraint *constraint;
char constraint_buf[512];
char *constraint_str[2] = { constraint_buf, NULL };
gint row;
sprintf(constraint_buf, "%s %s ",
cell_name (lhs_col, lhs_row),
type_str);
strcat(constraint_buf, cell_name(rhs_col, rhs_row));
gtk_clist_append (constraint_dialog->clist, constraint_str);
constraint = g_new (SolverConstraint, 1);
constraint->lhs = sheet_cell_fetch (constraint_dialog->sheet,
lhs_col, lhs_row);
constraint->rhs = sheet_cell_fetch (constraint_dialog->sheet,
rhs_col, rhs_row);
constraint->lhs = sheet_cell_get (constraint_dialog->sheet,
lhs_col, lhs_row);
if (constraint->lhs == NULL) {
cell_error:
gnumeric_notice (constraint_dialog->wb,
GNOME_MESSAGE_BOX_ERROR,
_("You gave a cell reference that contain "
"no data."));
return 1;
}
constraint->rhs = sheet_cell_get (constraint_dialog->sheet,
rhs_col, rhs_row);
if (constraint->rhs == NULL)
goto cell_error;
row = gtk_clist_append (constraint_dialog->clist, constraint_str);
constraint->type = g_malloc (strlen (type_str) + 1);
strcpy (constraint->type, type_str);
constraint->str = g_malloc (strlen (constraint_buf)+1);
......@@ -207,6 +218,10 @@ add_constraint(constraint_dialog_t *constraint_dialog,
constraint_dialog->constraints =
g_slist_append(constraint_dialog->constraints,
(gpointer) constraint);
gtk_clist_set_row_data (constraint_dialog->clist, row,
(gpointer) constraint);
return 0;
}
/* 'Constraint Add' button clicked */
......@@ -294,8 +309,10 @@ add_dialog:
type_str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(type_entry)->entry));
add_constraint(constraint_dialog, lhs_col, lhs_row, rhs_col, rhs_row,
type_str);
if (add_constraint(constraint_dialog, lhs_col,
lhs_row, rhs_col, rhs_row,
type_str))
goto add_dialog;
gtk_entry_set_text (GTK_ENTRY (lhs_entry), "");
gtk_entry_set_text (GTK_ENTRY (rhs_entry), "");
......
......@@ -93,6 +93,8 @@ void dialog_goal_seek (Workbook *wb, Sheet *sheet);
void dialog_solver (Workbook *wb, Sheet *sheet);
void dialog_printer_setup (Workbook *wb, Sheet *sheet);
void dialog_summary_update (Workbook *wb, SummaryInfo *sin);
void dialog_autosave (Workbook *wb);
gint dialog_autosave_callback (gpointer *data);
void dialog_data_analysis (Workbook *wb, Sheet *sheet);
char *dialog_get_sheet_name (Workbook *wb, const char *name);
gboolean dialog_get_number (Workbook *wb,
......
......@@ -117,6 +117,11 @@ struct _Workbook {
gboolean display_formulas;
WorkbookPrivate *priv;
gboolean autosave;
gboolean autosave_prompt;
gint autosave_minutes;
gint autosave_timer;
};
typedef struct {
......
......@@ -135,6 +135,12 @@ summary_cmd (GtkWidget *widget, Workbook *wb)
dialog_summary_update (wb, wb->summary_info);
}
static void
autosave_cmd (GtkWidget *widget, Workbook *wb)
{
dialog_autosave (wb);
}
static void
plugins_cmd (GtkWidget *widget, Workbook *wb)
{
......@@ -1139,6 +1145,8 @@ static GnomeUIInfo workbook_menu_format [] = {
/* Tools menu */
static GnomeUIInfo workbook_menu_tools [] = {
{ GNOME_APP_UI_ITEM, N_("_Auto Save..."), N_("Auto Save"),
autosave_cmd },
{ GNOME_APP_UI_ITEM, N_("_Sort..."),
N_("Sort the selected cells"), sort_cells_cmd },
GNOMEUIINFO_SEPARATOR,
......@@ -2043,6 +2051,13 @@ workbook_new (void)
wb->toplevel = gnome_app_new ("Gnumeric", "Gnumeric");
wb->table = gtk_table_new (0, 0, 0);
wb->display_formulas = FALSE;
wb->autosave = FALSE;
wb->autosave_prompt = TRUE;
wb->autosave_minutes = 15;
wb->autosave_timer =
gtk_timeout_add(wb->autosave_minutes*60000,
dialog_autosave_callback, wb);
gtk_window_set_policy (GTK_WINDOW (wb->toplevel), 1, 1, 0);
sx = MAX (gdk_screen_width () - 64, 400);
......
......@@ -117,6 +117,11 @@ struct _Workbook {
gboolean display_formulas;
WorkbookPrivate *priv;
gboolean autosave;
gboolean autosave_prompt;
gint autosave_minutes;
gint autosave_timer;
};
typedef struct {
......
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