Commit 9a04a8ea authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

new function. Handle. Handle.


2000-05-03  Jody Goldberg <jgoldberg@home.com>

	* src/command-context.c (gnumeric_error_invalid) : new function.
	* src/command-context-gui.c (ccg_error_invalid) : Handle.
	* src/command-context-corba.c (ccc_error_invalid) : Handle.

	* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
	  workbook_rename_sheet.

	* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
	  empty.  Take a CommandContext and report the error.  Invert the
	  return value.
parent 52d34b69
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
2000-05-03 Jody Goldberg <jgoldberg@home.com>
* src/command-context.c (gnumeric_error_invalid) : new function.
* src/command-context-gui.c (ccg_error_invalid) : Handle.
* src/command-context-corba.c (ccc_error_invalid) : Handle.
* src/commands.c (cmd_rename_sheet_{undo,redo}) : Pass a context to
workbook_rename_sheet.
* src/workbook.c (workbook_rename_sheet) : Sheet names can not be
empty. Take a CommandContext and report the error. Invert the
return value.
* src/format.c (pre_parse_format) : Fix old typo that was causing
bug 10001 by breaking AM/PM.
......
......@@ -16,19 +16,19 @@
#define CCG_CLASS(o) CMD_CONTEXT_CORBA_CLASS (GTK_OBJECT (o)->klass)
static void
ccc_error_plugin_problem (CommandContext *context, char const * const message)
ccc_error_plugin_problem (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
static void
ccc_error_read (CommandContext *context, char const * const message)
ccc_error_read (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
static void
ccc_error_save (CommandContext *context, char const * const message)
ccc_error_save (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
......@@ -44,7 +44,13 @@ ccc_error_splits_array (CommandContext *context)
}
static void
ccc_error_sys_err (CommandContext *context, char const * const message)
ccc_error_sys_err (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
static void
ccc_error_invalid (CommandContext *context, char const * message, char const *value)
{
/* FIXME set exception */
}
......@@ -59,6 +65,7 @@ ccc_init_class (GtkObjectClass *object_class)
cc_class->error_save = ccc_error_save;
cc_class->error_splits_array = ccc_error_splits_array;
cc_class->error_sys_err = ccc_error_sys_err;
cc_class->error_invalid = ccc_error_invalid;
}
GNUMERIC_MAKE_TYPE(command_context_corba, "CommandContextCorba", CommandContextCorba, ccc_init_class, NULL, PARENT_TYPE)
......
......@@ -16,7 +16,7 @@
#define CCG_CLASS(o) CMD_CONTEXT_GUI_CLASS (GTK_OBJECT (o)->klass)
static void
ccg_error_plugin_problem (CommandContext *context, char const * const message)
ccg_error_plugin_problem (CommandContext *context, char const * message)
{
CommandContextGui *ccg = COMMAND_CONTEXT_GUI (context);
......@@ -24,7 +24,7 @@ ccg_error_plugin_problem (CommandContext *context, char const * const message)
}
static void
ccg_error_read (CommandContext *context, char const * const message)
ccg_error_read (CommandContext *context, char const * message)
{
CommandContextGui *ccg = COMMAND_CONTEXT_GUI (context);
......@@ -32,7 +32,7 @@ ccg_error_read (CommandContext *context, char const * const message)
}
static void
ccg_error_save (CommandContext *context, char const * const message)
ccg_error_save (CommandContext *context, char const * message)
{
CommandContextGui *ccg = COMMAND_CONTEXT_GUI (context);
......@@ -49,23 +49,34 @@ ccg_error_splits_array (CommandContext *context)
}
static void
ccg_error_sys_err (CommandContext *context, char const * const message)
ccg_error_sys_err (CommandContext *context, char const * message)
{
CommandContextGui *ccg = COMMAND_CONTEXT_GUI (context);
gnumeric_notice (ccg->wb, GNOME_MESSAGE_BOX_ERROR, message);
}
static void
ccg_error_invalid (CommandContext *context, char const * message, char const * value)
{
CommandContextGui *ccg = COMMAND_CONTEXT_GUI (context);
char *buf = g_strconcat (message, " : ", value, NULL);
gnumeric_notice (ccg->wb, GNOME_MESSAGE_BOX_ERROR, buf);
g_free (buf);
}
static void
ccg_init_class (GtkObjectClass *object_class)
{
CommandContextClass *cc_class = (CommandContextClass *) object_class;
cc_class->error_plugin_problem = ccg_error_plugin_problem;
cc_class->error_read = ccg_error_read;
cc_class->error_save = ccg_error_save;
cc_class->error_splits_array = ccg_error_splits_array;
cc_class->error_sys_err = ccg_error_sys_err;
cc_class->error_plugin_problem = &ccg_error_plugin_problem;
cc_class->error_read = &ccg_error_read;
cc_class->error_save = &ccg_error_save;
cc_class->error_splits_array = &ccg_error_splits_array;
cc_class->error_sys_err = &ccg_error_sys_err;
cc_class->error_invalid = &ccg_error_invalid;
}
GNUMERIC_MAKE_TYPE(command_context_gui, "CommandContextGui", CommandContextGui, ccg_init_class, NULL, PARENT_TYPE)
......
......@@ -124,5 +124,14 @@ gnumeric_error_sys_err (CommandContext *context, char const *message)
CC_CLASS (context)->error_sys_err (context, message);
}
void
gnumeric_error_invalid (CommandContext *context, char const *message, char const *val)
{
g_return_if_fail (context);
g_return_if_fail (IS_COMMAND_CONTEXT (context));
CC_CLASS (context)->error_invalid (context, message, val);
}
GNUMERIC_MAKE_TYPE(command_context, "CommandContext", CommandContext, NULL, NULL, PARENT_TYPE);
......@@ -19,14 +19,17 @@ struct _CommandContext {
typedef struct {
GtkObjectClass parent_class;
void (*error_sys_err) (CommandContext *context,
char const * const message);
char const * message);
void (*error_plugin_problem) (CommandContext *context,
char const * const message);
char const * message);
void (*error_read) (CommandContext *context,
char const * const message);
char const * message);
void (*error_save) (CommandContext *context,
char const * const message);
char const * message);
void (*error_splits_array) (CommandContext *context);
void (*error_invalid) (CommandContext *context,
char const * message,
char const * val);
} CommandContextClass;
GtkType command_context_get_type (void);
......@@ -49,6 +52,7 @@ void gnumeric_error_sys_err (CommandContext *context, char const *message
void gnumeric_error_plugin_problem (CommandContext *context, char const *message);
void gnumeric_error_read (CommandContext *context, char const *message);
void gnumeric_error_save (CommandContext *context, char const *message);
void gnumeric_error_invalid (CommandContext *context, char const *message, char const *val);
void gnumeric_error_splits_array (CommandContext *context);
#endif /* GNUMERIC_COMMAND_CONTEXT_H */
......@@ -1151,7 +1151,8 @@ cmd_rename_sheet_undo (GnumericCommand *cmd, CommandContext *context)
g_return_val_if_fail (me != NULL, TRUE);
return !workbook_rename_sheet (me->wb, me->new_name, me->old_name);
return workbook_rename_sheet (context, me->wb,
me->new_name, me->old_name);
}
static gboolean
......@@ -1161,7 +1162,8 @@ cmd_rename_sheet_redo (GnumericCommand *cmd, CommandContext *context)
g_return_val_if_fail (me != NULL, TRUE);
return !workbook_rename_sheet (me->wb, me->old_name, me->new_name);
return workbook_rename_sheet (context, me->wb,
me->old_name, me->new_name);
}
static void
cmd_rename_sheet_destroy (GtkObject *cmd)
......
......@@ -42,7 +42,8 @@ el_entry_activate (GtkWidget *entry, El *el)
gboolean accept = TRUE;
char *text = gtk_entry_get_text (GTK_ENTRY (el->entry));
gtk_signal_emit (GTK_OBJECT (el), el_signals [TEXT_CHANGED], text, &accept);
gtk_signal_emit (GTK_OBJECT (el), el_signals [TEXT_CHANGED], text,
&accept);
if (accept)
editable_label_set_text (el, text);
......
......@@ -16,19 +16,19 @@
#define CCG_CLASS(o) CMD_CONTEXT_CORBA_CLASS (GTK_OBJECT (o)->klass)
static void
ccc_error_plugin_problem (CommandContext *context, char const * const message)
ccc_error_plugin_problem (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
static void
ccc_error_read (CommandContext *context, char const * const message)
ccc_error_read (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
static void
ccc_error_save (CommandContext *context, char const * const message)
ccc_error_save (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
......@@ -44,7 +44,13 @@ ccc_error_splits_array (CommandContext *context)
}
static void
ccc_error_sys_err (CommandContext *context, char const * const message)
ccc_error_sys_err (CommandContext *context, char const * message)
{
/* FIXME set exception */
}
static void
ccc_error_invalid (CommandContext *context, char const * message, char const *value)
{
/* FIXME set exception */
}
......@@ -59,6 +65,7 @@ ccc_init_class (GtkObjectClass *object_class)
cc_class->error_save = ccc_error_save;
cc_class->error_splits_array = ccc_error_splits_array;
cc_class->error_sys_err = ccc_error_sys_err;
cc_class->error_invalid = ccc_error_invalid;
}
GNUMERIC_MAKE_TYPE(command_context_corba, "CommandContextCorba", CommandContextCorba, ccc_init_class, NULL, PARENT_TYPE)
......
......@@ -173,7 +173,8 @@ Sheet *workbook_sheet_lookup (Workbook *wb, const char *sheet_name);
void workbook_set_dirty (Workbook *wb, gboolean is_dirty);
gboolean workbook_is_dirty (Workbook *wb);
gboolean workbook_is_pristine (Workbook *wb);
gboolean workbook_rename_sheet (Workbook *wb,
gboolean workbook_rename_sheet (CommandContext *,
Workbook *wb,
const char *old_name,
const char *new_name);
int workbook_sheet_count (Workbook *wb);
......
......@@ -2689,27 +2689,41 @@ workbook_get_attributev (Workbook *wb, guint *n_args)
* @old_name: the name of the sheet we want to rename
* @new_name: new name we want to assing to the sheet.
*
* Returns TRUE if it was possible to rename the sheet to @new_name,
* otherwise it returns FALSE for any possible error condition.
* Returns TRUE if there was a problem changing the name
* return FALSE otherwise.
*/
gboolean
workbook_rename_sheet (Workbook *wb, const char *old_name, const char *new_name)
workbook_rename_sheet (CommandContext *context,
Workbook *wb,
const char *old_name,
const char *new_name)
{
Sheet *sheet;
GtkNotebook *notebook;
int sheets, i;
g_return_val_if_fail (wb != NULL, FALSE);
g_return_val_if_fail (old_name != NULL, FALSE);
g_return_val_if_fail (new_name != NULL, FALSE);
g_return_val_if_fail (wb != NULL, TRUE);
g_return_val_if_fail (old_name != NULL, TRUE);
g_return_val_if_fail (new_name != NULL, TRUE);
if (strlen (new_name) < 1) {
gnumeric_error_invalid (context,
_("Sheet name"),
_("must have at least 1 letter"));
return TRUE;
}
/* Do not let two sheets in the workbook have the same name */
if (g_hash_table_lookup (wb->sheets, new_name))
return FALSE;
if (g_hash_table_lookup (wb->sheets, new_name)) {
gnumeric_error_invalid (context,
_("Duplicate Sheet name"),
new_name);
return TRUE;
}
sheet = (Sheet *) g_hash_table_lookup (wb->sheets, old_name);
if (sheet == NULL)
return FALSE;
g_return_val_if_fail (sheet != NULL, TRUE);
g_hash_table_remove (wb->sheets, old_name);
sheet_rename (sheet, new_name);
......@@ -2737,7 +2751,7 @@ workbook_rename_sheet (Workbook *wb, const char *old_name, const char *new_name)
}
}
return TRUE;
return FALSE;
}
......@@ -2751,12 +2765,14 @@ sheet_label_editing_stopped_signal (EditableLabel *el, Workbook *wb)
* Signal handler for EditableLabel's text_changed signal.
*/
static gboolean
sheet_label_text_changed_signal (EditableLabel *el, const char *new_name, Workbook *wb)
sheet_label_text_changed_signal (EditableLabel *el,
const char *new_name,
Workbook *wb)
{
gboolean ans;
ans = cmd_rename_sheet (workbook_command_context_gui (wb),
wb, el->text, new_name);
ans = !cmd_rename_sheet (workbook_command_context_gui (wb),
wb, el->text, new_name);
workbook_focus_current_sheet (wb);
return ans;
......@@ -2979,7 +2995,7 @@ workbook_attach_sheet (Workbook *wb, Sheet *sheet)
* gtk_notebook_set_tab_label kills our widget & replaces with a label.
*/
gtk_object_set_data (GTK_OBJECT (t), "sheet_label", sheet_label);
gtk_signal_connect (
gtk_signal_connect_after (
GTK_OBJECT (sheet_label), "text_changed",
GTK_SIGNAL_FUNC (sheet_label_text_changed_signal), wb);
gtk_signal_connect (
......
......@@ -173,7 +173,8 @@ Sheet *workbook_sheet_lookup (Workbook *wb, const char *sheet_name);
void workbook_set_dirty (Workbook *wb, gboolean is_dirty);
gboolean workbook_is_dirty (Workbook *wb);
gboolean workbook_is_pristine (Workbook *wb);
gboolean workbook_rename_sheet (Workbook *wb,
gboolean workbook_rename_sheet (CommandContext *,
Workbook *wb,
const char *old_name,
const char *new_name);
int workbook_sheet_count (Workbook *wb);
......
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