Commit a0d2eecd authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

- Patch from list to enable sheet renaming from notebook tab popup.

- Adjust redraw and recalc to be associated with command.
- Partial cmd wrapper for sheet renaming (unused)

2000-01-07  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_move_range) : Recalc here until there is a
	  command wrapper for shift and cut_paste.

	* src/sheet.c (sheet_{insert,delete}_{rows,cols}) : Move recalc
	  request into the command wrapper.
	* src/eval.c (sheet_recalc_dependencies) : Ditto.

2000-01-07  Mike Kestner <mkestner@enteract.com>

	* src/workbook.c (sheet_action_rename_sheet) : Enable rename from the
	  popup menu associated with sheet tabs.
parent d71cf601
2000-01-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Recalc here until there is a
command wrapper for shift and cut_paste.
* src/sheet.c (sheet_{insert,delete}_{rows,cols}) : Move recalc
request into the command wrapper.
* src/eval.c (sheet_recalc_dependencies) : Ditto.
2000-01-07 Mike Kestner <mkestner@enteract.com>
* src/workbook.c (sheet_action_rename_sheet) : Enable rename from the
popup menu associated with sheet tabs.
2000-01-07 Michael Meeks <mmeeks@gnu.org>
* src/eval.c (sheet_recalc_dependencies): add precondition, use
......
2000-01-07 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Recalc here until there is a
command wrapper for shift and cut_paste.
* src/sheet.c (sheet_{insert,delete}_{rows,cols}) : Move recalc
request into the command wrapper.
* src/eval.c (sheet_recalc_dependencies) : Ditto.
2000-01-07 Mike Kestner <mkestner@enteract.com>
* src/workbook.c (sheet_action_rename_sheet) : Enable rename from the
popup menu associated with sheet tabs.
2000-01-07 Michael Meeks <mmeeks@gnu.org>
* src/eval.c (sheet_recalc_dependencies): add precondition, use
......
......@@ -40,11 +40,15 @@
*
* That way undo redo just become applications of the old or the new styles.
*
* FIXME : fine tune the use of these commands so that they actually
* execute the operation. Redo must be capable of applying the
* command, so lets avoid duplicating logic. SetText is a good
* example of the WRONG way to do it. I use that as an after thought
* and hence treat formating differenting.
* Design thoughts :
* 1) redo : this should be renamed 'exec' and should be the place that the
* the actual command executes. This avoid duplicating the code for
* application and re-application.
*
* 2) The command objects are responsible for generating recalc and redraw
* events. None of the internal utility routines should do so. Those are
* expensive events and should only be done once per command to avoid
* duplicating work.
*
* TODO : Add user preference for undo buffer size limit (# of commands ?)
* TODO : Possibly clear lists on save.
......@@ -258,7 +262,7 @@ command_list_release (GSList *cmd_list)
* @trouble : A flag indicating whether there was a problem with the
* command.
*
* returns : @trouble.
* returns : TRUE if there was an error.
*/
static gboolean
command_push_undo (Workbook *wb, GtkObject *cmd, gboolean const trouble)
......@@ -465,6 +469,9 @@ cmd_ins_del_row_col_undo (GnumericCommand *cmd, CommandContext *context)
workbook_expr_unrelocate (me->sheet->workbook, me->reloc_storage);
me->reloc_storage = NULL;
workbook_recalc (me->sheet->workbook);
sheet_redraw_all (me->sheet);
return trouble;
}
......@@ -509,6 +516,9 @@ cmd_ins_del_row_col_redo (GnumericCommand *cmd, CommandContext *context)
me->count, &me->reloc_storage);
}
workbook_recalc (me->sheet->workbook);
sheet_redraw_all (me->sheet);
return trouble;
}
......@@ -776,9 +786,16 @@ cmd_paste_cut (CommandContext *context, ExprRelocateInfo const * const info)
trouble = cmd_paste_cut_redo (GNUMERIC_COMMAND(me), context);
/* Register the command object */
/* NOTE : if the destination workbook is different from the source workbook
* should we have undo elements in both menus ?? It seems poor form to
* hit undo in 1 window and effect another ...
*
* Maybe queue it as 2 different commands, as a clear in one book and
* a paste in the other. This is not symetric though. What happens to the
* cells in the original sheet that now reference the cells in the other.
* When do they reset to the original ? Probably when the clear in the original
* is undone.
*/
return command_push_undo (info->target_sheet->workbook, obj, trouble);
}
......@@ -835,9 +852,64 @@ cmd_format (CommandContext *context,
}
#endif
/******************************************************************/
#define CMD_RENAME_SHEET_TYPE (cmd_rename_sheet_get_type ())
#define CMD_RENAME_SHEET(o) (GTK_CHECK_CAST ((o), CMD_RENAME_SHEET_TYPE, CmdRenameSheet))
typedef struct
{
GnumericCommand parent;
char *name;
} CmdRenameSheet;
GNUMERIC_MAKE_COMMAND (CmdRenameSheet, cmd_rename_sheet);
static gboolean
cmd_rename_sheet_undo (GnumericCommand *cmd, CommandContext *context)
{
CmdRenameSheet *me = CMD_RENAME_SHEET(cmd);
g_return_val_if_fail (me != NULL, TRUE);
/* FIXME : Fill in */
return FALSE;
}
static gboolean
cmd_rename_sheet_redo (GnumericCommand *cmd, CommandContext *context)
{
CmdRenameSheet *me = CMD_RENAME_SHEET(cmd);
g_return_val_if_fail (me != NULL, TRUE);
/* FIXME : Fill in */
return FALSE;
}
static void
cmd_rename_sheet_destroy (GtkObject *cmd)
{
CmdRenameSheet *me = CMD_RENAME_SHEET(cmd);
g_free (me->name);
gnumeric_command_destroy (cmd);
}
gboolean
cmd_rename_sheet (CommandContext *context,
Workbook *wb, const char *old_name, const char *new_name)
{
/* FIXME : Finish */
return workbook_rename_sheet (wb, old_name, new_name);
}
/******************************************************************/
/* TODO : Make a list of commands that should have undo support that dont
* even have stubs
* - Rename sheet
* - Autofill
* - Array formula creation.
* - Row/Col size changes
* - insert data/time
*/
......@@ -27,4 +27,7 @@ gboolean cmd_delete_rows (CommandContext *context,
gboolean cmd_paste_cut (CommandContext *context,
ExprRelocateInfo const * const info);
gboolean cmd_rename_sheet (CommandContext *context, Workbook *wb,
const char *old_name, const char *new_name);
#endif /* GNUMERIC_COMMAND_CONTEXT_H */
......@@ -959,9 +959,19 @@ search_range_deps (gpointer key, gpointer value, gpointer closure)
c->list = g_list_concat (c->list, g_list_copy (deprange->cell_list));
}
/**
* sheet_region_get_deps :
* Get a list of the elements that depend on the specified range.
*
* @sheet : The sheet.
* @start_col : The target range.
* @start_row :
* @end_col :
* @end_row :
*/
GList *
sheet_region_get_deps (Sheet *sheet, int start_col, int start_row,
int end_col, int end_row)
sheet_region_get_deps (Sheet *sheet,
int start_col, int start_row, int end_col, int end_row)
{
int ix, iy;
get_range_dep_closure_t closure;
......@@ -1014,11 +1024,10 @@ cb_single_get_all_depends (gpointer key, gpointer value, gpointer closure)
/**
* sheet_recalc_dependencies :
* Force a recalc of anything that depends on the cells in this sheet.
* Queue a recalc of anything that depends on the cells in this sheet.
* Do not actually recalc, just queue them up.
*
* @sheet : The sheet.
*
* This seems like over kill we could probably use a finer grained test.
*/
void
sheet_recalc_dependencies (Sheet *sheet)
......@@ -1039,6 +1048,4 @@ sheet_recalc_dependencies (Sheet *sheet)
if (deps)
cell_queue_recalc_list (deps, TRUE);
workbook_recalc (sheet->workbook);
}
......@@ -959,9 +959,19 @@ search_range_deps (gpointer key, gpointer value, gpointer closure)
c->list = g_list_concat (c->list, g_list_copy (deprange->cell_list));
}
/**
* sheet_region_get_deps :
* Get a list of the elements that depend on the specified range.
*
* @sheet : The sheet.
* @start_col : The target range.
* @start_row :
* @end_col :
* @end_row :
*/
GList *
sheet_region_get_deps (Sheet *sheet, int start_col, int start_row,
int end_col, int end_row)
sheet_region_get_deps (Sheet *sheet,
int start_col, int start_row, int end_col, int end_row)
{
int ix, iy;
get_range_dep_closure_t closure;
......@@ -1014,11 +1024,10 @@ cb_single_get_all_depends (gpointer key, gpointer value, gpointer closure)
/**
* sheet_recalc_dependencies :
* Force a recalc of anything that depends on the cells in this sheet.
* Queue a recalc of anything that depends on the cells in this sheet.
* Do not actually recalc, just queue them up.
*
* @sheet : The sheet.
*
* This seems like over kill we could probably use a finer grained test.
*/
void
sheet_recalc_dependencies (Sheet *sheet)
......@@ -1039,6 +1048,4 @@ sheet_recalc_dependencies (Sheet *sheet)
if (deps)
cell_queue_recalc_list (deps, TRUE);
workbook_recalc (sheet->workbook);
}
......@@ -3377,9 +3377,6 @@ sheet_insert_cols (CommandContext *context, Sheet *sheet,
/* 5. Recompute dependencies */
sheet_recalc_dependencies (sheet);
/* 6. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
......@@ -3450,9 +3447,6 @@ sheet_delete_cols (CommandContext *context, Sheet *sheet,
/* 6. Recompute dependencies */
sheet_recalc_dependencies (sheet);
/* 7. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
......@@ -3526,9 +3520,6 @@ sheet_insert_rows (CommandContext *context, Sheet *sheet,
/* 5. Recompute dependencies */
sheet_recalc_dependencies (sheet);
/* 6. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
......@@ -3599,9 +3590,6 @@ sheet_delete_rows (CommandContext *context, Sheet *sheet,
/* 6. Recompute dependencies */
sheet_recalc_dependencies (sheet);
/* 7. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
......@@ -3688,7 +3676,8 @@ sheet_move_range (CommandContext *context,
/* 6. Recompute dependencies */
sheet_recalc_dependencies (rinfo->target_sheet);
/* 7. Redraw */
/* 7. Recalc & Redraw */
workbook_recalc (rinfo->target_sheet->workbook);
sheet_redraw_all (rinfo->target_sheet);
}
......
......@@ -2366,6 +2366,24 @@ sheet_action_delete_sheet (GtkWidget *widget, Sheet *current_sheet)
workbook_recalc_all (wb);
}
/*
* sheet_action_rename_sheet:
* Invoked when the user selects the option to rename a sheet
*/
static void
sheet_action_rename_sheet (GtkWidget *widget, Sheet *current_sheet)
{
char *new_name;
Workbook *wb = current_sheet->workbook;
new_name = dialog_get_sheet_name (wb, current_sheet->name);
if (!new_name)
return;
workbook_rename_sheet (wb, current_sheet->name, new_name);
g_free (new_name);
}
#define SHEET_CONTEXT_TEST_SIZE 1
struct {
......@@ -2375,6 +2393,7 @@ struct {
} sheet_label_context_actions [] = {
{ N_("Add another sheet"), sheet_action_add_sheet, 0 },
{ N_("Remove this sheet"), sheet_action_delete_sheet, SHEET_CONTEXT_TEST_SIZE },
{ N_("Rename this sheet"), sheet_action_rename_sheet, 0 },
{ NULL, NULL }
};
......
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